2 * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2010 Marek Olšák <maraeo@gmail.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 /* r300_render: Vertex and index buffer primitive emission. Contains both
25 * HW TCL fastpath rendering, and SW TCL Draw-assisted rendering. */
27 #include "draw/draw_context.h"
28 #include "draw/draw_vbuf.h"
30 #include "util/u_inlines.h"
32 #include "util/u_format.h"
33 #include "util/u_memory.h"
34 #include "util/u_upload_mgr.h"
35 #include "util/u_prim.h"
38 #include "r300_context.h"
39 #include "r300_screen_buffer.h"
40 #include "r300_emit.h"
45 #define IMMD_DWORDS 32
47 static uint32_t r300_translate_primitive(unsigned prim
)
49 static const int prim_conv
[] = {
50 R300_VAP_VF_CNTL__PRIM_POINTS
,
51 R300_VAP_VF_CNTL__PRIM_LINES
,
52 R300_VAP_VF_CNTL__PRIM_LINE_LOOP
,
53 R300_VAP_VF_CNTL__PRIM_LINE_STRIP
,
54 R300_VAP_VF_CNTL__PRIM_TRIANGLES
,
55 R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP
,
56 R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN
,
57 R300_VAP_VF_CNTL__PRIM_QUADS
,
58 R300_VAP_VF_CNTL__PRIM_QUAD_STRIP
,
59 R300_VAP_VF_CNTL__PRIM_POLYGON
,
65 unsigned hwprim
= prim_conv
[prim
];
71 static uint32_t r300_provoking_vertex_fixes(struct r300_context
*r300
,
74 struct r300_rs_state
* rs
= (struct r300_rs_state
*)r300
->rs_state
.state
;
75 uint32_t color_control
= rs
->color_control
;
77 /* By default (see r300_state.c:r300_create_rs_state) color_control is
78 * initialized to provoking the first vertex.
80 * Triangle fans must be reduced to the second vertex, not the first, in
81 * Gallium flatshade-first mode, as per the GL spec.
82 * (http://www.opengl.org/registry/specs/ARB/provoking_vertex.txt)
84 * Quads never provoke correctly in flatshade-first mode. The first
85 * vertex is never considered as provoking, so only the second, third,
86 * and fourth vertices can be selected, and both "third" and "last" modes
87 * select the fourth vertex. This is probably due to D3D lacking quads.
89 * Similarly, polygons reduce to the first, not the last, vertex, when in
90 * "last" mode, and all other modes start from the second vertex.
95 if (rs
->rs
.flatshade_first
) {
97 case PIPE_PRIM_TRIANGLE_FAN
:
98 color_control
|= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND
;
100 case PIPE_PRIM_QUADS
:
101 case PIPE_PRIM_QUAD_STRIP
:
102 case PIPE_PRIM_POLYGON
:
103 color_control
|= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST
;
106 color_control
|= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_FIRST
;
110 color_control
|= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST
;
113 return color_control
;
116 void r500_emit_index_bias(struct r300_context
*r300
, int index_bias
)
121 OUT_CS_REG(R500_VAP_INDEX_OFFSET
,
122 (index_bias
& 0xFFFFFF) | (index_bias
< 0 ? 1<<24 : 0));
126 static void r300_emit_draw_init(struct r300_context
*r300
, unsigned mode
,
127 unsigned min_index
, unsigned max_index
)
132 OUT_CS_REG(R300_GA_COLOR_CONTROL
,
133 r300_provoking_vertex_fixes(r300
, mode
));
134 OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX
, 2);
140 /* This function splits the index bias value into two parts:
141 * - buffer_offset: the value that can be safely added to buffer offsets
142 * in r300_emit_vertex_arrays (it must yield a positive offset when added to
143 * a vertex buffer offset)
144 * - index_offset: the value that must be manually subtracted from indices
145 * in an index buffer to achieve negative offsets. */
146 static void r300_split_index_bias(struct r300_context
*r300
, int index_bias
,
147 int *buffer_offset
, int *index_offset
)
149 struct pipe_vertex_buffer
*vb
, *vbufs
= r300
->vbuf_mgr
->vertex_buffer
;
150 struct pipe_vertex_element
*velem
= r300
->velems
->velem
;
154 if (index_bias
< 0) {
155 /* See how large index bias we may subtract. We must be careful
156 * here because negative buffer offsets are not allowed
158 max_neg_bias
= INT_MAX
;
159 for (i
= 0; i
< r300
->velems
->count
; i
++) {
160 vb
= &vbufs
[velem
[i
].vertex_buffer_index
];
161 size
= (vb
->buffer_offset
+ velem
[i
].src_offset
) / vb
->stride
;
162 max_neg_bias
= MIN2(max_neg_bias
, size
);
165 /* Now set the minimum allowed value. */
166 *buffer_offset
= MAX2(-max_neg_bias
, index_bias
);
168 /* A positive index bias is OK. */
169 *buffer_offset
= index_bias
;
172 *index_offset
= index_bias
- *buffer_offset
;
175 enum r300_prepare_flags
{
176 PREP_EMIT_STATES
= (1 << 0), /* call emit_dirty_state and friends? */
177 PREP_VALIDATE_VBOS
= (1 << 1), /* validate VBOs? */
178 PREP_EMIT_AOS
= (1 << 2), /* call emit_vertex_arrays? */
179 PREP_EMIT_AOS_SWTCL
= (1 << 3), /* call emit_vertex_arrays_swtcl? */
180 PREP_INDEXED
= (1 << 4) /* is this draw_elements? */
184 * Check if the requested number of dwords is available in the CS and
186 * \param r300 The context.
187 * \param flags See r300_prepare_flags.
188 * \param cs_dwords The number of dwords to reserve in CS.
189 * \return TRUE if the CS was flushed
191 static boolean
r300_reserve_cs_dwords(struct r300_context
*r300
,
192 enum r300_prepare_flags flags
,
195 boolean flushed
= FALSE
;
196 boolean first_draw
= flags
& PREP_EMIT_STATES
;
197 boolean emit_vertex_arrays
= flags
& PREP_EMIT_AOS
;
198 boolean emit_vertex_arrays_swtcl
= flags
& PREP_EMIT_AOS_SWTCL
;
200 /* Add dirty state, index offset, and AOS. */
202 cs_dwords
+= r300_get_num_dirty_dwords(r300
);
204 if (r300
->screen
->caps
.is_r500
)
205 cs_dwords
+= 2; /* emit_index_offset */
207 if (emit_vertex_arrays
)
208 cs_dwords
+= 55; /* emit_vertex_arrays */
210 if (emit_vertex_arrays_swtcl
)
211 cs_dwords
+= 7; /* emit_vertex_arrays_swtcl */
214 cs_dwords
+= r300_get_num_cs_end_dwords(r300
);
216 /* Reserve requested CS space. */
217 if (cs_dwords
> (RADEON_MAX_CMDBUF_DWORDS
- r300
->cs
->cdw
)) {
218 r300_flush(&r300
->context
, RADEON_FLUSH_ASYNC
, NULL
);
226 * Validate buffers and emit dirty state.
227 * \param r300 The context.
228 * \param flags See r300_prepare_flags.
229 * \param index_buffer The index buffer to validate. The parameter may be NULL.
230 * \param buffer_offset The offset passed to emit_vertex_arrays.
231 * \param index_bias The index bias to emit.
232 * \param instance_id Index of instance to render
233 * \return TRUE if rendering should be skipped
235 static boolean
r300_emit_states(struct r300_context
*r300
,
236 enum r300_prepare_flags flags
,
237 struct pipe_resource
*index_buffer
,
239 int index_bias
, int instance_id
)
241 boolean first_draw
= flags
& PREP_EMIT_STATES
;
242 boolean emit_vertex_arrays
= flags
& PREP_EMIT_AOS
;
243 boolean emit_vertex_arrays_swtcl
= flags
& PREP_EMIT_AOS_SWTCL
;
244 boolean indexed
= flags
& PREP_INDEXED
;
245 boolean validate_vbos
= flags
& PREP_VALIDATE_VBOS
;
247 /* Validate buffers and emit dirty state if needed. */
249 if (!r300_emit_buffer_validate(r300
, validate_vbos
,
251 fprintf(stderr
, "r300: CS space validation failed. "
252 "(not enough memory?) Skipping rendering.\n");
256 r300_emit_dirty_state(r300
);
257 if (r300
->screen
->caps
.is_r500
) {
258 if (r300
->screen
->caps
.has_tcl
)
259 r500_emit_index_bias(r300
, index_bias
);
261 r500_emit_index_bias(r300
, 0);
264 if (emit_vertex_arrays
&&
265 (r300
->vertex_arrays_dirty
||
266 r300
->vertex_arrays_indexed
!= indexed
||
267 r300
->vertex_arrays_offset
!= buffer_offset
||
268 r300
->vertex_arrays_instance_id
!= instance_id
)) {
269 r300_emit_vertex_arrays(r300
, buffer_offset
, indexed
, instance_id
);
271 r300
->vertex_arrays_dirty
= FALSE
;
272 r300
->vertex_arrays_indexed
= indexed
;
273 r300
->vertex_arrays_offset
= buffer_offset
;
274 r300
->vertex_arrays_instance_id
= instance_id
;
277 if (emit_vertex_arrays_swtcl
)
278 r300_emit_vertex_arrays_swtcl(r300
, indexed
);
285 * Check if the requested number of dwords is available in the CS and
286 * if not, flush. Then validate buffers and emit dirty state.
287 * \param r300 The context.
288 * \param flags See r300_prepare_flags.
289 * \param index_buffer The index buffer to validate. The parameter may be NULL.
290 * \param cs_dwords The number of dwords to reserve in CS.
291 * \param buffer_offset The offset passed to emit_vertex_arrays.
292 * \param index_bias The index bias to emit.
293 * \param instance_id The instance to render.
294 * \return TRUE if rendering should be skipped
296 static boolean
r300_prepare_for_rendering(struct r300_context
*r300
,
297 enum r300_prepare_flags flags
,
298 struct pipe_resource
*index_buffer
,
304 /* Make sure there is enough space in the command stream and emit states. */
305 if (r300_reserve_cs_dwords(r300
, flags
, cs_dwords
))
306 flags
|= PREP_EMIT_STATES
;
308 return r300_emit_states(r300
, flags
, index_buffer
, buffer_offset
,
309 index_bias
, instance_id
);
312 static boolean
immd_is_good_idea(struct r300_context
*r300
,
315 struct pipe_vertex_element
* velem
;
316 struct pipe_resource
*buf
;
317 boolean checked
[PIPE_MAX_ATTRIBS
] = {0};
318 unsigned vertex_element_count
= r300
->velems
->count
;
321 if (DBG_ON(r300
, DBG_NO_IMMD
)) {
329 if (count
* r300
->velems
->vertex_size_dwords
> IMMD_DWORDS
) {
333 /* We shouldn't map buffers referenced by CS, busy buffers,
334 * and ones placed in VRAM. */
335 for (i
= 0; i
< vertex_element_count
; i
++) {
336 velem
= &r300
->velems
->velem
[i
];
337 vbi
= velem
->vertex_buffer_index
;
340 buf
= r300
->vbuf_mgr
->real_vertex_buffer
[vbi
];
342 if ((r300_resource(buf
)->domain
!= RADEON_DOMAIN_GTT
)) {
352 /*****************************************************************************
353 * The HWTCL draw functions. *
354 ****************************************************************************/
356 static void r300_draw_arrays_immediate(struct r300_context
*r300
,
357 const struct pipe_draw_info
*info
)
359 struct pipe_vertex_element
* velem
;
360 struct pipe_vertex_buffer
* vbuf
;
361 unsigned vertex_element_count
= r300
->velems
->count
;
364 /* Size of the vertex, in dwords. */
365 unsigned vertex_size
= r300
->velems
->vertex_size_dwords
;
367 /* The number of dwords for this draw operation. */
368 unsigned dwords
= 4 + info
->count
* vertex_size
;
370 /* Size of the vertex element, in dwords. */
371 unsigned size
[PIPE_MAX_ATTRIBS
];
373 /* Stride to the same attrib in the next vertex in the vertex buffer,
375 unsigned stride
[PIPE_MAX_ATTRIBS
];
377 /* Mapped vertex buffers. */
378 uint32_t* map
[PIPE_MAX_ATTRIBS
] = {0};
379 uint32_t* mapelem
[PIPE_MAX_ATTRIBS
];
383 if (!r300_prepare_for_rendering(r300
, PREP_EMIT_STATES
, NULL
, dwords
, 0, 0, -1))
386 /* Calculate the vertex size, offsets, strides etc. and map the buffers. */
387 for (i
= 0; i
< vertex_element_count
; i
++) {
388 velem
= &r300
->velems
->velem
[i
];
389 size
[i
] = r300
->velems
->format_size
[i
] / 4;
390 vbi
= velem
->vertex_buffer_index
;
391 vbuf
= &r300
->vbuf_mgr
->vertex_buffer
[vbi
];
392 stride
[i
] = vbuf
->stride
/ 4;
394 /* Map the buffer. */
396 map
[vbi
] = (uint32_t*)r300
->rws
->buffer_map(
397 r300_resource(r300
->vbuf_mgr
->real_vertex_buffer
[vbi
])->buf
,
398 r300
->cs
, PIPE_TRANSFER_READ
| PIPE_TRANSFER_UNSYNCHRONIZED
);
399 map
[vbi
] += (vbuf
->buffer_offset
/ 4) + stride
[i
] * info
->start
;
401 mapelem
[i
] = map
[vbi
] + (velem
->src_offset
/ 4);
404 r300_emit_draw_init(r300
, info
->mode
, 0, info
->count
-1);
407 OUT_CS_REG(R300_VAP_VTX_SIZE
, vertex_size
);
408 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2
, info
->count
* vertex_size
);
409 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED
| (info
->count
<< 16) |
410 r300_translate_primitive(info
->mode
));
413 for (v
= 0; v
< info
->count
; v
++) {
414 for (i
= 0; i
< vertex_element_count
; i
++) {
415 OUT_CS_TABLE(&mapelem
[i
][stride
[i
] * v
], size
[i
]);
421 for (i
= 0; i
< vertex_element_count
; i
++) {
422 vbi
= r300
->velems
->velem
[i
].vertex_buffer_index
;
425 r300
->rws
->buffer_unmap(r300_resource(r300
->vbuf_mgr
->real_vertex_buffer
[vbi
])->buf
);
431 static void r300_emit_draw_arrays(struct r300_context
*r300
,
435 boolean alt_num_verts
= count
> 65535;
438 if (count
>= (1 << 24)) {
439 fprintf(stderr
, "r300: Got a huge number of vertices: %i, "
440 "refusing to render.\n", count
);
444 r300_emit_draw_init(r300
, mode
, 0, count
-1);
446 BEGIN_CS(2 + (alt_num_verts
? 2 : 0));
448 OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES
, count
);
450 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2
, 0);
451 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST
| (count
<< 16) |
452 r300_translate_primitive(mode
) |
453 (alt_num_verts
? R500_VAP_VF_CNTL__USE_ALT_NUM_VERTS
: 0));
457 static void r300_emit_draw_elements(struct r300_context
*r300
,
458 struct pipe_resource
* indexBuffer
,
465 uint16_t *imm_indices3
)
467 uint32_t count_dwords
, offset_dwords
;
468 boolean alt_num_verts
= count
> 65535;
471 if (count
>= (1 << 24) || max_index
>= (1 << 24)) {
472 fprintf(stderr
, "r300: Got a huge number of vertices: %i, "
473 "refusing to render (max_index: %i).\n", count
, max_index
);
477 DBG(r300
, DBG_DRAW
, "r300: Indexbuf of %u indices, min %u max %u\n",
478 count
, min_index
, max_index
);
480 r300_emit_draw_init(r300
, mode
, min_index
, max_index
);
482 /* If start is odd, render the first triangle with indices embedded
483 * in the command stream. This will increase start by 3 and make it
484 * even. We can then proceed without a fallback. */
485 if (indexSize
== 2 && (start
& 1) &&
486 mode
== PIPE_PRIM_TRIANGLES
) {
488 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2
, 2);
489 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (3 << 16) |
490 R300_VAP_VF_CNTL__PRIM_TRIANGLES
);
491 OUT_CS(imm_indices3
[1] << 16 | imm_indices3
[0]);
492 OUT_CS(imm_indices3
[2]);
501 offset_dwords
= indexSize
* start
/ sizeof(uint32_t);
503 BEGIN_CS(8 + (alt_num_verts
? 2 : 0));
505 OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES
, count
);
507 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2
, 0);
508 if (indexSize
== 4) {
509 count_dwords
= count
;
510 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (count
<< 16) |
511 R300_VAP_VF_CNTL__INDEX_SIZE_32bit
|
512 r300_translate_primitive(mode
) |
513 (alt_num_verts
? R500_VAP_VF_CNTL__USE_ALT_NUM_VERTS
: 0));
515 count_dwords
= (count
+ 1) / 2;
516 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (count
<< 16) |
517 r300_translate_primitive(mode
) |
518 (alt_num_verts
? R500_VAP_VF_CNTL__USE_ALT_NUM_VERTS
: 0));
521 OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER
, 2);
522 OUT_CS(R300_INDX_BUFFER_ONE_REG_WR
| (R300_VAP_PORT_IDX0
>> 2) |
523 (0 << R300_INDX_BUFFER_SKIP_SHIFT
));
524 OUT_CS(offset_dwords
<< 2);
525 OUT_CS(count_dwords
);
526 OUT_CS_RELOC(r300_resource(indexBuffer
));
530 static void r300_draw_elements_immediate(struct r300_context
*r300
,
531 const struct pipe_draw_info
*info
)
536 unsigned index_size
= r300
->index_buffer
.index_size
;
537 unsigned i
, count_dwords
= index_size
== 4 ? info
->count
:
538 (info
->count
+ 1) / 2;
541 /* 19 dwords for r300_draw_elements_immediate. Give up if the function fails. */
542 if (!r300_prepare_for_rendering(r300
,
543 PREP_EMIT_STATES
| PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
|
544 PREP_INDEXED
, NULL
, 2+count_dwords
, 0, info
->index_bias
, -1))
547 r300_emit_draw_init(r300
, info
->mode
, info
->min_index
, info
->max_index
);
549 BEGIN_CS(2 + count_dwords
);
550 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2
, count_dwords
);
552 switch (index_size
) {
554 ptr1
= r300_resource(r300
->index_buffer
.buffer
)->b
.user_ptr
;
557 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (info
->count
<< 16) |
558 r300_translate_primitive(info
->mode
));
560 if (info
->index_bias
&& !r300
->screen
->caps
.is_r500
) {
561 for (i
= 0; i
< info
->count
-1; i
+= 2)
562 OUT_CS(((ptr1
[i
+1] + info
->index_bias
) << 16) |
563 (ptr1
[i
] + info
->index_bias
));
566 OUT_CS(ptr1
[i
] + info
->index_bias
);
568 for (i
= 0; i
< info
->count
-1; i
+= 2)
569 OUT_CS(((ptr1
[i
+1]) << 16) |
578 ptr2
= (uint16_t*)r300_resource(r300
->index_buffer
.buffer
)->b
.user_ptr
;
581 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (info
->count
<< 16) |
582 r300_translate_primitive(info
->mode
));
584 if (info
->index_bias
&& !r300
->screen
->caps
.is_r500
) {
585 for (i
= 0; i
< info
->count
-1; i
+= 2)
586 OUT_CS(((ptr2
[i
+1] + info
->index_bias
) << 16) |
587 (ptr2
[i
] + info
->index_bias
));
590 OUT_CS(ptr2
[i
] + info
->index_bias
);
592 OUT_CS_TABLE(ptr2
, count_dwords
);
597 ptr4
= (uint32_t*)r300_resource(r300
->index_buffer
.buffer
)->b
.user_ptr
;
600 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (info
->count
<< 16) |
601 R300_VAP_VF_CNTL__INDEX_SIZE_32bit
|
602 r300_translate_primitive(info
->mode
));
604 if (info
->index_bias
&& !r300
->screen
->caps
.is_r500
) {
605 for (i
= 0; i
< info
->count
; i
++)
606 OUT_CS(ptr4
[i
] + info
->index_bias
);
608 OUT_CS_TABLE(ptr4
, count_dwords
);
615 static void r300_draw_elements(struct r300_context
*r300
,
616 const struct pipe_draw_info
*info
,
619 struct pipe_resource
*indexBuffer
= r300
->index_buffer
.buffer
;
620 unsigned indexSize
= r300
->index_buffer
.index_size
;
621 struct pipe_resource
* orgIndexBuffer
= indexBuffer
;
622 unsigned start
= info
->start
;
623 unsigned count
= info
->count
;
624 boolean alt_num_verts
= r300
->screen
->caps
.is_r500
&&
626 unsigned short_count
;
627 int buffer_offset
= 0, index_offset
= 0; /* for index bias emulation */
628 uint16_t indices3
[3];
630 if (info
->index_bias
&& !r300
->screen
->caps
.is_r500
) {
631 r300_split_index_bias(r300
, info
->index_bias
, &buffer_offset
, &index_offset
);
634 r300_translate_index_buffer(r300
, &indexBuffer
, &indexSize
, index_offset
,
637 /* Fallback for misaligned ushort indices. */
638 if (indexSize
== 2 && (start
& 1) &&
639 !r300_resource(indexBuffer
)->b
.user_ptr
) {
640 /* If we got here, then orgIndexBuffer == indexBuffer. */
641 uint16_t *ptr
= r300
->rws
->buffer_map(r300_resource(orgIndexBuffer
)->buf
,
644 PIPE_TRANSFER_UNSYNCHRONIZED
);
646 if (info
->mode
== PIPE_PRIM_TRIANGLES
) {
647 memcpy(indices3
, ptr
+ start
, 6);
649 /* Copy the mapped index buffer directly to the upload buffer.
650 * The start index will be aligned simply from the fact that
651 * every sub-buffer in the upload buffer is aligned. */
652 r300_upload_index_buffer(r300
, &indexBuffer
, indexSize
, &start
,
653 count
, (uint8_t*)ptr
);
655 r300
->rws
->buffer_unmap(r300_resource(orgIndexBuffer
)->buf
);
657 if (r300_resource(indexBuffer
)->b
.user_ptr
)
658 r300_upload_index_buffer(r300
, &indexBuffer
, indexSize
,
660 r300_resource(indexBuffer
)->b
.user_ptr
);
663 /* 19 dwords for emit_draw_elements. Give up if the function fails. */
664 if (!r300_prepare_for_rendering(r300
,
665 PREP_EMIT_STATES
| PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
|
666 PREP_INDEXED
, indexBuffer
, 19, buffer_offset
, info
->index_bias
,
670 if (alt_num_verts
|| count
<= 65535) {
671 r300_emit_draw_elements(r300
, indexBuffer
, indexSize
, info
->min_index
,
672 info
->max_index
, info
->mode
, start
, count
,
676 /* The maximum must be divisible by 4 and 3,
677 * so that quad and triangle lists are split correctly.
679 * Strips, loops, and fans won't work. */
680 short_count
= MIN2(count
, 65532);
682 r300_emit_draw_elements(r300
, indexBuffer
, indexSize
,
683 info
->min_index
, info
->max_index
,
684 info
->mode
, start
, short_count
, indices3
);
686 start
+= short_count
;
687 count
-= short_count
;
689 /* 15 dwords for emit_draw_elements */
691 if (!r300_prepare_for_rendering(r300
,
692 PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
| PREP_INDEXED
,
693 indexBuffer
, 19, buffer_offset
, info
->index_bias
,
701 if (indexBuffer
!= orgIndexBuffer
) {
702 pipe_resource_reference( &indexBuffer
, NULL
);
706 static void r300_draw_arrays(struct r300_context
*r300
,
707 const struct pipe_draw_info
*info
,
710 boolean alt_num_verts
= r300
->screen
->caps
.is_r500
&&
712 unsigned start
= info
->start
;
713 unsigned count
= info
->count
;
714 unsigned short_count
;
716 /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
717 if (!r300_prepare_for_rendering(r300
,
718 PREP_EMIT_STATES
| PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
,
719 NULL
, 9, start
, 0, instance_id
))
722 if (alt_num_verts
|| count
<= 65535) {
723 r300_emit_draw_arrays(r300
, info
->mode
, count
);
726 /* The maximum must be divisible by 4 and 3,
727 * so that quad and triangle lists are split correctly.
729 * Strips, loops, and fans won't work. */
730 short_count
= MIN2(count
, 65532);
731 r300_emit_draw_arrays(r300
, info
->mode
, short_count
);
733 start
+= short_count
;
734 count
-= short_count
;
736 /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
738 if (!r300_prepare_for_rendering(r300
,
739 PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
, NULL
, 9,
740 start
, 0, instance_id
))
747 static void r300_draw_arrays_instanced(struct r300_context
*r300
,
748 const struct pipe_draw_info
*info
)
752 for (i
= 0; i
< info
->instance_count
; i
++)
753 r300_draw_arrays(r300
, info
, i
);
756 static void r300_draw_elements_instanced(struct r300_context
*r300
,
757 const struct pipe_draw_info
*info
)
761 for (i
= 0; i
< info
->instance_count
; i
++)
762 r300_draw_elements(r300
, info
, i
);
765 static void r300_draw_vbo(struct pipe_context
* pipe
,
766 const struct pipe_draw_info
*dinfo
)
768 struct r300_context
* r300
= r300_context(pipe
);
769 struct pipe_draw_info info
= *dinfo
;
770 boolean buffers_updated
, uploader_flushed
;
772 info
.indexed
= info
.indexed
&& r300
->index_buffer
.buffer
;
774 if (r300
->skip_rendering
||
775 !u_trim_pipe_prim(info
.mode
, &info
.count
)) {
779 r300_update_derived_state(r300
);
781 /* Start the vbuf manager and update buffers if needed. */
782 u_vbuf_mgr_draw_begin(r300
->vbuf_mgr
, &info
,
783 &buffers_updated
, &uploader_flushed
);
784 if (buffers_updated
) {
785 r300
->vertex_arrays_dirty
= TRUE
;
790 info
.start
+= r300
->index_buffer
.offset
;
791 info
.max_index
= MIN2(r300
->vbuf_mgr
->max_index
, info
.max_index
);
793 if (info
.instance_count
<= 1) {
794 if (info
.count
<= 8 &&
795 r300_resource(r300
->index_buffer
.buffer
)->b
.user_ptr
) {
796 r300_draw_elements_immediate(r300
, &info
);
798 r300_draw_elements(r300
, &info
, -1);
801 r300_draw_elements_instanced(r300
, &info
);
804 if (info
.instance_count
<= 1) {
805 if (immd_is_good_idea(r300
, info
.count
)) {
806 r300_draw_arrays_immediate(r300
, &info
);
808 r300_draw_arrays(r300
, &info
, -1);
811 r300_draw_arrays_instanced(r300
, &info
);
815 u_vbuf_mgr_draw_end(r300
->vbuf_mgr
);
818 /****************************************************************************
819 * The rest of this file is for SW TCL rendering only. Please be polite and *
820 * keep these functions separated so that they are easier to locate. ~C. *
821 ***************************************************************************/
823 /* SW TCL elements, using Draw. */
824 static void r300_swtcl_draw_vbo(struct pipe_context
* pipe
,
825 const struct pipe_draw_info
*info
)
827 struct r300_context
* r300
= r300_context(pipe
);
828 struct pipe_transfer
*vb_transfer
[PIPE_MAX_ATTRIBS
];
829 struct pipe_transfer
*ib_transfer
= NULL
;
830 unsigned count
= info
->count
;
832 void *indices
= NULL
;
833 boolean indexed
= info
->indexed
&& r300
->index_buffer
.buffer
;
835 if (r300
->skip_rendering
) {
839 if (!u_trim_pipe_prim(info
->mode
, &count
)) {
843 r300_update_derived_state(r300
);
845 r300_reserve_cs_dwords(r300
,
846 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
|
847 (indexed
? PREP_INDEXED
: 0),
850 for (i
= 0; i
< r300
->vbuf_mgr
->nr_vertex_buffers
; i
++) {
851 if (r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
) {
852 void *buf
= pipe_buffer_map(pipe
,
853 r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
,
855 PIPE_TRANSFER_UNSYNCHRONIZED
,
857 draw_set_mapped_vertex_buffer(r300
->draw
, i
, buf
);
862 indices
= pipe_buffer_map(pipe
, r300
->index_buffer
.buffer
,
864 PIPE_TRANSFER_UNSYNCHRONIZED
, &ib_transfer
);
867 draw_set_mapped_index_buffer(r300
->draw
, indices
);
869 r300
->draw_vbo_locked
= TRUE
;
870 r300
->draw_first_emitted
= FALSE
;
871 draw_vbo(r300
->draw
, info
);
872 draw_flush(r300
->draw
);
873 r300
->draw_vbo_locked
= FALSE
;
875 for (i
= 0; i
< r300
->vbuf_mgr
->nr_vertex_buffers
; i
++) {
876 if (r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
) {
877 pipe_buffer_unmap(pipe
, vb_transfer
[i
]);
878 draw_set_mapped_vertex_buffer(r300
->draw
, i
, NULL
);
883 pipe_buffer_unmap(pipe
, ib_transfer
);
884 draw_set_mapped_index_buffer(r300
->draw
, NULL
);
888 /* Object for rendering using Draw. */
891 struct vbuf_render base
;
894 struct r300_context
* r300
;
896 /* Vertex information */
905 struct pipe_transfer
*vbo_transfer
;
908 static INLINE
struct r300_render
*
909 r300_render(struct vbuf_render
* render
)
911 return (struct r300_render
*)render
;
914 static const struct vertex_info
*
915 r300_render_get_vertex_info(struct vbuf_render
* render
)
917 struct r300_render
* r300render
= r300_render(render
);
918 struct r300_context
* r300
= r300render
->r300
;
920 return &r300
->vertex_info
;
923 static boolean
r300_render_allocate_vertices(struct vbuf_render
* render
,
927 struct r300_render
* r300render
= r300_render(render
);
928 struct r300_context
* r300
= r300render
->r300
;
929 struct pipe_screen
* screen
= r300
->context
.screen
;
930 size_t size
= (size_t)vertex_size
* (size_t)count
;
932 DBG(r300
, DBG_DRAW
, "r300: render_allocate_vertices (size: %d)\n", size
);
934 if (size
+ r300
->draw_vbo_offset
> r300
->draw_vbo_size
)
936 pipe_resource_reference(&r300
->vbo
, NULL
);
937 r300
->vbo
= pipe_buffer_create(screen
,
938 PIPE_BIND_VERTEX_BUFFER
,
940 R300_MAX_DRAW_VBO_SIZE
);
941 r300
->draw_vbo_offset
= 0;
942 r300
->draw_vbo_size
= R300_MAX_DRAW_VBO_SIZE
;
945 r300render
->vertex_size
= vertex_size
;
947 return (r300
->vbo
) ? TRUE
: FALSE
;
950 static void* r300_render_map_vertices(struct vbuf_render
* render
)
952 struct r300_render
* r300render
= r300_render(render
);
953 struct r300_context
* r300
= r300render
->r300
;
955 assert(!r300render
->vbo_transfer
);
957 DBG(r300
, DBG_DRAW
, "r300: render_map_vertices\n");
959 r300render
->vbo_ptr
= pipe_buffer_map(&r300render
->r300
->context
,
961 PIPE_TRANSFER_WRITE
|
962 PIPE_TRANSFER_UNSYNCHRONIZED
,
963 &r300render
->vbo_transfer
);
965 assert(r300render
->vbo_ptr
);
967 return ((uint8_t*)r300render
->vbo_ptr
+ r300
->draw_vbo_offset
);
970 static void r300_render_unmap_vertices(struct vbuf_render
* render
,
974 struct r300_render
* r300render
= r300_render(render
);
975 struct pipe_context
* context
= &r300render
->r300
->context
;
976 struct r300_context
* r300
= r300render
->r300
;
978 assert(r300render
->vbo_transfer
);
980 DBG(r300
, DBG_DRAW
, "r300: render_unmap_vertices\n");
982 r300render
->vbo_max_used
= MAX2(r300render
->vbo_max_used
,
983 r300render
->vertex_size
* (max
+ 1));
984 pipe_buffer_unmap(context
, r300render
->vbo_transfer
);
986 r300render
->vbo_transfer
= NULL
;
989 static void r300_render_release_vertices(struct vbuf_render
* render
)
991 struct r300_render
* r300render
= r300_render(render
);
992 struct r300_context
* r300
= r300render
->r300
;
994 DBG(r300
, DBG_DRAW
, "r300: render_release_vertices\n");
996 r300
->draw_vbo_offset
+= r300render
->vbo_max_used
;
997 r300render
->vbo_max_used
= 0;
1000 static boolean
r300_render_set_primitive(struct vbuf_render
* render
,
1003 struct r300_render
* r300render
= r300_render(render
);
1005 r300render
->prim
= prim
;
1006 r300render
->hwprim
= r300_translate_primitive(prim
);
1011 static void r300_render_draw_arrays(struct vbuf_render
* render
,
1015 struct r300_render
* r300render
= r300_render(render
);
1016 struct r300_context
* r300
= r300render
->r300
;
1019 unsigned dwords
= 6;
1022 (void) i
; (void) ptr
;
1024 DBG(r300
, DBG_DRAW
, "r300: render_draw_arrays (count: %d)\n", count
);
1026 if (r300
->draw_first_emitted
) {
1027 if (!r300_prepare_for_rendering(r300
,
1028 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
,
1029 NULL
, dwords
, 0, 0, -1))
1032 if (!r300_emit_states(r300
,
1033 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
,
1039 OUT_CS_REG(R300_GA_COLOR_CONTROL
,
1040 r300_provoking_vertex_fixes(r300
, r300render
->prim
));
1041 OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX
, count
- 1);
1042 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2
, 0);
1043 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST
| (count
<< 16) |
1044 r300render
->hwprim
);
1047 r300
->draw_first_emitted
= TRUE
;
1050 static void r300_render_draw_elements(struct vbuf_render
* render
,
1051 const ushort
* indices
,
1054 struct r300_render
* r300render
= r300_render(render
);
1055 struct r300_context
* r300
= r300render
->r300
;
1057 unsigned end_cs_dwords
;
1058 unsigned max_index
= (r300
->draw_vbo_size
- r300
->draw_vbo_offset
) /
1059 (r300render
->r300
->vertex_info
.size
* 4) - 1;
1060 unsigned short_count
;
1061 unsigned free_dwords
;
1064 DBG(r300
, DBG_DRAW
, "r300: render_draw_elements (count: %d)\n", count
);
1066 if (r300
->draw_first_emitted
) {
1067 if (!r300_prepare_for_rendering(r300
,
1068 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1069 NULL
, 256, 0, 0, -1))
1072 if (!r300_emit_states(r300
,
1073 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1078 /* Below we manage the CS space manually because there may be more
1079 * indices than it can fit in CS. */
1081 end_cs_dwords
= r300_get_num_cs_end_dwords(r300
);
1084 free_dwords
= RADEON_MAX_CMDBUF_DWORDS
- r300
->cs
->cdw
;
1086 short_count
= MIN2(count
, (free_dwords
- end_cs_dwords
- 6) * 2);
1088 BEGIN_CS(6 + (short_count
+1)/2);
1089 OUT_CS_REG(R300_GA_COLOR_CONTROL
,
1090 r300_provoking_vertex_fixes(r300
, r300render
->prim
));
1091 OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX
, max_index
);
1092 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2
, (short_count
+1)/2);
1093 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (short_count
<< 16) |
1094 r300render
->hwprim
);
1095 for (i
= 0; i
< short_count
-1; i
+= 2) {
1096 OUT_CS(indices
[i
+1] << 16 | indices
[i
]);
1098 if (short_count
% 2) {
1099 OUT_CS(indices
[short_count
-1]);
1103 /* OK now subtract the emitted indices and see if we need to emit
1104 * another draw packet. */
1105 indices
+= short_count
;
1106 count
-= short_count
;
1109 if (!r300_prepare_for_rendering(r300
,
1110 PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1111 NULL
, 256, 0, 0, -1))
1114 end_cs_dwords
= r300_get_num_cs_end_dwords(r300
);
1118 r300
->draw_first_emitted
= TRUE
;
1121 static void r300_render_destroy(struct vbuf_render
* render
)
1126 static struct vbuf_render
* r300_render_create(struct r300_context
* r300
)
1128 struct r300_render
* r300render
= CALLOC_STRUCT(r300_render
);
1130 r300render
->r300
= r300
;
1132 r300render
->base
.max_vertex_buffer_bytes
= 1024 * 1024;
1133 r300render
->base
.max_indices
= 16 * 1024;
1135 r300render
->base
.get_vertex_info
= r300_render_get_vertex_info
;
1136 r300render
->base
.allocate_vertices
= r300_render_allocate_vertices
;
1137 r300render
->base
.map_vertices
= r300_render_map_vertices
;
1138 r300render
->base
.unmap_vertices
= r300_render_unmap_vertices
;
1139 r300render
->base
.set_primitive
= r300_render_set_primitive
;
1140 r300render
->base
.draw_elements
= r300_render_draw_elements
;
1141 r300render
->base
.draw_arrays
= r300_render_draw_arrays
;
1142 r300render
->base
.release_vertices
= r300_render_release_vertices
;
1143 r300render
->base
.destroy
= r300_render_destroy
;
1145 return &r300render
->base
;
1148 struct draw_stage
* r300_draw_stage(struct r300_context
* r300
)
1150 struct vbuf_render
* render
;
1151 struct draw_stage
* stage
;
1153 render
= r300_render_create(r300
);
1159 stage
= draw_vbuf_stage(r300
->draw
, render
);
1162 render
->destroy(render
);
1166 draw_set_render(r300
->draw
, render
);
1171 void r300_draw_flush_vbuf(struct r300_context
*r300
)
1173 pipe_resource_reference(&r300
->vbo
, NULL
);
1174 r300
->draw_vbo_size
= 0;
1177 /****************************************************************************
1178 * End of SW TCL functions *
1179 ***************************************************************************/
1181 /* This functions is used to draw a rectangle for the blitter module.
1183 * If we rendered a quad, the pixels on the main diagonal
1184 * would be computed and stored twice, which makes the clear/copy codepaths
1185 * somewhat inefficient. Instead we use a rectangular point sprite. */
1186 static void r300_blitter_draw_rectangle(struct blitter_context
*blitter
,
1187 unsigned x1
, unsigned y1
,
1188 unsigned x2
, unsigned y2
,
1190 enum blitter_attrib_type type
,
1191 const float attrib
[4])
1193 struct r300_context
*r300
= r300_context(util_blitter_get_pipe(blitter
));
1194 unsigned last_sprite_coord_enable
= r300
->sprite_coord_enable
;
1195 unsigned width
= x2
- x1
;
1196 unsigned height
= y2
- y1
;
1197 unsigned vertex_size
=
1198 type
== UTIL_BLITTER_ATTRIB_COLOR
|| !r300
->draw
? 8 : 4;
1199 unsigned dwords
= 13 + vertex_size
+
1200 (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
? 7 : 0);
1201 const float zeros
[4] = {0, 0, 0, 0};
1204 if (r300
->skip_rendering
)
1207 r300
->context
.set_vertex_buffers(&r300
->context
, 0, NULL
);
1209 if (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
)
1210 r300
->sprite_coord_enable
= 1;
1212 r300_update_derived_state(r300
);
1214 /* Mark some states we don't care about as non-dirty. */
1215 r300
->clip_state
.dirty
= FALSE
;
1216 r300
->viewport_state
.dirty
= FALSE
;
1218 if (!r300_prepare_for_rendering(r300
, PREP_EMIT_STATES
, NULL
, dwords
, 0, 0, -1))
1221 DBG(r300
, DBG_DRAW
, "r300: draw_rectangle\n");
1225 OUT_CS_REG(R300_GA_POINT_SIZE
, (height
* 6) | ((width
* 6) << 16));
1227 if (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
) {
1228 /* Set up the GA to generate texcoords. */
1229 OUT_CS_REG(R300_GB_ENABLE
, R300_GB_POINT_STUFF_ENABLE
|
1230 (R300_GB_TEX_STR
<< R300_GB_TEX0_SOURCE_SHIFT
));
1231 OUT_CS_REG_SEQ(R300_GA_POINT_S0
, 4);
1232 OUT_CS_32F(attrib
[0]);
1233 OUT_CS_32F(attrib
[3]);
1234 OUT_CS_32F(attrib
[2]);
1235 OUT_CS_32F(attrib
[1]);
1238 /* Set up VAP controls. */
1239 OUT_CS_REG(R300_VAP_CLIP_CNTL
, R300_CLIP_DISABLE
);
1240 OUT_CS_REG(R300_VAP_VTE_CNTL
, R300_VTX_XY_FMT
| R300_VTX_Z_FMT
);
1241 OUT_CS_REG(R300_VAP_VTX_SIZE
, vertex_size
);
1242 OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX
, 2);
1247 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2
, vertex_size
);
1248 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED
| (1 << 16) |
1249 R300_VAP_VF_CNTL__PRIM_POINTS
);
1251 OUT_CS_32F(x1
+ width
* 0.5f
);
1252 OUT_CS_32F(y1
+ height
* 0.5f
);
1256 if (vertex_size
== 8) {
1259 OUT_CS_TABLE(attrib
, 4);
1264 /* Restore the state. */
1265 r300_mark_atom_dirty(r300
, &r300
->clip_state
);
1266 r300_mark_atom_dirty(r300
, &r300
->rs_state
);
1267 r300_mark_atom_dirty(r300
, &r300
->viewport_state
);
1269 r300
->sprite_coord_enable
= last_sprite_coord_enable
;
1272 static void r300_resource_resolve(struct pipe_context
* pipe
,
1273 struct pipe_resource
* dest
,
1275 struct pipe_resource
* src
,
1278 struct r300_context
* r300
= r300_context(pipe
);
1279 struct pipe_surface
* srcsurf
, surf_tmpl
;
1280 struct r300_aa_state
*aa
= (struct r300_aa_state
*)r300
->aa_state
.state
;
1281 float color
[] = {0, 0, 0, 0};
1283 memset(&surf_tmpl
, 0, sizeof(surf_tmpl
));
1284 surf_tmpl
.format
= src
->format
;
1285 surf_tmpl
.usage
= 0; /* not really a surface hence no bind flags */
1286 surf_tmpl
.u
.tex
.level
= 0; /* msaa resources cannot have mipmaps */
1287 surf_tmpl
.u
.tex
.first_layer
= src_layer
;
1288 surf_tmpl
.u
.tex
.last_layer
= src_layer
;
1289 srcsurf
= pipe
->create_surface(pipe
, src
, &surf_tmpl
);
1290 surf_tmpl
.format
= dest
->format
;
1291 surf_tmpl
.u
.tex
.first_layer
= dst_layer
;
1292 surf_tmpl
.u
.tex
.last_layer
= dst_layer
;
1294 DBG(r300
, DBG_DRAW
, "r300: Resolving resource...\n");
1296 /* Enable AA resolve. */
1297 aa
->dest
= r300_surface(pipe
->create_surface(pipe
, dest
, &surf_tmpl
));
1300 R300_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_RESOLVE
|
1301 R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE
;
1302 r300
->aa_state
.size
= 10;
1303 r300_mark_atom_dirty(r300
, &r300
->aa_state
);
1305 /* Resolve the surface. */
1306 r300
->context
.clear_render_target(pipe
,
1307 srcsurf
, color
, 0, 0, src
->width0
, src
->height0
);
1309 /* Disable AA resolve. */
1310 aa
->aaresolve_ctl
= 0;
1311 r300
->aa_state
.size
= 4;
1312 r300_mark_atom_dirty(r300
, &r300
->aa_state
);
1314 pipe_surface_reference((struct pipe_surface
**)&srcsurf
, NULL
);
1315 pipe_surface_reference((struct pipe_surface
**)&aa
->dest
, NULL
);
1318 void r300_init_render_functions(struct r300_context
*r300
)
1320 /* Set draw functions based on presence of HW TCL. */
1321 if (r300
->screen
->caps
.has_tcl
) {
1322 r300
->context
.draw_vbo
= r300_draw_vbo
;
1324 r300
->context
.draw_vbo
= r300_swtcl_draw_vbo
;
1327 r300
->context
.resource_resolve
= r300_resource_resolve
;
1328 r300
->blitter
->draw_rectangle
= r300_blitter_draw_rectangle
;
1330 /* Plug in the two-sided stencil reference value fallback if needed. */
1331 if (!r300
->screen
->caps
.is_r500
)
1332 r300_plug_in_stencil_ref_fallback(r300
);