2 * Copyright (c) 2014-2015 Etnaviv Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Wladimir J. van der Laan <laanwj@gmail.com>
27 #include "etnaviv_emit.h"
29 #include "etnaviv_blend.h"
30 #include "etnaviv_compiler.h"
31 #include "etnaviv_context.h"
32 #include "etnaviv_rasterizer.h"
33 #include "etnaviv_resource.h"
34 #include "etnaviv_rs.h"
35 #include "etnaviv_screen.h"
36 #include "etnaviv_shader.h"
37 #include "etnaviv_texture.h"
38 #include "etnaviv_translate.h"
39 #include "etnaviv_uniforms.h"
40 #include "etnaviv_util.h"
41 #include "etnaviv_zsa.h"
42 #include "hw/common.xml.h"
43 #include "hw/state.xml.h"
44 #include "util/u_math.h"
46 struct etna_coalesce
{
52 /* Queue a STALL command (queues 2 words) */
54 CMD_STALL(struct etna_cmd_stream
*stream
, uint32_t from
, uint32_t to
)
56 etna_cmd_stream_emit(stream
, VIV_FE_STALL_HEADER_OP_STALL
);
57 etna_cmd_stream_emit(stream
, VIV_FE_STALL_TOKEN_FROM(from
) | VIV_FE_STALL_TOKEN_TO(to
));
61 etna_stall(struct etna_cmd_stream
*stream
, uint32_t from
, uint32_t to
)
63 etna_cmd_stream_reserve(stream
, 4);
65 etna_emit_load_state(stream
, VIVS_GL_SEMAPHORE_TOKEN
>> 2, 1, 0);
66 etna_cmd_stream_emit(stream
, VIVS_GL_SEMAPHORE_TOKEN_FROM(from
) | VIVS_GL_SEMAPHORE_TOKEN_TO(to
));
68 if (from
== SYNC_RECIPIENT_FE
) {
69 /* if the frontend is to be stalled, queue a STALL frontend command */
70 CMD_STALL(stream
, from
, to
);
72 /* otherwise, load the STALL token state */
73 etna_emit_load_state(stream
, VIVS_GL_STALL_TOKEN
>> 2, 1, 0);
74 etna_cmd_stream_emit(stream
, VIVS_GL_STALL_TOKEN_FROM(from
) | VIVS_GL_STALL_TOKEN_TO(to
));
79 etna_coalesce_start(struct etna_cmd_stream
*stream
,
80 struct etna_coalesce
*coalesce
)
82 coalesce
->start
= etna_cmd_stream_offset(stream
);
83 coalesce
->last_reg
= 0;
84 coalesce
->last_fixp
= 0;
88 etna_coalesce_end(struct etna_cmd_stream
*stream
,
89 struct etna_coalesce
*coalesce
)
91 uint32_t end
= etna_cmd_stream_offset(stream
);
92 uint32_t size
= end
- coalesce
->start
;
95 uint32_t offset
= coalesce
->start
- 1;
96 uint32_t value
= etna_cmd_stream_get(stream
, offset
);
98 value
|= VIV_FE_LOAD_STATE_HEADER_COUNT(size
);
99 etna_cmd_stream_set(stream
, offset
, value
);
102 /* append needed padding */
104 etna_cmd_stream_emit(stream
, 0xdeadbeef);
108 check_coalsence(struct etna_cmd_stream
*stream
, struct etna_coalesce
*coalesce
,
109 uint32_t reg
, uint32_t fixp
)
111 if (coalesce
->last_reg
!= 0) {
112 if (((coalesce
->last_reg
+ 4) != reg
) || (coalesce
->last_fixp
!= fixp
)) {
113 etna_coalesce_end(stream
, coalesce
);
114 etna_emit_load_state(stream
, reg
>> 2, 0, fixp
);
115 coalesce
->start
= etna_cmd_stream_offset(stream
);
118 etna_emit_load_state(stream
, reg
>> 2, 0, fixp
);
119 coalesce
->start
= etna_cmd_stream_offset(stream
);
122 coalesce
->last_reg
= reg
;
123 coalesce
->last_fixp
= fixp
;
127 etna_coalsence_emit(struct etna_cmd_stream
*stream
,
128 struct etna_coalesce
*coalesce
, uint32_t reg
,
131 check_coalsence(stream
, coalesce
, reg
, 0);
132 etna_cmd_stream_emit(stream
, value
);
136 etna_coalsence_emit_fixp(struct etna_cmd_stream
*stream
,
137 struct etna_coalesce
*coalesce
, uint32_t reg
,
140 check_coalsence(stream
, coalesce
, reg
, 1);
141 etna_cmd_stream_emit(stream
, value
);
145 etna_coalsence_emit_reloc(struct etna_cmd_stream
*stream
,
146 struct etna_coalesce
*coalesce
, uint32_t reg
,
147 const struct etna_reloc
*r
)
150 check_coalsence(stream
, coalesce
, reg
, 0);
151 etna_cmd_stream_reloc(stream
, r
);
155 #define EMIT_STATE(state_name, src_value) \
156 etna_coalsence_emit(stream, &coalesce, VIVS_##state_name, src_value)
158 #define EMIT_STATE_FIXP(state_name, src_value) \
159 etna_coalsence_emit_fixp(stream, &coalesce, VIVS_##state_name, src_value)
161 #define EMIT_STATE_RELOC(state_name, src_value) \
162 etna_coalsence_emit_reloc(stream, &coalesce, VIVS_##state_name, src_value)
164 /* submit RS state, without any processing and no dependence on context
165 * except TS if this is a source-to-destination blit. */
167 etna_submit_rs_state(struct etna_context
*ctx
,
168 const struct compiled_rs_state
*cs
)
170 struct etna_screen
*screen
= etna_screen(ctx
->base
.screen
);
171 struct etna_cmd_stream
*stream
= ctx
->stream
;
172 struct etna_coalesce coalesce
;
174 ctx
->stats
.rs_operations
++;
176 if (screen
->specs
.pixel_pipes
== 1) {
177 etna_cmd_stream_reserve(stream
, 22);
178 etna_coalesce_start(stream
, &coalesce
);
179 /* 0/1 */ EMIT_STATE(RS_CONFIG
, cs
->RS_CONFIG
);
180 /* 2 */ EMIT_STATE_RELOC(RS_SOURCE_ADDR
, &cs
->source
[0]);
181 /* 3 */ EMIT_STATE(RS_SOURCE_STRIDE
, cs
->RS_SOURCE_STRIDE
);
182 /* 4 */ EMIT_STATE_RELOC(RS_DEST_ADDR
, &cs
->dest
[0]);
183 /* 5 */ EMIT_STATE(RS_DEST_STRIDE
, cs
->RS_DEST_STRIDE
);
184 /* 6/7 */ EMIT_STATE(RS_WINDOW_SIZE
, cs
->RS_WINDOW_SIZE
);
185 /* 8/9 */ EMIT_STATE(RS_DITHER(0), cs
->RS_DITHER
[0]);
186 /*10 */ EMIT_STATE(RS_DITHER(1), cs
->RS_DITHER
[1]);
188 /*12/13*/ EMIT_STATE(RS_CLEAR_CONTROL
, cs
->RS_CLEAR_CONTROL
);
189 /*14 */ EMIT_STATE(RS_FILL_VALUE(0), cs
->RS_FILL_VALUE
[0]);
190 /*15 */ EMIT_STATE(RS_FILL_VALUE(1), cs
->RS_FILL_VALUE
[1]);
191 /*16 */ EMIT_STATE(RS_FILL_VALUE(2), cs
->RS_FILL_VALUE
[2]);
192 /*17 */ EMIT_STATE(RS_FILL_VALUE(3), cs
->RS_FILL_VALUE
[3]);
193 /*18/19*/ EMIT_STATE(RS_EXTRA_CONFIG
, cs
->RS_EXTRA_CONFIG
);
194 /*20/21*/ EMIT_STATE(RS_KICKER
, 0xbeebbeeb);
195 etna_coalesce_end(stream
, &coalesce
);
196 } else if (screen
->specs
.pixel_pipes
== 2) {
197 etna_cmd_stream_reserve(stream
, 34); /* worst case - both pipes multi=1 */
198 etna_coalesce_start(stream
, &coalesce
);
199 /* 0/1 */ EMIT_STATE(RS_CONFIG
, cs
->RS_CONFIG
);
200 /* 2/3 */ EMIT_STATE(RS_SOURCE_STRIDE
, cs
->RS_SOURCE_STRIDE
);
201 /* 4/5 */ EMIT_STATE(RS_DEST_STRIDE
, cs
->RS_DEST_STRIDE
);
202 /* 6/7 */ EMIT_STATE_RELOC(RS_PIPE_SOURCE_ADDR(0), &cs
->source
[0]);
203 if (cs
->RS_SOURCE_STRIDE
& VIVS_RS_SOURCE_STRIDE_MULTI
) {
204 /*8 */ EMIT_STATE_RELOC(RS_PIPE_SOURCE_ADDR(1), &cs
->source
[1]);
207 /*10/11*/ EMIT_STATE_RELOC(RS_PIPE_DEST_ADDR(0), &cs
->dest
[0]);
208 if (cs
->RS_DEST_STRIDE
& VIVS_RS_DEST_STRIDE_MULTI
) {
209 /*12*/ EMIT_STATE_RELOC(RS_PIPE_DEST_ADDR(1), &cs
->dest
[1]);
212 /*14/15*/ EMIT_STATE(RS_PIPE_OFFSET(0), cs
->RS_PIPE_OFFSET
[0]);
213 /*16 */ EMIT_STATE(RS_PIPE_OFFSET(1), cs
->RS_PIPE_OFFSET
[1]);
215 /*18/19*/ EMIT_STATE(RS_WINDOW_SIZE
, cs
->RS_WINDOW_SIZE
);
216 /*20/21*/ EMIT_STATE(RS_DITHER(0), cs
->RS_DITHER
[0]);
217 /*22 */ EMIT_STATE(RS_DITHER(1), cs
->RS_DITHER
[1]);
219 /*24/25*/ EMIT_STATE(RS_CLEAR_CONTROL
, cs
->RS_CLEAR_CONTROL
);
220 /*26 */ EMIT_STATE(RS_FILL_VALUE(0), cs
->RS_FILL_VALUE
[0]);
221 /*27 */ EMIT_STATE(RS_FILL_VALUE(1), cs
->RS_FILL_VALUE
[1]);
222 /*28 */ EMIT_STATE(RS_FILL_VALUE(2), cs
->RS_FILL_VALUE
[2]);
223 /*29 */ EMIT_STATE(RS_FILL_VALUE(3), cs
->RS_FILL_VALUE
[3]);
224 /*30/31*/ EMIT_STATE(RS_EXTRA_CONFIG
, cs
->RS_EXTRA_CONFIG
);
225 /*32/33*/ EMIT_STATE(RS_KICKER
, 0xbeebbeeb);
226 etna_coalesce_end(stream
, &coalesce
);
232 /* Create bit field that specifies which samplers are active and thus need to be
234 * 32 bits is enough for 32 samplers. As far as I know this is the upper bound
235 * supported on any Vivante hw
239 active_samplers_bits(struct etna_context
*ctx
)
241 return ctx
->active_sampler_views
& ctx
->active_samplers
;
244 #define ETNA_3D_CONTEXT_SIZE (400) /* keep this number above "Total state updates (fixed)" from gen_weave_state tool */
247 required_stream_size(struct etna_context
*ctx
)
249 unsigned size
= ETNA_3D_CONTEXT_SIZE
;
254 /* vertex elements */
255 size
+= ctx
->vertex_elements
->num_elements
+ 1;
257 /* uniforms - worst case (2 words per uniform load) */
258 size
+= ctx
->shader
.vs
->uniforms
.const_count
* 2;
259 size
+= ctx
->shader
.fs
->uniforms
.const_count
* 2;
262 size
+= ctx
->shader_state
.vs_inst_mem_size
+ 1;
263 size
+= ctx
->shader_state
.ps_inst_mem_size
+ 1;
265 /* DRAW_INDEXED_PRIMITIVES command */
268 /* reserve for alignment etc. */
274 /* Weave state before draw operation. This function merges all the compiled
275 * state blocks under the context into one device register state. Parts of
276 * this state that are changed since last call (dirty) will be uploaded as
277 * state changes in the command buffer. */
279 etna_emit_state(struct etna_context
*ctx
)
281 struct etna_cmd_stream
*stream
= ctx
->stream
;
282 uint32_t active_samplers
= active_samplers_bits(ctx
);
284 /* Pre-reserve the command buffer space which we are likely to need.
285 * This must cover all the state emitted below, and the following
287 etna_cmd_stream_reserve(stream
, required_stream_size(ctx
));
289 uint32_t dirty
= ctx
->dirty
;
291 /* Pre-processing: see what caches we need to flush before making state changes. */
292 uint32_t to_flush
= 0;
293 if (unlikely(dirty
& (ETNA_DIRTY_BLEND
))) {
294 /* Need flush COLOR when changing PE.COLOR_FORMAT.OVERWRITE. */
297 if ((ctx
->gpu3d
.PE_COLOR_FORMAT
& VIVS_PE_COLOR_FORMAT_OVERWRITE
) !=
298 (etna_blend_state(ctx
->blend
)->PE_COLOR_FORMAT
& VIVS_PE_COLOR_FORMAT_OVERWRITE
))
300 to_flush
|= VIVS_GL_FLUSH_CACHE_COLOR
;
302 if (unlikely(dirty
& (ETNA_DIRTY_TEXTURE_CACHES
)))
303 to_flush
|= VIVS_GL_FLUSH_CACHE_TEXTURE
;
304 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
))) /* Framebuffer config changed? */
305 to_flush
|= VIVS_GL_FLUSH_CACHE_COLOR
| VIVS_GL_FLUSH_CACHE_DEPTH
;
306 if (DBG_ENABLED(ETNA_DBG_CFLUSH_ALL
))
307 to_flush
|= VIVS_GL_FLUSH_CACHE_TEXTURE
| VIVS_GL_FLUSH_CACHE_COLOR
| VIVS_GL_FLUSH_CACHE_DEPTH
;
310 etna_set_state(stream
, VIVS_GL_FLUSH_CACHE
, to_flush
);
311 etna_stall(stream
, SYNC_RECIPIENT_RA
, SYNC_RECIPIENT_PE
);
314 /* If MULTI_SAMPLE_CONFIG.MSAA_SAMPLES changed, clobber affected shader
315 * state to make sure it is always rewritten. */
316 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
))) {
317 if ((ctx
->gpu3d
.GL_MULTI_SAMPLE_CONFIG
& VIVS_GL_MULTI_SAMPLE_CONFIG_MSAA_SAMPLES__MASK
) !=
318 (ctx
->framebuffer
.GL_MULTI_SAMPLE_CONFIG
& VIVS_GL_MULTI_SAMPLE_CONFIG_MSAA_SAMPLES__MASK
)) {
319 /* XXX what does the GPU set these states to on MSAA samples change?
320 * Does it do the right thing?
321 * (increase/decrease as necessary) or something else? Just set some
322 * invalid value until we know for
324 ctx
->gpu3d
.PS_INPUT_COUNT
= 0xffffffff;
325 ctx
->gpu3d
.PS_TEMP_REGISTER_CONTROL
= 0xffffffff;
329 /* Update vertex elements. This is different from any of the other states, in that
330 * a) the number of vertex elements written matters: so write only active ones
331 * b) the vertex element states must all be written: do not skip entries that stay the same */
332 if (dirty
& (ETNA_DIRTY_VERTEX_ELEMENTS
)) {
333 /* Special case: vertex elements must always be sent in full if changed */
334 /*00600*/ etna_set_state_multi(stream
, VIVS_FE_VERTEX_ELEMENT_CONFIG(0),
335 ctx
->vertex_elements
->num_elements
,
336 ctx
->vertex_elements
->FE_VERTEX_ELEMENT_CONFIG
);
339 /* The following code is originally generated by gen_merge_state.py, to
340 * emit state in increasing order of address (this makes it possible to merge
341 * consecutive register updates into one SET_STATE command)
343 * There have been some manual changes, where the weaving operation is not
346 * - num vertex elements
351 * - removed ETNA_DIRTY_BASE_SETUP statements -- these are guaranteed to not
353 * - PS / framebuffer interaction for MSAA
354 * - move update of GL_MULTI_SAMPLE_CONFIG first
355 * - add unlikely()/likely()
357 struct etna_coalesce coalesce
;
359 etna_coalesce_start(stream
, &coalesce
);
361 /* begin only EMIT_STATE -- make sure no new etna_reserve calls are done here
364 /* multi sample config is set first, and outside of the normal sorting
365 * order, as changing the multisample state clobbers PS.INPUT_COUNT (and
366 * possibly PS.TEMP_REGISTER_CONTROL).
368 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
| ETNA_DIRTY_SAMPLE_MASK
))) {
369 uint32_t val
= VIVS_GL_MULTI_SAMPLE_CONFIG_MSAA_ENABLES(ctx
->sample_mask
);
370 val
|= ctx
->framebuffer
.GL_MULTI_SAMPLE_CONFIG
;
372 /*03818*/ EMIT_STATE(GL_MULTI_SAMPLE_CONFIG
, val
);
374 if (likely(dirty
& (ETNA_DIRTY_INDEX_BUFFER
))) {
375 /*00644*/ EMIT_STATE_RELOC(FE_INDEX_STREAM_BASE_ADDR
, &ctx
->index_buffer
.FE_INDEX_STREAM_BASE_ADDR
);
376 /*00648*/ EMIT_STATE(FE_INDEX_STREAM_CONTROL
, ctx
->index_buffer
.FE_INDEX_STREAM_CONTROL
);
378 if (likely(dirty
& (ETNA_DIRTY_VERTEX_BUFFERS
))) {
379 /*0064C*/ EMIT_STATE_RELOC(FE_VERTEX_STREAM_BASE_ADDR
, &ctx
->vertex_buffer
.cvb
[0].FE_VERTEX_STREAM_BASE_ADDR
);
380 /*00650*/ EMIT_STATE(FE_VERTEX_STREAM_CONTROL
, ctx
->vertex_buffer
.cvb
[0].FE_VERTEX_STREAM_CONTROL
);
382 if (likely(dirty
& (ETNA_DIRTY_INDEX_BUFFER
))) {
383 /*00674*/ EMIT_STATE(FE_PRIMITIVE_RESTART_INDEX
, ctx
->index_buffer
.FE_PRIMITIVE_RESTART_INDEX
);
385 if (likely(dirty
& (ETNA_DIRTY_VERTEX_BUFFERS
))) {
386 for (int x
= 1; x
< ctx
->vertex_buffer
.count
; ++x
) {
387 /*00680*/ EMIT_STATE_RELOC(FE_VERTEX_STREAMS_BASE_ADDR(x
), &ctx
->vertex_buffer
.cvb
[x
].FE_VERTEX_STREAM_BASE_ADDR
);
389 for (int x
= 1; x
< ctx
->vertex_buffer
.count
; ++x
) {
390 if (ctx
->vertex_buffer
.cvb
[x
].FE_VERTEX_STREAM_BASE_ADDR
.bo
) {
391 /*006A0*/ EMIT_STATE(FE_VERTEX_STREAMS_CONTROL(x
), ctx
->vertex_buffer
.cvb
[x
].FE_VERTEX_STREAM_CONTROL
);
395 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
396 /*00800*/ EMIT_STATE(VS_END_PC
, ctx
->shader_state
.VS_END_PC
);
398 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
| ETNA_DIRTY_RASTERIZER
))) {
399 bool point_size_per_vertex
=
400 etna_rasterizer_state(ctx
->rasterizer
)->point_size_per_vertex
;
402 /*00804*/ EMIT_STATE(VS_OUTPUT_COUNT
,
403 point_size_per_vertex
404 ? ctx
->shader_state
.VS_OUTPUT_COUNT_PSIZE
405 : ctx
->shader_state
.VS_OUTPUT_COUNT
);
407 if (unlikely(dirty
& (ETNA_DIRTY_VERTEX_ELEMENTS
| ETNA_DIRTY_SHADER
))) {
408 /*00808*/ EMIT_STATE(VS_INPUT_COUNT
, ctx
->shader_state
.VS_INPUT_COUNT
);
409 /*0080C*/ EMIT_STATE(VS_TEMP_REGISTER_CONTROL
, ctx
->shader_state
.VS_TEMP_REGISTER_CONTROL
);
411 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
412 for (int x
= 0; x
< 4; ++x
) {
413 /*00810*/ EMIT_STATE(VS_OUTPUT(x
), ctx
->shader_state
.VS_OUTPUT
[x
]);
416 if (unlikely(dirty
& (ETNA_DIRTY_VERTEX_ELEMENTS
| ETNA_DIRTY_SHADER
))) {
417 for (int x
= 0; x
< 4; ++x
) {
418 /*00820*/ EMIT_STATE(VS_INPUT(x
), ctx
->shader_state
.VS_INPUT
[x
]);
421 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
422 /*00830*/ EMIT_STATE(VS_LOAD_BALANCING
, ctx
->shader_state
.VS_LOAD_BALANCING
);
423 /*00838*/ EMIT_STATE(VS_START_PC
, ctx
->shader_state
.VS_START_PC
);
424 if (ctx
->specs
.has_shader_range_registers
) {
425 /*0085C*/ EMIT_STATE(VS_RANGE
, (ctx
->shader_state
.vs_inst_mem_size
/ 4 - 1) << 16);
428 if (unlikely(dirty
& (ETNA_DIRTY_VIEWPORT
))) {
429 /*00A00*/ EMIT_STATE_FIXP(PA_VIEWPORT_SCALE_X
, ctx
->viewport
.PA_VIEWPORT_SCALE_X
);
430 /*00A04*/ EMIT_STATE_FIXP(PA_VIEWPORT_SCALE_Y
, ctx
->viewport
.PA_VIEWPORT_SCALE_Y
);
431 /*00A08*/ EMIT_STATE(PA_VIEWPORT_SCALE_Z
, ctx
->viewport
.PA_VIEWPORT_SCALE_Z
);
432 /*00A0C*/ EMIT_STATE_FIXP(PA_VIEWPORT_OFFSET_X
, ctx
->viewport
.PA_VIEWPORT_OFFSET_X
);
433 /*00A10*/ EMIT_STATE_FIXP(PA_VIEWPORT_OFFSET_Y
, ctx
->viewport
.PA_VIEWPORT_OFFSET_Y
);
434 /*00A14*/ EMIT_STATE(PA_VIEWPORT_OFFSET_Z
, ctx
->viewport
.PA_VIEWPORT_OFFSET_Z
);
436 if (unlikely(dirty
& (ETNA_DIRTY_RASTERIZER
))) {
437 struct etna_rasterizer_state
*rasterizer
= etna_rasterizer_state(ctx
->rasterizer
);
439 /*00A18*/ EMIT_STATE(PA_LINE_WIDTH
, rasterizer
->PA_LINE_WIDTH
);
440 /*00A1C*/ EMIT_STATE(PA_POINT_SIZE
, rasterizer
->PA_POINT_SIZE
);
441 /*00A28*/ EMIT_STATE(PA_SYSTEM_MODE
, rasterizer
->PA_SYSTEM_MODE
);
443 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
444 /*00A30*/ EMIT_STATE(PA_ATTRIBUTE_ELEMENT_COUNT
, ctx
->shader_state
.PA_ATTRIBUTE_ELEMENT_COUNT
);
446 if (unlikely(dirty
& (ETNA_DIRTY_RASTERIZER
| ETNA_DIRTY_SHADER
))) {
447 uint32_t val
= etna_rasterizer_state(ctx
->rasterizer
)->PA_CONFIG
;
448 /*00A34*/ EMIT_STATE(PA_CONFIG
, val
& ctx
->shader_state
.PA_CONFIG
);
450 if (unlikely(dirty
& (ETNA_DIRTY_RASTERIZER
))) {
451 struct etna_rasterizer_state
*rasterizer
= etna_rasterizer_state(ctx
->rasterizer
);
452 /*00A38*/ EMIT_STATE(PA_WIDE_LINE_WIDTH0
, rasterizer
->PA_LINE_WIDTH
);
453 /*00A3C*/ EMIT_STATE(PA_WIDE_LINE_WIDTH1
, rasterizer
->PA_LINE_WIDTH
);
455 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
456 for (int x
= 0; x
< 10; ++x
) {
457 /*00A40*/ EMIT_STATE(PA_SHADER_ATTRIBUTES(x
), ctx
->shader_state
.PA_SHADER_ATTRIBUTES
[x
]);
460 if (unlikely(dirty
& (ETNA_DIRTY_SCISSOR
| ETNA_DIRTY_FRAMEBUFFER
|
461 ETNA_DIRTY_RASTERIZER
| ETNA_DIRTY_VIEWPORT
))) {
462 /* this is a bit of a mess: rasterizer.scissor determines whether to use
463 * only the framebuffer scissor, or specific scissor state, and the
464 * viewport clips too so the logic spans four CSOs */
465 struct etna_rasterizer_state
*rasterizer
= etna_rasterizer_state(ctx
->rasterizer
);
467 uint32_t scissor_left
=
468 MAX2(ctx
->framebuffer
.SE_SCISSOR_LEFT
, ctx
->viewport
.SE_SCISSOR_LEFT
);
469 uint32_t scissor_top
=
470 MAX2(ctx
->framebuffer
.SE_SCISSOR_TOP
, ctx
->viewport
.SE_SCISSOR_TOP
);
471 uint32_t scissor_right
=
472 MIN2(ctx
->framebuffer
.SE_SCISSOR_RIGHT
, ctx
->viewport
.SE_SCISSOR_RIGHT
);
473 uint32_t scissor_bottom
=
474 MIN2(ctx
->framebuffer
.SE_SCISSOR_BOTTOM
, ctx
->viewport
.SE_SCISSOR_BOTTOM
);
476 if (rasterizer
->scissor
) {
477 scissor_left
= MAX2(ctx
->scissor
.SE_SCISSOR_LEFT
, scissor_left
);
478 scissor_top
= MAX2(ctx
->scissor
.SE_SCISSOR_TOP
, scissor_top
);
479 scissor_right
= MIN2(ctx
->scissor
.SE_SCISSOR_RIGHT
, scissor_right
);
480 scissor_bottom
= MIN2(ctx
->scissor
.SE_SCISSOR_BOTTOM
, scissor_bottom
);
483 /*00C00*/ EMIT_STATE_FIXP(SE_SCISSOR_LEFT
, scissor_left
);
484 /*00C04*/ EMIT_STATE_FIXP(SE_SCISSOR_TOP
, scissor_top
);
485 /*00C08*/ EMIT_STATE_FIXP(SE_SCISSOR_RIGHT
, scissor_right
);
486 /*00C0C*/ EMIT_STATE_FIXP(SE_SCISSOR_BOTTOM
, scissor_bottom
);
488 if (unlikely(dirty
& (ETNA_DIRTY_RASTERIZER
))) {
489 struct etna_rasterizer_state
*rasterizer
= etna_rasterizer_state(ctx
->rasterizer
);
491 /*00C10*/ EMIT_STATE(SE_DEPTH_SCALE
, rasterizer
->SE_DEPTH_SCALE
);
492 /*00C14*/ EMIT_STATE(SE_DEPTH_BIAS
, rasterizer
->SE_DEPTH_BIAS
);
493 /*00C18*/ EMIT_STATE(SE_CONFIG
, rasterizer
->SE_CONFIG
);
495 if (unlikely(dirty
& (ETNA_DIRTY_SCISSOR
| ETNA_DIRTY_FRAMEBUFFER
|
496 ETNA_DIRTY_RASTERIZER
| ETNA_DIRTY_VIEWPORT
))) {
497 struct etna_rasterizer_state
*rasterizer
= etna_rasterizer_state(ctx
->rasterizer
);
499 uint32_t clip_right
=
500 MIN2(ctx
->framebuffer
.SE_CLIP_RIGHT
, ctx
->viewport
.SE_CLIP_RIGHT
);
501 uint32_t clip_bottom
=
502 MIN2(ctx
->framebuffer
.SE_CLIP_BOTTOM
, ctx
->viewport
.SE_CLIP_BOTTOM
);
504 if (rasterizer
->scissor
) {
505 clip_right
= MIN2(ctx
->scissor
.SE_CLIP_RIGHT
, clip_right
);
506 clip_bottom
= MIN2(ctx
->scissor
.SE_CLIP_BOTTOM
, clip_bottom
);
509 /*00C20*/ EMIT_STATE_FIXP(SE_CLIP_RIGHT
, clip_right
);
510 /*00C24*/ EMIT_STATE_FIXP(SE_CLIP_BOTTOM
, clip_bottom
);
512 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
513 /*00E00*/ EMIT_STATE(RA_CONTROL
, ctx
->shader_state
.RA_CONTROL
);
515 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
))) {
516 /*00E04*/ EMIT_STATE(RA_MULTISAMPLE_UNK00E04
, ctx
->framebuffer
.RA_MULTISAMPLE_UNK00E04
);
517 for (int x
= 0; x
< 4; ++x
) {
518 /*00E10*/ EMIT_STATE(RA_MULTISAMPLE_UNK00E10(x
), ctx
->framebuffer
.RA_MULTISAMPLE_UNK00E10
[x
]);
520 for (int x
= 0; x
< 16; ++x
) {
521 /*00E40*/ EMIT_STATE(RA_CENTROID_TABLE(x
), ctx
->framebuffer
.RA_CENTROID_TABLE
[x
]);
524 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
| ETNA_DIRTY_FRAMEBUFFER
))) {
525 /*01000*/ EMIT_STATE(PS_END_PC
, ctx
->shader_state
.PS_END_PC
);
526 /*01004*/ EMIT_STATE(PS_OUTPUT_REG
, ctx
->shader_state
.PS_OUTPUT_REG
);
527 /*01008*/ EMIT_STATE(PS_INPUT_COUNT
,
528 ctx
->framebuffer
.msaa_mode
529 ? ctx
->shader_state
.PS_INPUT_COUNT_MSAA
530 : ctx
->shader_state
.PS_INPUT_COUNT
);
531 /*0100C*/ EMIT_STATE(PS_TEMP_REGISTER_CONTROL
,
532 ctx
->framebuffer
.msaa_mode
533 ? ctx
->shader_state
.PS_TEMP_REGISTER_CONTROL_MSAA
534 : ctx
->shader_state
.PS_TEMP_REGISTER_CONTROL
);
535 /*01010*/ EMIT_STATE(PS_CONTROL
, ctx
->shader_state
.PS_CONTROL
);
536 /*01018*/ EMIT_STATE(PS_START_PC
, ctx
->shader_state
.PS_START_PC
);
537 if (ctx
->specs
.has_shader_range_registers
) {
538 /*0101C*/ EMIT_STATE(PS_RANGE
, ((ctx
->shader_state
.ps_inst_mem_size
/ 4 - 1 + 0x100) << 16) |
542 if (unlikely(dirty
& (ETNA_DIRTY_ZSA
| ETNA_DIRTY_FRAMEBUFFER
))) {
543 uint32_t val
= etna_zsa_state(ctx
->zsa
)->PE_DEPTH_CONFIG
;
544 /*01400*/ EMIT_STATE(PE_DEPTH_CONFIG
, val
| ctx
->framebuffer
.PE_DEPTH_CONFIG
);
546 if (unlikely(dirty
& (ETNA_DIRTY_VIEWPORT
))) {
547 /*01404*/ EMIT_STATE(PE_DEPTH_NEAR
, ctx
->viewport
.PE_DEPTH_NEAR
);
548 /*01408*/ EMIT_STATE(PE_DEPTH_FAR
, ctx
->viewport
.PE_DEPTH_FAR
);
550 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
))) {
551 /*0140C*/ EMIT_STATE(PE_DEPTH_NORMALIZE
, ctx
->framebuffer
.PE_DEPTH_NORMALIZE
);
553 if (ctx
->specs
.pixel_pipes
== 1) {
554 /*01410*/ EMIT_STATE_RELOC(PE_DEPTH_ADDR
, &ctx
->framebuffer
.PE_DEPTH_ADDR
);
557 /*01414*/ EMIT_STATE(PE_DEPTH_STRIDE
, ctx
->framebuffer
.PE_DEPTH_STRIDE
);
559 if (unlikely(dirty
& (ETNA_DIRTY_ZSA
))) {
560 uint32_t val
= etna_zsa_state(ctx
->zsa
)->PE_STENCIL_OP
;
561 /*01418*/ EMIT_STATE(PE_STENCIL_OP
, val
);
563 if (unlikely(dirty
& (ETNA_DIRTY_ZSA
| ETNA_DIRTY_STENCIL_REF
))) {
564 uint32_t val
= etna_zsa_state(ctx
->zsa
)->PE_STENCIL_CONFIG
;
565 /*0141C*/ EMIT_STATE(PE_STENCIL_CONFIG
, val
| ctx
->stencil_ref
.PE_STENCIL_CONFIG
);
567 if (unlikely(dirty
& (ETNA_DIRTY_ZSA
))) {
568 uint32_t val
= etna_zsa_state(ctx
->zsa
)->PE_ALPHA_OP
;
569 /*01420*/ EMIT_STATE(PE_ALPHA_OP
, val
);
571 if (unlikely(dirty
& (ETNA_DIRTY_BLEND_COLOR
))) {
572 /*01424*/ EMIT_STATE(PE_ALPHA_BLEND_COLOR
, ctx
->blend_color
.PE_ALPHA_BLEND_COLOR
);
574 if (unlikely(dirty
& (ETNA_DIRTY_BLEND
))) {
575 uint32_t val
= etna_blend_state(ctx
->blend
)->PE_ALPHA_CONFIG
;
576 /*01428*/ EMIT_STATE(PE_ALPHA_CONFIG
, val
);
578 if (unlikely(dirty
& (ETNA_DIRTY_BLEND
| ETNA_DIRTY_FRAMEBUFFER
))) {
580 /* Use the components and overwrite bits in framebuffer.PE_COLOR_FORMAT
581 * as a mask to enable the bits from blend PE_COLOR_FORMAT */
582 val
= ~(VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK
|
583 VIVS_PE_COLOR_FORMAT_OVERWRITE
);
584 val
|= etna_blend_state(ctx
->blend
)->PE_COLOR_FORMAT
;
585 val
&= ctx
->framebuffer
.PE_COLOR_FORMAT
;
586 /*0142C*/ EMIT_STATE(PE_COLOR_FORMAT
, val
);
588 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
))) {
589 if (ctx
->specs
.pixel_pipes
== 1) {
590 /*01430*/ EMIT_STATE_RELOC(PE_COLOR_ADDR
, &ctx
->framebuffer
.PE_COLOR_ADDR
);
591 /*01434*/ EMIT_STATE(PE_COLOR_STRIDE
, ctx
->framebuffer
.PE_COLOR_STRIDE
);
592 /*01454*/ EMIT_STATE(PE_HDEPTH_CONTROL
, ctx
->framebuffer
.PE_HDEPTH_CONTROL
);
593 } else if (ctx
->specs
.pixel_pipes
== 2) {
594 /*01434*/ EMIT_STATE(PE_COLOR_STRIDE
, ctx
->framebuffer
.PE_COLOR_STRIDE
);
595 /*01454*/ EMIT_STATE(PE_HDEPTH_CONTROL
, ctx
->framebuffer
.PE_HDEPTH_CONTROL
);
596 /*01460*/ EMIT_STATE_RELOC(PE_PIPE_COLOR_ADDR(0), &ctx
->framebuffer
.PE_PIPE_COLOR_ADDR
[0]);
597 /*01464*/ EMIT_STATE_RELOC(PE_PIPE_COLOR_ADDR(1), &ctx
->framebuffer
.PE_PIPE_COLOR_ADDR
[1]);
598 /*01480*/ EMIT_STATE_RELOC(PE_PIPE_DEPTH_ADDR(0), &ctx
->framebuffer
.PE_PIPE_DEPTH_ADDR
[0]);
599 /*01484*/ EMIT_STATE_RELOC(PE_PIPE_DEPTH_ADDR(1), &ctx
->framebuffer
.PE_PIPE_DEPTH_ADDR
[1]);
604 if (unlikely(dirty
& (ETNA_DIRTY_STENCIL_REF
))) {
605 /*014A0*/ EMIT_STATE(PE_STENCIL_CONFIG_EXT
, ctx
->stencil_ref
.PE_STENCIL_CONFIG_EXT
);
607 if (unlikely(dirty
& (ETNA_DIRTY_BLEND
| ETNA_DIRTY_FRAMEBUFFER
))) {
608 struct etna_blend_state
*blend
= etna_blend_state(ctx
->blend
);
609 /*014A4*/ EMIT_STATE(PE_LOGIC_OP
, blend
->PE_LOGIC_OP
| ctx
->framebuffer
.PE_LOGIC_OP
);
611 if (unlikely(dirty
& (ETNA_DIRTY_BLEND
))) {
612 struct etna_blend_state
*blend
= etna_blend_state(ctx
->blend
);
613 for (int x
= 0; x
< 2; ++x
) {
614 /*014A8*/ EMIT_STATE(PE_DITHER(x
), blend
->PE_DITHER
[x
]);
617 if (unlikely(dirty
& (ETNA_DIRTY_FRAMEBUFFER
| ETNA_DIRTY_TS
))) {
618 /*01654*/ EMIT_STATE(TS_MEM_CONFIG
, ctx
->framebuffer
.TS_MEM_CONFIG
);
619 /*01658*/ EMIT_STATE_RELOC(TS_COLOR_STATUS_BASE
, &ctx
->framebuffer
.TS_COLOR_STATUS_BASE
);
620 /*0165C*/ EMIT_STATE_RELOC(TS_COLOR_SURFACE_BASE
, &ctx
->framebuffer
.TS_COLOR_SURFACE_BASE
);
621 /*01660*/ EMIT_STATE(TS_COLOR_CLEAR_VALUE
, ctx
->framebuffer
.TS_COLOR_CLEAR_VALUE
);
622 /*01664*/ EMIT_STATE_RELOC(TS_DEPTH_STATUS_BASE
, &ctx
->framebuffer
.TS_DEPTH_STATUS_BASE
);
623 /*01668*/ EMIT_STATE_RELOC(TS_DEPTH_SURFACE_BASE
, &ctx
->framebuffer
.TS_DEPTH_SURFACE_BASE
);
624 /*0166C*/ EMIT_STATE(TS_DEPTH_CLEAR_VALUE
, ctx
->framebuffer
.TS_DEPTH_CLEAR_VALUE
);
626 if (unlikely(dirty
& (ETNA_DIRTY_SAMPLER_VIEWS
| ETNA_DIRTY_SAMPLERS
))) {
627 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
628 uint32_t val
= 0; /* 0 == sampler inactive */
630 /* set active samplers to their configuration value (determined by both
631 * the sampler state and sampler view) */
632 if ((1 << x
) & active_samplers
) {
633 struct etna_sampler_state
*ss
= etna_sampler_state(ctx
->sampler
[x
]);
634 struct etna_sampler_view
*sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
636 val
= (ss
->TE_SAMPLER_CONFIG0
& sv
->TE_SAMPLER_CONFIG0_MASK
) |
637 sv
->TE_SAMPLER_CONFIG0
;
640 /*02000*/ EMIT_STATE(TE_SAMPLER_CONFIG0(x
), val
);
643 if (unlikely(dirty
& (ETNA_DIRTY_SAMPLER_VIEWS
))) {
644 struct etna_sampler_view
*sv
;
646 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
647 if ((1 << x
) & active_samplers
) {
648 sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
649 /*02040*/ EMIT_STATE(TE_SAMPLER_SIZE(x
), sv
->TE_SAMPLER_SIZE
);
652 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
653 if ((1 << x
) & active_samplers
) {
654 sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
655 /*02080*/ EMIT_STATE(TE_SAMPLER_LOG_SIZE(x
), sv
->TE_SAMPLER_LOG_SIZE
);
659 if (unlikely(dirty
& (ETNA_DIRTY_SAMPLER_VIEWS
| ETNA_DIRTY_SAMPLERS
))) {
660 struct etna_sampler_state
*ss
;
661 struct etna_sampler_view
*sv
;
663 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
664 if ((1 << x
) & active_samplers
) {
665 ss
= etna_sampler_state(ctx
->sampler
[x
]);
666 sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
668 /* min and max lod is determined both by the sampler and the view */
669 /*020C0*/ EMIT_STATE(TE_SAMPLER_LOD_CONFIG(x
),
670 ss
->TE_SAMPLER_LOD_CONFIG
|
671 VIVS_TE_SAMPLER_LOD_CONFIG_MAX(MIN2(ss
->max_lod
, sv
->max_lod
)) |
672 VIVS_TE_SAMPLER_LOD_CONFIG_MIN(MAX2(ss
->min_lod
, sv
->min_lod
)));
675 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
676 if ((1 << x
) & active_samplers
) {
677 ss
= etna_sampler_state(ctx
->sampler
[x
]);
678 sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
680 /*021C0*/ EMIT_STATE(TE_SAMPLER_CONFIG1(x
), ss
->TE_SAMPLER_CONFIG1
|
681 sv
->TE_SAMPLER_CONFIG1
);
685 if (unlikely(dirty
& (ETNA_DIRTY_SAMPLER_VIEWS
))) {
686 for (int y
= 0; y
< VIVS_TE_SAMPLER_LOD_ADDR__LEN
; ++y
) {
687 for (int x
= 0; x
< VIVS_TE_SAMPLER__LEN
; ++x
) {
688 if ((1 << x
) & active_samplers
) {
689 struct etna_sampler_view
*sv
= etna_sampler_view(ctx
->sampler_view
[x
]);
690 /*02400*/ EMIT_STATE_RELOC(TE_SAMPLER_LOD_ADDR(x
, y
),&sv
->TE_SAMPLER_LOD_ADDR
[y
]);
695 if (unlikely(dirty
& (ETNA_DIRTY_SHADER
))) {
696 /*0381C*/ EMIT_STATE(GL_VARYING_TOTAL_COMPONENTS
, ctx
->shader_state
.GL_VARYING_TOTAL_COMPONENTS
);
697 /*03820*/ EMIT_STATE(GL_VARYING_NUM_COMPONENTS
, ctx
->shader_state
.GL_VARYING_NUM_COMPONENTS
);
698 for (int x
= 0; x
< 2; ++x
) {
699 /*03828*/ EMIT_STATE(GL_VARYING_COMPONENT_USE(x
), ctx
->shader_state
.GL_VARYING_COMPONENT_USE
[x
]);
702 etna_coalesce_end(stream
, &coalesce
);
703 /* end only EMIT_STATE */
705 /* Insert a FE/PE stall as changing the shader instructions (and maybe
706 * the uniforms) can corrupt the previous in-progress draw operation.
707 * Observed with amoeba on GC2000 during the right-to-left rendering
708 * of PI, and can cause GPU hangs immediately after.
709 * I summise that this is because the "new" locations at 0xc000 are not
710 * properly protected against updates as other states seem to be. Hence,
711 * we detect the "new" vertex shader instruction offset to apply this. */
712 if (ctx
->dirty
& (ETNA_DIRTY_SHADER
| ETNA_DIRTY_CONSTBUF
) && ctx
->specs
.vs_offset
> 0x4000)
713 etna_stall(ctx
->stream
, SYNC_RECIPIENT_FE
, SYNC_RECIPIENT_PE
);
715 /* We need to update the uniform cache only if one of the following bits are
717 * - ETNA_DIRTY_SHADER
718 * - ETNA_DIRTY_CONSTBUF
719 * - uniforms_dirty_bits
721 * In case of ETNA_DIRTY_SHADER we need load all uniforms from the cache. In
723 * other cases we can load on the changed uniforms.
725 static const uint32_t uniform_dirty_bits
=
726 ETNA_DIRTY_SHADER
| ETNA_DIRTY_CONSTBUF
;
728 if (dirty
& (uniform_dirty_bits
| ctx
->shader
.fs
->uniforms_dirty_bits
))
730 ctx
, ctx
->shader
.vs
, &ctx
->constant_buffer
[PIPE_SHADER_VERTEX
],
731 ctx
->shader_state
.VS_UNIFORMS
, &ctx
->shader_state
.vs_uniforms_size
);
733 if (dirty
& (uniform_dirty_bits
| ctx
->shader
.vs
->uniforms_dirty_bits
))
735 ctx
, ctx
->shader
.fs
, &ctx
->constant_buffer
[PIPE_SHADER_FRAGMENT
],
736 ctx
->shader_state
.PS_UNIFORMS
, &ctx
->shader_state
.ps_uniforms_size
);
738 /**** Large dynamically-sized state ****/
739 if (dirty
& (ETNA_DIRTY_SHADER
)) {
740 /* Special case: a new shader was loaded; simply re-load all uniforms and
741 * shader code at once */
743 etna_set_state_multi(stream
, ctx
->specs
.vs_offset
,
744 ctx
->shader_state
.vs_inst_mem_size
,
745 ctx
->shader_state
.VS_INST_MEM
);
747 etna_set_state_multi(stream
, ctx
->specs
.ps_offset
,
748 ctx
->shader_state
.ps_inst_mem_size
,
749 ctx
->shader_state
.PS_INST_MEM
);
750 /*05000*/ etna_set_state_multi(stream
, VIVS_VS_UNIFORMS(0),
751 ctx
->shader_state
.vs_uniforms_size
,
752 ctx
->shader_state
.VS_UNIFORMS
);
753 /*07000*/ etna_set_state_multi(stream
, VIVS_PS_UNIFORMS(0),
754 ctx
->shader_state
.ps_uniforms_size
,
755 ctx
->shader_state
.PS_UNIFORMS
);
757 /* Copy uniforms to gpu3d, so that incremental updates to uniforms are
758 * possible as long as the
759 * same shader remains bound */
760 ctx
->gpu3d
.vs_uniforms_size
= ctx
->shader_state
.vs_uniforms_size
;
761 ctx
->gpu3d
.ps_uniforms_size
= ctx
->shader_state
.ps_uniforms_size
;
762 memcpy(ctx
->gpu3d
.VS_UNIFORMS
, ctx
->shader_state
.VS_UNIFORMS
,
763 ctx
->shader_state
.vs_uniforms_size
* 4);
764 memcpy(ctx
->gpu3d
.PS_UNIFORMS
, ctx
->shader_state
.PS_UNIFORMS
,
765 ctx
->shader_state
.ps_uniforms_size
* 4);
767 etna_coalesce_start(stream
, &coalesce
);
768 for (int x
= 0; x
< ctx
->shader
.vs
->uniforms
.const_count
; ++x
) {
769 if (ctx
->gpu3d
.VS_UNIFORMS
[x
] != ctx
->shader_state
.VS_UNIFORMS
[x
]) {
770 /*05000*/ EMIT_STATE(VS_UNIFORMS(x
), ctx
->shader_state
.VS_UNIFORMS
[x
]);
771 ctx
->gpu3d
.VS_UNIFORMS
[x
] = ctx
->shader_state
.VS_UNIFORMS
[x
];
774 etna_coalesce_end(stream
, &coalesce
);
776 etna_coalesce_start(stream
, &coalesce
);
777 for (int x
= 0; x
< ctx
->shader
.fs
->uniforms
.const_count
; ++x
) {
778 if (ctx
->gpu3d
.PS_UNIFORMS
[x
] != ctx
->shader_state
.PS_UNIFORMS
[x
]) {
779 /*07000*/ EMIT_STATE(PS_UNIFORMS(x
), ctx
->shader_state
.PS_UNIFORMS
[x
]);
780 ctx
->gpu3d
.PS_UNIFORMS
[x
] = ctx
->shader_state
.PS_UNIFORMS
[x
];
783 etna_coalesce_end(stream
, &coalesce
);
785 /**** End of state update ****/
787 #undef EMIT_STATE_FIXP
788 #undef EMIT_STATE_RELOC