2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
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 NONINFRINGEMENT. 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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Rob Clark <robclark@freedesktop.org>
27 #include "pipe/p_state.h"
28 #include "util/u_string.h"
29 #include "util/u_memory.h"
30 #include "util/u_helpers.h"
31 #include "util/u_format.h"
32 #include "util/u_viewport.h"
34 #include "freedreno_resource.h"
35 #include "freedreno_query_hw.h"
38 #include "fd5_blend.h"
39 #include "fd5_context.h"
40 #include "fd5_program.h"
41 #include "fd5_rasterizer.h"
42 #include "fd5_texture.h"
43 #include "fd5_format.h"
46 /* regid: base const register
47 * prsc or dwords: buffer containing constant values
48 * sizedwords: size of const value buffer
51 fd5_emit_const(struct fd_ringbuffer
*ring
, enum shader_t type
,
52 uint32_t regid
, uint32_t offset
, uint32_t sizedwords
,
53 const uint32_t *dwords
, struct pipe_resource
*prsc
)
56 enum a4xx_state_src src
;
58 debug_assert((regid
% 4) == 0);
59 debug_assert((sizedwords
% 4) == 0);
69 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + sz
);
70 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
71 CP_LOAD_STATE4_0_STATE_SRC(src
) |
72 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type
)) |
73 CP_LOAD_STATE4_0_NUM_UNIT(sizedwords
/4));
75 struct fd_bo
*bo
= fd_resource(prsc
)->bo
;
76 OUT_RELOC(ring
, bo
, offset
,
77 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
), 0);
79 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
80 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
81 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
82 dwords
= (uint32_t *)&((uint8_t *)dwords
)[offset
];
84 for (i
= 0; i
< sz
; i
++) {
85 OUT_RING(ring
, dwords
[i
]);
90 fd5_emit_const_bo(struct fd_ringbuffer
*ring
, enum shader_t type
, boolean write
,
91 uint32_t regid
, uint32_t num
, struct pipe_resource
**prscs
, uint32_t *offsets
)
93 uint32_t anum
= align(num
, 2);
96 debug_assert((regid
% 4) == 0);
98 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * anum
));
99 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
100 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
101 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type
)) |
102 CP_LOAD_STATE4_0_NUM_UNIT(anum
/2));
103 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
104 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
105 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
107 for (i
= 0; i
< num
; i
++) {
110 OUT_RELOCW(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
112 OUT_RELOC(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
115 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
116 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
120 for (; i
< anum
; i
++) {
121 OUT_RING(ring
, 0xffffffff);
122 OUT_RING(ring
, 0xffffffff);
126 /* Border color layout is diff from a4xx/a5xx.. if it turns out to be
127 * the same as a6xx then move this somewhere common ;-)
129 * Entry layout looks like (total size, 0x60 bytes):
132 struct PACKED bcolor_entry
{
144 uint32_t z24
; /* also s8? */
148 #define FD5_BORDER_COLOR_SIZE 0x60
149 #define FD5_BORDER_COLOR_UPLOAD_SIZE (2 * PIPE_MAX_SAMPLERS * FD5_BORDER_COLOR_SIZE)
152 setup_border_colors(struct fd_texture_stateobj
*tex
, struct bcolor_entry
*entries
)
155 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD5_BORDER_COLOR_SIZE
);
157 for (i
= 0; i
< tex
->num_samplers
; i
++) {
158 struct bcolor_entry
*e
= &entries
[i
];
159 struct pipe_sampler_state
*sampler
= tex
->samplers
[i
];
160 union pipe_color_union
*bc
;
165 bc
= &sampler
->border_color
;
170 * The border colors need to be swizzled in a particular
171 * format-dependent order. Even though samplers don't know about
172 * formats, we can assume that with a GL state tracker, there's a
173 * 1:1 correspondence between sampler and texture. Take advantage
176 if ((i
>= tex
->num_textures
) || !tex
->textures
[i
])
179 const struct util_format_description
*desc
=
180 util_format_description(tex
->textures
[i
]->format
);
188 for (j
= 0; j
< 4; j
++) {
189 int c
= desc
->swizzle
[j
];
194 if (desc
->channel
[c
].pure_integer
) {
196 switch (desc
->channel
[c
].size
) {
198 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
199 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3);
202 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
203 clamped
= CLAMP(bc
->i
[j
], -128, 127);
205 clamped
= CLAMP(bc
->ui
[j
], 0, 255);
208 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
209 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3ff);
212 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
213 clamped
= CLAMP(bc
->i
[j
], -32768, 32767);
215 clamped
= CLAMP(bc
->ui
[j
], 0, 65535);
218 assert(!"Unexpected bit size");
223 e
->fp32
[c
] = bc
->ui
[j
];
224 e
->fp16
[c
] = clamped
;
227 float f_u
= CLAMP(f
, 0, 1);
228 float f_s
= CLAMP(f
, -1, 1);
231 e
->fp16
[c
] = util_float_to_half(f
);
232 e
->ui16
[c
] = f_u
* 0xffff;
233 e
->si16
[c
] = f_s
* 0x7fff;
234 e
->ui8
[c
] = f_u
* 0xff;
235 e
->si8
[c
] = f_s
* 0x7f;
237 e
->rgb565
|= (int)(f_u
* 0x3f) << 5;
239 e
->rgb565
|= (int)(f_u
* 0x1f) << (c
? 11 : 0);
241 e
->rgb5a1
|= (f_u
> 0.5) ? 0x8000 : 0;
243 e
->rgb5a1
|= (int)(f_u
* 0x1f) << (c
* 5);
245 e
->rgb10a2
|= (int)(f_u
* 0x3) << 30;
247 e
->rgb10a2
|= (int)(f_u
* 0x3ff) << (c
* 10);
248 e
->rgba4
|= (int)(f_u
* 0xf) << (c
* 4);
250 e
->z24
= f_u
* 0xffffff;
255 memset(&e
->__pad0
, 0, sizeof(e
->__pad0
));
256 memset(&e
->__pad1
, 0, sizeof(e
->__pad1
));
262 emit_border_color(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
)
264 struct fd5_context
*fd5_ctx
= fd5_context(ctx
);
265 struct bcolor_entry
*entries
;
269 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD5_BORDER_COLOR_SIZE
);
271 u_upload_alloc(fd5_ctx
->border_color_uploader
,
272 0, FD5_BORDER_COLOR_UPLOAD_SIZE
,
273 FD5_BORDER_COLOR_UPLOAD_SIZE
, &off
,
274 &fd5_ctx
->border_color_buf
,
279 setup_border_colors(&ctx
->tex
[PIPE_SHADER_VERTEX
], &entries
[0]);
280 setup_border_colors(&ctx
->tex
[PIPE_SHADER_FRAGMENT
],
281 &entries
[ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
]);
283 OUT_PKT4(ring
, REG_A5XX_TPL1_TP_BORDER_COLOR_BASE_ADDR_LO
, 2);
284 OUT_RELOC(ring
, fd_resource(fd5_ctx
->border_color_buf
)->bo
, off
, 0, 0);
286 u_upload_unmap(fd5_ctx
->border_color_uploader
);
290 emit_textures(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
291 enum a4xx_state_block sb
, struct fd_texture_stateobj
*tex
)
293 bool needs_border
= false;
294 unsigned bcolor_offset
= (sb
== SB4_FS_TEX
) ? ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
: 0;
297 if (tex
->num_samplers
> 0) {
298 /* output sampler state: */
299 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (4 * tex
->num_samplers
));
300 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
301 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
302 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
303 CP_LOAD_STATE4_0_NUM_UNIT(tex
->num_samplers
));
304 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_SHADER
) |
305 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
306 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
307 for (i
= 0; i
< tex
->num_samplers
; i
++) {
308 static const struct fd5_sampler_stateobj dummy_sampler
= {};
309 const struct fd5_sampler_stateobj
*sampler
= tex
->samplers
[i
] ?
310 fd5_sampler_stateobj(tex
->samplers
[i
]) :
312 OUT_RING(ring
, sampler
->texsamp0
);
313 OUT_RING(ring
, sampler
->texsamp1
);
314 OUT_RING(ring
, sampler
->texsamp2
|
315 A5XX_TEX_SAMP_2_BCOLOR_OFFSET(bcolor_offset
));
316 OUT_RING(ring
, sampler
->texsamp3
);
318 needs_border
|= sampler
->needs_border
;
322 if (tex
->num_textures
> 0) {
323 unsigned num_textures
= tex
->num_textures
;
325 /* emit texture state: */
326 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (12 * num_textures
));
327 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
328 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
329 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
330 CP_LOAD_STATE4_0_NUM_UNIT(num_textures
));
331 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
) |
332 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
333 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
334 for (i
= 0; i
< tex
->num_textures
; i
++) {
335 static const struct fd5_pipe_sampler_view dummy_view
= {};
336 const struct fd5_pipe_sampler_view
*view
= tex
->textures
[i
] ?
337 fd5_pipe_sampler_view(tex
->textures
[i
]) :
340 OUT_RING(ring
, view
->texconst0
);
341 OUT_RING(ring
, view
->texconst1
);
342 OUT_RING(ring
, view
->texconst2
);
343 OUT_RING(ring
, view
->texconst3
);
344 if (view
->base
.texture
) {
345 struct fd_resource
*rsc
= fd_resource(view
->base
.texture
);
346 OUT_RELOC(ring
, rsc
->bo
, view
->offset
,
347 (uint64_t)view
->texconst5
<< 32, 0);
349 OUT_RING(ring
, 0x00000000);
350 OUT_RING(ring
, view
->texconst5
);
352 OUT_RING(ring
, view
->texconst6
);
353 OUT_RING(ring
, view
->texconst7
);
354 OUT_RING(ring
, view
->texconst8
);
355 OUT_RING(ring
, view
->texconst9
);
356 OUT_RING(ring
, view
->texconst10
);
357 OUT_RING(ring
, view
->texconst11
);
365 emit_ssbos(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
366 enum a4xx_state_block sb
, struct fd_shaderbuf_stateobj
*so
)
368 unsigned count
= util_last_bit(so
->enabled_mask
);
373 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (4 * count
));
374 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
375 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
376 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
377 CP_LOAD_STATE4_0_NUM_UNIT(count
));
378 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(0) |
379 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
380 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
381 for (unsigned i
= 0; i
< count
; i
++) {
382 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
384 struct fd_resource
*rsc
= fd_resource(buf
->buffer
);
385 OUT_RELOCW(ring
, rsc
->bo
, 0, 0, 0);
387 OUT_RING(ring
, 0x00000000);
388 OUT_RING(ring
, 0x00000000);
390 OUT_RING(ring
, 0x00000000);
391 OUT_RING(ring
, 0x00000000);
394 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * count
));
395 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
396 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
397 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
398 CP_LOAD_STATE4_0_NUM_UNIT(count
));
399 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(1) |
400 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
401 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
402 for (unsigned i
= 0; i
< count
; i
++) {
403 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
405 // TODO maybe offset encoded somewhere here??
406 OUT_RING(ring
, (buf
->buffer_size
<< 16));
407 OUT_RING(ring
, 0x00000000);
410 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * count
));
411 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
412 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
413 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
414 CP_LOAD_STATE4_0_NUM_UNIT(count
));
415 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(2) |
416 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
417 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
418 for (unsigned i
= 0; i
< count
; i
++) {
419 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
421 struct fd_resource
*rsc
= fd_resource(buf
->buffer
);
422 OUT_RELOCW(ring
, rsc
->bo
, 0, 0, 0);
424 OUT_RING(ring
, 0x00000000);
425 OUT_RING(ring
, 0x00000000);
431 fd5_emit_vertex_bufs(struct fd_ringbuffer
*ring
, struct fd5_emit
*emit
)
434 const struct fd_vertex_state
*vtx
= emit
->vtx
;
435 const struct ir3_shader_variant
*vp
= fd5_emit_get_vp(emit
);
437 for (i
= 0, j
= 0; i
<= vp
->inputs_count
; i
++) {
438 if (vp
->inputs
[i
].sysval
)
440 if (vp
->inputs
[i
].compmask
) {
441 struct pipe_vertex_element
*elem
= &vtx
->vtx
->pipe
[i
];
442 const struct pipe_vertex_buffer
*vb
=
443 &vtx
->vertexbuf
.vb
[elem
->vertex_buffer_index
];
444 struct fd_resource
*rsc
= fd_resource(vb
->buffer
.resource
);
445 enum pipe_format pfmt
= elem
->src_format
;
446 enum a5xx_vtx_fmt fmt
= fd5_pipe2vtx(pfmt
);
447 bool isint
= util_format_is_pure_integer(pfmt
);
448 uint32_t off
= vb
->buffer_offset
+ elem
->src_offset
;
449 uint32_t size
= fd_bo_size(rsc
->bo
) - off
;
450 debug_assert(fmt
!= ~0);
452 OUT_PKT4(ring
, REG_A5XX_VFD_FETCH(j
), 4);
453 OUT_RELOC(ring
, rsc
->bo
, off
, 0, 0);
454 OUT_RING(ring
, size
); /* VFD_FETCH[j].SIZE */
455 OUT_RING(ring
, vb
->stride
); /* VFD_FETCH[j].STRIDE */
457 OUT_PKT4(ring
, REG_A5XX_VFD_DECODE(j
), 2);
458 OUT_RING(ring
, A5XX_VFD_DECODE_INSTR_IDX(j
) |
459 A5XX_VFD_DECODE_INSTR_FORMAT(fmt
) |
460 COND(elem
->instance_divisor
, A5XX_VFD_DECODE_INSTR_INSTANCED
) |
461 A5XX_VFD_DECODE_INSTR_SWAP(fd5_pipe2swap(pfmt
)) |
462 A5XX_VFD_DECODE_INSTR_UNK30
|
463 COND(!isint
, A5XX_VFD_DECODE_INSTR_FLOAT
));
464 OUT_RING(ring
, MAX2(1, elem
->instance_divisor
)); /* VFD_DECODE[j].STEP_RATE */
466 OUT_PKT4(ring
, REG_A5XX_VFD_DEST_CNTL(j
), 1);
467 OUT_RING(ring
, A5XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vp
->inputs
[i
].compmask
) |
468 A5XX_VFD_DEST_CNTL_INSTR_REGID(vp
->inputs
[i
].regid
));
474 OUT_PKT4(ring
, REG_A5XX_VFD_CONTROL_0
, 1);
475 OUT_RING(ring
, A5XX_VFD_CONTROL_0_VTXCNT(j
));
479 fd5_emit_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
480 struct fd5_emit
*emit
)
482 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
483 const struct ir3_shader_variant
*vp
= fd5_emit_get_vp(emit
);
484 const struct ir3_shader_variant
*fp
= fd5_emit_get_fp(emit
);
485 const enum fd_dirty_3d_state dirty
= emit
->dirty
;
486 bool needs_border
= false;
488 emit_marker5(ring
, 5);
490 if ((dirty
& FD_DIRTY_FRAMEBUFFER
) && !emit
->key
.binning_pass
) {
491 unsigned char mrt_comp
[A5XX_MAX_RENDER_TARGETS
] = {0};
493 for (unsigned i
= 0; i
< A5XX_MAX_RENDER_TARGETS
; i
++) {
494 mrt_comp
[i
] = ((i
< pfb
->nr_cbufs
) && pfb
->cbufs
[i
]) ? 0xf : 0;
497 OUT_PKT4(ring
, REG_A5XX_RB_RENDER_COMPONENTS
, 1);
498 OUT_RING(ring
, A5XX_RB_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
499 A5XX_RB_RENDER_COMPONENTS_RT1(mrt_comp
[1]) |
500 A5XX_RB_RENDER_COMPONENTS_RT2(mrt_comp
[2]) |
501 A5XX_RB_RENDER_COMPONENTS_RT3(mrt_comp
[3]) |
502 A5XX_RB_RENDER_COMPONENTS_RT4(mrt_comp
[4]) |
503 A5XX_RB_RENDER_COMPONENTS_RT5(mrt_comp
[5]) |
504 A5XX_RB_RENDER_COMPONENTS_RT6(mrt_comp
[6]) |
505 A5XX_RB_RENDER_COMPONENTS_RT7(mrt_comp
[7]));
508 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_FRAMEBUFFER
)) {
509 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
510 uint32_t rb_alpha_control
= zsa
->rb_alpha_control
;
512 if (util_format_is_pure_integer(pipe_surface_format(pfb
->cbufs
[0])))
513 rb_alpha_control
&= ~A5XX_RB_ALPHA_CONTROL_ALPHA_TEST
;
515 OUT_PKT4(ring
, REG_A5XX_RB_ALPHA_CONTROL
, 1);
516 OUT_RING(ring
, rb_alpha_control
);
518 OUT_PKT4(ring
, REG_A5XX_RB_STENCIL_CONTROL
, 1);
519 OUT_RING(ring
, zsa
->rb_stencil_control
);
522 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_BLEND
| FD_DIRTY_PROG
)) {
523 struct fd5_blend_stateobj
*blend
= fd5_blend_stateobj(ctx
->blend
);
524 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
527 struct fd_resource
*rsc
= fd_resource(pfb
->zsbuf
->texture
);
528 uint32_t gras_lrz_cntl
= zsa
->gras_lrz_cntl
;
530 if (emit
->no_lrz_write
|| !rsc
->lrz
|| !rsc
->lrz_valid
)
532 else if (emit
->key
.binning_pass
&& blend
->lrz_write
&& zsa
->lrz_write
)
533 gras_lrz_cntl
|= A5XX_GRAS_LRZ_CNTL_LRZ_WRITE
;
535 OUT_PKT4(ring
, REG_A5XX_GRAS_LRZ_CNTL
, 1);
536 OUT_RING(ring
, gras_lrz_cntl
);
540 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_STENCIL_REF
)) {
541 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
542 struct pipe_stencil_ref
*sr
= &ctx
->stencil_ref
;
544 OUT_PKT4(ring
, REG_A5XX_RB_STENCILREFMASK
, 2);
545 OUT_RING(ring
, zsa
->rb_stencilrefmask
|
546 A5XX_RB_STENCILREFMASK_STENCILREF(sr
->ref_value
[0]));
547 OUT_RING(ring
, zsa
->rb_stencilrefmask_bf
|
548 A5XX_RB_STENCILREFMASK_BF_STENCILREF(sr
->ref_value
[1]));
551 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
552 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
553 bool fragz
= fp
->has_kill
| fp
->writes_pos
;
555 OUT_PKT4(ring
, REG_A5XX_RB_DEPTH_CNTL
, 1);
556 OUT_RING(ring
, zsa
->rb_depth_cntl
);
558 OUT_PKT4(ring
, REG_A5XX_RB_DEPTH_PLANE_CNTL
, 1);
559 OUT_RING(ring
, COND(fragz
, A5XX_RB_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
) |
560 COND(fragz
&& fp
->frag_coord
, A5XX_RB_DEPTH_PLANE_CNTL_UNK1
));
562 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_DEPTH_PLANE_CNTL
, 1);
563 OUT_RING(ring
, COND(fragz
, A5XX_GRAS_SU_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
) |
564 COND(fragz
&& fp
->frag_coord
, A5XX_GRAS_SU_DEPTH_PLANE_CNTL_UNK1
));
567 if (dirty
& FD_DIRTY_SCISSOR
) {
568 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
570 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0
, 2);
571 OUT_RING(ring
, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->minx
) |
572 A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->miny
));
573 OUT_RING(ring
, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
574 A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
576 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0
, 2);
577 OUT_RING(ring
, A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->minx
) |
578 A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->miny
));
579 OUT_RING(ring
, A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
580 A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
582 ctx
->batch
->max_scissor
.minx
= MIN2(ctx
->batch
->max_scissor
.minx
, scissor
->minx
);
583 ctx
->batch
->max_scissor
.miny
= MIN2(ctx
->batch
->max_scissor
.miny
, scissor
->miny
);
584 ctx
->batch
->max_scissor
.maxx
= MAX2(ctx
->batch
->max_scissor
.maxx
, scissor
->maxx
);
585 ctx
->batch
->max_scissor
.maxy
= MAX2(ctx
->batch
->max_scissor
.maxy
, scissor
->maxy
);
588 if (dirty
& FD_DIRTY_VIEWPORT
) {
589 fd_wfi(ctx
->batch
, ring
);
590 OUT_PKT4(ring
, REG_A5XX_GRAS_CL_VPORT_XOFFSET_0
, 6);
591 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_XOFFSET_0(ctx
->viewport
.translate
[0]));
592 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_XSCALE_0(ctx
->viewport
.scale
[0]));
593 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_YOFFSET_0(ctx
->viewport
.translate
[1]));
594 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_YSCALE_0(ctx
->viewport
.scale
[1]));
595 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_ZOFFSET_0(ctx
->viewport
.translate
[2]));
596 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_ZSCALE_0(ctx
->viewport
.scale
[2]));
599 if (dirty
& FD_DIRTY_PROG
)
600 fd5_program_emit(ctx
, ring
, emit
);
602 if (dirty
& FD_DIRTY_RASTERIZER
) {
603 struct fd5_rasterizer_stateobj
*rasterizer
=
604 fd5_rasterizer_stateobj(ctx
->rasterizer
);
606 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CNTL
, 1);
607 OUT_RING(ring
, rasterizer
->gras_su_cntl
);
609 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POINT_MINMAX
, 2);
610 OUT_RING(ring
, rasterizer
->gras_su_point_minmax
);
611 OUT_RING(ring
, rasterizer
->gras_su_point_size
);
613 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POLY_OFFSET_SCALE
, 3);
614 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_scale
);
615 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_offset
);
616 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_clamp
);
618 OUT_PKT4(ring
, REG_A5XX_PC_RASTER_CNTL
, 1);
619 OUT_RING(ring
, rasterizer
->pc_raster_cntl
);
621 OUT_PKT4(ring
, REG_A5XX_GRAS_CL_CNTL
, 1);
622 OUT_RING(ring
, rasterizer
->gras_cl_clip_cntl
);
625 /* note: must come after program emit.. because there is some overlap
626 * in registers, ex. PC_PRIMITIVE_CNTL and we rely on some cached
627 * values from fd5_program_emit() to avoid having to re-emit the prog
628 * every time rast state changes.
630 * Since the primitive restart state is not part of a tracked object, we
631 * re-emit this register every time.
633 if (emit
->info
&& ctx
->rasterizer
) {
634 struct fd5_rasterizer_stateobj
*rasterizer
=
635 fd5_rasterizer_stateobj(ctx
->rasterizer
);
636 unsigned max_loc
= fd5_context(ctx
)->max_loc
;
638 OUT_PKT4(ring
, REG_A5XX_PC_PRIMITIVE_CNTL
, 1);
639 OUT_RING(ring
, rasterizer
->pc_primitive_cntl
|
640 A5XX_PC_PRIMITIVE_CNTL_STRIDE_IN_VPC(max_loc
) |
641 COND(emit
->info
->primitive_restart
&& emit
->info
->index_size
,
642 A5XX_PC_PRIMITIVE_CNTL_PRIMITIVE_RESTART
));
645 if (dirty
& (FD_DIRTY_FRAMEBUFFER
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
646 uint32_t posz_regid
= ir3_find_output_regid(fp
, FRAG_RESULT_DEPTH
);
647 unsigned nr
= pfb
->nr_cbufs
;
649 if (emit
->key
.binning_pass
)
651 else if (ctx
->rasterizer
->rasterizer_discard
)
654 OUT_PKT4(ring
, REG_A5XX_RB_FS_OUTPUT_CNTL
, 1);
655 OUT_RING(ring
, A5XX_RB_FS_OUTPUT_CNTL_MRT(nr
) |
656 COND(fp
->writes_pos
, A5XX_RB_FS_OUTPUT_CNTL_FRAG_WRITES_Z
));
658 OUT_PKT4(ring
, REG_A5XX_SP_FS_OUTPUT_CNTL
, 1);
659 OUT_RING(ring
, A5XX_SP_FS_OUTPUT_CNTL_MRT(nr
) |
660 A5XX_SP_FS_OUTPUT_CNTL_DEPTH_REGID(posz_regid
) |
661 A5XX_SP_FS_OUTPUT_CNTL_SAMPLEMASK_REGID(regid(63, 0)));
664 if (emit
->prog
== &ctx
->prog
) { /* evil hack to deal sanely with clear path */
665 ir3_emit_vs_consts(vp
, ring
, ctx
, emit
->info
);
666 if (!emit
->key
.binning_pass
)
667 ir3_emit_fs_consts(fp
, ring
, ctx
);
669 struct pipe_stream_output_info
*info
= &vp
->shader
->stream_output
;
670 if (info
->num_outputs
) {
671 struct fd_streamout_stateobj
*so
= &ctx
->streamout
;
673 for (unsigned i
= 0; i
< so
->num_targets
; i
++) {
674 struct pipe_stream_output_target
*target
= so
->targets
[i
];
679 unsigned offset
= (so
->offsets
[i
] * info
->stride
[i
] * 4) +
680 target
->buffer_offset
;
682 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(i
), 3);
683 /* VPC_SO[i].BUFFER_BASE_LO: */
684 OUT_RELOCW(ring
, fd_resource(target
->buffer
)->bo
, 0, 0, 0);
685 OUT_RING(ring
, target
->buffer_size
+ offset
);
687 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(i
), 3);
688 OUT_RING(ring
, offset
);
689 /* VPC_SO[i].FLUSH_BASE_LO/HI: */
690 // TODO just give hw a dummy addr for now.. we should
691 // be using this an then CP_MEM_TO_REG to set the
692 // VPC_SO[i].BUFFER_OFFSET for the next draw..
693 OUT_RELOCW(ring
, fd5_context(ctx
)->blit_mem
, 0x100, 0, 0);
695 emit
->streamout_mask
|= (1 << i
);
700 if ((dirty
& FD_DIRTY_BLEND
)) {
701 struct fd5_blend_stateobj
*blend
= fd5_blend_stateobj(ctx
->blend
);
704 for (i
= 0; i
< A5XX_MAX_RENDER_TARGETS
; i
++) {
705 enum pipe_format format
= pipe_surface_format(pfb
->cbufs
[i
]);
706 bool is_int
= util_format_is_pure_integer(format
);
707 bool has_alpha
= util_format_has_alpha(format
);
708 uint32_t control
= blend
->rb_mrt
[i
].control
;
709 uint32_t blend_control
= blend
->rb_mrt
[i
].blend_control_alpha
;
712 control
&= A5XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK
;
713 control
|= A5XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY
);
717 blend_control
|= blend
->rb_mrt
[i
].blend_control_rgb
;
719 blend_control
|= blend
->rb_mrt
[i
].blend_control_no_alpha_rgb
;
720 control
&= ~A5XX_RB_MRT_CONTROL_BLEND2
;
723 OUT_PKT4(ring
, REG_A5XX_RB_MRT_CONTROL(i
), 1);
724 OUT_RING(ring
, control
);
726 OUT_PKT4(ring
, REG_A5XX_RB_MRT_BLEND_CONTROL(i
), 1);
727 OUT_RING(ring
, blend_control
);
730 OUT_PKT4(ring
, REG_A5XX_RB_BLEND_CNTL
, 1);
731 OUT_RING(ring
, blend
->rb_blend_cntl
|
732 A5XX_RB_BLEND_CNTL_SAMPLE_MASK(0xffff));
734 OUT_PKT4(ring
, REG_A5XX_SP_BLEND_CNTL
, 1);
735 OUT_RING(ring
, blend
->sp_blend_cntl
);
738 if (dirty
& FD_DIRTY_BLEND_COLOR
) {
739 struct pipe_blend_color
*bcolor
= &ctx
->blend_color
;
741 OUT_PKT4(ring
, REG_A5XX_RB_BLEND_RED
, 8);
742 OUT_RING(ring
, A5XX_RB_BLEND_RED_FLOAT(bcolor
->color
[0]) |
743 A5XX_RB_BLEND_RED_UINT(bcolor
->color
[0] * 0xff) |
744 A5XX_RB_BLEND_RED_SINT(bcolor
->color
[0] * 0x7f));
745 OUT_RING(ring
, A5XX_RB_BLEND_RED_F32(bcolor
->color
[0]));
746 OUT_RING(ring
, A5XX_RB_BLEND_GREEN_FLOAT(bcolor
->color
[1]) |
747 A5XX_RB_BLEND_GREEN_UINT(bcolor
->color
[1] * 0xff) |
748 A5XX_RB_BLEND_GREEN_SINT(bcolor
->color
[1] * 0x7f));
749 OUT_RING(ring
, A5XX_RB_BLEND_RED_F32(bcolor
->color
[1]));
750 OUT_RING(ring
, A5XX_RB_BLEND_BLUE_FLOAT(bcolor
->color
[2]) |
751 A5XX_RB_BLEND_BLUE_UINT(bcolor
->color
[2] * 0xff) |
752 A5XX_RB_BLEND_BLUE_SINT(bcolor
->color
[2] * 0x7f));
753 OUT_RING(ring
, A5XX_RB_BLEND_BLUE_F32(bcolor
->color
[2]));
754 OUT_RING(ring
, A5XX_RB_BLEND_ALPHA_FLOAT(bcolor
->color
[3]) |
755 A5XX_RB_BLEND_ALPHA_UINT(bcolor
->color
[3] * 0xff) |
756 A5XX_RB_BLEND_ALPHA_SINT(bcolor
->color
[3] * 0x7f));
757 OUT_RING(ring
, A5XX_RB_BLEND_ALPHA_F32(bcolor
->color
[3]));
760 if (ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] & FD_DIRTY_SHADER_TEX
) {
761 needs_border
|= emit_textures(ctx
, ring
, SB4_VS_TEX
,
762 &ctx
->tex
[PIPE_SHADER_VERTEX
]);
763 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 1);
764 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_VERTEX
].num_textures
);
767 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_TEX
) {
768 needs_border
|= emit_textures(ctx
, ring
, SB4_FS_TEX
,
769 &ctx
->tex
[PIPE_SHADER_FRAGMENT
]);
770 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 1);
771 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_FRAGMENT
].num_textures
);
774 OUT_PKT4(ring
, REG_A5XX_TPL1_CS_TEX_COUNT
, 1);
778 emit_border_color(ctx
, ring
);
780 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_SSBO
)
781 emit_ssbos(ctx
, ring
, SB4_SSBO
, &ctx
->shaderbuf
[PIPE_SHADER_FRAGMENT
]);
785 fd5_emit_cs_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
786 struct ir3_shader_variant
*cp
)
788 enum fd_dirty_shader_state dirty
= ctx
->dirty_shader
[PIPE_SHADER_COMPUTE
];
790 if (dirty
& FD_DIRTY_SHADER_TEX
) {
791 bool needs_border
= false;
792 needs_border
|= emit_textures(ctx
, ring
, SB4_CS_TEX
,
793 &ctx
->tex
[PIPE_SHADER_COMPUTE
]);
796 emit_border_color(ctx
, ring
);
798 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 1);
801 OUT_PKT4(ring
, REG_A5XX_TPL1_HS_TEX_COUNT
, 1);
804 OUT_PKT4(ring
, REG_A5XX_TPL1_DS_TEX_COUNT
, 1);
807 OUT_PKT4(ring
, REG_A5XX_TPL1_GS_TEX_COUNT
, 1);
810 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 1);
813 OUT_PKT4(ring
, REG_A5XX_TPL1_CS_TEX_COUNT
, 1);
814 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_COMPUTE
].num_textures
);
817 if (dirty
& FD_DIRTY_SHADER_SSBO
)
818 emit_ssbos(ctx
, ring
, SB4_CS_SSBO
, &ctx
->shaderbuf
[PIPE_SHADER_COMPUTE
]);
821 /* emit setup at begin of new cmdstream buffer (don't rely on previous
822 * state, there could have been a context switch between ioctls):
825 fd5_emit_restore(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
)
827 struct fd_context
*ctx
= batch
->ctx
;
829 fd5_set_render_mode(ctx
, ring
, BYPASS
);
830 fd5_cache_flush(batch
, ring
);
832 OUT_PKT4(ring
, REG_A5XX_HLSQ_UPDATE_CNTL
, 1);
833 OUT_RING(ring
, 0xfffff);
836 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
837 0000000500024048: 70d08003 00000000 001c5000 00000005
838 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
839 0000000500024058: 70d08003 00000010 001c7000 00000005
841 t7 opcode: CP_WAIT_FOR_IDLE (26) (1 dwords)
842 0000000500024068: 70268000
845 OUT_PKT4(ring
, REG_A5XX_PC_RESTART_INDEX
, 1);
846 OUT_RING(ring
, 0xffffffff);
848 OUT_PKT4(ring
, REG_A5XX_PC_RASTER_CNTL
, 1);
849 OUT_RING(ring
, 0x00000012);
851 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POINT_MINMAX
, 2);
852 OUT_RING(ring
, A5XX_GRAS_SU_POINT_MINMAX_MIN(1.0) |
853 A5XX_GRAS_SU_POINT_MINMAX_MAX(4092.0));
854 OUT_RING(ring
, A5XX_GRAS_SU_POINT_SIZE(0.5));
856 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL
, 1);
857 OUT_RING(ring
, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */
859 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_CNTL
, 1);
860 OUT_RING(ring
, 0x00000000); /* GRAS_SC_SCREEN_SCISSOR_CNTL */
862 OUT_PKT4(ring
, REG_A5XX_SP_VS_CONFIG_MAX_CONST
, 1);
863 OUT_RING(ring
, 0); /* SP_VS_CONFIG_MAX_CONST */
865 OUT_PKT4(ring
, REG_A5XX_SP_FS_CONFIG_MAX_CONST
, 1);
866 OUT_RING(ring
, 0); /* SP_FS_CONFIG_MAX_CONST */
868 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E292
, 2);
869 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E292 */
870 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E293 */
872 OUT_PKT4(ring
, REG_A5XX_RB_MODE_CNTL
, 1);
873 OUT_RING(ring
, 0x00000044); /* RB_MODE_CNTL */
875 OUT_PKT4(ring
, REG_A5XX_RB_DBG_ECO_CNTL
, 1);
876 OUT_RING(ring
, 0x00100000); /* RB_DBG_ECO_CNTL */
878 OUT_PKT4(ring
, REG_A5XX_VFD_MODE_CNTL
, 1);
879 OUT_RING(ring
, 0x00000000); /* VFD_MODE_CNTL */
881 OUT_PKT4(ring
, REG_A5XX_PC_MODE_CNTL
, 1);
882 OUT_RING(ring
, 0x0000001f); /* PC_MODE_CNTL */
884 OUT_PKT4(ring
, REG_A5XX_SP_MODE_CNTL
, 1);
885 OUT_RING(ring
, 0x0000001e); /* SP_MODE_CNTL */
887 OUT_PKT4(ring
, REG_A5XX_SP_DBG_ECO_CNTL
, 1);
888 OUT_RING(ring
, 0x40000800); /* SP_DBG_ECO_CNTL */
890 OUT_PKT4(ring
, REG_A5XX_TPL1_MODE_CNTL
, 1);
891 OUT_RING(ring
, 0x00000544); /* TPL1_MODE_CNTL */
893 OUT_PKT4(ring
, REG_A5XX_HLSQ_TIMEOUT_THRESHOLD_0
, 2);
894 OUT_RING(ring
, 0x00000080); /* HLSQ_TIMEOUT_THRESHOLD_0 */
895 OUT_RING(ring
, 0x00000000); /* HLSQ_TIMEOUT_THRESHOLD_1 */
897 OUT_PKT4(ring
, REG_A5XX_VPC_DBG_ECO_CNTL
, 1);
898 OUT_RING(ring
, 0x00000400); /* VPC_DBG_ECO_CNTL */
900 OUT_PKT4(ring
, REG_A5XX_HLSQ_MODE_CNTL
, 1);
901 OUT_RING(ring
, 0x00000001); /* HLSQ_MODE_CNTL */
903 OUT_PKT4(ring
, REG_A5XX_VPC_MODE_CNTL
, 1);
904 OUT_RING(ring
, 0x00000000); /* VPC_MODE_CNTL */
906 /* we don't use this yet.. probably best to disable.. */
907 OUT_PKT7(ring
, CP_SET_DRAW_STATE
, 3);
908 OUT_RING(ring
, CP_SET_DRAW_STATE__0_COUNT(0) |
909 CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS
|
910 CP_SET_DRAW_STATE__0_GROUP_ID(0));
911 OUT_RING(ring
, CP_SET_DRAW_STATE__1_ADDR_LO(0));
912 OUT_RING(ring
, CP_SET_DRAW_STATE__2_ADDR_HI(0));
914 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL
, 1);
915 OUT_RING(ring
, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */
917 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_BIN_CNTL
, 1);
918 OUT_RING(ring
, 0x00000000); /* GRAS_SC_BIN_CNTL */
920 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_BIN_CNTL
, 1);
921 OUT_RING(ring
, 0x00000000); /* GRAS_SC_BIN_CNTL */
923 OUT_PKT4(ring
, REG_A5XX_VPC_FS_PRIMITIVEID_CNTL
, 1);
924 OUT_RING(ring
, 0x000000ff); /* VPC_FS_PRIMITIVEID_CNTL */
926 OUT_PKT4(ring
, REG_A5XX_VPC_SO_OVERRIDE
, 1);
927 OUT_RING(ring
, A5XX_VPC_SO_OVERRIDE_SO_DISABLE
);
929 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(0), 3);
930 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_LO_0 */
931 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_HI_0 */
932 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_SIZE_0 */
934 OUT_PKT4(ring
, REG_A5XX_VPC_SO_FLUSH_BASE_LO(0), 2);
935 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_LO_0 */
936 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_HI_0 */
938 OUT_PKT4(ring
, REG_A5XX_PC_GS_PARAM
, 1);
939 OUT_RING(ring
, 0x00000000); /* PC_GS_PARAM */
941 OUT_PKT4(ring
, REG_A5XX_PC_HS_PARAM
, 1);
942 OUT_RING(ring
, 0x00000000); /* PC_HS_PARAM */
944 OUT_PKT4(ring
, REG_A5XX_TPL1_TP_FS_ROTATION_CNTL
, 1);
945 OUT_RING(ring
, 0x00000000); /* TPL1_TP_FS_ROTATION_CNTL */
947 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E001
, 1);
948 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E001 */
950 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E004
, 1);
951 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E004 */
953 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E093
, 1);
954 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E093 */
956 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E29A
, 1);
957 OUT_RING(ring
, 0x00ffff00); /* UNKNOWN_E29A */
959 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUF_CNTL
, 1);
960 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUF_CNTL */
962 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(0), 1);
963 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E2AB */
965 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E389
, 1);
966 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E389 */
968 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E38D
, 1);
969 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E38D */
971 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5AB
, 1);
972 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E5AB */
974 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5C2
, 1);
975 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E5C2 */
977 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(1), 3);
978 OUT_RING(ring
, 0x00000000);
979 OUT_RING(ring
, 0x00000000);
980 OUT_RING(ring
, 0x00000000);
982 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(1), 6);
983 OUT_RING(ring
, 0x00000000);
984 OUT_RING(ring
, 0x00000000);
985 OUT_RING(ring
, 0x00000000);
986 OUT_RING(ring
, 0x00000000);
987 OUT_RING(ring
, 0x00000000);
988 OUT_RING(ring
, 0x00000000);
990 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(2), 6);
991 OUT_RING(ring
, 0x00000000);
992 OUT_RING(ring
, 0x00000000);
993 OUT_RING(ring
, 0x00000000);
994 OUT_RING(ring
, 0x00000000);
995 OUT_RING(ring
, 0x00000000);
996 OUT_RING(ring
, 0x00000000);
998 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(3), 3);
999 OUT_RING(ring
, 0x00000000);
1000 OUT_RING(ring
, 0x00000000);
1001 OUT_RING(ring
, 0x00000000);
1003 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5DB
, 1);
1004 OUT_RING(ring
, 0x00000000);
1006 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E600
, 1);
1007 OUT_RING(ring
, 0x00000000);
1009 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E640
, 1);
1010 OUT_RING(ring
, 0x00000000);
1012 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 4);
1013 OUT_RING(ring
, 0x00000000);
1014 OUT_RING(ring
, 0x00000000);
1015 OUT_RING(ring
, 0x00000000);
1016 OUT_RING(ring
, 0x00000000);
1018 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 2);
1019 OUT_RING(ring
, 0x00000000);
1020 OUT_RING(ring
, 0x00000000);
1022 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7C0
, 3);
1023 OUT_RING(ring
, 0x00000000);
1024 OUT_RING(ring
, 0x00000000);
1025 OUT_RING(ring
, 0x00000000);
1027 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7C5
, 3);
1028 OUT_RING(ring
, 0x00000000);
1029 OUT_RING(ring
, 0x00000000);
1030 OUT_RING(ring
, 0x00000000);
1032 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7CA
, 3);
1033 OUT_RING(ring
, 0x00000000);
1034 OUT_RING(ring
, 0x00000000);
1035 OUT_RING(ring
, 0x00000000);
1037 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7CF
, 3);
1038 OUT_RING(ring
, 0x00000000);
1039 OUT_RING(ring
, 0x00000000);
1040 OUT_RING(ring
, 0x00000000);
1042 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7D4
, 3);
1043 OUT_RING(ring
, 0x00000000);
1044 OUT_RING(ring
, 0x00000000);
1045 OUT_RING(ring
, 0x00000000);
1047 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7D9
, 3);
1048 OUT_RING(ring
, 0x00000000);
1049 OUT_RING(ring
, 0x00000000);
1050 OUT_RING(ring
, 0x00000000);
1052 OUT_PKT4(ring
, REG_A5XX_RB_CLEAR_CNTL
, 1);
1053 OUT_RING(ring
, 0x00000000);
1057 fd5_emit_ib(struct fd_ringbuffer
*ring
, struct fd_ringbuffer
*target
)
1059 __OUT_IB5(ring
, target
);
1063 fd5_emit_init(struct pipe_context
*pctx
)
1065 struct fd_context
*ctx
= fd_context(pctx
);
1066 ctx
->emit_const
= fd5_emit_const
;
1067 ctx
->emit_const_bo
= fd5_emit_const_bo
;
1068 ctx
->emit_ib
= fd5_emit_ib
;