2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2009 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_emit: Functions for emitting state. */
26 #include "util/u_format.h"
27 #include "util/u_math.h"
28 #include "util/u_mm.h"
30 #include "r300_context.h"
33 #include "r300_emit.h"
35 #include "r300_screen.h"
36 #include "r300_screen_buffer.h"
39 void r300_emit_blend_state(struct r300_context
* r300
,
40 unsigned size
, void* state
)
42 struct r300_blend_state
* blend
= (struct r300_blend_state
*)state
;
43 struct pipe_framebuffer_state
* fb
=
44 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
48 WRITE_CS_TABLE(blend
->cb
, size
);
50 WRITE_CS_TABLE(blend
->cb_no_readwrite
, size
);
54 void r300_emit_blend_color_state(struct r300_context
* r300
,
55 unsigned size
, void* state
)
57 struct r300_blend_color_state
* bc
= (struct r300_blend_color_state
*)state
;
60 WRITE_CS_TABLE(bc
->cb
, size
);
63 void r300_emit_clip_state(struct r300_context
* r300
,
64 unsigned size
, void* state
)
66 struct r300_clip_state
* clip
= (struct r300_clip_state
*)state
;
69 WRITE_CS_TABLE(clip
->cb
, size
);
72 void r300_emit_dsa_state(struct r300_context
* r300
, unsigned size
, void* state
)
74 struct r300_dsa_state
* dsa
= (struct r300_dsa_state
*)state
;
75 struct pipe_framebuffer_state
* fb
=
76 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
80 WRITE_CS_TABLE(&dsa
->cb_begin
, size
);
82 WRITE_CS_TABLE(dsa
->cb_no_readwrite
, size
);
86 static void get_rc_constant_state(
88 struct r300_context
* r300
,
89 struct rc_constant
* constant
)
91 struct r300_textures_state
* texstate
= r300
->textures_state
.state
;
92 struct r300_texture
*tex
;
94 assert(constant
->Type
== RC_CONSTANT_STATE
);
96 /* vec should either be (0, 0, 0, 1), which should be a relatively safe
97 * RGBA or STRQ value, or it could be one of the RC_CONSTANT_STATE
100 switch (constant
->u
.State
[0]) {
101 /* Factor for converting rectangle coords to
102 * normalized coords. Should only show up on non-r500. */
103 case RC_STATE_R300_TEXRECT_FACTOR
:
104 tex
= r300_texture(texstate
->sampler_views
[constant
->u
.State
[1]]->base
.texture
);
105 vec
[0] = 1.0 / tex
->desc
.width0
;
106 vec
[1] = 1.0 / tex
->desc
.height0
;
111 case RC_STATE_R300_TEXSCALE_FACTOR
:
112 tex
= r300_texture(texstate
->sampler_views
[constant
->u
.State
[1]]->base
.texture
);
113 /* Add a small number to the texture size to work around rounding errors in hw. */
114 vec
[0] = tex
->desc
.b
.b
.width0
/ (tex
->desc
.width0
+ 0.001f
);
115 vec
[1] = tex
->desc
.b
.b
.height0
/ (tex
->desc
.height0
+ 0.001f
);
116 vec
[2] = tex
->desc
.b
.b
.depth0
/ (tex
->desc
.depth0
+ 0.001f
);
120 case RC_STATE_R300_VIEWPORT_SCALE
:
121 vec
[0] = r300
->viewport
.scale
[0];
122 vec
[1] = r300
->viewport
.scale
[1];
123 vec
[2] = r300
->viewport
.scale
[2];
127 case RC_STATE_R300_VIEWPORT_OFFSET
:
128 vec
[0] = r300
->viewport
.translate
[0];
129 vec
[1] = r300
->viewport
.translate
[1];
130 vec
[2] = r300
->viewport
.translate
[2];
135 fprintf(stderr
, "r300: Implementation error: "
136 "Unknown RC_CONSTANT type %d\n", constant
->u
.State
[0]);
144 /* Convert a normal single-precision float into the 7.16 format
145 * used by the R300 fragment shader.
147 uint32_t pack_float24(float f
)
155 uint32_t float24
= 0;
162 mantissa
= frexpf(f
, &exponent
);
166 float24
|= (1 << 23);
167 mantissa
= mantissa
* -1.0;
169 /* Handle exponent, bias of 63 */
171 float24
|= (exponent
<< 16);
172 /* Kill 7 LSB of mantissa */
173 float24
|= (u
.u
& 0x7FFFFF) >> 7;
178 void r300_emit_fs(struct r300_context
* r300
, unsigned size
, void *state
)
180 struct r300_fragment_shader
*fs
= r300_fs(r300
);
183 WRITE_CS_TABLE(fs
->shader
->cb_code
, fs
->shader
->cb_code_size
);
186 void r300_emit_fs_constants(struct r300_context
* r300
, unsigned size
, void *state
)
188 struct r300_fragment_shader
*fs
= r300_fs(r300
);
189 struct r300_constant_buffer
*buf
= (struct r300_constant_buffer
*)state
;
190 unsigned count
= fs
->shader
->externals_count
;
198 OUT_CS_REG_SEQ(R300_PFS_PARAM_0_X
, count
* 4);
199 if (buf
->remap_table
){
200 for (i
= 0; i
< count
; i
++) {
201 float *data
= (float*)&buf
->ptr
[buf
->remap_table
[i
]*4];
202 for (j
= 0; j
< 4; j
++)
203 OUT_CS(pack_float24(data
[j
]));
206 for (i
= 0; i
< count
; i
++)
207 for (j
= 0; j
< 4; j
++)
208 OUT_CS(pack_float24(*(float*)&buf
->ptr
[i
*4+j
]));
214 void r300_emit_fs_rc_constant_state(struct r300_context
* r300
, unsigned size
, void *state
)
216 struct r300_fragment_shader
*fs
= r300_fs(r300
);
217 struct rc_constant_list
*constants
= &fs
->shader
->code
.constants
;
219 unsigned count
= fs
->shader
->rc_state_count
;
220 unsigned first
= fs
->shader
->externals_count
;
221 unsigned end
= constants
->Count
;
229 for(i
= first
; i
< end
; ++i
) {
230 if (constants
->Constants
[i
].Type
== RC_CONSTANT_STATE
) {
233 get_rc_constant_state(data
, r300
, &constants
->Constants
[i
]);
235 OUT_CS_REG_SEQ(R300_PFS_PARAM_0_X
+ i
* 16, 4);
236 for (j
= 0; j
< 4; j
++)
237 OUT_CS(pack_float24(data
[j
]));
243 void r500_emit_fs(struct r300_context
* r300
, unsigned size
, void *state
)
245 struct r300_fragment_shader
*fs
= r300_fs(r300
);
248 WRITE_CS_TABLE(fs
->shader
->cb_code
, fs
->shader
->cb_code_size
);
251 void r500_emit_fs_constants(struct r300_context
* r300
, unsigned size
, void *state
)
253 struct r300_fragment_shader
*fs
= r300_fs(r300
);
254 struct r300_constant_buffer
*buf
= (struct r300_constant_buffer
*)state
;
255 unsigned count
= fs
->shader
->externals_count
;
262 OUT_CS_REG(R500_GA_US_VECTOR_INDEX
, R500_GA_US_VECTOR_INDEX_TYPE_CONST
);
263 OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA
, count
* 4);
264 if (buf
->remap_table
){
265 for (unsigned i
= 0; i
< count
; i
++) {
266 uint32_t *data
= &buf
->ptr
[buf
->remap_table
[i
]*4];
267 OUT_CS_TABLE(data
, 4);
270 OUT_CS_TABLE(buf
->ptr
, count
* 4);
275 void r500_emit_fs_rc_constant_state(struct r300_context
* r300
, unsigned size
, void *state
)
277 struct r300_fragment_shader
*fs
= r300_fs(r300
);
278 struct rc_constant_list
*constants
= &fs
->shader
->code
.constants
;
280 unsigned count
= fs
->shader
->rc_state_count
;
281 unsigned first
= fs
->shader
->externals_count
;
282 unsigned end
= constants
->Count
;
289 for(i
= first
; i
< end
; ++i
) {
290 if (constants
->Constants
[i
].Type
== RC_CONSTANT_STATE
) {
293 get_rc_constant_state(data
, r300
, &constants
->Constants
[i
]);
295 OUT_CS_REG(R500_GA_US_VECTOR_INDEX
,
296 R500_GA_US_VECTOR_INDEX_TYPE_CONST
|
297 (i
& R500_GA_US_VECTOR_INDEX_MASK
));
298 OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA
, 4);
299 OUT_CS_TABLE(data
, 4);
305 void r300_emit_gpu_flush(struct r300_context
*r300
, unsigned size
, void *state
)
307 struct r300_gpu_flush
*gpuflush
= (struct r300_gpu_flush
*)state
;
308 struct pipe_framebuffer_state
* fb
=
309 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
310 uint32_t height
= fb
->height
;
311 uint32_t width
= fb
->width
;
314 if (r300
->cbzb_clear
) {
315 struct r300_surface
*surf
= r300_surface(fb
->cbufs
[0]);
317 height
= surf
->cbzb_height
;
318 width
= surf
->cbzb_width
;
321 DBG(r300
, DBG_SCISSOR
,
322 "r300: Scissor width: %i, height: %i, CBZB clear: %s\n",
323 width
, height
, r300
->cbzb_clear
? "YES" : "NO");
328 * By writing to the SC registers, SC & US assert idle. */
329 OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL
, 2);
330 if (r300
->screen
->caps
.is_r500
) {
332 OUT_CS(((width
- 1) << R300_SCISSORS_X_SHIFT
) |
333 ((height
- 1) << R300_SCISSORS_Y_SHIFT
));
335 OUT_CS((1440 << R300_SCISSORS_X_SHIFT
) |
336 (1440 << R300_SCISSORS_Y_SHIFT
));
337 OUT_CS(((width
+ 1440-1) << R300_SCISSORS_X_SHIFT
) |
338 ((height
+ 1440-1) << R300_SCISSORS_Y_SHIFT
));
341 /* Flush CB & ZB caches and wait until the 3D engine is idle and clean. */
342 OUT_CS_TABLE(gpuflush
->cb_flush_clean
, 6);
346 void r300_emit_aa_state(struct r300_context
*r300
, unsigned size
, void *state
)
348 struct r300_aa_state
*aa
= (struct r300_aa_state
*)state
;
352 OUT_CS_REG(R300_GB_AA_CONFIG
, aa
->aa_config
);
355 OUT_CS_REG(R300_RB3D_AARESOLVE_OFFSET
, aa
->dest
->offset
);
356 OUT_CS_RELOC(aa
->dest
);
358 OUT_CS_REG(R300_RB3D_AARESOLVE_PITCH
, aa
->dest
->pitch
);
359 OUT_CS_RELOC(aa
->dest
);
362 OUT_CS_REG(R300_RB3D_AARESOLVE_CTL
, aa
->aaresolve_ctl
);
366 void r300_emit_fb_state(struct r300_context
* r300
, unsigned size
, void* state
)
368 struct pipe_framebuffer_state
* fb
= (struct pipe_framebuffer_state
*)state
;
369 struct r300_surface
* surf
;
371 boolean can_hyperz
= r300
->rws
->get_value(r300
->rws
, R300_CAN_HYPERZ
);
372 uint32_t rb3d_cctl
= 0;
378 /* NUM_MULTIWRITES replicates COLOR[0] to all colorbuffers, which is not
379 * what we usually want. */
380 if (r300
->screen
->caps
.is_r500
) {
381 rb3d_cctl
= R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE
;
384 r300_fragment_shader_writes_all(r300_fs(r300
))) {
385 rb3d_cctl
|= R300_RB3D_CCTL_NUM_MULTIWRITES(fb
->nr_cbufs
);
388 OUT_CS_REG(R300_RB3D_CCTL
, rb3d_cctl
);
390 /* Set up colorbuffers. */
391 for (i
= 0; i
< fb
->nr_cbufs
; i
++) {
392 surf
= r300_surface(fb
->cbufs
[i
]);
394 OUT_CS_REG(R300_RB3D_COLOROFFSET0
+ (4 * i
), surf
->offset
);
397 OUT_CS_REG(R300_RB3D_COLORPITCH0
+ (4 * i
), surf
->pitch
);
401 /* Set up the ZB part of the CBZB clear. */
402 if (r300
->cbzb_clear
) {
403 surf
= r300_surface(fb
->cbufs
[0]);
405 OUT_CS_REG(R300_ZB_FORMAT
, surf
->cbzb_format
);
407 OUT_CS_REG(R300_ZB_DEPTHOFFSET
, surf
->cbzb_midpoint_offset
);
410 OUT_CS_REG(R300_ZB_DEPTHPITCH
, surf
->cbzb_pitch
);
414 "CBZB clearing cbuf %08x %08x\n", surf
->cbzb_format
,
417 /* Set up a zbuffer. */
418 else if (fb
->zsbuf
) {
419 surf
= r300_surface(fb
->zsbuf
);
421 OUT_CS_REG(R300_ZB_FORMAT
, surf
->format
);
423 OUT_CS_REG(R300_ZB_DEPTHOFFSET
, surf
->offset
);
426 OUT_CS_REG(R300_ZB_DEPTHPITCH
, surf
->pitch
);
431 struct r300_texture
*tex
;
432 int level
= surf
->base
.u
.tex
.level
;
433 tex
= r300_texture(surf
->base
.texture
);
435 surf_pitch
= surf
->pitch
& R300_DEPTHPITCH_MASK
;
438 if (r300
->screen
->caps
.hiz_ram
) {
439 if (tex
->hiz_mem
[level
]) {
440 OUT_CS_REG(R300_ZB_HIZ_OFFSET
, tex
->hiz_mem
[level
]->ofs
<< 2);
441 OUT_CS_REG(R300_ZB_HIZ_PITCH
, surf_pitch
);
443 OUT_CS_REG(R300_ZB_HIZ_OFFSET
, 0);
444 OUT_CS_REG(R300_ZB_HIZ_PITCH
, 0);
448 /* Z Mask RAM. (compressed zbuffer) */
449 OUT_CS_REG(R300_ZB_ZMASK_OFFSET
, 0);
450 OUT_CS_REG(R300_ZB_ZMASK_PITCH
, surf_pitch
);
457 void r300_emit_hyperz_state(struct r300_context
*r300
,
458 unsigned size
, void *state
)
460 struct r300_hyperz_state
*z
= state
;
464 WRITE_CS_TABLE(&z
->cb_flush_begin
, size
);
466 WRITE_CS_TABLE(&z
->cb_begin
, size
- 2);
469 void r300_emit_hyperz_end(struct r300_context
*r300
)
471 struct r300_hyperz_state z
=
472 *(struct r300_hyperz_state
*)r300
->hyperz_state
.state
;
476 z
.zb_depthclearvalue
= 0;
477 z
.sc_hyperz
= R300_SC_HYPERZ_ADJ_2
;
478 z
.gb_z_peq_config
= 0;
480 r300_emit_hyperz_state(r300
, r300
->hyperz_state
.size
, &z
);
483 void r300_emit_fb_state_pipelined(struct r300_context
*r300
,
484 unsigned size
, void *state
)
486 struct pipe_framebuffer_state
* fb
=
487 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
488 unsigned i
, num_cbufs
= fb
->nr_cbufs
;
491 /* If we use the multiwrite feature, the colorbuffers 2,3,4 must be
492 * marked as UNUSED in the US block. */
493 if (r300_fragment_shader_writes_all(r300_fs(r300
))) {
494 num_cbufs
= MIN2(num_cbufs
, 1);
499 /* Colorbuffer format in the US block.
500 * (must be written after unpipelined regs) */
501 OUT_CS_REG_SEQ(R300_US_OUT_FMT_0
, 4);
502 for (i
= 0; i
< num_cbufs
; i
++) {
503 OUT_CS(r300_surface(fb
->cbufs
[i
])->format
);
506 OUT_CS(R300_US_OUT_FMT_UNUSED
);
509 /* Multisampling. Depends on framebuffer sample count.
510 * These are pipelined regs and as such cannot be moved
511 * to the AA state. */
512 if (r300
->rws
->get_value(r300
->rws
, R300_VID_DRM_2_3_0
)) {
513 unsigned mspos0
= 0x66666666;
514 unsigned mspos1
= 0x6666666;
516 if (fb
->nr_cbufs
&& fb
->cbufs
[0]->texture
->nr_samples
> 1) {
517 /* Subsample placement. These may not be optimal. */
518 switch (fb
->cbufs
[0]->texture
->nr_samples
) {
536 debug_printf("r300: Bad number of multisamples!\n");
540 OUT_CS_REG_SEQ(R300_GB_MSPOS0
, 2);
547 void r300_emit_query_start(struct r300_context
*r300
, unsigned size
, void*state
)
549 struct r300_query
*query
= r300
->query_current
;
556 if (r300
->screen
->caps
.family
== CHIP_FAMILY_RV530
) {
557 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL
);
559 OUT_CS_REG(R300_SU_REG_DEST
, R300_RASTER_PIPE_SELECT_ALL
);
561 OUT_CS_REG(R300_ZB_ZPASS_DATA
, 0);
563 query
->begin_emitted
= TRUE
;
564 query
->flushed
= FALSE
;
567 static void r300_emit_query_end_frag_pipes(struct r300_context
*r300
,
568 struct r300_query
*query
)
570 struct r300_capabilities
* caps
= &r300
->screen
->caps
;
573 assert(caps
->num_frag_pipes
);
575 BEGIN_CS(6 * caps
->num_frag_pipes
+ 2);
576 /* I'm not so sure I like this switch, but it's hard to be elegant
577 * when there's so many special cases...
579 * So here's the basic idea. For each pipe, enable writes to it only,
580 * then put out the relocation for ZPASS_ADDR, taking into account a
581 * 4-byte offset for each pipe. RV380 and older are special; they have
582 * only two pipes, and the second pipe's enable is on bit 3, not bit 1,
583 * so there's a chipset cap for that. */
584 switch (caps
->num_frag_pipes
) {
587 OUT_CS_REG(R300_SU_REG_DEST
, 1 << 3);
588 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 3) * 4);
589 OUT_CS_RELOC(r300
->query_current
);
592 OUT_CS_REG(R300_SU_REG_DEST
, 1 << 2);
593 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 2) * 4);
594 OUT_CS_RELOC(r300
->query_current
);
597 /* As mentioned above, accomodate RV380 and older. */
598 OUT_CS_REG(R300_SU_REG_DEST
,
599 1 << (caps
->high_second_pipe
? 3 : 1));
600 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 1) * 4);
601 OUT_CS_RELOC(r300
->query_current
);
604 OUT_CS_REG(R300_SU_REG_DEST
, 1 << 0);
605 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 0) * 4);
606 OUT_CS_RELOC(r300
->query_current
);
609 fprintf(stderr
, "r300: Implementation error: Chipset reports %d"
610 " pixel pipes!\n", caps
->num_frag_pipes
);
614 /* And, finally, reset it to normal... */
615 OUT_CS_REG(R300_SU_REG_DEST
, 0xF);
619 static void rv530_emit_query_end_single_z(struct r300_context
*r300
,
620 struct r300_query
*query
)
625 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_0
);
626 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, query
->num_results
* 4);
627 OUT_CS_RELOC(r300
->query_current
);
628 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL
);
632 static void rv530_emit_query_end_double_z(struct r300_context
*r300
,
633 struct r300_query
*query
)
638 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_0
);
639 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 0) * 4);
640 OUT_CS_RELOC(r300
->query_current
);
641 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_1
);
642 OUT_CS_REG(R300_ZB_ZPASS_ADDR
, (query
->num_results
+ 1) * 4);
643 OUT_CS_RELOC(r300
->query_current
);
644 OUT_CS_REG(RV530_FG_ZBREG_DEST
, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL
);
648 void r300_emit_query_end(struct r300_context
* r300
)
650 struct r300_capabilities
*caps
= &r300
->screen
->caps
;
651 struct r300_query
*query
= r300
->query_current
;
656 if (query
->begin_emitted
== FALSE
)
659 if (caps
->family
== CHIP_FAMILY_RV530
) {
660 if (caps
->num_z_pipes
== 2)
661 rv530_emit_query_end_double_z(r300
, query
);
663 rv530_emit_query_end_single_z(r300
, query
);
665 r300_emit_query_end_frag_pipes(r300
, query
);
667 query
->begin_emitted
= FALSE
;
668 query
->num_results
+= query
->num_pipes
;
670 /* XXX grab all the results and reset the counter. */
671 if (query
->num_results
>= query
->buffer_size
/ 4 - 4) {
672 query
->num_results
= (query
->buffer_size
/ 4) / 2;
673 fprintf(stderr
, "r300: Rewinding OQBO...\n");
677 void r300_emit_invariant_state(struct r300_context
*r300
,
678 unsigned size
, void *state
)
681 WRITE_CS_TABLE(state
, size
);
684 void r300_emit_rs_state(struct r300_context
* r300
, unsigned size
, void* state
)
686 struct r300_rs_state
* rs
= state
;
690 OUT_CS_TABLE(rs
->cb_main
, RS_STATE_MAIN_SIZE
);
691 if (rs
->polygon_offset_enable
) {
692 if (r300
->zbuffer_bpp
== 16) {
693 OUT_CS_TABLE(rs
->cb_poly_offset_zb16
, 5);
695 OUT_CS_TABLE(rs
->cb_poly_offset_zb24
, 5);
701 void r300_emit_rs_block_state(struct r300_context
* r300
,
702 unsigned size
, void* state
)
704 struct r300_rs_block
* rs
= (struct r300_rs_block
*)state
;
706 /* It's the same for both INST and IP tables */
707 unsigned count
= (rs
->inst_count
& R300_RS_INST_COUNT_MASK
) + 1;
710 if (DBG_ON(r300
, DBG_RS_BLOCK
)) {
711 r500_dump_rs_block(rs
);
713 fprintf(stderr
, "r300: RS emit:\n");
715 for (i
= 0; i
< count
; i
++)
716 fprintf(stderr
, " : ip %d: 0x%08x\n", i
, rs
->ip
[i
]);
718 for (i
= 0; i
< count
; i
++)
719 fprintf(stderr
, " : inst %d: 0x%08x\n", i
, rs
->inst
[i
]);
721 fprintf(stderr
, " : count: 0x%08x inst_count: 0x%08x\n",
722 rs
->count
, rs
->inst_count
);
726 OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL
, 2);
727 OUT_CS(rs
->vap_vtx_state_cntl
);
728 OUT_CS(rs
->vap_vsm_vtx_assm
);
729 OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0
, 2);
730 OUT_CS(rs
->vap_out_vtx_fmt
[0]);
731 OUT_CS(rs
->vap_out_vtx_fmt
[1]);
732 OUT_CS_REG_SEQ(R300_GB_ENABLE
, 1);
733 OUT_CS(rs
->gb_enable
);
735 if (r300
->screen
->caps
.is_r500
) {
736 OUT_CS_REG_SEQ(R500_RS_IP_0
, count
);
738 OUT_CS_REG_SEQ(R300_RS_IP_0
, count
);
740 OUT_CS_TABLE(rs
->ip
, count
);
742 OUT_CS_REG_SEQ(R300_RS_COUNT
, 2);
744 OUT_CS(rs
->inst_count
);
746 if (r300
->screen
->caps
.is_r500
) {
747 OUT_CS_REG_SEQ(R500_RS_INST_0
, count
);
749 OUT_CS_REG_SEQ(R300_RS_INST_0
, count
);
751 OUT_CS_TABLE(rs
->inst
, count
);
755 void r300_emit_scissor_state(struct r300_context
* r300
,
756 unsigned size
, void* state
)
758 struct pipe_scissor_state
* scissor
= (struct pipe_scissor_state
*)state
;
762 OUT_CS_REG_SEQ(R300_SC_CLIPRECT_TL_0
, 2);
763 if (r300
->screen
->caps
.is_r500
) {
764 OUT_CS((scissor
->minx
<< R300_CLIPRECT_X_SHIFT
) |
765 (scissor
->miny
<< R300_CLIPRECT_Y_SHIFT
));
766 OUT_CS(((scissor
->maxx
- 1) << R300_CLIPRECT_X_SHIFT
) |
767 ((scissor
->maxy
- 1) << R300_CLIPRECT_Y_SHIFT
));
769 OUT_CS(((scissor
->minx
+ 1440) << R300_CLIPRECT_X_SHIFT
) |
770 ((scissor
->miny
+ 1440) << R300_CLIPRECT_Y_SHIFT
));
771 OUT_CS(((scissor
->maxx
+ 1440-1) << R300_CLIPRECT_X_SHIFT
) |
772 ((scissor
->maxy
+ 1440-1) << R300_CLIPRECT_Y_SHIFT
));
777 void r300_emit_textures_state(struct r300_context
*r300
,
778 unsigned size
, void *state
)
780 struct r300_textures_state
*allstate
= (struct r300_textures_state
*)state
;
781 struct r300_texture_sampler_state
*texstate
;
782 struct r300_texture
*tex
;
787 OUT_CS_REG(R300_TX_ENABLE
, allstate
->tx_enable
);
789 for (i
= 0; i
< allstate
->count
; i
++) {
790 if ((1 << i
) & allstate
->tx_enable
) {
791 texstate
= &allstate
->regs
[i
];
792 tex
= r300_texture(allstate
->sampler_views
[i
]->base
.texture
);
794 OUT_CS_REG(R300_TX_FILTER0_0
+ (i
* 4), texstate
->filter0
);
795 OUT_CS_REG(R300_TX_FILTER1_0
+ (i
* 4), texstate
->filter1
);
796 OUT_CS_REG(R300_TX_BORDER_COLOR_0
+ (i
* 4),
797 texstate
->border_color
);
799 OUT_CS_REG(R300_TX_FORMAT0_0
+ (i
* 4), texstate
->format
.format0
);
800 OUT_CS_REG(R300_TX_FORMAT1_0
+ (i
* 4), texstate
->format
.format1
);
801 OUT_CS_REG(R300_TX_FORMAT2_0
+ (i
* 4), texstate
->format
.format2
);
803 OUT_CS_REG(R300_TX_OFFSET_0
+ (i
* 4), texstate
->format
.tile_config
);
810 static void r300_update_vertex_arrays_cb(struct r300_context
*r300
, unsigned packet_size
)
812 struct pipe_vertex_buffer
*vb1
, *vb2
, *vbuf
= r300
->vbuf_mgr
->vertex_buffer
;
813 struct pipe_vertex_element
*velem
= r300
->velems
->velem
;
814 unsigned *hw_format_size
= r300
->velems
->format_size
;
815 unsigned size1
, size2
, vertex_array_count
= r300
->velems
->count
;
819 BEGIN_CB(r300
->vertex_arrays_cb
, packet_size
);
820 for (i
= 0; i
< vertex_array_count
- 1; i
+= 2) {
821 vb1
= &vbuf
[velem
[i
].vertex_buffer_index
];
822 vb2
= &vbuf
[velem
[i
+1].vertex_buffer_index
];
823 size1
= hw_format_size
[i
];
824 size2
= hw_format_size
[i
+1];
826 OUT_CB(R300_VBPNTR_SIZE0(size1
) | R300_VBPNTR_STRIDE0(vb1
->stride
) |
827 R300_VBPNTR_SIZE1(size2
) | R300_VBPNTR_STRIDE1(vb2
->stride
));
828 OUT_CB(vb1
->buffer_offset
+ velem
[i
].src_offset
);
829 OUT_CB(vb2
->buffer_offset
+ velem
[i
+1].src_offset
);
832 if (vertex_array_count
& 1) {
833 vb1
= &vbuf
[velem
[i
].vertex_buffer_index
];
834 size1
= hw_format_size
[i
];
836 OUT_CB(R300_VBPNTR_SIZE0(size1
) | R300_VBPNTR_STRIDE0(vb1
->stride
));
837 OUT_CB(vb1
->buffer_offset
+ velem
[i
].src_offset
);
841 r300
->vertex_arrays_dirty
= FALSE
;
844 void r300_emit_vertex_arrays(struct r300_context
* r300
, int offset
, boolean indexed
)
846 struct pipe_vertex_buffer
*vbuf
= r300
->vbuf_mgr
->vertex_buffer
;
847 struct pipe_resource
**valid_vbuf
= r300
->vbuf_mgr
->real_vertex_buffer
;
848 struct pipe_vertex_element
*velem
= r300
->velems
->velem
;
849 struct r300_buffer
*buf
;
851 unsigned vertex_array_count
= r300
->velems
->count
;
852 unsigned packet_size
= (vertex_array_count
* 3 + 1) / 2;
855 BEGIN_CS(2 + packet_size
+ vertex_array_count
* 2);
856 OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR
, packet_size
);
857 OUT_CS(vertex_array_count
| (!indexed
? R300_VC_FORCE_PREFETCH
: 0));
860 if (r300
->vertex_arrays_dirty
) {
861 r300_update_vertex_arrays_cb(r300
, packet_size
);
863 OUT_CS_TABLE(r300
->vertex_arrays_cb
, packet_size
);
865 struct pipe_vertex_buffer
*vb1
, *vb2
;
866 unsigned *hw_format_size
= r300
->velems
->format_size
;
867 unsigned size1
, size2
;
869 for (i
= 0; i
< vertex_array_count
- 1; i
+= 2) {
870 vb1
= &vbuf
[velem
[i
].vertex_buffer_index
];
871 vb2
= &vbuf
[velem
[i
+1].vertex_buffer_index
];
872 size1
= hw_format_size
[i
];
873 size2
= hw_format_size
[i
+1];
875 OUT_CS(R300_VBPNTR_SIZE0(size1
) | R300_VBPNTR_STRIDE0(vb1
->stride
) |
876 R300_VBPNTR_SIZE1(size2
) | R300_VBPNTR_STRIDE1(vb2
->stride
));
877 OUT_CS(vb1
->buffer_offset
+ velem
[i
].src_offset
+ offset
* vb1
->stride
);
878 OUT_CS(vb2
->buffer_offset
+ velem
[i
+1].src_offset
+ offset
* vb2
->stride
);
881 if (vertex_array_count
& 1) {
882 vb1
= &vbuf
[velem
[i
].vertex_buffer_index
];
883 size1
= hw_format_size
[i
];
885 OUT_CS(R300_VBPNTR_SIZE0(size1
) | R300_VBPNTR_STRIDE0(vb1
->stride
));
886 OUT_CS(vb1
->buffer_offset
+ velem
[i
].src_offset
+ offset
* vb1
->stride
);
890 for (i
= 0; i
< vertex_array_count
; i
++) {
891 buf
= r300_buffer(valid_vbuf
[velem
[i
].vertex_buffer_index
]);
897 void r300_emit_vertex_arrays_swtcl(struct r300_context
*r300
, boolean indexed
)
901 DBG(r300
, DBG_SWTCL
, "r300: Preparing vertex buffer %p for render, "
902 "vertex size %d\n", r300
->vbo
,
903 r300
->vertex_info
.size
);
904 /* Set the pointer to our vertex buffer. The emitted values are this:
905 * PACKET3 [3D_LOAD_VBPNTR]
907 * FORMAT [size | stride << 8]
908 * OFFSET [offset into BO]
909 * VBPNTR [relocated BO]
912 OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR
, 3);
913 OUT_CS(1 | (!indexed
? R300_VC_FORCE_PREFETCH
: 0));
914 OUT_CS(r300
->vertex_info
.size
|
915 (r300
->vertex_info
.size
<< 8));
916 OUT_CS(r300
->draw_vbo_offset
);
918 OUT_CS_RELOC(r300_buffer(r300
->vbo
));
922 void r300_emit_vertex_stream_state(struct r300_context
* r300
,
923 unsigned size
, void* state
)
925 struct r300_vertex_stream_state
*streams
=
926 (struct r300_vertex_stream_state
*)state
;
930 if (DBG_ON(r300
, DBG_PSC
)) {
931 fprintf(stderr
, "r300: PSC emit:\n");
933 for (i
= 0; i
< streams
->count
; i
++) {
934 fprintf(stderr
, " : prog_stream_cntl%d: 0x%08x\n", i
,
935 streams
->vap_prog_stream_cntl
[i
]);
938 for (i
= 0; i
< streams
->count
; i
++) {
939 fprintf(stderr
, " : prog_stream_cntl_ext%d: 0x%08x\n", i
,
940 streams
->vap_prog_stream_cntl_ext
[i
]);
945 OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0
, streams
->count
);
946 OUT_CS_TABLE(streams
->vap_prog_stream_cntl
, streams
->count
);
947 OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0
, streams
->count
);
948 OUT_CS_TABLE(streams
->vap_prog_stream_cntl_ext
, streams
->count
);
952 void r300_emit_pvs_flush(struct r300_context
* r300
, unsigned size
, void* state
)
957 OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG
, 0x0);
961 void r300_emit_vap_invariant_state(struct r300_context
*r300
,
962 unsigned size
, void *state
)
965 WRITE_CS_TABLE(state
, size
);
968 void r300_emit_vs_state(struct r300_context
* r300
, unsigned size
, void* state
)
970 struct r300_vertex_shader
* vs
= (struct r300_vertex_shader
*)state
;
971 struct r300_vertex_program_code
* code
= &vs
->code
;
972 struct r300_screen
* r300screen
= r300
->screen
;
973 unsigned instruction_count
= code
->length
/ 4;
975 unsigned vtx_mem_size
= r300screen
->caps
.is_r500
? 128 : 72;
976 unsigned input_count
= MAX2(util_bitcount(code
->InputsRead
), 1);
977 unsigned output_count
= MAX2(util_bitcount(code
->OutputsWritten
), 1);
978 unsigned temp_count
= MAX2(code
->num_temporaries
, 1);
980 unsigned pvs_num_slots
= MIN3(vtx_mem_size
/ input_count
,
981 vtx_mem_size
/ output_count
, 10);
982 unsigned pvs_num_controllers
= MIN2(vtx_mem_size
/ temp_count
, 5);
988 /* R300_VAP_PVS_CODE_CNTL_0
989 * R300_VAP_PVS_CONST_CNTL
990 * R300_VAP_PVS_CODE_CNTL_1
991 * See the r5xx docs for instructions on how to use these. */
992 OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0
, R300_PVS_FIRST_INST(0) |
993 R300_PVS_XYZW_VALID_INST(instruction_count
- 1) |
994 R300_PVS_LAST_INST(instruction_count
- 1));
995 OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1
, instruction_count
- 1);
997 OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG
, 0);
998 OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA
, code
->length
);
999 OUT_CS_TABLE(code
->body
.d
, code
->length
);
1001 OUT_CS_REG(R300_VAP_CNTL
, R300_PVS_NUM_SLOTS(pvs_num_slots
) |
1002 R300_PVS_NUM_CNTLRS(pvs_num_controllers
) |
1003 R300_PVS_NUM_FPUS(r300screen
->caps
.num_vert_fpus
) |
1004 R300_PVS_VF_MAX_VTX_NUM(12) |
1005 (r300screen
->caps
.is_r500
? R500_TCL_STATE_OPTIMIZATION
: 0));
1007 /* Emit flow control instructions. */
1008 if (code
->num_fc_ops
) {
1010 OUT_CS_REG(R300_VAP_PVS_FLOW_CNTL_OPC
, code
->fc_ops
);
1011 if (r300screen
->caps
.is_r500
) {
1012 OUT_CS_REG_SEQ(R500_VAP_PVS_FLOW_CNTL_ADDRS_LW_0
, code
->num_fc_ops
* 2);
1013 OUT_CS_TABLE(code
->fc_op_addrs
.r500
, code
->num_fc_ops
* 2);
1015 OUT_CS_REG_SEQ(R300_VAP_PVS_FLOW_CNTL_ADDRS_0
, code
->num_fc_ops
);
1016 OUT_CS_TABLE(code
->fc_op_addrs
.r300
, code
->num_fc_ops
);
1018 OUT_CS_REG_SEQ(R300_VAP_PVS_FLOW_CNTL_LOOP_INDEX_0
, code
->num_fc_ops
);
1019 OUT_CS_TABLE(code
->fc_loop_index
, code
->num_fc_ops
);
1025 void r300_emit_vs_constants(struct r300_context
* r300
,
1026 unsigned size
, void *state
)
1029 ((struct r300_vertex_shader
*)r300
->vs_state
.state
)->externals_count
;
1030 struct r300_constant_buffer
*buf
= (struct r300_constant_buffer
*)state
;
1031 struct r300_vertex_shader
*vs
= (struct r300_vertex_shader
*)r300
->vs_state
.state
;
1033 int imm_first
= vs
->externals_count
;
1034 int imm_end
= vs
->code
.constants
.Count
;
1035 int imm_count
= vs
->immediates_count
;
1039 OUT_CS_REG(R300_VAP_PVS_CONST_CNTL
,
1040 R300_PVS_CONST_BASE_OFFSET(buf
->buffer_base
) |
1041 R300_PVS_MAX_CONST_ADDR(MAX2(imm_end
- 1, 0)));
1042 if (vs
->externals_count
) {
1043 OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG
,
1044 (r300
->screen
->caps
.is_r500
?
1045 R500_PVS_CONST_START
: R300_PVS_CONST_START
) + buf
->buffer_base
);
1046 OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA
, count
* 4);
1047 if (buf
->remap_table
){
1048 for (i
= 0; i
< count
; i
++) {
1049 uint32_t *data
= &buf
->ptr
[buf
->remap_table
[i
]*4];
1050 OUT_CS_TABLE(data
, 4);
1053 OUT_CS_TABLE(buf
->ptr
, count
* 4);
1057 /* Emit immediates. */
1059 OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG
,
1060 (r300
->screen
->caps
.is_r500
?
1061 R500_PVS_CONST_START
: R300_PVS_CONST_START
) +
1062 buf
->buffer_base
+ imm_first
);
1063 OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA
, imm_count
* 4);
1064 for (i
= imm_first
; i
< imm_end
; i
++) {
1065 const float *data
= vs
->code
.constants
.Constants
[i
].u
.Immediate
;
1066 OUT_CS_TABLE(data
, 4);
1072 void r300_emit_viewport_state(struct r300_context
* r300
,
1073 unsigned size
, void* state
)
1075 struct r300_viewport_state
* viewport
= (struct r300_viewport_state
*)state
;
1079 OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE
, 6);
1080 OUT_CS_TABLE(&viewport
->xscale
, 6);
1081 OUT_CS_REG(R300_VAP_VTE_CNTL
, viewport
->vte_control
);
1085 static void r300_emit_hiz_line_clear(struct r300_context
*r300
, int start
, uint16_t count
, uint32_t val
)
1089 OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_HIZ
, 2);
1096 #define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y))
1098 void r300_emit_hiz_clear(struct r300_context
*r300
, unsigned size
, void *state
)
1100 struct pipe_framebuffer_state
*fb
=
1101 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
1102 struct r300_hyperz_state
*z
=
1103 (struct r300_hyperz_state
*)r300
->hyperz_state
.state
;
1104 struct r300_screen
* r300screen
= r300
->screen
;
1105 uint32_t stride
, offset
= 0, height
, offset_shift
;
1106 struct r300_texture
* tex
;
1109 tex
= r300_texture(fb
->zsbuf
->texture
);
1111 offset
= tex
->hiz_mem
[fb
->zsbuf
->u
.tex
.level
]->ofs
;
1112 stride
= tex
->desc
.stride_in_pixels
[fb
->zsbuf
->u
.tex
.level
];
1114 /* convert from pixels to 4x4 blocks */
1115 stride
= ALIGN_DIVUP(stride
, 4);
1117 stride
= ALIGN_DIVUP(stride
, r300screen
->caps
.num_frag_pipes
);
1118 /* there are 4 blocks per dwords */
1119 stride
= ALIGN_DIVUP(stride
, 4);
1121 height
= ALIGN_DIVUP(fb
->zsbuf
->height
, 4);
1124 offset_shift
+= (r300screen
->caps
.num_frag_pipes
/ 2);
1126 for (i
= 0; i
< height
; i
++) {
1127 offset
= i
* stride
;
1128 offset
<<= offset_shift
;
1129 r300_emit_hiz_line_clear(r300
, offset
, stride
, 0xffffffff);
1131 z
->current_func
= -1;
1133 /* Mark the current zbuffer's hiz ram as in use. */
1134 tex
->hiz_in_use
[fb
->zsbuf
->u
.tex
.level
] = TRUE
;
1137 void r300_emit_zmask_clear(struct r300_context
*r300
, unsigned size
, void *state
)
1139 struct pipe_framebuffer_state
*fb
=
1140 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
1141 struct r300_texture
*tex
;
1144 tex
= r300_texture(fb
->zsbuf
->texture
);
1147 OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_ZMASK
, 2);
1149 OUT_CS(tex
->desc
.zmask_dwords
[fb
->zsbuf
->u
.tex
.level
]);
1153 /* Mark the current zbuffer's zmask as in use. */
1154 r300
->zmask_in_use
= TRUE
;
1155 r300_mark_atom_dirty(r300
, &r300
->hyperz_state
);
1158 void r300_emit_ztop_state(struct r300_context
* r300
,
1159 unsigned size
, void* state
)
1161 struct r300_ztop_state
* ztop
= (struct r300_ztop_state
*)state
;
1165 OUT_CS_REG(R300_ZB_ZTOP
, ztop
->z_buffer_top
);
1169 void r300_emit_texture_cache_inval(struct r300_context
* r300
, unsigned size
, void* state
)
1174 OUT_CS_REG(R300_TX_INVALTAGS
, 0);
1178 boolean
r300_emit_buffer_validate(struct r300_context
*r300
,
1179 boolean do_validate_vertex_buffers
,
1180 struct pipe_resource
*index_buffer
)
1182 struct pipe_framebuffer_state
*fb
=
1183 (struct pipe_framebuffer_state
*)r300
->fb_state
.state
;
1184 struct r300_textures_state
*texstate
=
1185 (struct r300_textures_state
*)r300
->textures_state
.state
;
1186 struct r300_texture
*tex
;
1188 boolean flushed
= FALSE
;
1191 if (r300
->fb_state
.dirty
) {
1192 /* Color buffers... */
1193 for (i
= 0; i
< fb
->nr_cbufs
; i
++) {
1194 tex
= r300_texture(fb
->cbufs
[i
]->texture
);
1195 assert(tex
&& tex
->buf
&& "cbuf is marked, but NULL!");
1196 r300
->rws
->cs_add_reloc(r300
->cs
, tex
->cs_buf
, 0,
1197 r300_surface(fb
->cbufs
[i
])->domain
);
1199 /* ...depth buffer... */
1201 tex
= r300_texture(fb
->zsbuf
->texture
);
1202 assert(tex
&& tex
->buf
&& "zsbuf is marked, but NULL!");
1203 r300
->rws
->cs_add_reloc(r300
->cs
, tex
->cs_buf
, 0,
1204 r300_surface(fb
->zsbuf
)->domain
);
1207 if (r300
->textures_state
.dirty
) {
1208 /* ...textures... */
1209 for (i
= 0; i
< texstate
->count
; i
++) {
1210 if (!(texstate
->tx_enable
& (1 << i
))) {
1214 tex
= r300_texture(texstate
->sampler_views
[i
]->base
.texture
);
1215 r300
->rws
->cs_add_reloc(r300
->cs
, tex
->cs_buf
, tex
->domain
, 0);
1218 /* ...occlusion query buffer... */
1219 if (r300
->query_current
)
1220 r300
->rws
->cs_add_reloc(r300
->cs
, r300
->query_current
->cs_buf
,
1221 0, r300
->query_current
->domain
);
1222 /* ...vertex buffer for SWTCL path... */
1224 r300
->rws
->cs_add_reloc(r300
->cs
, r300_buffer(r300
->vbo
)->cs_buf
,
1225 r300_buffer(r300
->vbo
)->domain
, 0);
1226 /* ...vertex buffers for HWTCL path... */
1227 if (do_validate_vertex_buffers
) {
1228 struct pipe_resource
**buf
= r300
->vbuf_mgr
->real_vertex_buffer
;
1229 struct pipe_resource
**last
= r300
->vbuf_mgr
->real_vertex_buffer
+
1230 r300
->vbuf_mgr
->nr_real_vertex_buffers
;
1231 for (; buf
!= last
; buf
++) {
1235 r300
->rws
->cs_add_reloc(r300
->cs
, r300_buffer(*buf
)->cs_buf
,
1236 r300_buffer(*buf
)->domain
, 0);
1239 /* ...and index buffer for HWTCL path. */
1241 r300
->rws
->cs_add_reloc(r300
->cs
, r300_buffer(index_buffer
)->cs_buf
,
1242 r300_buffer(index_buffer
)->domain
, 0);
1244 /* Now do the validation. */
1245 if (!r300
->rws
->cs_validate(r300
->cs
)) {
1246 /* Ooops, an infinite loop, give up. */
1250 r300
->context
.flush(&r300
->context
, 0, NULL
);
1258 unsigned r300_get_num_dirty_dwords(struct r300_context
*r300
)
1260 struct r300_atom
* atom
;
1261 unsigned dwords
= 0;
1263 foreach_dirty_atom(r300
, atom
) {
1265 dwords
+= atom
->size
;
1269 /* let's reserve some more, just in case */
1275 unsigned r300_get_num_cs_end_dwords(struct r300_context
*r300
)
1277 unsigned dwords
= 0;
1279 /* Emitted in flush. */
1280 dwords
+= 26; /* emit_query_end */
1281 dwords
+= r300
->hyperz_state
.size
+ 2; /* emit_hyperz_end + zcache flush */
1282 if (r300
->screen
->caps
.index_bias_supported
)
1288 /* Emit all dirty state. */
1289 void r300_emit_dirty_state(struct r300_context
* r300
)
1291 struct r300_atom
*atom
;
1293 foreach_dirty_atom(r300
, atom
) {
1295 atom
->emit(r300
, atom
->size
, atom
->state
);
1296 atom
->dirty
= FALSE
;
1300 r300
->first_dirty
= NULL
;
1301 r300
->last_dirty
= NULL
;