2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Rob Clark <robclark@freedesktop.org>
28 #include "pipe/p_state.h"
29 #include "util/u_string.h"
30 #include "util/u_memory.h"
31 #include "util/u_helpers.h"
32 #include "util/u_format.h"
33 #include "util/u_viewport.h"
35 #include "freedreno_resource.h"
36 #include "freedreno_query_hw.h"
39 #include "fd6_blend.h"
40 #include "fd6_context.h"
41 #include "fd6_image.h"
42 #include "fd6_program.h"
43 #include "fd6_rasterizer.h"
44 #include "fd6_texture.h"
45 #include "fd6_format.h"
49 shader_t_to_opcode(enum shader_t type
)
56 return CP_LOAD_STATE6_GEOM
;
59 return CP_LOAD_STATE6_FRAG
;
61 unreachable("bad shader type");
65 /* regid: base const register
66 * prsc or dwords: buffer containing constant values
67 * sizedwords: size of const value buffer
70 fd6_emit_const(struct fd_ringbuffer
*ring
, enum shader_t type
,
71 uint32_t regid
, uint32_t offset
, uint32_t sizedwords
,
72 const uint32_t *dwords
, struct pipe_resource
*prsc
)
75 enum a6xx_state_src src
;
77 debug_assert((regid
% 4) == 0);
78 debug_assert((sizedwords
% 4) == 0);
88 OUT_PKT7(ring
, shader_t_to_opcode(type
), 3 + sz
);
89 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(regid
/4) |
90 CP_LOAD_STATE6_0_STATE_TYPE(ST6_CONSTANTS
) |
91 CP_LOAD_STATE6_0_STATE_SRC(src
) |
92 CP_LOAD_STATE6_0_STATE_BLOCK(fd6_stage2shadersb(type
)) |
93 CP_LOAD_STATE6_0_NUM_UNIT(sizedwords
/4));
95 struct fd_bo
*bo
= fd_resource(prsc
)->bo
;
96 OUT_RELOC(ring
, bo
, offset
, 0, 0);
98 OUT_RING(ring
, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
99 OUT_RING(ring
, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
100 dwords
= (uint32_t *)&((uint8_t *)dwords
)[offset
];
102 for (i
= 0; i
< sz
; i
++) {
103 OUT_RING(ring
, dwords
[i
]);
108 fd6_emit_const_bo(struct fd_ringbuffer
*ring
, enum shader_t type
, boolean write
,
109 uint32_t regid
, uint32_t num
, struct pipe_resource
**prscs
, uint32_t *offsets
)
111 uint32_t anum
= align(num
, 2);
114 debug_assert((regid
% 4) == 0);
116 OUT_PKT7(ring
, shader_t_to_opcode(type
), 3 + (2 * anum
));
117 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(regid
/4) |
118 CP_LOAD_STATE6_0_STATE_TYPE(ST6_CONSTANTS
)|
119 CP_LOAD_STATE6_0_STATE_SRC(SS6_DIRECT
) |
120 CP_LOAD_STATE6_0_STATE_BLOCK(fd6_stage2shadersb(type
)) |
121 CP_LOAD_STATE6_0_NUM_UNIT(anum
/2));
122 OUT_RING(ring
, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
123 OUT_RING(ring
, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
125 for (i
= 0; i
< num
; i
++) {
128 OUT_RELOCW(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
130 OUT_RELOC(ring
, fd_resource(prscs
[i
])->bo
, offsets
[i
], 0, 0);
133 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
134 OUT_RING(ring
, 0xbad00000 | (i
<< 16));
138 for (; i
< anum
; i
++) {
139 OUT_RING(ring
, 0xffffffff);
140 OUT_RING(ring
, 0xffffffff);
144 /* Border color layout is diff from a4xx/a5xx.. if it turns out to be
145 * the same as a6xx then move this somewhere common ;-)
147 * Entry layout looks like (total size, 0x60 bytes):
150 struct PACKED bcolor_entry
{
162 uint32_t z24
; /* also s8? */
166 #define FD6_BORDER_COLOR_SIZE 0x60
167 #define FD6_BORDER_COLOR_UPLOAD_SIZE (2 * PIPE_MAX_SAMPLERS * FD6_BORDER_COLOR_SIZE)
170 setup_border_colors(struct fd_texture_stateobj
*tex
, struct bcolor_entry
*entries
)
173 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD6_BORDER_COLOR_SIZE
);
175 for (i
= 0; i
< tex
->num_samplers
; i
++) {
176 struct bcolor_entry
*e
= &entries
[i
];
177 struct pipe_sampler_state
*sampler
= tex
->samplers
[i
];
178 union pipe_color_union
*bc
;
183 bc
= &sampler
->border_color
;
188 * The border colors need to be swizzled in a particular
189 * format-dependent order. Even though samplers don't know about
190 * formats, we can assume that with a GL state tracker, there's a
191 * 1:1 correspondence between sampler and texture. Take advantage
194 if ((i
>= tex
->num_textures
) || !tex
->textures
[i
])
197 const struct util_format_description
*desc
=
198 util_format_description(tex
->textures
[i
]->format
);
206 for (j
= 0; j
< 4; j
++) {
207 int c
= desc
->swizzle
[j
];
212 if (desc
->channel
[c
].pure_integer
) {
214 switch (desc
->channel
[c
].size
) {
216 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
217 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3);
220 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
221 clamped
= CLAMP(bc
->i
[j
], -128, 127);
223 clamped
= CLAMP(bc
->ui
[j
], 0, 255);
226 assert(desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_UNSIGNED
);
227 clamped
= CLAMP(bc
->ui
[j
], 0, 0x3ff);
230 if (desc
->channel
[c
].type
== UTIL_FORMAT_TYPE_SIGNED
)
231 clamped
= CLAMP(bc
->i
[j
], -32768, 32767);
233 clamped
= CLAMP(bc
->ui
[j
], 0, 65535);
236 assert(!"Unexpected bit size");
241 e
->fp32
[c
] = bc
->ui
[j
];
242 e
->fp16
[c
] = clamped
;
245 float f_u
= CLAMP(f
, 0, 1);
246 float f_s
= CLAMP(f
, -1, 1);
249 e
->fp16
[c
] = util_float_to_half(f
);
250 e
->ui16
[c
] = f_u
* 0xffff;
251 e
->si16
[c
] = f_s
* 0x7fff;
252 e
->ui8
[c
] = f_u
* 0xff;
253 e
->si8
[c
] = f_s
* 0x7f;
255 e
->rgb565
|= (int)(f_u
* 0x3f) << 5;
257 e
->rgb565
|= (int)(f_u
* 0x1f) << (c
? 11 : 0);
259 e
->rgb5a1
|= (f_u
> 0.5) ? 0x8000 : 0;
261 e
->rgb5a1
|= (int)(f_u
* 0x1f) << (c
* 5);
263 e
->rgb10a2
|= (int)(f_u
* 0x3) << 30;
265 e
->rgb10a2
|= (int)(f_u
* 0x3ff) << (c
* 10);
266 e
->rgba4
|= (int)(f_u
* 0xf) << (c
* 4);
268 e
->z24
= f_u
* 0xffffff;
273 memset(&e
->__pad0
, 0, sizeof(e
->__pad0
));
274 memset(&e
->__pad1
, 0, sizeof(e
->__pad1
));
280 emit_border_color(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
)
282 struct fd6_context
*fd6_ctx
= fd6_context(ctx
);
283 struct bcolor_entry
*entries
;
287 STATIC_ASSERT(sizeof(struct bcolor_entry
) == FD6_BORDER_COLOR_SIZE
);
289 u_upload_alloc(fd6_ctx
->border_color_uploader
,
290 0, FD6_BORDER_COLOR_UPLOAD_SIZE
,
291 FD6_BORDER_COLOR_UPLOAD_SIZE
, &off
,
292 &fd6_ctx
->border_color_buf
,
297 setup_border_colors(&ctx
->tex
[PIPE_SHADER_VERTEX
], &entries
[0]);
298 setup_border_colors(&ctx
->tex
[PIPE_SHADER_FRAGMENT
],
299 &entries
[ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
]);
301 OUT_PKT4(ring
, REG_A6XX_SP_TP_BORDER_COLOR_BASE_ADDR_LO
, 2);
302 OUT_RELOC(ring
, fd_resource(fd6_ctx
->border_color_buf
)->bo
, off
, 0, 0);
304 u_upload_unmap(fd6_ctx
->border_color_uploader
);
308 emit_textures(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
309 enum a6xx_state_block sb
, struct fd_texture_stateobj
*tex
)
311 bool needs_border
= false;
312 unsigned bcolor_offset
;
313 unsigned opcode
, tex_samp_reg
, tex_const_reg
;
317 opcode
= CP_LOAD_STATE6_GEOM
;
319 tex_samp_reg
= REG_A6XX_SP_VS_TEX_SAMP_LO
;
320 tex_const_reg
= REG_A6XX_SP_VS_TEX_CONST_LO
;
323 opcode
= CP_LOAD_STATE6_FRAG
;
324 bcolor_offset
= ctx
->tex
[PIPE_SHADER_VERTEX
].num_samplers
;
325 tex_samp_reg
= REG_A6XX_SP_FS_TEX_SAMP_LO
;
326 tex_const_reg
= REG_A6XX_SP_FS_TEX_CONST_LO
;
329 opcode
= CP_LOAD_STATE6_FRAG
;
331 tex_samp_reg
= REG_A6XX_SP_CS_TEX_SAMP_LO
;
332 tex_const_reg
= REG_A6XX_SP_CS_TEX_CONST_LO
;
335 unreachable("bad state block");
339 if (tex
->num_samplers
> 0) {
340 struct fd_ringbuffer
*state
=
341 fd_ringbuffer_new_object(ctx
->pipe
, tex
->num_samplers
* 4);
342 for (unsigned i
= 0; i
< tex
->num_samplers
; i
++) {
343 static const struct fd6_sampler_stateobj dummy_sampler
= {};
344 const struct fd6_sampler_stateobj
*sampler
= tex
->samplers
[i
] ?
345 fd6_sampler_stateobj(tex
->samplers
[i
]) : &dummy_sampler
;
346 OUT_RING(state
, sampler
->texsamp0
);
347 OUT_RING(state
, sampler
->texsamp1
);
348 OUT_RING(state
, sampler
->texsamp2
|
349 A6XX_TEX_SAMP_2_BCOLOR_OFFSET(bcolor_offset
));
350 OUT_RING(state
, sampler
->texsamp3
);
351 needs_border
|= sampler
->needs_border
;
354 /* output sampler state: */
355 OUT_PKT7(ring
, opcode
, 3);
356 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(0) |
357 CP_LOAD_STATE6_0_STATE_TYPE(ST6_SHADER
) |
358 CP_LOAD_STATE6_0_STATE_SRC(SS6_INDIRECT
) |
359 CP_LOAD_STATE6_0_STATE_BLOCK(sb
) |
360 CP_LOAD_STATE6_0_NUM_UNIT(tex
->num_samplers
));
361 OUT_RB(ring
, state
); /* SRC_ADDR_LO/HI */
363 OUT_PKT4(ring
, tex_samp_reg
, 2);
364 OUT_RB(ring
, state
); /* SRC_ADDR_LO/HI */
366 fd_ringbuffer_del(state
);
369 if (tex
->num_textures
> 0) {
370 struct fd_ringbuffer
*state
=
371 fd_ringbuffer_new_object(ctx
->pipe
, tex
->num_textures
* 16);
372 for (unsigned i
= 0; i
< tex
->num_textures
; i
++) {
373 static const struct fd6_pipe_sampler_view dummy_view
= {};
374 const struct fd6_pipe_sampler_view
*view
= tex
->textures
[i
] ?
375 fd6_pipe_sampler_view(tex
->textures
[i
]) : &dummy_view
;
376 enum a6xx_tile_mode tile_mode
= TILE6_LINEAR
;
378 if (view
->base
.texture
)
379 tile_mode
= fd_resource(view
->base
.texture
)->tile_mode
;
381 OUT_RING(state
, view
->texconst0
|
382 A6XX_TEX_CONST_0_TILE_MODE(tile_mode
));
383 OUT_RING(state
, view
->texconst1
);
384 OUT_RING(state
, view
->texconst2
);
385 OUT_RING(state
, view
->texconst3
);
387 if (view
->base
.texture
) {
388 struct fd_resource
*rsc
= fd_resource(view
->base
.texture
);
389 if (view
->base
.format
== PIPE_FORMAT_X32_S8X24_UINT
)
391 OUT_RELOC(state
, rsc
->bo
, view
->offset
,
392 (uint64_t)view
->texconst5
<< 32, 0);
394 OUT_RING(state
, 0x00000000);
395 OUT_RING(state
, view
->texconst5
);
398 OUT_RING(state
, view
->texconst6
);
399 OUT_RING(state
, view
->texconst7
);
400 OUT_RING(state
, view
->texconst8
);
401 OUT_RING(state
, view
->texconst9
);
402 OUT_RING(state
, view
->texconst10
);
403 OUT_RING(state
, view
->texconst11
);
410 /* emit texture state: */
411 OUT_PKT7(ring
, opcode
, 3);
412 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(0) |
413 CP_LOAD_STATE6_0_STATE_TYPE(ST6_CONSTANTS
) |
414 CP_LOAD_STATE6_0_STATE_SRC(SS6_INDIRECT
) |
415 CP_LOAD_STATE6_0_STATE_BLOCK(sb
) |
416 CP_LOAD_STATE6_0_NUM_UNIT(tex
->num_textures
));
417 OUT_RB(ring
, state
); /* SRC_ADDR_LO/HI */
419 OUT_PKT4(ring
, tex_const_reg
, 2);
420 OUT_RB(ring
, state
); /* SRC_ADDR_LO/HI */
422 fd_ringbuffer_del(state
);
429 emit_ssbos(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
430 enum a6xx_state_block sb
, struct fd_shaderbuf_stateobj
*so
)
432 unsigned count
= util_last_bit(so
->enabled_mask
);
441 opcode
= CP_LOAD_STATE6_GEOM
;
444 unreachable("bad state block");
447 OUT_PKT7(ring
, opcode
, 3 + (4 * count
));
448 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(0) |
449 CP_LOAD_STATE6_0_STATE_TYPE(0) |
450 CP_LOAD_STATE6_0_STATE_SRC(SS6_DIRECT
) |
451 CP_LOAD_STATE6_0_STATE_BLOCK(sb
) |
452 CP_LOAD_STATE6_0_NUM_UNIT(count
));
453 OUT_RING(ring
, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
454 OUT_RING(ring
, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
455 for (unsigned i
= 0; i
< count
; i
++) {
456 OUT_RING(ring
, 0x00000000);
457 OUT_RING(ring
, 0x00000000);
458 OUT_RING(ring
, 0x00000000);
459 OUT_RING(ring
, 0x00000000);
463 OUT_PKT7(ring
, opcode
, 3 + (2 * count
));
464 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(0) |
465 CP_LOAD_STATE6_0_STATE_TYPE(1) |
466 CP_LOAD_STATE6_0_STATE_SRC(SS6_DIRECT
) |
467 CP_LOAD_STATE6_0_STATE_BLOCK(sb
) |
468 CP_LOAD_STATE6_0_NUM_UNIT(count
));
469 OUT_RING(ring
, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
470 OUT_RING(ring
, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
471 for (unsigned i
= 0; i
< count
; i
++) {
472 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
473 unsigned sz
= buf
->buffer_size
;
475 /* width is in dwords, overflows into height: */
478 OUT_RING(ring
, A6XX_SSBO_1_0_WIDTH(sz
));
479 OUT_RING(ring
, A6XX_SSBO_1_1_HEIGHT(sz
>> 16));
483 OUT_PKT7(ring
, opcode
, 3 + (2 * count
));
484 OUT_RING(ring
, CP_LOAD_STATE6_0_DST_OFF(0) |
485 CP_LOAD_STATE6_0_STATE_TYPE(2) |
486 CP_LOAD_STATE6_0_STATE_SRC(SS6_DIRECT
) |
487 CP_LOAD_STATE6_0_STATE_BLOCK(sb
) |
488 CP_LOAD_STATE6_0_NUM_UNIT(count
));
489 OUT_RING(ring
, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
490 OUT_RING(ring
, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
491 for (unsigned i
= 0; i
< count
; i
++) {
492 struct pipe_shader_buffer
*buf
= &so
->sb
[i
];
494 struct fd_resource
*rsc
= fd_resource(buf
->buffer
);
495 OUT_RELOCW(ring
, rsc
->bo
, buf
->buffer_offset
, 0, 0);
497 OUT_RING(ring
, 0x00000000);
498 OUT_RING(ring
, 0x00000000);
504 fd6_emit_vertex_bufs(struct fd_ringbuffer
*ring
, struct fd6_emit
*emit
)
507 const struct fd_vertex_state
*vtx
= emit
->vtx
;
508 const struct ir3_shader_variant
*vp
= fd6_emit_get_vp(emit
);
510 for (i
= 0, j
= 0; i
<= vp
->inputs_count
; i
++) {
511 if (vp
->inputs
[i
].sysval
)
513 if (vp
->inputs
[i
].compmask
) {
514 struct pipe_vertex_element
*elem
= &vtx
->vtx
->pipe
[i
];
515 const struct pipe_vertex_buffer
*vb
=
516 &vtx
->vertexbuf
.vb
[elem
->vertex_buffer_index
];
517 struct fd_resource
*rsc
= fd_resource(vb
->buffer
.resource
);
518 enum pipe_format pfmt
= elem
->src_format
;
519 enum a6xx_vtx_fmt fmt
= fd6_pipe2vtx(pfmt
);
520 bool isint
= util_format_is_pure_integer(pfmt
);
521 uint32_t off
= vb
->buffer_offset
+ elem
->src_offset
;
522 uint32_t size
= fd_bo_size(rsc
->bo
) - off
;
523 debug_assert(fmt
!= ~0);
526 /* see dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.bind_vertex_buffer_offset_near_wrap_10
528 if (off
> fd_bo_size(rsc
->bo
))
532 OUT_PKT4(ring
, REG_A6XX_VFD_FETCH(j
), 4);
533 OUT_RELOC(ring
, rsc
->bo
, off
, 0, 0);
534 OUT_RING(ring
, size
); /* VFD_FETCH[j].SIZE */
535 OUT_RING(ring
, vb
->stride
); /* VFD_FETCH[j].STRIDE */
537 OUT_PKT4(ring
, REG_A6XX_VFD_DECODE(j
), 2);
538 OUT_RING(ring
, A6XX_VFD_DECODE_INSTR_IDX(j
) |
539 A6XX_VFD_DECODE_INSTR_FORMAT(fmt
) |
540 COND(elem
->instance_divisor
, A6XX_VFD_DECODE_INSTR_INSTANCED
) |
541 A6XX_VFD_DECODE_INSTR_SWAP(fd6_pipe2swap(pfmt
)) |
542 A6XX_VFD_DECODE_INSTR_UNK30
|
543 COND(!isint
, A6XX_VFD_DECODE_INSTR_FLOAT
));
544 OUT_RING(ring
, MAX2(1, elem
->instance_divisor
)); /* VFD_DECODE[j].STEP_RATE */
546 OUT_PKT4(ring
, REG_A6XX_VFD_DEST_CNTL(j
), 1);
547 OUT_RING(ring
, A6XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vp
->inputs
[i
].compmask
) |
548 A6XX_VFD_DEST_CNTL_INSTR_REGID(vp
->inputs
[i
].regid
));
554 OUT_PKT4(ring
, REG_A6XX_VFD_CONTROL_0
, 1);
555 OUT_RING(ring
, A6XX_VFD_CONTROL_0_VTXCNT(j
) | (j
<< 8));
559 fd6_emit_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
560 struct fd6_emit
*emit
)
562 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
563 const struct ir3_shader_variant
*vp
= fd6_emit_get_vp(emit
);
564 const struct ir3_shader_variant
*fp
= fd6_emit_get_fp(emit
);
565 const enum fd_dirty_3d_state dirty
= emit
->dirty
;
566 bool needs_border
= false;
568 emit_marker6(ring
, 5);
570 if ((dirty
& FD_DIRTY_FRAMEBUFFER
) && !emit
->key
.binning_pass
) {
571 unsigned char mrt_comp
[A6XX_MAX_RENDER_TARGETS
] = {0};
573 for (unsigned i
= 0; i
< pfb
->nr_cbufs
; i
++) {
574 mrt_comp
[i
] = ((i
< pfb
->nr_cbufs
) && pfb
->cbufs
[i
]) ? 0xf : 0;
577 OUT_PKT4(ring
, REG_A6XX_RB_RENDER_COMPONENTS
, 1);
578 OUT_RING(ring
, A6XX_RB_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
579 A6XX_RB_RENDER_COMPONENTS_RT1(mrt_comp
[1]) |
580 A6XX_RB_RENDER_COMPONENTS_RT2(mrt_comp
[2]) |
581 A6XX_RB_RENDER_COMPONENTS_RT3(mrt_comp
[3]) |
582 A6XX_RB_RENDER_COMPONENTS_RT4(mrt_comp
[4]) |
583 A6XX_RB_RENDER_COMPONENTS_RT5(mrt_comp
[5]) |
584 A6XX_RB_RENDER_COMPONENTS_RT6(mrt_comp
[6]) |
585 A6XX_RB_RENDER_COMPONENTS_RT7(mrt_comp
[7]));
587 OUT_PKT4(ring
, REG_A6XX_SP_FS_RENDER_COMPONENTS
, 1);
589 A6XX_SP_FS_RENDER_COMPONENTS_RT0(mrt_comp
[0]) |
590 A6XX_SP_FS_RENDER_COMPONENTS_RT1(mrt_comp
[0]) |
591 A6XX_SP_FS_RENDER_COMPONENTS_RT2(mrt_comp
[0]) |
592 A6XX_SP_FS_RENDER_COMPONENTS_RT3(mrt_comp
[0]) |
593 A6XX_SP_FS_RENDER_COMPONENTS_RT4(mrt_comp
[0]) |
594 A6XX_SP_FS_RENDER_COMPONENTS_RT5(mrt_comp
[0]) |
595 A6XX_SP_FS_RENDER_COMPONENTS_RT6(mrt_comp
[0]) |
596 A6XX_SP_FS_RENDER_COMPONENTS_RT7(mrt_comp
[0]));
599 if (dirty
& FD_DIRTY_ZSA
) {
600 struct fd6_zsa_stateobj
*zsa
= fd6_zsa_stateobj(ctx
->zsa
);
601 uint32_t rb_alpha_control
= zsa
->rb_alpha_control
;
603 if (util_format_is_pure_integer(pipe_surface_format(pfb
->cbufs
[0])))
604 rb_alpha_control
&= ~A6XX_RB_ALPHA_CONTROL_ALPHA_TEST
;
606 OUT_PKT4(ring
, REG_A6XX_RB_ALPHA_CONTROL
, 1);
607 OUT_RING(ring
, rb_alpha_control
);
609 OUT_PKT4(ring
, REG_A6XX_RB_STENCIL_CONTROL
, 1);
610 OUT_RING(ring
, zsa
->rb_stencil_control
);
613 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_BLEND
| FD_DIRTY_PROG
)) {
614 struct fd6_blend_stateobj
*blend
= fd6_blend_stateobj(ctx
->blend
);
615 struct fd6_zsa_stateobj
*zsa
= fd6_zsa_stateobj(ctx
->zsa
);
618 struct fd_resource
*rsc
= fd_resource(pfb
->zsbuf
->texture
);
619 uint32_t gras_lrz_cntl
= zsa
->gras_lrz_cntl
;
621 if (emit
->no_lrz_write
|| !rsc
->lrz
|| !rsc
->lrz_valid
)
623 else if (emit
->key
.binning_pass
&& blend
->lrz_write
&& zsa
->lrz_write
)
624 gras_lrz_cntl
|= A6XX_GRAS_LRZ_CNTL_LRZ_WRITE
;
626 OUT_PKT4(ring
, REG_A6XX_GRAS_LRZ_CNTL
, 1);
627 OUT_RING(ring
, gras_lrz_cntl
);
631 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_STENCIL_REF
)) {
632 struct fd6_zsa_stateobj
*zsa
= fd6_zsa_stateobj(ctx
->zsa
);
633 struct pipe_stencil_ref
*sr
= &ctx
->stencil_ref
;
635 OUT_PKT4(ring
, REG_A6XX_RB_STENCILREF
, 3);
636 OUT_RING(ring
, A6XX_RB_STENCILREF_REF(sr
->ref_value
[0])); // TODO bf?
637 OUT_RING(ring
, zsa
->rb_stencilmask
);
638 OUT_RING(ring
, zsa
->rb_stencilwrmask
);
641 if (dirty
& (FD_DIRTY_ZSA
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
642 struct fd6_zsa_stateobj
*zsa
= fd6_zsa_stateobj(ctx
->zsa
);
643 bool fragz
= fp
->has_kill
| fp
->writes_pos
;
645 OUT_PKT4(ring
, REG_A6XX_RB_DEPTH_CNTL
, 1);
646 OUT_RING(ring
, zsa
->rb_depth_cntl
);
648 OUT_PKT4(ring
, REG_A6XX_RB_DEPTH_PLANE_CNTL
, 1);
649 OUT_RING(ring
, COND(fragz
, A6XX_RB_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
));
651 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_DEPTH_PLANE_CNTL
, 1);
652 OUT_RING(ring
, COND(fragz
, A6XX_GRAS_SU_DEPTH_PLANE_CNTL_FRAG_WRITES_Z
));
655 if (dirty
& FD_DIRTY_SCISSOR
) {
656 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
658 OUT_PKT4(ring
, REG_A6XX_GRAS_SC_SCREEN_SCISSOR_TL_0
, 2);
659 OUT_RING(ring
, A6XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->minx
) |
660 A6XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->miny
));
661 OUT_RING(ring
, A6XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
662 A6XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
664 OUT_PKT4(ring
, REG_A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0
, 2);
665 OUT_RING(ring
, A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->minx
) |
666 A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->miny
));
667 OUT_RING(ring
, A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor
->maxx
- 1) |
668 A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor
->maxy
- 1));
670 ctx
->batch
->max_scissor
.minx
= MIN2(ctx
->batch
->max_scissor
.minx
, scissor
->minx
);
671 ctx
->batch
->max_scissor
.miny
= MIN2(ctx
->batch
->max_scissor
.miny
, scissor
->miny
);
672 ctx
->batch
->max_scissor
.maxx
= MAX2(ctx
->batch
->max_scissor
.maxx
, scissor
->maxx
);
673 ctx
->batch
->max_scissor
.maxy
= MAX2(ctx
->batch
->max_scissor
.maxy
, scissor
->maxy
);
676 if (dirty
& FD_DIRTY_VIEWPORT
) {
677 fd_wfi(ctx
->batch
, ring
);
678 OUT_PKT4(ring
, REG_A6XX_GRAS_CL_VPORT_XOFFSET_0
, 6);
679 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_XOFFSET_0(ctx
->viewport
.translate
[0]));
680 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_XSCALE_0(ctx
->viewport
.scale
[0]));
681 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_YOFFSET_0(ctx
->viewport
.translate
[1]));
682 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_YSCALE_0(ctx
->viewport
.scale
[1]));
683 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_ZOFFSET_0(ctx
->viewport
.translate
[2]));
684 OUT_RING(ring
, A6XX_GRAS_CL_VPORT_ZSCALE_0(ctx
->viewport
.scale
[2]));
687 if (dirty
& FD_DIRTY_PROG
)
688 fd6_program_emit(ctx
, ring
, emit
);
690 if (dirty
& FD_DIRTY_RASTERIZER
) {
691 struct fd6_rasterizer_stateobj
*rasterizer
=
692 fd6_rasterizer_stateobj(ctx
->rasterizer
);
694 OUT_PKT4(ring
, REG_A6XX_GRAS_UNKNOWN_8000
, 1);
695 OUT_RING(ring
, 0x80);
696 OUT_PKT4(ring
, REG_A6XX_GRAS_UNKNOWN_8001
, 1);
698 OUT_PKT4(ring
, REG_A6XX_GRAS_UNKNOWN_8004
, 1);
701 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_CNTL
, 1);
702 OUT_RING(ring
, rasterizer
->gras_su_cntl
);
704 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_POINT_MINMAX
, 2);
705 OUT_RING(ring
, rasterizer
->gras_su_point_minmax
);
706 OUT_RING(ring
, rasterizer
->gras_su_point_size
);
708 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_POLY_OFFSET_SCALE
, 3);
709 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_scale
);
710 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_offset
);
711 OUT_RING(ring
, rasterizer
->gras_su_poly_offset_clamp
);
714 OUT_PKT4(ring
, REG_A6XX_PC_RASTER_CNTL
, 1);
715 OUT_RING(ring
, rasterizer
->pc_raster_cntl
);
717 OUT_PKT4(ring
, REG_A6XX_GRAS_CL_CNTL
, 1);
718 OUT_RING(ring
, rasterizer
->gras_cl_clip_cntl
);
722 /* note: must come after program emit.. because there is some overlap
723 * in registers, ex. PC_PRIMITIVE_CNTL and we rely on some cached
724 * values from fd6_program_emit() to avoid having to re-emit the prog
725 * every time rast state changes.
727 * Since the primitive restart state is not part of a tracked object, we
728 * re-emit this register every time.
730 if (emit
->info
&& ctx
->rasterizer
) {
731 struct fd6_rasterizer_stateobj
*rasterizer
=
732 fd6_rasterizer_stateobj(ctx
->rasterizer
);
733 OUT_PKT4(ring
, REG_A6XX_PC_UNKNOWN_9806
, 1);
735 OUT_PKT4(ring
, REG_A6XX_PC_UNKNOWN_9990
, 1);
737 OUT_PKT4(ring
, REG_A6XX_VFD_UNKNOWN_A008
, 1);
741 OUT_PKT4(ring
, REG_A6XX_PC_PRIMITIVE_CNTL_0
, 1);
742 OUT_RING(ring
, rasterizer
->pc_primitive_cntl
|
743 COND(emit
->info
->primitive_restart
&& emit
->info
->index_size
,
744 A6XX_PC_PRIMITIVE_CNTL_0_PRIMITIVE_RESTART
));
747 if (dirty
& (FD_DIRTY_FRAMEBUFFER
| FD_DIRTY_RASTERIZER
| FD_DIRTY_PROG
)) {
748 uint32_t posz_regid
= ir3_find_output_regid(fp
, FRAG_RESULT_DEPTH
);
749 unsigned nr
= pfb
->nr_cbufs
;
751 if (emit
->key
.binning_pass
)
753 else if (ctx
->rasterizer
->rasterizer_discard
)
756 OUT_PKT4(ring
, REG_A6XX_RB_FS_OUTPUT_CNTL0
, 2);
757 OUT_RING(ring
, COND(fp
->writes_pos
, A6XX_RB_FS_OUTPUT_CNTL0_FRAG_WRITES_Z
));
758 OUT_RING(ring
, A6XX_RB_FS_OUTPUT_CNTL1_MRT(nr
));
760 OUT_PKT4(ring
, REG_A6XX_SP_FS_OUTPUT_CNTL0
, 2);
761 OUT_RING(ring
, A6XX_SP_FS_OUTPUT_CNTL0_DEPTH_REGID(posz_regid
) |
763 OUT_RING(ring
, A6XX_SP_FS_OUTPUT_CNTL1_MRT(nr
));
766 ir3_emit_vs_consts(vp
, ring
, ctx
, emit
->info
);
767 if (!emit
->key
.binning_pass
)
768 ir3_emit_fs_consts(fp
, ring
, ctx
);
770 struct pipe_stream_output_info
*info
= &vp
->shader
->stream_output
;
771 if (info
->num_outputs
) {
772 struct fd_streamout_stateobj
*so
= &ctx
->streamout
;
774 emit
->streamout_mask
= 0;
776 for (unsigned i
= 0; i
< so
->num_targets
; i
++) {
777 struct pipe_stream_output_target
*target
= so
->targets
[i
];
782 unsigned offset
= (so
->offsets
[i
] * info
->stride
[i
] * 4) +
783 target
->buffer_offset
;
785 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_BASE_LO(i
), 3);
786 /* VPC_SO[i].BUFFER_BASE_LO: */
787 OUT_RELOCW(ring
, fd_resource(target
->buffer
)->bo
, 0, 0, 0);
788 OUT_RING(ring
, target
->buffer_size
+ offset
);
790 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_OFFSET(i
), 3);
791 OUT_RING(ring
, offset
);
792 /* VPC_SO[i].FLUSH_BASE_LO/HI: */
793 // TODO just give hw a dummy addr for now.. we should
794 // be using this an then CP_MEM_TO_REG to set the
795 // VPC_SO[i].BUFFER_OFFSET for the next draw..
796 OUT_RELOCW(ring
, fd6_context(ctx
)->blit_mem
, 0x100, 0, 0);
798 emit
->streamout_mask
|= (1 << i
);
801 if (emit
->streamout_mask
) {
802 struct fd6_streamout_state
*tf
= &fd6_context(ctx
)->tf
;
804 OUT_PKT7(ring
, CP_CONTEXT_REG_BUNCH
, 12 + (2 * tf
->prog_count
));
805 OUT_RING(ring
, REG_A6XX_VPC_SO_BUF_CNTL
);
806 OUT_RING(ring
, tf
->vpc_so_buf_cntl
);
807 OUT_RING(ring
, REG_A6XX_VPC_SO_NCOMP(0));
808 OUT_RING(ring
, tf
->ncomp
[0]);
809 OUT_RING(ring
, REG_A6XX_VPC_SO_NCOMP(1));
810 OUT_RING(ring
, tf
->ncomp
[1]);
811 OUT_RING(ring
, REG_A6XX_VPC_SO_NCOMP(2));
812 OUT_RING(ring
, tf
->ncomp
[2]);
813 OUT_RING(ring
, REG_A6XX_VPC_SO_NCOMP(3));
814 OUT_RING(ring
, tf
->ncomp
[3]);
815 OUT_RING(ring
, REG_A6XX_VPC_SO_CNTL
);
816 OUT_RING(ring
, A6XX_VPC_SO_CNTL_ENABLE
);
817 for (unsigned i
= 0; i
< tf
->prog_count
; i
++) {
818 OUT_RING(ring
, REG_A6XX_VPC_SO_PROG
);
819 OUT_RING(ring
, tf
->prog
[i
]);
822 OUT_PKT4(ring
, REG_A6XX_VPC_SO_OVERRIDE
, 1);
825 OUT_PKT7(ring
, CP_CONTEXT_REG_BUNCH
, 4);
826 OUT_RING(ring
, REG_A6XX_VPC_SO_CNTL
);
828 OUT_RING(ring
, REG_A6XX_VPC_SO_BUF_CNTL
);
831 OUT_PKT4(ring
, REG_A6XX_VPC_SO_OVERRIDE
, 1);
832 OUT_RING(ring
, A6XX_VPC_SO_OVERRIDE_SO_DISABLE
);
836 if ((dirty
& FD_DIRTY_BLEND
)) {
837 struct fd6_blend_stateobj
*blend
= fd6_blend_stateobj(ctx
->blend
);
840 for (i
= 0; i
< A6XX_MAX_RENDER_TARGETS
; i
++) {
841 enum pipe_format format
= pipe_surface_format(pfb
->cbufs
[i
]);
842 bool is_int
= util_format_is_pure_integer(format
);
843 bool has_alpha
= util_format_has_alpha(format
);
844 uint32_t control
= blend
->rb_mrt
[i
].control
;
845 uint32_t blend_control
= blend
->rb_mrt
[i
].blend_control_alpha
;
848 control
&= A6XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK
;
849 control
|= A6XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY
);
853 blend_control
|= blend
->rb_mrt
[i
].blend_control_rgb
;
855 blend_control
|= blend
->rb_mrt
[i
].blend_control_no_alpha_rgb
;
856 control
&= ~A6XX_RB_MRT_CONTROL_BLEND2
;
859 OUT_PKT4(ring
, REG_A6XX_RB_MRT_CONTROL(i
), 1);
860 OUT_RING(ring
, control
);
862 OUT_PKT4(ring
, REG_A6XX_RB_MRT_BLEND_CONTROL(i
), 1);
863 OUT_RING(ring
, blend_control
);
866 OUT_PKT4(ring
, REG_A6XX_RB_BLEND_CNTL
, 1);
867 OUT_RING(ring
, blend
->rb_blend_cntl
|
868 A6XX_RB_BLEND_CNTL_SAMPLE_MASK(0xffff));
870 OUT_PKT4(ring
, REG_A6XX_SP_BLEND_CNTL
, 1);
871 OUT_RING(ring
, blend
->sp_blend_cntl
);
874 if (dirty
& FD_DIRTY_BLEND_COLOR
) {
875 struct pipe_blend_color
*bcolor
= &ctx
->blend_color
;
877 OUT_PKT4(ring
, REG_A6XX_RB_BLEND_RED_F32
, 4);
878 OUT_RING(ring
, A6XX_RB_BLEND_RED_F32(bcolor
->color
[0]));
879 OUT_RING(ring
, A6XX_RB_BLEND_GREEN_F32(bcolor
->color
[1]));
880 OUT_RING(ring
, A6XX_RB_BLEND_BLUE_F32(bcolor
->color
[2]));
881 OUT_RING(ring
, A6XX_RB_BLEND_ALPHA_F32(bcolor
->color
[3]));
884 if (ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] & FD_DIRTY_SHADER_TEX
) {
885 needs_border
|= emit_textures(ctx
, ring
, SB6_VS_TEX
,
886 &ctx
->tex
[PIPE_SHADER_VERTEX
]);
887 OUT_PKT4(ring
, REG_A6XX_SP_VS_TEX_COUNT
, 1);
888 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_VERTEX
].num_textures
);
891 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_TEX
) {
892 needs_border
|= emit_textures(ctx
, ring
, SB6_FS_TEX
,
893 &ctx
->tex
[PIPE_SHADER_FRAGMENT
]);
894 OUT_PKT4(ring
, REG_A6XX_SP_FS_TEX_COUNT
, 1);
895 OUT_RING(ring
, ctx
->tex
[PIPE_SHADER_FRAGMENT
].num_textures
);
899 OUT_PKT4(ring
, REG_A6XX_TPL1_FS_TEX_COUNT
, 1);
900 OUT_RING(ring
, ctx
->shaderimg
[PIPE_SHADER_FRAGMENT
].enabled_mask
?
901 ~0 : ctx
->tex
[PIPE_SHADER_FRAGMENT
].num_textures
);
903 OUT_PKT4(ring
, REG_A6XX_TPL1_CS_TEX_COUNT
, 1);
908 emit_border_color(ctx
, ring
);
910 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_SSBO
)
911 emit_ssbos(ctx
, ring
, SB6_SSBO
, &ctx
->shaderbuf
[PIPE_SHADER_FRAGMENT
]);
913 if (ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] & FD_DIRTY_SHADER_IMAGE
)
914 fd6_emit_images(ctx
, ring
, PIPE_SHADER_FRAGMENT
);
918 fd6_emit_cs_state(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
919 struct ir3_shader_variant
*cp
)
921 enum fd_dirty_shader_state dirty
= ctx
->dirty_shader
[PIPE_SHADER_COMPUTE
];
923 if (dirty
& FD_DIRTY_SHADER_TEX
) {
924 bool needs_border
= false;
925 needs_border
|= emit_textures(ctx
, ring
, SB6_CS_TEX
,
926 &ctx
->tex
[PIPE_SHADER_COMPUTE
]);
929 emit_border_color(ctx
, ring
);
932 OUT_PKT4(ring
, REG_A6XX_TPL1_VS_TEX_COUNT
, 1);
935 OUT_PKT4(ring
, REG_A6XX_TPL1_HS_TEX_COUNT
, 1);
938 OUT_PKT4(ring
, REG_A6XX_TPL1_DS_TEX_COUNT
, 1);
941 OUT_PKT4(ring
, REG_A6XX_TPL1_GS_TEX_COUNT
, 1);
944 OUT_PKT4(ring
, REG_A6XX_TPL1_FS_TEX_COUNT
, 1);
950 OUT_PKT4(ring
, REG_A6XX_TPL1_CS_TEX_COUNT
, 1);
951 OUT_RING(ring
, ctx
->shaderimg
[PIPE_SHADER_COMPUTE
].enabled_mask
?
952 ~0 : ctx
->tex
[PIPE_SHADER_COMPUTE
].num_textures
);
955 if (dirty
& FD_DIRTY_SHADER_SSBO
)
956 emit_ssbos(ctx
, ring
, SB6_CS_SSBO
, &ctx
->shaderbuf
[PIPE_SHADER_COMPUTE
]);
958 if (dirty
& FD_DIRTY_SHADER_IMAGE
)
959 fd6_emit_images(ctx
, ring
, PIPE_SHADER_COMPUTE
);
963 /* emit setup at begin of new cmdstream buffer (don't rely on previous
964 * state, there could have been a context switch between ioctls):
967 fd6_emit_restore(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
)
969 //struct fd_context *ctx = batch->ctx;
971 fd6_cache_flush(batch
, ring
);
973 OUT_PKT4(ring
, REG_A6XX_HLSQ_UPDATE_CNTL
, 1);
974 OUT_RING(ring
, 0xfffff);
977 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
978 0000000500024048: 70d08003 00000000 001c5000 00000005
979 t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords)
980 0000000500024058: 70d08003 00000010 001c7000 00000005
982 t7 opcode: CP_WAIT_FOR_IDLE (26) (1 dwords)
983 0000000500024068: 70268000
986 WRITE(REG_A6XX_RB_CCU_CNTL
, 0x7c400004);
987 WRITE(REG_A6XX_RB_UNKNOWN_8E04
, 0x00100000);
988 WRITE(REG_A6XX_SP_UNKNOWN_AE04
, 0x8);
989 WRITE(REG_A6XX_SP_UNKNOWN_AE00
, 0);
990 WRITE(REG_A6XX_SP_UNKNOWN_AE0F
, 0x3f);
991 WRITE(REG_A6XX_SP_UNKNOWN_B605
, 0x44);
992 WRITE(REG_A6XX_SP_UNKNOWN_B600
, 0x100000);
993 WRITE(REG_A6XX_HLSQ_UNKNOWN_BE00
, 0x80);
994 WRITE(REG_A6XX_HLSQ_UNKNOWN_BE01
, 0);
996 WRITE(REG_A6XX_VPC_UNKNOWN_9600
, 0);
997 WRITE(REG_A6XX_GRAS_UNKNOWN_8600
, 0x880);
998 WRITE(REG_A6XX_HLSQ_UNKNOWN_BE04
, 0);
999 WRITE(REG_A6XX_SP_UNKNOWN_AE03
, 0x00000410);
1000 WRITE(REG_A6XX_SP_UNKNOWN_AB20
, 0);
1001 WRITE(REG_A6XX_SP_UNKNOWN_B182
, 0);
1002 WRITE(REG_A6XX_HLSQ_UNKNOWN_BB11
, 0);
1003 WRITE(REG_A6XX_UCHE_UNKNOWN_0E12
, 0x3200000);
1004 WRITE(REG_A6XX_UCHE_CLIENT_PF
, 4);
1005 WRITE(REG_A6XX_RB_UNKNOWN_8E01
, 0x0);
1006 WRITE(REG_A6XX_SP_UNKNOWN_AB00
, 0x5);
1007 WRITE(REG_A6XX_VFD_UNKNOWN_A009
, 0x00000001);
1008 WRITE(REG_A6XX_RB_UNKNOWN_8811
, 0x00000010);
1009 WRITE(REG_A6XX_PC_MODE_CNTL
, 0x1f);
1011 OUT_PKT4(ring
, REG_A6XX_RB_SRGB_CNTL
, 1);
1014 WRITE(REG_A6XX_GRAS_UNKNOWN_8101
, 0);
1015 WRITE(REG_A6XX_GRAS_2D_BLIT_INFO
,
1016 A6XX_GRAS_2D_BLIT_INFO_COLOR_FORMAT(RB6_R8G8B8_UNORM
));
1017 WRITE(REG_A6XX_GRAS_UNKNOWN_8109
, 0);
1018 WRITE(REG_A6XX_GRAS_UNKNOWN_8110
, 0);
1020 WRITE(REG_A6XX_RB_RENDER_CONTROL0
, 0x401);
1021 WRITE(REG_A6XX_RB_RENDER_CONTROL1
, 0);
1022 WRITE(REG_A6XX_RB_FS_OUTPUT_CNTL0
, 0);
1023 WRITE(REG_A6XX_RB_UNKNOWN_8810
, 0);
1024 WRITE(REG_A6XX_RB_UNKNOWN_8818
, 0);
1025 WRITE(REG_A6XX_RB_UNKNOWN_8819
, 0);
1026 WRITE(REG_A6XX_RB_UNKNOWN_881A
, 0);
1027 WRITE(REG_A6XX_RB_UNKNOWN_881B
, 0);
1028 WRITE(REG_A6XX_RB_UNKNOWN_881C
, 0);
1029 WRITE(REG_A6XX_RB_UNKNOWN_881D
, 0);
1030 WRITE(REG_A6XX_RB_UNKNOWN_881E
, 0);
1031 WRITE(REG_A6XX_RB_UNKNOWN_88F0
, 0);
1033 WRITE(REG_A6XX_VPC_UNKNOWN_9101
, 0xffff00);
1034 WRITE(REG_A6XX_VPC_UNKNOWN_9107
, 0);
1036 WRITE(REG_A6XX_VPC_UNKNOWN_9236
, 1);
1037 WRITE(REG_A6XX_VPC_UNKNOWN_9300
, 0);
1039 WRITE(REG_A6XX_VPC_SO_OVERRIDE
, A6XX_VPC_SO_OVERRIDE_SO_DISABLE
);
1041 WRITE(REG_A6XX_PC_UNKNOWN_9801
, 0);
1042 WRITE(REG_A6XX_PC_UNKNOWN_9806
, 0);
1043 WRITE(REG_A6XX_PC_UNKNOWN_9980
, 0);
1045 WRITE(REG_A6XX_PC_UNKNOWN_9B06
, 0);
1046 WRITE(REG_A6XX_PC_UNKNOWN_9B06
, 0);
1048 WRITE(REG_A6XX_SP_UNKNOWN_A81B
, 0);
1050 WRITE(REG_A6XX_SP_UNKNOWN_B183
, 0);
1052 WRITE(REG_A6XX_GRAS_UNKNOWN_8099
, 0);
1053 WRITE(REG_A6XX_GRAS_UNKNOWN_809B
, 0);
1054 WRITE(REG_A6XX_GRAS_UNKNOWN_80A0
, 2);
1055 WRITE(REG_A6XX_GRAS_UNKNOWN_80AF
, 0);
1056 WRITE(REG_A6XX_VPC_UNKNOWN_9210
, 0);
1057 WRITE(REG_A6XX_VPC_UNKNOWN_9211
, 0);
1058 WRITE(REG_A6XX_VPC_UNKNOWN_9602
, 0);
1059 WRITE(REG_A6XX_PC_UNKNOWN_9981
, 0x3);
1060 WRITE(REG_A6XX_PC_UNKNOWN_9E72
, 0);
1061 WRITE(REG_A6XX_VPC_UNKNOWN_9108
, 0x3);
1062 WRITE(REG_A6XX_SP_TP_UNKNOWN_B304
, 0);
1063 WRITE(REG_A6XX_SP_TP_UNKNOWN_B309
, 0x000000a2);
1064 WRITE(REG_A6XX_RB_UNKNOWN_8804
, 0);
1065 WRITE(REG_A6XX_GRAS_UNKNOWN_80A4
, 0);
1066 WRITE(REG_A6XX_GRAS_UNKNOWN_80A5
, 0);
1067 WRITE(REG_A6XX_GRAS_UNKNOWN_80A6
, 0);
1068 WRITE(REG_A6XX_RB_UNKNOWN_8805
, 0);
1069 WRITE(REG_A6XX_RB_UNKNOWN_8806
, 0);
1070 WRITE(REG_A6XX_RB_UNKNOWN_8878
, 0);
1071 WRITE(REG_A6XX_RB_UNKNOWN_8879
, 0);
1072 WRITE(REG_A6XX_HLSQ_CONTROL_5_REG
, 0xfc);
1074 emit_marker6(ring
, 7);
1076 OUT_PKT4(ring
, REG_A6XX_VFD_MODE_CNTL
, 1);
1077 OUT_RING(ring
, 0x00000000); /* VFD_MODE_CNTL */
1079 WRITE(REG_A6XX_VFD_UNKNOWN_A008
, 0);
1081 OUT_PKT4(ring
, REG_A6XX_PC_MODE_CNTL
, 1);
1082 OUT_RING(ring
, 0x0000001f); /* PC_MODE_CNTL */
1084 /* we don't use this yet.. probably best to disable.. */
1085 OUT_PKT7(ring
, CP_SET_DRAW_STATE
, 3);
1086 OUT_RING(ring
, CP_SET_DRAW_STATE__0_COUNT(0) |
1087 CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS
|
1088 CP_SET_DRAW_STATE__0_GROUP_ID(0));
1089 OUT_RING(ring
, CP_SET_DRAW_STATE__1_ADDR_LO(0));
1090 OUT_RING(ring
, CP_SET_DRAW_STATE__2_ADDR_HI(0));
1092 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_BASE_LO(0), 3);
1093 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_LO_0 */
1094 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_BASE_HI_0 */
1095 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUFFER_SIZE_0 */
1097 OUT_PKT4(ring
, REG_A6XX_VPC_SO_FLUSH_BASE_LO(0), 2);
1098 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_LO_0 */
1099 OUT_RING(ring
, 0x00000000); /* VPC_SO_FLUSH_BASE_HI_0 */
1101 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUF_CNTL
, 1);
1102 OUT_RING(ring
, 0x00000000); /* VPC_SO_BUF_CNTL */
1104 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_OFFSET(0), 1);
1105 OUT_RING(ring
, 0x00000000); /* UNKNOWN_E2AB */
1107 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_BASE_LO(1), 3);
1108 OUT_RING(ring
, 0x00000000);
1109 OUT_RING(ring
, 0x00000000);
1110 OUT_RING(ring
, 0x00000000);
1112 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_OFFSET(1), 6);
1113 OUT_RING(ring
, 0x00000000);
1114 OUT_RING(ring
, 0x00000000);
1115 OUT_RING(ring
, 0x00000000);
1116 OUT_RING(ring
, 0x00000000);
1117 OUT_RING(ring
, 0x00000000);
1118 OUT_RING(ring
, 0x00000000);
1120 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_OFFSET(2), 6);
1121 OUT_RING(ring
, 0x00000000);
1122 OUT_RING(ring
, 0x00000000);
1123 OUT_RING(ring
, 0x00000000);
1124 OUT_RING(ring
, 0x00000000);
1125 OUT_RING(ring
, 0x00000000);
1126 OUT_RING(ring
, 0x00000000);
1128 OUT_PKT4(ring
, REG_A6XX_VPC_SO_BUFFER_OFFSET(3), 3);
1129 OUT_RING(ring
, 0x00000000);
1130 OUT_RING(ring
, 0x00000000);
1131 OUT_RING(ring
, 0x00000000);
1133 OUT_PKT4(ring
, REG_A6XX_SP_HS_CTRL_REG0
, 1);
1134 OUT_RING(ring
, 0x00000000);
1136 OUT_PKT4(ring
, REG_A6XX_SP_GS_CTRL_REG0
, 1);
1137 OUT_RING(ring
, 0x00000000);
1141 fd6_emit_ib(struct fd_ringbuffer
*ring
, struct fd_ringbuffer
*target
)
1143 emit_marker6(ring
, 6);
1144 __OUT_IB5(ring
, target
);
1145 emit_marker6(ring
, 6);
1149 fd6_mem_to_mem(struct fd_ringbuffer
*ring
, struct pipe_resource
*dst
,
1150 unsigned dst_off
, struct pipe_resource
*src
, unsigned src_off
,
1151 unsigned sizedwords
)
1153 struct fd_bo
*src_bo
= fd_resource(src
)->bo
;
1154 struct fd_bo
*dst_bo
= fd_resource(dst
)->bo
;
1157 for (i
= 0; i
< sizedwords
; i
++) {
1158 OUT_PKT7(ring
, CP_MEM_TO_MEM
, 5);
1159 OUT_RING(ring
, 0x00000000);
1160 OUT_RELOCW(ring
, dst_bo
, dst_off
, 0, 0);
1161 OUT_RELOC (ring
, src_bo
, src_off
, 0, 0);
1169 fd6_emit_init(struct pipe_context
*pctx
)
1171 struct fd_context
*ctx
= fd_context(pctx
);
1172 ctx
->emit_const
= fd6_emit_const
;
1173 ctx
->emit_const_bo
= fd6_emit_const_bo
;
1174 ctx
->emit_ib
= fd6_emit_ib
;
1175 ctx
->mem_to_mem
= fd6_mem_to_mem
;