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 if (indexSize
== 2 && (start
& 1))
677 short_count
= MIN2(count
, 65535);
679 short_count
= MIN2(count
, 65534);
681 r300_emit_draw_elements(r300
, indexBuffer
, indexSize
,
682 info
->min_index
, info
->max_index
,
683 info
->mode
, start
, short_count
, indices3
);
685 start
+= short_count
;
686 count
-= short_count
;
688 /* 15 dwords for emit_draw_elements */
690 if (!r300_prepare_for_rendering(r300
,
691 PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
| PREP_INDEXED
,
692 indexBuffer
, 19, buffer_offset
, info
->index_bias
,
700 if (indexBuffer
!= orgIndexBuffer
) {
701 pipe_resource_reference( &indexBuffer
, NULL
);
705 static void r300_draw_arrays(struct r300_context
*r300
,
706 const struct pipe_draw_info
*info
,
709 boolean alt_num_verts
= r300
->screen
->caps
.is_r500
&&
711 unsigned start
= info
->start
;
712 unsigned count
= info
->count
;
713 unsigned short_count
;
715 /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
716 if (!r300_prepare_for_rendering(r300
,
717 PREP_EMIT_STATES
| PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
,
718 NULL
, 9, start
, 0, instance_id
))
721 if (alt_num_verts
|| count
<= 65535) {
722 r300_emit_draw_arrays(r300
, info
->mode
, count
);
725 short_count
= MIN2(count
, 65535);
726 r300_emit_draw_arrays(r300
, info
->mode
, short_count
);
728 start
+= short_count
;
729 count
-= short_count
;
731 /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
733 if (!r300_prepare_for_rendering(r300
,
734 PREP_VALIDATE_VBOS
| PREP_EMIT_AOS
, NULL
, 9,
735 start
, 0, instance_id
))
742 static void r300_draw_arrays_instanced(struct r300_context
*r300
,
743 const struct pipe_draw_info
*info
)
747 for (i
= 0; i
< info
->instance_count
; i
++)
748 r300_draw_arrays(r300
, info
, i
);
751 static void r300_draw_elements_instanced(struct r300_context
*r300
,
752 const struct pipe_draw_info
*info
)
756 for (i
= 0; i
< info
->instance_count
; i
++)
757 r300_draw_elements(r300
, info
, i
);
760 static void r300_draw_vbo(struct pipe_context
* pipe
,
761 const struct pipe_draw_info
*dinfo
)
763 struct r300_context
* r300
= r300_context(pipe
);
764 struct pipe_draw_info info
= *dinfo
;
765 boolean buffers_updated
, uploader_flushed
;
767 info
.indexed
= info
.indexed
&& r300
->index_buffer
.buffer
;
769 if (r300
->skip_rendering
||
770 !u_trim_pipe_prim(info
.mode
, &info
.count
)) {
774 r300_update_derived_state(r300
);
776 /* Start the vbuf manager and update buffers if needed. */
777 u_vbuf_mgr_draw_begin(r300
->vbuf_mgr
, &info
,
778 &buffers_updated
, &uploader_flushed
);
779 if (buffers_updated
) {
780 r300
->vertex_arrays_dirty
= TRUE
;
785 info
.start
+= r300
->index_buffer
.offset
;
786 info
.max_index
= MIN2(r300
->vbuf_mgr
->max_index
, info
.max_index
);
788 if (info
.instance_count
<= 1) {
789 if (info
.count
<= 8 &&
790 r300_resource(r300
->index_buffer
.buffer
)->b
.user_ptr
) {
791 r300_draw_elements_immediate(r300
, &info
);
793 r300_draw_elements(r300
, &info
, -1);
796 r300_draw_elements_instanced(r300
, &info
);
799 if (info
.instance_count
<= 1) {
800 if (immd_is_good_idea(r300
, info
.count
)) {
801 r300_draw_arrays_immediate(r300
, &info
);
803 r300_draw_arrays(r300
, &info
, -1);
806 r300_draw_arrays_instanced(r300
, &info
);
810 u_vbuf_mgr_draw_end(r300
->vbuf_mgr
);
813 /****************************************************************************
814 * The rest of this file is for SW TCL rendering only. Please be polite and *
815 * keep these functions separated so that they are easier to locate. ~C. *
816 ***************************************************************************/
818 /* SW TCL elements, using Draw. */
819 static void r300_swtcl_draw_vbo(struct pipe_context
* pipe
,
820 const struct pipe_draw_info
*info
)
822 struct r300_context
* r300
= r300_context(pipe
);
823 struct pipe_transfer
*vb_transfer
[PIPE_MAX_ATTRIBS
];
824 struct pipe_transfer
*ib_transfer
= NULL
;
825 unsigned count
= info
->count
;
827 void *indices
= NULL
;
828 boolean indexed
= info
->indexed
&& r300
->index_buffer
.buffer
;
830 if (r300
->skip_rendering
) {
834 if (!u_trim_pipe_prim(info
->mode
, &count
)) {
838 r300_update_derived_state(r300
);
840 r300_reserve_cs_dwords(r300
,
841 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
|
842 (indexed
? PREP_INDEXED
: 0),
845 for (i
= 0; i
< r300
->vbuf_mgr
->nr_vertex_buffers
; i
++) {
846 if (r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
) {
847 void *buf
= pipe_buffer_map(pipe
,
848 r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
,
850 PIPE_TRANSFER_UNSYNCHRONIZED
,
852 draw_set_mapped_vertex_buffer(r300
->draw
, i
, buf
);
857 indices
= pipe_buffer_map(pipe
, r300
->index_buffer
.buffer
,
859 PIPE_TRANSFER_UNSYNCHRONIZED
, &ib_transfer
);
862 draw_set_mapped_index_buffer(r300
->draw
, indices
);
864 r300
->draw_vbo_locked
= TRUE
;
865 r300
->draw_first_emitted
= FALSE
;
866 draw_vbo(r300
->draw
, info
);
867 draw_flush(r300
->draw
);
868 r300
->draw_vbo_locked
= FALSE
;
870 for (i
= 0; i
< r300
->vbuf_mgr
->nr_vertex_buffers
; i
++) {
871 if (r300
->vbuf_mgr
->vertex_buffer
[i
].buffer
) {
872 pipe_buffer_unmap(pipe
, vb_transfer
[i
]);
873 draw_set_mapped_vertex_buffer(r300
->draw
, i
, NULL
);
878 pipe_buffer_unmap(pipe
, ib_transfer
);
879 draw_set_mapped_index_buffer(r300
->draw
, NULL
);
883 /* Object for rendering using Draw. */
886 struct vbuf_render base
;
889 struct r300_context
* r300
;
891 /* Vertex information */
900 struct pipe_transfer
*vbo_transfer
;
903 static INLINE
struct r300_render
*
904 r300_render(struct vbuf_render
* render
)
906 return (struct r300_render
*)render
;
909 static const struct vertex_info
*
910 r300_render_get_vertex_info(struct vbuf_render
* render
)
912 struct r300_render
* r300render
= r300_render(render
);
913 struct r300_context
* r300
= r300render
->r300
;
915 return &r300
->vertex_info
;
918 static boolean
r300_render_allocate_vertices(struct vbuf_render
* render
,
922 struct r300_render
* r300render
= r300_render(render
);
923 struct r300_context
* r300
= r300render
->r300
;
924 struct pipe_screen
* screen
= r300
->context
.screen
;
925 size_t size
= (size_t)vertex_size
* (size_t)count
;
927 DBG(r300
, DBG_DRAW
, "r300: render_allocate_vertices (size: %d)\n", size
);
929 if (size
+ r300
->draw_vbo_offset
> r300
->draw_vbo_size
)
931 pipe_resource_reference(&r300
->vbo
, NULL
);
932 r300
->vbo
= pipe_buffer_create(screen
,
933 PIPE_BIND_VERTEX_BUFFER
,
935 R300_MAX_DRAW_VBO_SIZE
);
936 r300
->draw_vbo_offset
= 0;
937 r300
->draw_vbo_size
= R300_MAX_DRAW_VBO_SIZE
;
940 r300render
->vertex_size
= vertex_size
;
942 return (r300
->vbo
) ? TRUE
: FALSE
;
945 static void* r300_render_map_vertices(struct vbuf_render
* render
)
947 struct r300_render
* r300render
= r300_render(render
);
948 struct r300_context
* r300
= r300render
->r300
;
950 assert(!r300render
->vbo_transfer
);
952 DBG(r300
, DBG_DRAW
, "r300: render_map_vertices\n");
954 r300render
->vbo_ptr
= pipe_buffer_map(&r300render
->r300
->context
,
956 PIPE_TRANSFER_WRITE
|
957 PIPE_TRANSFER_UNSYNCHRONIZED
,
958 &r300render
->vbo_transfer
);
960 assert(r300render
->vbo_ptr
);
962 return ((uint8_t*)r300render
->vbo_ptr
+ r300
->draw_vbo_offset
);
965 static void r300_render_unmap_vertices(struct vbuf_render
* render
,
969 struct r300_render
* r300render
= r300_render(render
);
970 struct pipe_context
* context
= &r300render
->r300
->context
;
971 struct r300_context
* r300
= r300render
->r300
;
973 assert(r300render
->vbo_transfer
);
975 DBG(r300
, DBG_DRAW
, "r300: render_unmap_vertices\n");
977 r300render
->vbo_max_used
= MAX2(r300render
->vbo_max_used
,
978 r300render
->vertex_size
* (max
+ 1));
979 pipe_buffer_unmap(context
, r300render
->vbo_transfer
);
981 r300render
->vbo_transfer
= NULL
;
984 static void r300_render_release_vertices(struct vbuf_render
* render
)
986 struct r300_render
* r300render
= r300_render(render
);
987 struct r300_context
* r300
= r300render
->r300
;
989 DBG(r300
, DBG_DRAW
, "r300: render_release_vertices\n");
991 r300
->draw_vbo_offset
+= r300render
->vbo_max_used
;
992 r300render
->vbo_max_used
= 0;
995 static boolean
r300_render_set_primitive(struct vbuf_render
* render
,
998 struct r300_render
* r300render
= r300_render(render
);
1000 r300render
->prim
= prim
;
1001 r300render
->hwprim
= r300_translate_primitive(prim
);
1006 static void r300_render_draw_arrays(struct vbuf_render
* render
,
1010 struct r300_render
* r300render
= r300_render(render
);
1011 struct r300_context
* r300
= r300render
->r300
;
1014 unsigned dwords
= 6;
1017 (void) i
; (void) ptr
;
1019 DBG(r300
, DBG_DRAW
, "r300: render_draw_arrays (count: %d)\n", count
);
1021 if (r300
->draw_first_emitted
) {
1022 if (!r300_prepare_for_rendering(r300
,
1023 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
,
1024 NULL
, dwords
, 0, 0, -1))
1027 if (!r300_emit_states(r300
,
1028 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
,
1034 OUT_CS_REG(R300_GA_COLOR_CONTROL
,
1035 r300_provoking_vertex_fixes(r300
, r300render
->prim
));
1036 OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX
, count
- 1);
1037 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2
, 0);
1038 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST
| (count
<< 16) |
1039 r300render
->hwprim
);
1042 r300
->draw_first_emitted
= TRUE
;
1045 static void r300_render_draw_elements(struct vbuf_render
* render
,
1046 const ushort
* indices
,
1049 struct r300_render
* r300render
= r300_render(render
);
1050 struct r300_context
* r300
= r300render
->r300
;
1052 unsigned end_cs_dwords
;
1053 unsigned max_index
= (r300
->draw_vbo_size
- r300
->draw_vbo_offset
) /
1054 (r300render
->r300
->vertex_info
.size
* 4) - 1;
1055 unsigned short_count
;
1056 unsigned free_dwords
;
1059 DBG(r300
, DBG_DRAW
, "r300: render_draw_elements (count: %d)\n", count
);
1061 if (r300
->draw_first_emitted
) {
1062 if (!r300_prepare_for_rendering(r300
,
1063 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1064 NULL
, 256, 0, 0, -1))
1067 if (!r300_emit_states(r300
,
1068 PREP_EMIT_STATES
| PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1073 /* Below we manage the CS space manually because there may be more
1074 * indices than it can fit in CS. */
1076 end_cs_dwords
= r300_get_num_cs_end_dwords(r300
);
1079 free_dwords
= RADEON_MAX_CMDBUF_DWORDS
- r300
->cs
->cdw
;
1081 short_count
= MIN2(count
, (free_dwords
- end_cs_dwords
- 6) * 2);
1083 BEGIN_CS(6 + (short_count
+1)/2);
1084 OUT_CS_REG(R300_GA_COLOR_CONTROL
,
1085 r300_provoking_vertex_fixes(r300
, r300render
->prim
));
1086 OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX
, max_index
);
1087 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2
, (short_count
+1)/2);
1088 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (short_count
<< 16) |
1089 r300render
->hwprim
);
1090 for (i
= 0; i
< short_count
-1; i
+= 2) {
1091 OUT_CS(indices
[i
+1] << 16 | indices
[i
]);
1093 if (short_count
% 2) {
1094 OUT_CS(indices
[short_count
-1]);
1098 /* OK now subtract the emitted indices and see if we need to emit
1099 * another draw packet. */
1100 indices
+= short_count
;
1101 count
-= short_count
;
1104 if (!r300_prepare_for_rendering(r300
,
1105 PREP_EMIT_AOS_SWTCL
| PREP_INDEXED
,
1106 NULL
, 256, 0, 0, -1))
1109 end_cs_dwords
= r300_get_num_cs_end_dwords(r300
);
1113 r300
->draw_first_emitted
= TRUE
;
1116 static void r300_render_destroy(struct vbuf_render
* render
)
1121 static struct vbuf_render
* r300_render_create(struct r300_context
* r300
)
1123 struct r300_render
* r300render
= CALLOC_STRUCT(r300_render
);
1125 r300render
->r300
= r300
;
1127 r300render
->base
.max_vertex_buffer_bytes
= 1024 * 1024;
1128 r300render
->base
.max_indices
= 16 * 1024;
1130 r300render
->base
.get_vertex_info
= r300_render_get_vertex_info
;
1131 r300render
->base
.allocate_vertices
= r300_render_allocate_vertices
;
1132 r300render
->base
.map_vertices
= r300_render_map_vertices
;
1133 r300render
->base
.unmap_vertices
= r300_render_unmap_vertices
;
1134 r300render
->base
.set_primitive
= r300_render_set_primitive
;
1135 r300render
->base
.draw_elements
= r300_render_draw_elements
;
1136 r300render
->base
.draw_arrays
= r300_render_draw_arrays
;
1137 r300render
->base
.release_vertices
= r300_render_release_vertices
;
1138 r300render
->base
.destroy
= r300_render_destroy
;
1140 return &r300render
->base
;
1143 struct draw_stage
* r300_draw_stage(struct r300_context
* r300
)
1145 struct vbuf_render
* render
;
1146 struct draw_stage
* stage
;
1148 render
= r300_render_create(r300
);
1154 stage
= draw_vbuf_stage(r300
->draw
, render
);
1157 render
->destroy(render
);
1161 draw_set_render(r300
->draw
, render
);
1166 void r300_draw_flush_vbuf(struct r300_context
*r300
)
1168 pipe_resource_reference(&r300
->vbo
, NULL
);
1169 r300
->draw_vbo_size
= 0;
1172 /****************************************************************************
1173 * End of SW TCL functions *
1174 ***************************************************************************/
1176 /* This functions is used to draw a rectangle for the blitter module.
1178 * If we rendered a quad, the pixels on the main diagonal
1179 * would be computed and stored twice, which makes the clear/copy codepaths
1180 * somewhat inefficient. Instead we use a rectangular point sprite. */
1181 static void r300_blitter_draw_rectangle(struct blitter_context
*blitter
,
1182 unsigned x1
, unsigned y1
,
1183 unsigned x2
, unsigned y2
,
1185 enum blitter_attrib_type type
,
1186 const float attrib
[4])
1188 struct r300_context
*r300
= r300_context(util_blitter_get_pipe(blitter
));
1189 unsigned last_sprite_coord_enable
= r300
->sprite_coord_enable
;
1190 unsigned width
= x2
- x1
;
1191 unsigned height
= y2
- y1
;
1192 unsigned vertex_size
=
1193 type
== UTIL_BLITTER_ATTRIB_COLOR
|| !r300
->draw
? 8 : 4;
1194 unsigned dwords
= 13 + vertex_size
+
1195 (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
? 7 : 0);
1196 const float zeros
[4] = {0, 0, 0, 0};
1199 if (r300
->skip_rendering
)
1202 r300
->context
.set_vertex_buffers(&r300
->context
, 0, NULL
);
1204 if (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
)
1205 r300
->sprite_coord_enable
= 1;
1207 r300_update_derived_state(r300
);
1209 /* Mark some states we don't care about as non-dirty. */
1210 r300
->clip_state
.dirty
= FALSE
;
1211 r300
->viewport_state
.dirty
= FALSE
;
1213 if (!r300_prepare_for_rendering(r300
, PREP_EMIT_STATES
, NULL
, dwords
, 0, 0, -1))
1216 DBG(r300
, DBG_DRAW
, "r300: draw_rectangle\n");
1220 OUT_CS_REG(R300_GA_POINT_SIZE
, (height
* 6) | ((width
* 6) << 16));
1222 if (type
== UTIL_BLITTER_ATTRIB_TEXCOORD
) {
1223 /* Set up the GA to generate texcoords. */
1224 OUT_CS_REG(R300_GB_ENABLE
, R300_GB_POINT_STUFF_ENABLE
|
1225 (R300_GB_TEX_STR
<< R300_GB_TEX0_SOURCE_SHIFT
));
1226 OUT_CS_REG_SEQ(R300_GA_POINT_S0
, 4);
1227 OUT_CS_32F(attrib
[0]);
1228 OUT_CS_32F(attrib
[3]);
1229 OUT_CS_32F(attrib
[2]);
1230 OUT_CS_32F(attrib
[1]);
1233 /* Set up VAP controls. */
1234 OUT_CS_REG(R300_VAP_CLIP_CNTL
, R300_CLIP_DISABLE
);
1235 OUT_CS_REG(R300_VAP_VTE_CNTL
, R300_VTX_XY_FMT
| R300_VTX_Z_FMT
);
1236 OUT_CS_REG(R300_VAP_VTX_SIZE
, vertex_size
);
1237 OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX
, 2);
1242 OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2
, vertex_size
);
1243 OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED
| (1 << 16) |
1244 R300_VAP_VF_CNTL__PRIM_POINTS
);
1246 OUT_CS_32F(x1
+ width
* 0.5f
);
1247 OUT_CS_32F(y1
+ height
* 0.5f
);
1251 if (vertex_size
== 8) {
1254 OUT_CS_TABLE(attrib
, 4);
1259 /* Restore the state. */
1260 r300_mark_atom_dirty(r300
, &r300
->clip_state
);
1261 r300_mark_atom_dirty(r300
, &r300
->rs_state
);
1262 r300_mark_atom_dirty(r300
, &r300
->viewport_state
);
1264 r300
->sprite_coord_enable
= last_sprite_coord_enable
;
1267 static void r300_resource_resolve(struct pipe_context
* pipe
,
1268 struct pipe_resource
* dest
,
1270 struct pipe_resource
* src
,
1273 struct r300_context
* r300
= r300_context(pipe
);
1274 struct pipe_surface
* srcsurf
, surf_tmpl
;
1275 struct r300_aa_state
*aa
= (struct r300_aa_state
*)r300
->aa_state
.state
;
1276 float color
[] = {0, 0, 0, 0};
1278 memset(&surf_tmpl
, 0, sizeof(surf_tmpl
));
1279 surf_tmpl
.format
= src
->format
;
1280 surf_tmpl
.usage
= 0; /* not really a surface hence no bind flags */
1281 surf_tmpl
.u
.tex
.level
= 0; /* msaa resources cannot have mipmaps */
1282 surf_tmpl
.u
.tex
.first_layer
= src_layer
;
1283 surf_tmpl
.u
.tex
.last_layer
= src_layer
;
1284 srcsurf
= pipe
->create_surface(pipe
, src
, &surf_tmpl
);
1285 surf_tmpl
.format
= dest
->format
;
1286 surf_tmpl
.u
.tex
.first_layer
= dst_layer
;
1287 surf_tmpl
.u
.tex
.last_layer
= dst_layer
;
1289 DBG(r300
, DBG_DRAW
, "r300: Resolving resource...\n");
1291 /* Enable AA resolve. */
1292 aa
->dest
= r300_surface(pipe
->create_surface(pipe
, dest
, &surf_tmpl
));
1295 R300_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_RESOLVE
|
1296 R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE
;
1297 r300
->aa_state
.size
= 10;
1298 r300_mark_atom_dirty(r300
, &r300
->aa_state
);
1300 /* Resolve the surface. */
1301 r300
->context
.clear_render_target(pipe
,
1302 srcsurf
, color
, 0, 0, src
->width0
, src
->height0
);
1304 /* Disable AA resolve. */
1305 aa
->aaresolve_ctl
= 0;
1306 r300
->aa_state
.size
= 4;
1307 r300_mark_atom_dirty(r300
, &r300
->aa_state
);
1309 pipe_surface_reference((struct pipe_surface
**)&srcsurf
, NULL
);
1310 pipe_surface_reference((struct pipe_surface
**)&aa
->dest
, NULL
);
1313 void r300_init_render_functions(struct r300_context
*r300
)
1315 /* Set draw functions based on presence of HW TCL. */
1316 if (r300
->screen
->caps
.has_tcl
) {
1317 r300
->context
.draw_vbo
= r300_draw_vbo
;
1319 r300
->context
.draw_vbo
= r300_swtcl_draw_vbo
;
1322 r300
->context
.resource_resolve
= r300_resource_resolve
;
1323 r300
->blitter
->draw_rectangle
= r300_blitter_draw_rectangle
;
1325 /* Plug in the two-sided stencil reference value fallback if needed. */
1326 if (!r300
->screen
->caps
.is_r500
)
1327 r300_plug_in_stencil_ref_fallback(r300
);