2 * Copyright 2008 Ben Skeggs
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #include "pipe/p_context.h"
24 #include "pipe/p_state.h"
25 #include "pipe/p_inlines.h"
27 #include "util/u_format.h"
29 #include "nv50_context.h"
32 nv50_push_elements_u08(struct nv50_context
*, uint8_t *, unsigned);
35 nv50_push_elements_u16(struct nv50_context
*, uint16_t *, unsigned);
38 nv50_push_elements_u32(struct nv50_context
*, uint32_t *, unsigned);
41 nv50_push_arrays(struct nv50_context
*, unsigned, unsigned);
43 static INLINE
unsigned
44 nv50_prim(unsigned mode
)
47 case PIPE_PRIM_POINTS
: return NV50TCL_VERTEX_BEGIN_POINTS
;
48 case PIPE_PRIM_LINES
: return NV50TCL_VERTEX_BEGIN_LINES
;
49 case PIPE_PRIM_LINE_LOOP
: return NV50TCL_VERTEX_BEGIN_LINE_LOOP
;
50 case PIPE_PRIM_LINE_STRIP
: return NV50TCL_VERTEX_BEGIN_LINE_STRIP
;
51 case PIPE_PRIM_TRIANGLES
: return NV50TCL_VERTEX_BEGIN_TRIANGLES
;
52 case PIPE_PRIM_TRIANGLE_STRIP
:
53 return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP
;
54 case PIPE_PRIM_TRIANGLE_FAN
: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN
;
55 case PIPE_PRIM_QUADS
: return NV50TCL_VERTEX_BEGIN_QUADS
;
56 case PIPE_PRIM_QUAD_STRIP
: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP
;
57 case PIPE_PRIM_POLYGON
: return NV50TCL_VERTEX_BEGIN_POLYGON
;
62 NOUVEAU_ERR("invalid primitive type %d\n", mode
);
63 return NV50TCL_VERTEX_BEGIN_POINTS
;
66 static INLINE
uint32_t
67 nv50_vbo_type_to_hw(unsigned type
)
70 case PIPE_FORMAT_TYPE_FLOAT
:
71 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_FLOAT
;
72 case PIPE_FORMAT_TYPE_UNORM
:
73 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UNORM
;
74 case PIPE_FORMAT_TYPE_SNORM
:
75 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SNORM
;
76 case PIPE_FORMAT_TYPE_USCALED
:
77 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_USCALED
;
78 case PIPE_FORMAT_TYPE_SSCALED
:
79 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SSCALED
;
81 case PIPE_FORMAT_TYPE_UINT:
82 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UINT;
83 case PIPE_FORMAT_TYPE_SINT:
84 return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SINT; */
90 static INLINE
uint32_t
91 nv50_vbo_size_to_hw(unsigned size
, unsigned nr_c
)
93 static const uint32_t hw_values
[] = {
95 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8
,
96 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8
,
97 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8_8
,
98 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_8_8_8_8
,
99 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16
,
100 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16
,
101 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16_16
,
102 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_16_16_16_16
,
104 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32
,
105 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32
,
106 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32_32
,
107 NV50TCL_VERTEX_ARRAY_ATTRIB_SIZE_32_32_32_32
};
109 /* we'd also have R11G11B10 and R10G10B10A2 */
111 assert(nr_c
> 0 && nr_c
<= 4);
117 return hw_values
[size
+ (nr_c
- 1)];
120 static INLINE
uint32_t
121 nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element
*ve
)
123 uint32_t hw_type
, hw_size
;
124 enum pipe_format pf
= ve
->src_format
;
125 unsigned size
= pf_size_x(pf
) << pf_exp2(pf
);
127 hw_type
= nv50_vbo_type_to_hw(pf_type(pf
));
128 hw_size
= nv50_vbo_size_to_hw(size
, ve
->nr_components
);
130 if (!hw_type
|| !hw_size
) {
131 NOUVEAU_ERR("unsupported vbo format: %s\n", pf_name(pf
));
136 if (util_format_description(pf
)->swizzle
[0] == UTIL_FORMAT_SWIZZLE_Z
) /* BGRA */
137 hw_size
|= (1 << 31); /* no real swizzle bits :-( */
139 return (hw_type
| hw_size
);
143 nv50_draw_arrays(struct pipe_context
*pipe
, unsigned mode
, unsigned start
,
146 struct nv50_context
*nv50
= nv50_context(pipe
);
147 struct nouveau_channel
*chan
= nv50
->screen
->tesla
->channel
;
148 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
151 nv50_state_validate(nv50
);
153 BEGIN_RING(chan
, tesla
, 0x142c, 1);
155 BEGIN_RING(chan
, tesla
, 0x142c, 1);
158 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_BEGIN
, 1);
159 OUT_RING (chan
, nv50_prim(mode
));
162 ret
= nv50_push_arrays(nv50
, start
, count
);
164 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_BUFFER_FIRST
, 2);
165 OUT_RING (chan
, start
);
166 OUT_RING (chan
, count
);
169 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_END
, 1);
175 static INLINE boolean
176 nv50_draw_elements_inline_u08(struct nv50_context
*nv50
, uint8_t *map
,
177 unsigned start
, unsigned count
)
179 struct nouveau_channel
*chan
= nv50
->screen
->tesla
->channel
;
180 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
185 return nv50_push_elements_u08(nv50
, map
, count
);
188 BEGIN_RING(chan
, tesla
, 0x15e8, 1);
189 OUT_RING (chan
, map
[0]);
195 unsigned nr
= count
> 2046 ? 2046 : count
;
198 BEGIN_RING(chan
, tesla
, 0x400015f0, nr
>> 1);
199 for (i
= 0; i
< nr
; i
+= 2)
200 OUT_RING (chan
, (map
[i
+ 1] << 16) | map
[i
]);
208 static INLINE boolean
209 nv50_draw_elements_inline_u16(struct nv50_context
*nv50
, uint16_t *map
,
210 unsigned start
, unsigned count
)
212 struct nouveau_channel
*chan
= nv50
->screen
->tesla
->channel
;
213 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
218 return nv50_push_elements_u16(nv50
, map
, count
);
221 BEGIN_RING(chan
, tesla
, 0x15e8, 1);
222 OUT_RING (chan
, map
[0]);
228 unsigned nr
= count
> 2046 ? 2046 : count
;
231 BEGIN_RING(chan
, tesla
, 0x400015f0, nr
>> 1);
232 for (i
= 0; i
< nr
; i
+= 2)
233 OUT_RING (chan
, (map
[i
+ 1] << 16) | map
[i
]);
241 static INLINE boolean
242 nv50_draw_elements_inline_u32(struct nv50_context
*nv50
, uint32_t *map
,
243 unsigned start
, unsigned count
)
245 struct nouveau_channel
*chan
= nv50
->screen
->tesla
->channel
;
246 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
251 return nv50_push_elements_u32(nv50
, map
, count
);
254 unsigned nr
= count
> 2047 ? 2047 : count
;
256 BEGIN_RING(chan
, tesla
, 0x400015e8, nr
);
257 OUT_RINGp (chan
, map
, nr
);
266 nv50_draw_elements(struct pipe_context
*pipe
,
267 struct pipe_buffer
*indexBuffer
, unsigned indexSize
,
268 unsigned mode
, unsigned start
, unsigned count
)
270 struct nv50_context
*nv50
= nv50_context(pipe
);
271 struct nouveau_channel
*chan
= nv50
->screen
->tesla
->channel
;
272 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
273 struct pipe_screen
*pscreen
= pipe
->screen
;
277 map
= pipe_buffer_map(pscreen
, indexBuffer
, PIPE_BUFFER_USAGE_CPU_READ
);
279 nv50_state_validate(nv50
);
281 BEGIN_RING(chan
, tesla
, 0x142c, 1);
283 BEGIN_RING(chan
, tesla
, 0x142c, 1);
286 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_BEGIN
, 1);
287 OUT_RING (chan
, nv50_prim(mode
));
290 ret
= nv50_draw_elements_inline_u08(nv50
, map
, start
, count
);
293 ret
= nv50_draw_elements_inline_u16(nv50
, map
, start
, count
);
296 ret
= nv50_draw_elements_inline_u32(nv50
, map
, start
, count
);
303 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_END
, 1);
306 pipe_buffer_unmap(pscreen
, indexBuffer
);
311 static INLINE boolean
312 nv50_vbo_static_attrib(struct nv50_context
*nv50
, unsigned attrib
,
313 struct nouveau_stateobj
**pso
,
314 struct pipe_vertex_element
*ve
,
315 struct pipe_vertex_buffer
*vb
)
318 struct nouveau_stateobj
*so
;
319 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
320 struct nouveau_bo
*bo
= nouveau_bo(vb
->buffer
);
323 enum pipe_format pf
= ve
->src_format
;
325 if ((pf_type(pf
) != PIPE_FORMAT_TYPE_FLOAT
) ||
326 (pf_size_x(pf
) << pf_exp2(pf
)) != 32)
329 ret
= nouveau_bo_map(bo
, NOUVEAU_BO_RD
);
332 v
= (float *)(bo
->map
+ (vb
->buffer_offset
+ ve
->src_offset
));
336 *pso
= so
= so_new(nv50
->vtxelt_nr
* 5, 0);
338 switch (ve
->nr_components
) {
340 so_method(so
, tesla
, NV50TCL_VTX_ATTR_4F_X(attrib
), 4);
341 so_data (so
, fui(v
[0]));
342 so_data (so
, fui(v
[1]));
343 so_data (so
, fui(v
[2]));
344 so_data (so
, fui(v
[3]));
347 so_method(so
, tesla
, NV50TCL_VTX_ATTR_3F_X(attrib
), 3);
348 so_data (so
, fui(v
[0]));
349 so_data (so
, fui(v
[1]));
350 so_data (so
, fui(v
[2]));
353 so_method(so
, tesla
, NV50TCL_VTX_ATTR_2F_X(attrib
), 2);
354 so_data (so
, fui(v
[0]));
355 so_data (so
, fui(v
[1]));
358 so_method(so
, tesla
, NV50TCL_VTX_ATTR_1F(attrib
), 1);
359 so_data (so
, fui(v
[0]));
362 nouveau_bo_unmap(bo
);
366 nouveau_bo_unmap(bo
);
371 nv50_vbo_validate(struct nv50_context
*nv50
)
373 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
374 struct nouveau_stateobj
*vtxbuf
, *vtxfmt
, *vtxattr
;
377 /* don't validate if Gallium took away our buffers */
378 if (nv50
->vtxbuf_nr
== 0)
382 for (i
= 0; i
< nv50
->vtxbuf_nr
; ++i
)
383 if (nv50
->vtxbuf
[i
].stride
&&
384 !(nv50
->vtxbuf
[i
].buffer
->usage
& PIPE_BUFFER_USAGE_VERTEX
))
385 nv50
->vbo_fifo
= 0xffff;
387 n_ve
= MAX2(nv50
->vtxelt_nr
, nv50
->state
.vtxelt_nr
);
390 vtxbuf
= so_new(n_ve
* 7, nv50
->vtxelt_nr
* 4);
391 vtxfmt
= so_new(n_ve
+ 1, 0);
392 so_method(vtxfmt
, tesla
, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve
);
394 for (i
= 0; i
< nv50
->vtxelt_nr
; i
++) {
395 struct pipe_vertex_element
*ve
= &nv50
->vtxelt
[i
];
396 struct pipe_vertex_buffer
*vb
=
397 &nv50
->vtxbuf
[ve
->vertex_buffer_index
];
398 struct nouveau_bo
*bo
= nouveau_bo(vb
->buffer
);
399 uint32_t hw
= nv50_vbo_vtxelt_to_hw(ve
);
402 nv50_vbo_static_attrib(nv50
, i
, &vtxattr
, ve
, vb
)) {
403 so_data(vtxfmt
, hw
| (1 << 4));
405 so_method(vtxbuf
, tesla
,
406 NV50TCL_VERTEX_ARRAY_FORMAT(i
), 1);
409 nv50
->vbo_fifo
&= ~(1 << i
);
412 so_data(vtxfmt
, hw
| i
);
414 if (nv50
->vbo_fifo
) {
415 so_method(vtxbuf
, tesla
,
416 NV50TCL_VERTEX_ARRAY_FORMAT(i
), 1);
421 so_method(vtxbuf
, tesla
, NV50TCL_VERTEX_ARRAY_FORMAT(i
), 3);
422 so_data (vtxbuf
, 0x20000000 | vb
->stride
);
423 so_reloc (vtxbuf
, bo
, vb
->buffer_offset
+
424 ve
->src_offset
, NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
|
425 NOUVEAU_BO_RD
| NOUVEAU_BO_HIGH
, 0, 0);
426 so_reloc (vtxbuf
, bo
, vb
->buffer_offset
+
427 ve
->src_offset
, NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
|
428 NOUVEAU_BO_RD
| NOUVEAU_BO_LOW
, 0, 0);
430 /* vertex array limits */
431 so_method(vtxbuf
, tesla
, 0x1080 + (i
* 8), 2);
432 so_reloc (vtxbuf
, bo
, vb
->buffer
->size
- 1,
433 NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
| NOUVEAU_BO_RD
|
434 NOUVEAU_BO_HIGH
, 0, 0);
435 so_reloc (vtxbuf
, bo
, vb
->buffer
->size
- 1,
436 NOUVEAU_BO_VRAM
| NOUVEAU_BO_GART
| NOUVEAU_BO_RD
|
437 NOUVEAU_BO_LOW
, 0, 0);
439 for (; i
< n_ve
; ++i
) {
440 so_data (vtxfmt
, 0x7e080010);
442 so_method(vtxbuf
, tesla
, NV50TCL_VERTEX_ARRAY_FORMAT(i
), 1);
445 nv50
->state
.vtxelt_nr
= nv50
->vtxelt_nr
;
447 so_ref (vtxfmt
, &nv50
->state
.vtxfmt
);
448 so_ref (vtxbuf
, &nv50
->state
.vtxbuf
);
449 so_ref (vtxattr
, &nv50
->state
.vtxattr
);
450 so_ref (NULL
, &vtxbuf
);
451 so_ref (NULL
, &vtxfmt
);
452 so_ref (NULL
, &vtxattr
);
455 typedef void (*pfn_push
)(struct nouveau_channel
*, void *);
457 struct nv50_vbo_emitctx
468 emit_vtx_next(struct nouveau_channel
*chan
, struct nv50_vbo_emitctx
*emit
)
472 for (i
= 0; i
< emit
->nr_ve
; ++i
) {
473 emit
->push
[i
](chan
, emit
->map
[i
]);
474 emit
->map
[i
] += emit
->stride
[i
];
479 emit_vtx(struct nouveau_channel
*chan
, struct nv50_vbo_emitctx
*emit
,
484 for (i
= 0; i
< emit
->nr_ve
; ++i
)
485 emit
->push
[i
](chan
, emit
->map
[i
] + emit
->stride
[i
] * vi
);
488 static INLINE boolean
489 nv50_map_vbufs(struct nv50_context
*nv50
)
493 for (i
= 0; i
< nv50
->vtxbuf_nr
; ++i
) {
494 struct pipe_vertex_buffer
*vb
= &nv50
->vtxbuf
[i
];
495 unsigned size
, delta
;
497 if (nouveau_bo(vb
->buffer
)->map
)
500 size
= vb
->stride
* (vb
->max_index
+ 1);
501 delta
= vb
->buffer_offset
;
504 size
= vb
->buffer
->size
- vb
->buffer_offset
;
506 if (nouveau_bo_map_range(nouveau_bo(vb
->buffer
),
507 delta
, size
, NOUVEAU_BO_RD
))
511 if (i
== nv50
->vtxbuf_nr
)
514 nouveau_bo_unmap(nouveau_bo(nv50
->vtxbuf
[i
].buffer
));
519 nv50_unmap_vbufs(struct nv50_context
*nv50
)
523 for (i
= 0; i
< nv50
->vtxbuf_nr
; ++i
)
524 if (nouveau_bo(nv50
->vtxbuf
[i
].buffer
)->map
)
525 nouveau_bo_unmap(nouveau_bo(nv50
->vtxbuf
[i
].buffer
));
529 emit_b32_1(struct nouveau_channel
*chan
, void *data
)
533 OUT_RING(chan
, v
[0]);
537 emit_b32_2(struct nouveau_channel
*chan
, void *data
)
541 OUT_RING(chan
, v
[0]);
542 OUT_RING(chan
, v
[1]);
546 emit_b32_3(struct nouveau_channel
*chan
, void *data
)
550 OUT_RING(chan
, v
[0]);
551 OUT_RING(chan
, v
[1]);
552 OUT_RING(chan
, v
[2]);
556 emit_b32_4(struct nouveau_channel
*chan
, void *data
)
560 OUT_RING(chan
, v
[0]);
561 OUT_RING(chan
, v
[1]);
562 OUT_RING(chan
, v
[2]);
563 OUT_RING(chan
, v
[3]);
567 emit_b16_1(struct nouveau_channel
*chan
, void *data
)
571 OUT_RING(chan
, v
[0]);
575 emit_b16_3(struct nouveau_channel
*chan
, void *data
)
579 OUT_RING(chan
, (v
[1] << 16) | v
[0]);
580 OUT_RING(chan
, v
[2]);
584 emit_b08_1(struct nouveau_channel
*chan
, void *data
)
588 OUT_RING(chan
, v
[0]);
592 emit_b08_3(struct nouveau_channel
*chan
, void *data
)
596 OUT_RING(chan
, (v
[2] << 16) | (v
[1] << 8) | v
[0]);
600 emit_prepare(struct nv50_context
*nv50
, struct nv50_vbo_emitctx
*emit
,
605 if (nv50_map_vbufs(nv50
) == FALSE
)
609 emit
->vtx_dwords
= 0;
611 for (i
= 0; i
< nv50
->vtxelt_nr
; ++i
) {
612 struct pipe_vertex_element
*ve
;
613 struct pipe_vertex_buffer
*vb
;
614 unsigned n
, type
, size
;
616 ve
= &nv50
->vtxelt
[i
];
617 vb
= &nv50
->vtxbuf
[ve
->vertex_buffer_index
];
618 if (!(nv50
->vbo_fifo
& (1 << i
)))
622 emit
->stride
[n
] = vb
->stride
;
623 emit
->map
[n
] = nouveau_bo(vb
->buffer
)->map
+
624 (start
* vb
->stride
+ ve
->src_offset
);
626 type
= pf_type(ve
->src_format
);
627 size
= pf_size_x(ve
->src_format
) << pf_exp2(ve
->src_format
);
629 assert(ve
->nr_components
> 0 && ve
->nr_components
<= 4);
631 /* It shouldn't be necessary to push the implicit 1s
632 * for case 3 and size 8 cases 1, 2, 3.
636 NOUVEAU_ERR("unsupported vtxelt size: %u\n", size
);
639 switch (ve
->nr_components
) {
640 case 1: emit
->push
[n
] = emit_b32_1
; break;
641 case 2: emit
->push
[n
] = emit_b32_2
; break;
642 case 3: emit
->push
[n
] = emit_b32_3
; break;
643 case 4: emit
->push
[n
] = emit_b32_4
; break;
645 emit
->vtx_dwords
+= ve
->nr_components
;
648 switch (ve
->nr_components
) {
649 case 1: emit
->push
[n
] = emit_b16_1
; break;
650 case 2: emit
->push
[n
] = emit_b32_1
; break;
651 case 3: emit
->push
[n
] = emit_b16_3
; break;
652 case 4: emit
->push
[n
] = emit_b32_2
; break;
654 emit
->vtx_dwords
+= (ve
->nr_components
+ 1) >> 1;
657 switch (ve
->nr_components
) {
658 case 1: emit
->push
[n
] = emit_b08_1
; break;
659 case 2: emit
->push
[n
] = emit_b16_1
; break;
660 case 3: emit
->push
[n
] = emit_b08_3
; break;
661 case 4: emit
->push
[n
] = emit_b32_1
; break;
663 emit
->vtx_dwords
+= 1;
668 emit
->vtx_max
= 512 / emit
->vtx_dwords
;
674 nv50_push_arrays(struct nv50_context
*nv50
, unsigned start
, unsigned count
)
676 struct nouveau_channel
*chan
= nv50
->screen
->base
.channel
;
677 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
678 struct nv50_vbo_emitctx emit
;
680 if (emit_prepare(nv50
, &emit
, start
) == FALSE
)
684 unsigned i
, dw
, nr
= MIN2(count
, emit
.vtx_max
);
685 dw
= nr
* emit
.vtx_dwords
;
687 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_DATA
| 0x40000000, dw
);
688 for (i
= 0; i
< nr
; ++i
)
689 emit_vtx_next(chan
, &emit
);
693 nv50_unmap_vbufs(nv50
);
699 nv50_push_elements_u32(struct nv50_context
*nv50
, uint32_t *map
, unsigned count
)
701 struct nouveau_channel
*chan
= nv50
->screen
->base
.channel
;
702 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
703 struct nv50_vbo_emitctx emit
;
705 if (emit_prepare(nv50
, &emit
, 0) == FALSE
)
709 unsigned i
, dw
, nr
= MIN2(count
, emit
.vtx_max
);
710 dw
= nr
* emit
.vtx_dwords
;
712 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_DATA
| 0x40000000, dw
);
713 for (i
= 0; i
< nr
; ++i
)
714 emit_vtx(chan
, &emit
, *map
++);
718 nv50_unmap_vbufs(nv50
);
724 nv50_push_elements_u16(struct nv50_context
*nv50
, uint16_t *map
, unsigned count
)
726 struct nouveau_channel
*chan
= nv50
->screen
->base
.channel
;
727 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
728 struct nv50_vbo_emitctx emit
;
730 if (emit_prepare(nv50
, &emit
, 0) == FALSE
)
734 unsigned i
, dw
, nr
= MIN2(count
, emit
.vtx_max
);
735 dw
= nr
* emit
.vtx_dwords
;
737 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_DATA
| 0x40000000, dw
);
738 for (i
= 0; i
< nr
; ++i
)
739 emit_vtx(chan
, &emit
, *map
++);
743 nv50_unmap_vbufs(nv50
);
749 nv50_push_elements_u08(struct nv50_context
*nv50
, uint8_t *map
, unsigned count
)
751 struct nouveau_channel
*chan
= nv50
->screen
->base
.channel
;
752 struct nouveau_grobj
*tesla
= nv50
->screen
->tesla
;
753 struct nv50_vbo_emitctx emit
;
755 if (emit_prepare(nv50
, &emit
, 0) == FALSE
)
759 unsigned i
, dw
, nr
= MIN2(count
, emit
.vtx_max
);
760 dw
= nr
* emit
.vtx_dwords
;
762 BEGIN_RING(chan
, tesla
, NV50TCL_VERTEX_DATA
| 0x40000000, dw
);
763 for (i
= 0; i
< nr
; ++i
)
764 emit_vtx(chan
, &emit
, *map
++);
768 nv50_unmap_vbufs(nv50
);