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_image.h"
41 #include "fd5_program.h"
42 #include "fd5_rasterizer.h"
43 #include "fd5_texture.h"
44 #include "fd5_format.h"
47 /* regid: base const register
48 * prsc or dwords: buffer containing constant values
49 * sizedwords: size of const value buffer
52 fd5_emit_const(struct fd_ringbuffer
*ring
, enum shader_t type
,
53 uint32_t regid
, uint32_t offset
, uint32_t sizedwords
,
54 const uint32_t *dwords
, struct pipe_resource
*prsc
)
57 enum a4xx_state_src src
;
59 debug_assert((regid
% 4) == 0);
60 debug_assert((sizedwords
% 4) == 0);
70 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + sz
);
71 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
72 CP_LOAD_STATE4_0_STATE_SRC(src
) |
73 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type
)) |
74 CP_LOAD_STATE4_0_NUM_UNIT(sizedwords
/4));
76 struct fd_bo
*bo
= fd_resource(prsc
)->bo
;
77 OUT_RELOC(ring
, bo
, offset
,
78 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
), 0);
80 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
81 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
82 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
83 dwords
= (uint32_t *)&((uint8_t *)dwords
)[offset
];
85 for (i
= 0; i
< sz
; i
++) {
86 OUT_RING(ring
, dwords
[i
]);
91 fd5_emit_const_bo(struct fd_ringbuffer
*ring
, enum shader_t type
, boolean write
,
92 uint32_t regid
, uint32_t num
, struct pipe_resource
**prscs
, uint32_t *offsets
)
94 uint32_t anum
= align(num
, 2);
97 debug_assert((regid
% 4) == 0);
99 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * anum
));
100 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(regid
/4) |
101 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
102 CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type
)) |
103 CP_LOAD_STATE4_0_NUM_UNIT(anum
/2));
104 OUT_RING(ring
, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) |
105 CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
));
106 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
108 for (i
= 0; i
< num
; i
++) {
111 OUT_RELOCW(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
113 OUT_RELOC(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
116 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
117 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
121 for (; i
< anum
; i
++) {
122 OUT_RING(ring
, 0xffffffff);
123 OUT_RING(ring
, 0xffffffff);
127 /* Border color layout is diff from a4xx/a5xx.. if it turns out to be
128 * the same as a6xx then move this somewhere common ;-)
130 * Entry layout looks like (total size, 0x60 bytes):
133 struct PACKED bcolor_entry
{
145 uint32_t z24
; /* also s8? */
149 #define FD5_BORDER_COLOR_SIZE 0x60
150 #define FD5_BORDER_COLOR_UPLOAD_SIZE (2 * PIPE_MAX_SAMPLERS * FD5_BORDER_COLOR_SIZE)
153 setup_border_colors(struct fd_texture_stateobj
*tex
, struct bcolor_entry
*entries
)
156 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD5_BORDER_COLOR_SIZE
);
158 for (i
= 0; i
< tex
->num_samplers
; i
++) {
159 struct bcolor_entry
*e
= &entries
[i
];
160 struct pipe_sampler_state
*sampler
= tex
->samplers
[i
];
161 union pipe_color_union
*bc
;
166 bc
= &sampler
->border_color
;
171 * The border colors need to be swizzled in a particular
172 * format-dependent order. Even though samplers don't know about
173 * formats, we can assume that with a GL state tracker, there's a
174 * 1:1 correspondence between sampler and texture. Take advantage
177 if ((i
>= tex
->num_textures
) || !tex
->textures
[i
])
180 const struct util_format_description
*desc
=
181 util_format_description(tex
->textures
[i
]->format
);
189 for (j
= 0; j
< 4; j
++) {
190 int c
= desc
->swizzle
[j
];
195 if (desc
->channel
[c
].pure_integer
) {
197 switch (desc
->channel
[c
].size
) {
199 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
200 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3);
203 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
204 clamped
= CLAMP(bc
->i
[j
], -128, 127);
206 clamped
= CLAMP(bc
->ui
[j
], 0, 255);
209 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
210 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3ff);
213 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
214 clamped
= CLAMP(bc
->i
[j
], -32768, 32767);
216 clamped
= CLAMP(bc
->ui
[j
], 0, 65535);
219 assert(!"Unexpected bit size");
224 e
->fp32
[c
] = bc
->ui
[j
];
225 e
->fp16
[c
] = clamped
;
228 float f_u
= CLAMP(f
, 0, 1);
229 float f_s
= CLAMP(f
, -1, 1);
232 e
->fp16
[c
] = util_float_to_half(f
);
233 e
->ui16
[c
] = f_u
* 0xffff;
234 e
->si16
[c
] = f_s
* 0x7fff;
235 e
->ui8
[c
] = f_u
* 0xff;
236 e
->si8
[c
] = f_s
* 0x7f;
238 e
->rgb565
|= (int)(f_u
* 0x3f) << 5;
240 e
->rgb565
|= (int)(f_u
* 0x1f) << (c
? 11 : 0);
242 e
->rgb5a1
|= (f_u
> 0.5) ? 0x8000 : 0;
244 e
->rgb5a1
|= (int)(f_u
* 0x1f) << (c
* 5);
246 e
->rgb10a2
|= (int)(f_u
* 0x3) << 30;
248 e
->rgb10a2
|= (int)(f_u
* 0x3ff) << (c
* 10);
249 e
->rgba4
|= (int)(f_u
* 0xf) << (c
* 4);
251 e
->z24
= f_u
* 0xffffff;
256 memset(&e
->__pad0
, 0, sizeof(e
->__pad0
));
257 memset(&e
->__pad1
, 0, sizeof(e
->__pad1
));
263 emit_border_color(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
)
265 struct fd5_context
*fd5_ctx
= fd5_context(ctx
);
266 struct bcolor_entry
*entries
;
270 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD5_BORDER_COLOR_SIZE
);
272 u_upload_alloc(fd5_ctx
->border_color_uploader
,
273 0, FD5_BORDER_COLOR_UPLOAD_SIZE
,
274 FD5_BORDER_COLOR_UPLOAD_SIZE
, &off
,
275 &fd5_ctx
->border_color_buf
,
280 setup_border_colors(&ctx
->tex
[PIPE_SHADER_VERTEX
], &entries
[0]);
281 setup_border_colors(&ctx
->tex
[PIPE_SHADER_FRAGMENT
],
282 &entries
[ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
]);
284 OUT_PKT4(ring
, REG_A5XX_TPL1_TP_BORDER_COLOR_BASE_ADDR_LO
, 2);
285 OUT_RELOC(ring
, fd_resource(fd5_ctx
->border_color_buf
)->bo
, off
, 0, 0);
287 u_upload_unmap(fd5_ctx
->border_color_uploader
);
291 emit_textures(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
292 enum a4xx_state_block sb
, struct fd_texture_stateobj
*tex
)
294 bool needs_border
= false;
295 unsigned bcolor_offset
= (sb
== SB4_FS_TEX
) ? ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
: 0;
298 if (tex
->num_samplers
> 0) {
299 /* output sampler state: */
300 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (4 * tex
->num_samplers
));
301 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
302 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
303 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
304 CP_LOAD_STATE4_0_NUM_UNIT(tex
->num_samplers
));
305 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_SHADER
) |
306 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
307 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
308 for (i
= 0; i
< tex
->num_samplers
; i
++) {
309 static const struct fd5_sampler_stateobj dummy_sampler
= {};
310 const struct fd5_sampler_stateobj
*sampler
= tex
->samplers
[i
] ?
311 fd5_sampler_stateobj(tex
->samplers
[i
]) :
313 OUT_RING(ring
, sampler
->texsamp0
);
314 OUT_RING(ring
, sampler
->texsamp1
);
315 OUT_RING(ring
, sampler
->texsamp2
|
316 A5XX_TEX_SAMP_2_BCOLOR_OFFSET(bcolor_offset
));
317 OUT_RING(ring
, sampler
->texsamp3
);
319 needs_border
|= sampler
->needs_border
;
323 if (tex
->num_textures
> 0) {
324 unsigned num_textures
= tex
->num_textures
;
326 /* emit texture state: */
327 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (12 * num_textures
));
328 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
329 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
330 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
331 CP_LOAD_STATE4_0_NUM_UNIT(num_textures
));
332 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS
) |
333 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
334 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
335 for (i
= 0; i
< tex
->num_textures
; i
++) {
336 static const struct fd5_pipe_sampler_view dummy_view
= {};
337 const struct fd5_pipe_sampler_view
*view
= tex
->textures
[i
] ?
338 fd5_pipe_sampler_view(tex
->textures
[i
]) :
341 OUT_RING(ring
, view
->texconst0
);
342 OUT_RING(ring
, view
->texconst1
);
343 OUT_RING(ring
, view
->texconst2
);
344 OUT_RING(ring
, view
->texconst3
);
345 if (view
->base
.texture
) {
346 struct fd_resource
*rsc
= fd_resource(view
->base
.texture
);
347 OUT_RELOC(ring
, rsc
->bo
, view
->offset
,
348 (uint64_t)view
->texconst5
<< 32, 0);
350 OUT_RING(ring
, 0x00000000);
351 OUT_RING(ring
, view
->texconst5
);
353 OUT_RING(ring
, view
->texconst6
);
354 OUT_RING(ring
, view
->texconst7
);
355 OUT_RING(ring
, view
->texconst8
);
356 OUT_RING(ring
, view
->texconst9
);
357 OUT_RING(ring
, view
->texconst10
);
358 OUT_RING(ring
, view
->texconst11
);
366 emit_ssbos(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
367 enum a4xx_state_block sb
, struct fd_shaderbuf_stateobj
*so
)
369 unsigned count
= util_last_bit(so
->enabled_mask
);
374 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (4 * count
));
375 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
376 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
377 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
378 CP_LOAD_STATE4_0_NUM_UNIT(count
));
379 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(0) |
380 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
381 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
382 for (unsigned i
= 0; i
< count
; i
++) {
383 OUT_RING(ring
, 0x00000000);
384 OUT_RING(ring
, 0x00000000);
385 OUT_RING(ring
, 0x00000000);
386 OUT_RING(ring
, 0x00000000);
389 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * count
));
390 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
391 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
392 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
393 CP_LOAD_STATE4_0_NUM_UNIT(count
));
394 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(1) |
395 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
396 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
397 for (unsigned i
= 0; i
< count
; i
++) {
398 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
399 unsigned sz
= buf
->buffer_size
;
401 /* width is in dwords, overflows into height: */
404 OUT_RING(ring
, A5XX_SSBO_1_0_WIDTH(sz
));
405 OUT_RING(ring
, A5XX_SSBO_1_1_HEIGHT(sz
>> 16));
408 OUT_PKT7(ring
, CP_LOAD_STATE4
, 3 + (2 * count
));
409 OUT_RING(ring
, CP_LOAD_STATE4_0_DST_OFF(0) |
410 CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT
) |
411 CP_LOAD_STATE4_0_STATE_BLOCK(sb
) |
412 CP_LOAD_STATE4_0_NUM_UNIT(count
));
413 OUT_RING(ring
, CP_LOAD_STATE4_1_STATE_TYPE(2) |
414 CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
415 OUT_RING(ring
, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0));
416 for (unsigned i
= 0; i
< count
; i
++) {
417 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
419 struct fd_resource
*rsc
= fd_resource(buf
->buffer
);
420 OUT_RELOCW(ring
, rsc
->bo
, buf
->buffer_offset
, 0, 0);
422 OUT_RING(ring
, 0x00000000);
423 OUT_RING(ring
, 0x00000000);
429 fd5_emit_vertex_bufs(struct fd_ringbuffer
*ring
, struct fd5_emit
*emit
)
432 const struct fd_vertex_state
*vtx
= emit
->vtx
;
433 const struct ir3_shader_variant
*vp
= fd5_emit_get_vp(emit
);
435 for (i
= 0, j
= 0; i
<= vp
->inputs_count
; i
++) {
436 if (vp
->inputs
[i
].sysval
)
438 if (vp
->inputs
[i
].compmask
) {
439 struct pipe_vertex_element
*elem
= &vtx
->vtx
->pipe
[i
];
440 const struct pipe_vertex_buffer
*vb
=
441 &vtx
->vertexbuf
.vb
[elem
->vertex_buffer_index
];
442 struct fd_resource
*rsc
= fd_resource(vb
->buffer
.resource
);
443 enum pipe_format pfmt
= elem
->src_format
;
444 enum a5xx_vtx_fmt fmt
= fd5_pipe2vtx(pfmt
);
445 bool isint
= util_format_is_pure_integer(pfmt
);
446 uint32_t off
= vb
->buffer_offset
+ elem
->src_offset
;
447 uint32_t size
= fd_bo_size(rsc
->bo
) - off
;
448 debug_assert(fmt
!= ~0);
450 OUT_PKT4(ring
, REG_A5XX_VFD_FETCH(j
), 4);
451 OUT_RELOC(ring
, rsc
->bo
, off
, 0, 0);
452 OUT_RING(ring
, size
); /* VFD_FETCH[j].SIZE */
453 OUT_RING(ring
, vb
->stride
); /* VFD_FETCH[j].STRIDE */
455 OUT_PKT4(ring
, REG_A5XX_VFD_DECODE(j
), 2);
456 OUT_RING(ring
, A5XX_VFD_DECODE_INSTR_IDX(j
) |
457 A5XX_VFD_DECODE_INSTR_FORMAT(fmt
) |
458 COND(elem
->instance_divisor
, A5XX_VFD_DECODE_INSTR_INSTANCED
) |
459 A5XX_VFD_DECODE_INSTR_SWAP(fd5_pipe2swap(pfmt
)) |
460 A5XX_VFD_DECODE_INSTR_UNK30
|
461 COND(!isint
, A5XX_VFD_DECODE_INSTR_FLOAT
));
462 OUT_RING(ring
, MAX2(1, elem
->instance_divisor
)); /* VFD_DECODE[j].STEP_RATE */
464 OUT_PKT4(ring
, REG_A5XX_VFD_DEST_CNTL(j
), 1);
465 OUT_RING(ring
, A5XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vp
->inputs
[i
].compmask
) |
466 A5XX_VFD_DEST_CNTL_INSTR_REGID(vp
->inputs
[i
].regid
));
472 OUT_PKT4(ring
, REG_A5XX_VFD_CONTROL_0
, 1);
473 OUT_RING(ring
, A5XX_VFD_CONTROL_0_VTXCNT(j
));
477 fd5_emit_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
478 struct fd5_emit
*emit
)
480 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
481 const struct ir3_shader_variant
*vp
= fd5_emit_get_vp(emit
);
482 const struct ir3_shader_variant
*fp
= fd5_emit_get_fp(emit
);
483 const enum fd_dirty_3d_state dirty
= emit
->dirty
;
484 bool needs_border
= false;
486 emit_marker5(ring
, 5);
488 if ((dirty
& FD_DIRTY_FRAMEBUFFER
) && !emit
->key
.binning_pass
) {
489 unsigned char mrt_comp
[A5XX_MAX_RENDER_TARGETS
] = {0};
491 for (unsigned i
= 0; i
< A5XX_MAX_RENDER_TARGETS
; i
++) {
492 mrt_comp
[i
] = ((i
< pfb
->nr_cbufs
) && pfb
->cbufs
[i
]) ? 0xf : 0;
495 OUT_PKT4(ring
, REG_A5XX_RB_RENDER_COMPONENTS
, 1);
496 OUT_RING(ring
, A5XX_RB_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
497 A5XX_RB_RENDER_COMPONENTS_RT1(mrt_comp
[1]) |
498 A5XX_RB_RENDER_COMPONENTS_RT2(mrt_comp
[2]) |
499 A5XX_RB_RENDER_COMPONENTS_RT3(mrt_comp
[3]) |
500 A5XX_RB_RENDER_COMPONENTS_RT4(mrt_comp
[4]) |
501 A5XX_RB_RENDER_COMPONENTS_RT5(mrt_comp
[5]) |
502 A5XX_RB_RENDER_COMPONENTS_RT6(mrt_comp
[6]) |
503 A5XX_RB_RENDER_COMPONENTS_RT7(mrt_comp
[7]));
506 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_FRAMEBUFFER
)) {
507 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
508 uint32_t rb_alpha_control
= zsa
->rb_alpha_control
;
510 if (util_format_is_pure_integer(pipe_surface_format(pfb
->cbufs
[0])))
511 rb_alpha_control
&= ~A5XX_RB_ALPHA_CONTROL_ALPHA_TEST
;
513 OUT_PKT4(ring
, REG_A5XX_RB_ALPHA_CONTROL
, 1);
514 OUT_RING(ring
, rb_alpha_control
);
516 OUT_PKT4(ring
, REG_A5XX_RB_STENCIL_CONTROL
, 1);
517 OUT_RING(ring
, zsa
->rb_stencil_control
);
520 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_BLEND
| FD_DIRTY_PROG
)) {
521 struct fd5_blend_stateobj
*blend
= fd5_blend_stateobj(ctx
->blend
);
522 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
525 struct fd_resource
*rsc
= fd_resource(pfb
->zsbuf
->texture
);
526 uint32_t gras_lrz_cntl
= zsa
->gras_lrz_cntl
;
528 if (emit
->no_lrz_write
|| !rsc
->lrz
|| !rsc
->lrz_valid
)
530 else if (emit
->key
.binning_pass
&& blend
->lrz_write
&& zsa
->lrz_write
)
531 gras_lrz_cntl
|= A5XX_GRAS_LRZ_CNTL_LRZ_WRITE
;
533 OUT_PKT4(ring
, REG_A5XX_GRAS_LRZ_CNTL
, 1);
534 OUT_RING(ring
, gras_lrz_cntl
);
538 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_STENCIL_REF
)) {
539 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
540 struct pipe_stencil_ref
*sr
= &ctx
->stencil_ref
;
542 OUT_PKT4(ring
, REG_A5XX_RB_STENCILREFMASK
, 2);
543 OUT_RING(ring
, zsa
->rb_stencilrefmask
|
544 A5XX_RB_STENCILREFMASK_STENCILREF(sr
->ref_value
[0]));
545 OUT_RING(ring
, zsa
->rb_stencilrefmask_bf
|
546 A5XX_RB_STENCILREFMASK_BF_STENCILREF(sr
->ref_value
[1]));
549 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
550 struct fd5_zsa_stateobj
*zsa
= fd5_zsa_stateobj(ctx
->zsa
);
551 bool fragz
= fp
->has_kill
| fp
->writes_pos
;
553 OUT_PKT4(ring
, REG_A5XX_RB_DEPTH_CNTL
, 1);
554 OUT_RING(ring
, zsa
->rb_depth_cntl
);
556 OUT_PKT4(ring
, REG_A5XX_RB_DEPTH_PLANE_CNTL
, 1);
557 OUT_RING(ring
, COND(fragz
, A5XX_RB_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
) |
558 COND(fragz
&& fp
->frag_coord
, A5XX_RB_DEPTH_PLANE_CNTL_UNK1
));
560 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_DEPTH_PLANE_CNTL
, 1);
561 OUT_RING(ring
, COND(fragz
, A5XX_GRAS_SU_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
) |
562 COND(fragz
&& fp
->frag_coord
, A5XX_GRAS_SU_DEPTH_PLANE_CNTL_UNK1
));
565 if (dirty
& FD_DIRTY_SCISSOR
) {
566 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
568 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0
, 2);
569 OUT_RING(ring
, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->minx
) |
570 A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->miny
));
571 OUT_RING(ring
, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
572 A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
574 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0
, 2);
575 OUT_RING(ring
, A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->minx
) |
576 A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->miny
));
577 OUT_RING(ring
, A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
578 A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
580 ctx
->batch
->max_scissor
.minx
= MIN2(ctx
->batch
->max_scissor
.minx
, scissor
->minx
);
581 ctx
->batch
->max_scissor
.miny
= MIN2(ctx
->batch
->max_scissor
.miny
, scissor
->miny
);
582 ctx
->batch
->max_scissor
.maxx
= MAX2(ctx
->batch
->max_scissor
.maxx
, scissor
->maxx
);
583 ctx
->batch
->max_scissor
.maxy
= MAX2(ctx
->batch
->max_scissor
.maxy
, scissor
->maxy
);
586 if (dirty
& FD_DIRTY_VIEWPORT
) {
587 fd_wfi(ctx
->batch
, ring
);
588 OUT_PKT4(ring
, REG_A5XX_GRAS_CL_VPORT_XOFFSET_0
, 6);
589 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_XOFFSET_0(ctx
->viewport
.translate
[0]));
590 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_XSCALE_0(ctx
->viewport
.scale
[0]));
591 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_YOFFSET_0(ctx
->viewport
.translate
[1]));
592 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_YSCALE_0(ctx
->viewport
.scale
[1]));
593 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_ZOFFSET_0(ctx
->viewport
.translate
[2]));
594 OUT_RING(ring
, A5XX_GRAS_CL_VPORT_ZSCALE_0(ctx
->viewport
.scale
[2]));
597 if (dirty
& FD_DIRTY_PROG
)
598 fd5_program_emit(ctx
, ring
, emit
);
600 if (dirty
& FD_DIRTY_RASTERIZER
) {
601 struct fd5_rasterizer_stateobj
*rasterizer
=
602 fd5_rasterizer_stateobj(ctx
->rasterizer
);
604 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CNTL
, 1);
605 OUT_RING(ring
, rasterizer
->gras_su_cntl
);
607 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POINT_MINMAX
, 2);
608 OUT_RING(ring
, rasterizer
->gras_su_point_minmax
);
609 OUT_RING(ring
, rasterizer
->gras_su_point_size
);
611 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POLY_OFFSET_SCALE
, 3);
612 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_scale
);
613 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_offset
);
614 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_clamp
);
616 OUT_PKT4(ring
, REG_A5XX_PC_RASTER_CNTL
, 1);
617 OUT_RING(ring
, rasterizer
->pc_raster_cntl
);
619 OUT_PKT4(ring
, REG_A5XX_GRAS_CL_CNTL
, 1);
620 OUT_RING(ring
, rasterizer
->gras_cl_clip_cntl
);
623 /* note: must come after program emit.. because there is some overlap
624 * in registers, ex. PC_PRIMITIVE_CNTL and we rely on some cached
625 * values from fd5_program_emit() to avoid having to re-emit the prog
626 * every time rast state changes.
628 * Since the primitive restart state is not part of a tracked object, we
629 * re-emit this register every time.
631 if (emit
->info
&& ctx
->rasterizer
) {
632 struct fd5_rasterizer_stateobj
*rasterizer
=
633 fd5_rasterizer_stateobj(ctx
->rasterizer
);
634 unsigned max_loc
= fd5_context(ctx
)->max_loc
;
636 OUT_PKT4(ring
, REG_A5XX_PC_PRIMITIVE_CNTL
, 1);
637 OUT_RING(ring
, rasterizer
->pc_primitive_cntl
|
638 A5XX_PC_PRIMITIVE_CNTL_STRIDE_IN_VPC(max_loc
) |
639 COND(emit
->info
->primitive_restart
&& emit
->info
->index_size
,
640 A5XX_PC_PRIMITIVE_CNTL_PRIMITIVE_RESTART
));
643 if (dirty
& (FD_DIRTY_FRAMEBUFFER
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
644 uint32_t posz_regid
= ir3_find_output_regid(fp
, FRAG_RESULT_DEPTH
);
645 unsigned nr
= pfb
->nr_cbufs
;
647 if (emit
->key
.binning_pass
)
649 else if (ctx
->rasterizer
->rasterizer_discard
)
652 OUT_PKT4(ring
, REG_A5XX_RB_FS_OUTPUT_CNTL
, 1);
653 OUT_RING(ring
, A5XX_RB_FS_OUTPUT_CNTL_MRT(nr
) |
654 COND(fp
->writes_pos
, A5XX_RB_FS_OUTPUT_CNTL_FRAG_WRITES_Z
));
656 OUT_PKT4(ring
, REG_A5XX_SP_FS_OUTPUT_CNTL
, 1);
657 OUT_RING(ring
, A5XX_SP_FS_OUTPUT_CNTL_MRT(nr
) |
658 A5XX_SP_FS_OUTPUT_CNTL_DEPTH_REGID(posz_regid
) |
659 A5XX_SP_FS_OUTPUT_CNTL_SAMPLEMASK_REGID(regid(63, 0)));
662 if (emit
->prog
== &ctx
->prog
) { /* evil hack to deal sanely with clear path */
663 ir3_emit_vs_consts(vp
, ring
, ctx
, emit
->info
);
664 if (!emit
->key
.binning_pass
)
665 ir3_emit_fs_consts(fp
, ring
, ctx
);
667 struct pipe_stream_output_info
*info
= &vp
->shader
->stream_output
;
668 if (info
->num_outputs
) {
669 struct fd_streamout_stateobj
*so
= &ctx
->streamout
;
671 for (unsigned i
= 0; i
< so
->num_targets
; i
++) {
672 struct pipe_stream_output_target
*target
= so
->targets
[i
];
677 unsigned offset
= (so
->offsets
[i
] * info
->stride
[i
] * 4) +
678 target
->buffer_offset
;
680 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(i
), 3);
681 /* VPC_SO[i].BUFFER_BASE_LO: */
682 OUT_RELOCW(ring
, fd_resource(target
->buffer
)->bo
, 0, 0, 0);
683 OUT_RING(ring
, target
->buffer_size
+ offset
);
685 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(i
), 3);
686 OUT_RING(ring
, offset
);
687 /* VPC_SO[i].FLUSH_BASE_LO/HI: */
688 // TODO just give hw a dummy addr for now.. we should
689 // be using this an then CP_MEM_TO_REG to set the
690 // VPC_SO[i].BUFFER_OFFSET for the next draw..
691 OUT_RELOCW(ring
, fd5_context(ctx
)->blit_mem
, 0x100, 0, 0);
693 emit
->streamout_mask
|= (1 << i
);
698 if ((dirty
& FD_DIRTY_BLEND
)) {
699 struct fd5_blend_stateobj
*blend
= fd5_blend_stateobj(ctx
->blend
);
702 for (i
= 0; i
< A5XX_MAX_RENDER_TARGETS
; i
++) {
703 enum pipe_format format
= pipe_surface_format(pfb
->cbufs
[i
]);
704 bool is_int
= util_format_is_pure_integer(format
);
705 bool has_alpha
= util_format_has_alpha(format
);
706 uint32_t control
= blend
->rb_mrt
[i
].control
;
707 uint32_t blend_control
= blend
->rb_mrt
[i
].blend_control_alpha
;
710 control
&= A5XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK
;
711 control
|= A5XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY
);
715 blend_control
|= blend
->rb_mrt
[i
].blend_control_rgb
;
717 blend_control
|= blend
->rb_mrt
[i
].blend_control_no_alpha_rgb
;
718 control
&= ~A5XX_RB_MRT_CONTROL_BLEND2
;
721 OUT_PKT4(ring
, REG_A5XX_RB_MRT_CONTROL(i
), 1);
722 OUT_RING(ring
, control
);
724 OUT_PKT4(ring
, REG_A5XX_RB_MRT_BLEND_CONTROL(i
), 1);
725 OUT_RING(ring
, blend_control
);
728 OUT_PKT4(ring
, REG_A5XX_RB_BLEND_CNTL
, 1);
729 OUT_RING(ring
, blend
->rb_blend_cntl
|
730 A5XX_RB_BLEND_CNTL_SAMPLE_MASK(0xffff));
732 OUT_PKT4(ring
, REG_A5XX_SP_BLEND_CNTL
, 1);
733 OUT_RING(ring
, blend
->sp_blend_cntl
);
736 if (dirty
& FD_DIRTY_BLEND_COLOR
) {
737 struct pipe_blend_color
*bcolor
= &ctx
->blend_color
;
739 OUT_PKT4(ring
, REG_A5XX_RB_BLEND_RED
, 8);
740 OUT_RING(ring
, A5XX_RB_BLEND_RED_FLOAT(bcolor
->color
[0]) |
741 A5XX_RB_BLEND_RED_UINT(bcolor
->color
[0] * 0xff) |
742 A5XX_RB_BLEND_RED_SINT(bcolor
->color
[0] * 0x7f));
743 OUT_RING(ring
, A5XX_RB_BLEND_RED_F32(bcolor
->color
[0]));
744 OUT_RING(ring
, A5XX_RB_BLEND_GREEN_FLOAT(bcolor
->color
[1]) |
745 A5XX_RB_BLEND_GREEN_UINT(bcolor
->color
[1] * 0xff) |
746 A5XX_RB_BLEND_GREEN_SINT(bcolor
->color
[1] * 0x7f));
747 OUT_RING(ring
, A5XX_RB_BLEND_RED_F32(bcolor
->color
[1]));
748 OUT_RING(ring
, A5XX_RB_BLEND_BLUE_FLOAT(bcolor
->color
[2]) |
749 A5XX_RB_BLEND_BLUE_UINT(bcolor
->color
[2] * 0xff) |
750 A5XX_RB_BLEND_BLUE_SINT(bcolor
->color
[2] * 0x7f));
751 OUT_RING(ring
, A5XX_RB_BLEND_BLUE_F32(bcolor
->color
[2]));
752 OUT_RING(ring
, A5XX_RB_BLEND_ALPHA_FLOAT(bcolor
->color
[3]) |
753 A5XX_RB_BLEND_ALPHA_UINT(bcolor
->color
[3] * 0xff) |
754 A5XX_RB_BLEND_ALPHA_SINT(bcolor
->color
[3] * 0x7f));
755 OUT_RING(ring
, A5XX_RB_BLEND_ALPHA_F32(bcolor
->color
[3]));
758 if (ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] & FD_DIRTY_SHADER_TEX
) {
759 needs_border
|= emit_textures(ctx
, ring
, SB4_VS_TEX
,
760 &ctx
->tex
[PIPE_SHADER_VERTEX
]);
761 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 1);
762 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_VERTEX
].num_textures
);
765 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_TEX
) {
766 needs_border
|= emit_textures(ctx
, ring
, SB4_FS_TEX
,
767 &ctx
->tex
[PIPE_SHADER_FRAGMENT
]);
770 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 1);
771 OUT_RING(ring
, ctx
->shaderimg
[PIPE_SHADER_FRAGMENT
].enabled_mask
?
772 ~0 : 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
]);
783 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_IMAGE
)
784 fd5_emit_images(ctx
, ring
, PIPE_SHADER_FRAGMENT
);
788 fd5_emit_cs_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
789 struct ir3_shader_variant
*cp
)
791 enum fd_dirty_shader_state dirty
= ctx
->dirty_shader
[PIPE_SHADER_COMPUTE
];
793 if (dirty
& FD_DIRTY_SHADER_TEX
) {
794 bool needs_border
= false;
795 needs_border
|= emit_textures(ctx
, ring
, SB4_CS_TEX
,
796 &ctx
->tex
[PIPE_SHADER_COMPUTE
]);
799 emit_border_color(ctx
, ring
);
801 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 1);
804 OUT_PKT4(ring
, REG_A5XX_TPL1_HS_TEX_COUNT
, 1);
807 OUT_PKT4(ring
, REG_A5XX_TPL1_DS_TEX_COUNT
, 1);
810 OUT_PKT4(ring
, REG_A5XX_TPL1_GS_TEX_COUNT
, 1);
813 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 1);
817 OUT_PKT4(ring
, REG_A5XX_TPL1_CS_TEX_COUNT
, 1);
818 OUT_RING(ring
, ctx
->shaderimg
[PIPE_SHADER_COMPUTE
].enabled_mask
?
819 ~0 : ctx
->tex
[PIPE_SHADER_COMPUTE
].num_textures
);
821 if (dirty
& FD_DIRTY_SHADER_SSBO
)
822 emit_ssbos(ctx
, ring
, SB4_CS_SSBO
, &ctx
->shaderbuf
[PIPE_SHADER_COMPUTE
]);
824 if (dirty
& FD_DIRTY_SHADER_IMAGE
)
825 fd5_emit_images(ctx
, ring
, PIPE_SHADER_COMPUTE
);
828 /* emit setup at begin of new cmdstream buffer (don't rely on previous
829 * state, there could have been a context switch between ioctls):
832 fd5_emit_restore(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
)
834 struct fd_context
*ctx
= batch
->ctx
;
836 fd5_set_render_mode(ctx
, ring
, BYPASS
);
837 fd5_cache_flush(batch
, ring
);
839 OUT_PKT4(ring
, REG_A5XX_HLSQ_UPDATE_CNTL
, 1);
840 OUT_RING(ring
, 0xfffff);
843 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
844 0000000500024048: 70d08003 00000000 001c5000 00000005
845 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
846 0000000500024058: 70d08003 00000010 001c7000 00000005
848 t7 opcode: CP_WAIT_FOR_IDLE (26) (1 dwords)
849 0000000500024068: 70268000
852 OUT_PKT4(ring
, REG_A5XX_PC_RESTART_INDEX
, 1);
853 OUT_RING(ring
, 0xffffffff);
855 OUT_PKT4(ring
, REG_A5XX_PC_RASTER_CNTL
, 1);
856 OUT_RING(ring
, 0x00000012);
858 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_POINT_MINMAX
, 2);
859 OUT_RING(ring
, A5XX_GRAS_SU_POINT_MINMAX_MIN(1.0) |
860 A5XX_GRAS_SU_POINT_MINMAX_MAX(4092.0));
861 OUT_RING(ring
, A5XX_GRAS_SU_POINT_SIZE(0.5));
863 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL
, 1);
864 OUT_RING(ring
, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */
866 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_CNTL
, 1);
867 OUT_RING(ring
, 0x00000000); /* GRAS_SC_SCREEN_SCISSOR_CNTL */
869 OUT_PKT4(ring
, REG_A5XX_SP_VS_CONFIG_MAX_CONST
, 1);
870 OUT_RING(ring
, 0); /* SP_VS_CONFIG_MAX_CONST */
872 OUT_PKT4(ring
, REG_A5XX_SP_FS_CONFIG_MAX_CONST
, 1);
873 OUT_RING(ring
, 0); /* SP_FS_CONFIG_MAX_CONST */
875 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E292
, 2);
876 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E292 */
877 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E293 */
879 OUT_PKT4(ring
, REG_A5XX_RB_MODE_CNTL
, 1);
880 OUT_RING(ring
, 0x00000044); /* RB_MODE_CNTL */
882 OUT_PKT4(ring
, REG_A5XX_RB_DBG_ECO_CNTL
, 1);
883 OUT_RING(ring
, 0x00100000); /* RB_DBG_ECO_CNTL */
885 OUT_PKT4(ring
, REG_A5XX_VFD_MODE_CNTL
, 1);
886 OUT_RING(ring
, 0x00000000); /* VFD_MODE_CNTL */
888 OUT_PKT4(ring
, REG_A5XX_PC_MODE_CNTL
, 1);
889 OUT_RING(ring
, 0x0000001f); /* PC_MODE_CNTL */
891 OUT_PKT4(ring
, REG_A5XX_SP_MODE_CNTL
, 1);
892 OUT_RING(ring
, 0x0000001e); /* SP_MODE_CNTL */
894 OUT_PKT4(ring
, REG_A5XX_SP_DBG_ECO_CNTL
, 1);
895 OUT_RING(ring
, 0x40000800); /* SP_DBG_ECO_CNTL */
897 OUT_PKT4(ring
, REG_A5XX_TPL1_MODE_CNTL
, 1);
898 OUT_RING(ring
, 0x00000544); /* TPL1_MODE_CNTL */
900 OUT_PKT4(ring
, REG_A5XX_HLSQ_TIMEOUT_THRESHOLD_0
, 2);
901 OUT_RING(ring
, 0x00000080); /* HLSQ_TIMEOUT_THRESHOLD_0 */
902 OUT_RING(ring
, 0x00000000); /* HLSQ_TIMEOUT_THRESHOLD_1 */
904 OUT_PKT4(ring
, REG_A5XX_VPC_DBG_ECO_CNTL
, 1);
905 OUT_RING(ring
, 0x00000400); /* VPC_DBG_ECO_CNTL */
907 OUT_PKT4(ring
, REG_A5XX_HLSQ_MODE_CNTL
, 1);
908 OUT_RING(ring
, 0x00000001); /* HLSQ_MODE_CNTL */
910 OUT_PKT4(ring
, REG_A5XX_VPC_MODE_CNTL
, 1);
911 OUT_RING(ring
, 0x00000000); /* VPC_MODE_CNTL */
913 /* we don't use this yet.. probably best to disable.. */
914 OUT_PKT7(ring
, CP_SET_DRAW_STATE
, 3);
915 OUT_RING(ring
, CP_SET_DRAW_STATE__0_COUNT(0) |
916 CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS
|
917 CP_SET_DRAW_STATE__0_GROUP_ID(0));
918 OUT_RING(ring
, CP_SET_DRAW_STATE__1_ADDR_LO(0));
919 OUT_RING(ring
, CP_SET_DRAW_STATE__2_ADDR_HI(0));
921 OUT_PKT4(ring
, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL
, 1);
922 OUT_RING(ring
, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */
924 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_BIN_CNTL
, 1);
925 OUT_RING(ring
, 0x00000000); /* GRAS_SC_BIN_CNTL */
927 OUT_PKT4(ring
, REG_A5XX_GRAS_SC_BIN_CNTL
, 1);
928 OUT_RING(ring
, 0x00000000); /* GRAS_SC_BIN_CNTL */
930 OUT_PKT4(ring
, REG_A5XX_VPC_FS_PRIMITIVEID_CNTL
, 1);
931 OUT_RING(ring
, 0x000000ff); /* VPC_FS_PRIMITIVEID_CNTL */
933 OUT_PKT4(ring
, REG_A5XX_VPC_SO_OVERRIDE
, 1);
934 OUT_RING(ring
, A5XX_VPC_SO_OVERRIDE_SO_DISABLE
);
936 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(0), 3);
937 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_LO_0 */
938 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_HI_0 */
939 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_SIZE_0 */
941 OUT_PKT4(ring
, REG_A5XX_VPC_SO_FLUSH_BASE_LO(0), 2);
942 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_LO_0 */
943 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_HI_0 */
945 OUT_PKT4(ring
, REG_A5XX_PC_GS_PARAM
, 1);
946 OUT_RING(ring
, 0x00000000); /* PC_GS_PARAM */
948 OUT_PKT4(ring
, REG_A5XX_PC_HS_PARAM
, 1);
949 OUT_RING(ring
, 0x00000000); /* PC_HS_PARAM */
951 OUT_PKT4(ring
, REG_A5XX_TPL1_TP_FS_ROTATION_CNTL
, 1);
952 OUT_RING(ring
, 0x00000000); /* TPL1_TP_FS_ROTATION_CNTL */
954 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E001
, 1);
955 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E001 */
957 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E004
, 1);
958 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E004 */
960 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E093
, 1);
961 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E093 */
963 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E29A
, 1);
964 OUT_RING(ring
, 0x00ffff00); /* UNKNOWN_E29A */
966 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUF_CNTL
, 1);
967 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUF_CNTL */
969 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(0), 1);
970 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E2AB */
972 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E389
, 1);
973 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E389 */
975 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E38D
, 1);
976 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E38D */
978 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5AB
, 1);
979 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E5AB */
981 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5C2
, 1);
982 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E5C2 */
984 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_BASE_LO(1), 3);
985 OUT_RING(ring
, 0x00000000);
986 OUT_RING(ring
, 0x00000000);
987 OUT_RING(ring
, 0x00000000);
989 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(1), 6);
990 OUT_RING(ring
, 0x00000000);
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);
997 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(2), 6);
998 OUT_RING(ring
, 0x00000000);
999 OUT_RING(ring
, 0x00000000);
1000 OUT_RING(ring
, 0x00000000);
1001 OUT_RING(ring
, 0x00000000);
1002 OUT_RING(ring
, 0x00000000);
1003 OUT_RING(ring
, 0x00000000);
1005 OUT_PKT4(ring
, REG_A5XX_VPC_SO_BUFFER_OFFSET(3), 3);
1006 OUT_RING(ring
, 0x00000000);
1007 OUT_RING(ring
, 0x00000000);
1008 OUT_RING(ring
, 0x00000000);
1010 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E5DB
, 1);
1011 OUT_RING(ring
, 0x00000000);
1013 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E600
, 1);
1014 OUT_RING(ring
, 0x00000000);
1016 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E640
, 1);
1017 OUT_RING(ring
, 0x00000000);
1019 OUT_PKT4(ring
, REG_A5XX_TPL1_VS_TEX_COUNT
, 4);
1020 OUT_RING(ring
, 0x00000000);
1021 OUT_RING(ring
, 0x00000000);
1022 OUT_RING(ring
, 0x00000000);
1023 OUT_RING(ring
, 0x00000000);
1025 OUT_PKT4(ring
, REG_A5XX_TPL1_FS_TEX_COUNT
, 2);
1026 OUT_RING(ring
, 0x00000000);
1027 OUT_RING(ring
, 0x00000000);
1029 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7C0
, 3);
1030 OUT_RING(ring
, 0x00000000);
1031 OUT_RING(ring
, 0x00000000);
1032 OUT_RING(ring
, 0x00000000);
1034 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7C5
, 3);
1035 OUT_RING(ring
, 0x00000000);
1036 OUT_RING(ring
, 0x00000000);
1037 OUT_RING(ring
, 0x00000000);
1039 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7CA
, 3);
1040 OUT_RING(ring
, 0x00000000);
1041 OUT_RING(ring
, 0x00000000);
1042 OUT_RING(ring
, 0x00000000);
1044 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7CF
, 3);
1045 OUT_RING(ring
, 0x00000000);
1046 OUT_RING(ring
, 0x00000000);
1047 OUT_RING(ring
, 0x00000000);
1049 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7D4
, 3);
1050 OUT_RING(ring
, 0x00000000);
1051 OUT_RING(ring
, 0x00000000);
1052 OUT_RING(ring
, 0x00000000);
1054 OUT_PKT4(ring
, REG_A5XX_UNKNOWN_E7D9
, 3);
1055 OUT_RING(ring
, 0x00000000);
1056 OUT_RING(ring
, 0x00000000);
1057 OUT_RING(ring
, 0x00000000);
1059 OUT_PKT4(ring
, REG_A5XX_RB_CLEAR_CNTL
, 1);
1060 OUT_RING(ring
, 0x00000000);
1064 fd5_emit_ib(struct fd_ringbuffer
*ring
, struct fd_ringbuffer
*target
)
1066 __OUT_IB5(ring
, target
);
1070 fd5_emit_init(struct pipe_context
*pctx
)
1072 struct fd_context
*ctx
= fd_context(pctx
);
1073 ctx
->emit_const
= fd5_emit_const
;
1074 ctx
->emit_const_bo
= fd5_emit_const_bo
;
1075 ctx
->emit_ib
= fd5_emit_ib
;