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_prim.h"
33 #include "freedreno_state.h"
34 #include "freedreno_resource.h"
37 #include "fd6_context.h"
39 #include "fd6_program.h"
40 #include "fd6_format.h"
43 /* some bits in common w/ a4xx: */
44 #include "a4xx/fd4_draw.h"
47 draw_emit_indirect(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
,
48 enum pc_di_primtype primtype
,
49 enum pc_di_vis_cull_mode vismode
,
50 const struct pipe_draw_info
*info
,
51 unsigned index_offset
)
53 struct fd_resource
*ind
= fd_resource(info
->indirect
->buffer
);
55 if (info
->index_size
) {
56 struct pipe_resource
*idx
= info
->index
.resource
;
57 unsigned max_indicies
= (idx
->width0
- info
->indirect
->offset
) /
60 OUT_PKT7(ring
, CP_DRAW_INDX_INDIRECT
, 6);
61 OUT_RINGP(ring
, DRAW4(primtype
, DI_SRC_SEL_DMA
,
62 fd4_size2indextype(info
->index_size
), 0),
63 &batch
->draw_patches
);
64 OUT_RELOC(ring
, fd_resource(idx
)->bo
,
66 // XXX: Check A5xx vs A6xx
67 OUT_RING(ring
, A5XX_CP_DRAW_INDX_INDIRECT_3_MAX_INDICES(max_indicies
));
68 OUT_RELOC(ring
, ind
->bo
, info
->indirect
->offset
, 0, 0);
70 OUT_PKT7(ring
, CP_DRAW_INDIRECT
, 3);
71 OUT_RINGP(ring
, DRAW4(primtype
, DI_SRC_SEL_AUTO_INDEX
, 0, 0),
72 &batch
->draw_patches
);
73 OUT_RELOC(ring
, ind
->bo
, info
->indirect
->offset
, 0, 0);
78 draw_emit(struct fd_batch
*batch
, struct fd_ringbuffer
*ring
,
79 enum pc_di_primtype primtype
,
80 enum pc_di_vis_cull_mode vismode
,
81 const struct pipe_draw_info
*info
,
82 unsigned index_offset
)
84 enum pc_di_src_sel src_sel
;
86 if (info
->index_size
) {
87 assert(!info
->has_user_indices
);
89 struct pipe_resource
*idx_buffer
= info
->index
.resource
;
90 uint32_t idx_size
= info
->index_size
* info
->count
;
91 uint32_t idx_offset
= index_offset
+ info
->start
* info
->index_size
;
92 enum a4xx_index_size idx_type
= fd4_size2indextype(info
->index_size
);
93 src_sel
= DI_SRC_SEL_DMA
;
95 OUT_PKT7(ring
, CP_DRAW_INDX_OFFSET
, 7);
96 if (vismode
== USE_VISIBILITY
) {
97 /* leave vis mode blank for now, it will be patched up when
98 * we know if we are binning or not
100 OUT_RINGP(ring
, DRAW4(primtype
, src_sel
, idx_type
, 0) | 0x2000,
101 &batch
->draw_patches
);
103 OUT_RING(ring
, DRAW4(primtype
, src_sel
, idx_type
, vismode
) | 0x2000);
105 OUT_RING(ring
, info
->instance_count
); /* NumInstances */
106 OUT_RING(ring
, info
->count
); /* NumIndices */
107 OUT_RING(ring
, 0x0); /* XXX */
108 OUT_RELOC(ring
, fd_resource(idx_buffer
)->bo
, idx_offset
, 0, 0);
109 OUT_RING (ring
, idx_size
);
111 src_sel
= DI_SRC_SEL_AUTO_INDEX
;
113 OUT_PKT7(ring
, CP_DRAW_INDX_OFFSET
, 3);
114 if (vismode
== USE_VISIBILITY
) {
115 /* leave vis mode blank for now, it will be patched up when
116 * we know if we are binning or not
118 OUT_RINGP(ring
, DRAW4(primtype
, src_sel
, INDEX4_SIZE_32_BIT
, 0) | 0x2000,
119 &batch
->draw_patches
);
121 OUT_RING(ring
, DRAW4(primtype
, src_sel
, INDEX4_SIZE_32_BIT
, vismode
) | 0x2000);
123 OUT_RING(ring
, info
->instance_count
); /* NumInstances */
124 OUT_RING(ring
, info
->count
); /* NumIndices */
129 draw_impl(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
130 struct fd6_emit
*emit
, unsigned index_offset
)
132 const struct pipe_draw_info
*info
= emit
->info
;
133 enum pc_di_primtype primtype
= ctx
->primtypes
[info
->mode
];
135 fd6_emit_state(ctx
, ring
, emit
);
137 if (emit
->dirty
& (FD_DIRTY_VTXBUF
| FD_DIRTY_VTXSTATE
))
138 fd6_emit_vertex_bufs(ring
, emit
);
140 OUT_PKT4(ring
, REG_A6XX_VFD_INDEX_OFFSET
, 2);
141 OUT_RING(ring
, info
->index_size
? info
->index_bias
: info
->start
); /* VFD_INDEX_OFFSET */
142 OUT_RING(ring
, info
->start_instance
); /* VFD_INSTANCE_START_OFFSET */
144 OUT_PKT4(ring
, REG_A6XX_PC_RESTART_INDEX
, 1);
145 OUT_RING(ring
, info
->primitive_restart
? /* PC_RESTART_INDEX */
146 info
->restart_index
: 0xffffffff);
148 fd6_emit_render_cntl(ctx
, false, emit
->key
.binning_pass
);
150 /* for debug after a lock up, write a unique counter value
151 * to scratch7 for each draw, to make it easier to match up
152 * register dumps to cmdstream. The combination of IB
153 * (scratch6) and DRAW is enough to "triangulate" the
154 * particular draw that caused lockup.
156 emit_marker6(ring
, 7);
158 if (info
->indirect
) {
159 draw_emit_indirect(ctx
->batch
, ring
, primtype
,
160 emit
->key
.binning_pass
? IGNORE_VISIBILITY
: USE_VISIBILITY
,
163 draw_emit(ctx
->batch
, ring
, primtype
,
164 emit
->key
.binning_pass
? IGNORE_VISIBILITY
: USE_VISIBILITY
,
168 emit_marker6(ring
, 7);
169 fd_reset_wfi(ctx
->batch
);
172 /* fixup dirty shader state in case some "unrelated" (from the state-
173 * tracker's perspective) state change causes us to switch to a
177 fixup_shader_state(struct fd_context
*ctx
, struct ir3_shader_key
*key
)
179 struct fd6_context
*fd6_ctx
= fd6_context(ctx
);
180 struct ir3_shader_key
*last_key
= &fd6_ctx
->last_key
;
182 if (!ir3_shader_key_equal(last_key
, key
)) {
183 if (ir3_shader_key_changes_fs(last_key
, key
)) {
184 ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] |= FD_DIRTY_SHADER_PROG
;
185 ctx
->dirty
|= FD_DIRTY_PROG
;
188 if (ir3_shader_key_changes_vs(last_key
, key
)) {
189 ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] |= FD_DIRTY_SHADER_PROG
;
190 ctx
->dirty
|= FD_DIRTY_PROG
;
193 fd6_ctx
->last_key
= *key
;
198 fd6_draw_vbo(struct fd_context
*ctx
, const struct pipe_draw_info
*info
,
199 unsigned index_offset
)
201 struct fd6_context
*fd6_ctx
= fd6_context(ctx
);
202 struct fd6_emit emit
= {
203 .debug
= &ctx
->debug
,
208 .color_two_side
= ctx
->rasterizer
->light_twoside
,
209 .vclamp_color
= ctx
->rasterizer
->clamp_vertex_color
,
210 .fclamp_color
= ctx
->rasterizer
->clamp_fragment_color
,
211 .rasterflat
= ctx
->rasterizer
->flatshade
,
212 .half_precision
= ctx
->in_blit
&&
213 fd_half_precision(&ctx
->batch
->framebuffer
),
214 .ucp_enables
= ctx
->rasterizer
->clip_plane_enable
,
215 .has_per_samp
= (fd6_ctx
->fsaturate
|| fd6_ctx
->vsaturate
||
216 fd6_ctx
->fastc_srgb
|| fd6_ctx
->vastc_srgb
),
217 .vsaturate_s
= fd6_ctx
->vsaturate_s
,
218 .vsaturate_t
= fd6_ctx
->vsaturate_t
,
219 .vsaturate_r
= fd6_ctx
->vsaturate_r
,
220 .fsaturate_s
= fd6_ctx
->fsaturate_s
,
221 .fsaturate_t
= fd6_ctx
->fsaturate_t
,
222 .fsaturate_r
= fd6_ctx
->fsaturate_r
,
223 .vastc_srgb
= fd6_ctx
->vastc_srgb
,
224 .fastc_srgb
= fd6_ctx
->fastc_srgb
,
225 .vsamples
= ctx
->tex
[PIPE_SHADER_VERTEX
].samples
,
226 .fsamples
= ctx
->tex
[PIPE_SHADER_FRAGMENT
].samples
,
228 .rasterflat
= ctx
->rasterizer
->flatshade
,
229 .sprite_coord_enable
= ctx
->rasterizer
->sprite_coord_enable
,
230 .sprite_coord_mode
= ctx
->rasterizer
->sprite_coord_mode
,
233 fixup_shader_state(ctx
, &emit
.key
);
235 unsigned dirty
= ctx
->dirty
;
236 const struct ir3_shader_variant
*vp
= fd6_emit_get_vp(&emit
);
237 const struct ir3_shader_variant
*fp
= fd6_emit_get_fp(&emit
);
239 /* do regular pass first, since that is more likely to fail compiling: */
244 ctx
->stats
.vs_regs
+= ir3_shader_halfregs(vp
);
245 ctx
->stats
.fs_regs
+= ir3_shader_halfregs(fp
);
247 /* figure out whether we need to disable LRZ write for binning
248 * pass using draw pass's fp:
250 emit
.no_lrz_write
= fp
->writes_pos
|| fp
->has_kill
;
252 emit
.key
.binning_pass
= false;
255 draw_impl(ctx
, ctx
->batch
->draw
, &emit
, index_offset
);
257 /* and now binning pass: */
258 emit
.key
.binning_pass
= true;
259 emit
.dirty
= dirty
& ~(FD_DIRTY_BLEND
);
260 emit
.vp
= NULL
; /* we changed key so need to refetch vp */
262 draw_impl(ctx
, ctx
->batch
->binning
, &emit
, index_offset
);
264 if (emit
.streamout_mask
) {
265 struct fd_ringbuffer
*ring
= ctx
->batch
->draw
;
267 for (unsigned i
= 0; i
< PIPE_MAX_SO_BUFFERS
; i
++) {
268 if (emit
.streamout_mask
& (1 << i
)) {
269 OUT_PKT7(ring
, CP_EVENT_WRITE
, 1);
270 OUT_RING(ring
, FLUSH_SO_0
+ i
);
275 fd_context_all_clean(ctx
);
280 static bool is_z32(enum pipe_format format
)
283 case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
:
284 case PIPE_FORMAT_Z32_UNORM
:
285 case PIPE_FORMAT_Z32_FLOAT
:
294 fd6_clear_lrz(struct fd_batch
*batch
, struct fd_resource
*zsbuf
, double depth
)
296 struct fd_ringbuffer
*ring
;
297 uint32_t clear
= util_pack_z(PIPE_FORMAT_Z16_UNORM
, depth
);
299 // TODO mid-frame clears (ie. app doing crazy stuff)?? Maybe worth
300 // splitting both clear and lrz clear out into their own rb's. And
301 // just throw away any draws prior to clear. (Anything not fullscreen
302 // clear, just fallback to generic path that treats it as a normal
305 if (!batch
->lrz_clear
) {
306 batch
->lrz_clear
= fd_ringbuffer_new(batch
->ctx
->pipe
, 0x1000);
307 fd_ringbuffer_set_parent(batch
->lrz_clear
, batch
->gmem
);
310 ring
= batch
->lrz_clear
;
314 OUT_PKT4(ring
, REG_A6XX_RB_CCU_CNTL
, 1);
315 OUT_RING(ring
, 0x10000000);
317 OUT_PKT4(ring
, REG_A6XX_HLSQ_UPDATE_CNTL
, 1);
318 OUT_RING(ring
, 0x20fffff);
320 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_CNTL
, 1);
321 OUT_RING(ring
, A6XX_GRAS_SU_CNTL_LINEHALFWIDTH(0.0));
323 OUT_PKT4(ring
, REG_A6XX_GRAS_CNTL
, 1);
324 OUT_RING(ring
, 0x00000000);
326 OUT_PKT4(ring
, REG_A6XX_GRAS_CL_CNTL
, 1);
327 OUT_RING(ring
, 0x00000181);
329 OUT_PKT4(ring
, REG_A6XX_GRAS_LRZ_CNTL
, 1);
330 OUT_RING(ring
, 0x00000000);
332 OUT_PKT4(ring
, REG_A6XX_RB_MRT_BUF_INFO(0), 5);
333 OUT_RING(ring
, A6XX_RB_MRT_BUF_INFO_COLOR_FORMAT(RB5_R16_UNORM
) |
334 A6XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(TILE6_LINEAR
) |
335 A6XX_RB_MRT_BUF_INFO_COLOR_SWAP(WZYX
));
336 OUT_RING(ring
, A6XX_RB_MRT_PITCH(zsbuf
->lrz_pitch
* 2));
337 OUT_RING(ring
, A6XX_RB_MRT_ARRAY_PITCH(fd_bo_size(zsbuf
->lrz
)));
338 OUT_RELOCW(ring
, zsbuf
->lrz
, 0x1000, 0, 0);
340 OUT_PKT4(ring
, REG_A6XX_RB_RENDER_CNTL
, 1);
341 OUT_RING(ring
, 0x00000000);
343 OUT_PKT4(ring
, REG_A6XX_RB_DEST_MSAA_CNTL
, 1);
344 OUT_RING(ring
, A6XX_RB_DEST_MSAA_CNTL_SAMPLES(MSAA_ONE
));
346 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CNTL
, 1);
347 OUT_RING(ring
, A6XX_RB_BLIT_CNTL_BUF(BLIT_MRT0
));
349 OUT_PKT4(ring
, REG_A6XX_RB_CLEAR_CNTL
, 1);
350 OUT_RING(ring
, A6XX_RB_CLEAR_CNTL_FAST_CLEAR
|
351 A6XX_RB_CLEAR_CNTL_MASK(0xf));
353 OUT_PKT4(ring
, REG_A6XX_RB_CLEAR_COLOR_DW0
, 1);
354 OUT_RING(ring
, clear
); /* RB_CLEAR_COLOR_DW0 */
356 OUT_PKT4(ring
, REG_A6XX_VSC_RESOLVE_CNTL
, 2);
357 OUT_RING(ring
, A6XX_VSC_RESOLVE_CNTL_X(zsbuf
->lrz_width
) |
358 A6XX_VSC_RESOLVE_CNTL_Y(zsbuf
->lrz_height
));
359 OUT_RING(ring
, 0x00000000); // XXX UNKNOWN_0CDE
361 OUT_PKT4(ring
, REG_A6XX_RB_CNTL
, 1);
362 OUT_RING(ring
, A6XX_RB_CNTL_BYPASS
);
364 OUT_PKT4(ring
, REG_A6XX_RB_RESOLVE_CNTL_1
, 2);
365 OUT_RING(ring
, A6XX_RB_RESOLVE_CNTL_1_X(0) |
366 A6XX_RB_RESOLVE_CNTL_1_Y(0));
367 OUT_RING(ring
, A6XX_RB_RESOLVE_CNTL_2_X(zsbuf
->lrz_width
- 1) |
368 A6XX_RB_RESOLVE_CNTL_2_Y(zsbuf
->lrz_height
- 1));
370 fd6_emit_blit(batch
->ctx
, ring
);
377 /* Clear with CP_BLIT */
378 WRITE(REG_A6XX_GRAS_2D_BLIT_CNTL
, 0x10f43180);
380 OUT_PKT4(ring
, REG_A6XX_SP_PS_2D_SRC_INFO
, 7);
389 WRITE(0xacc0, 0xf181);
390 WRITE(0xacc0, 0xf181);
392 WRITE(REG_A6XX_GRAS_2D_BLIT_CNTL
, 0x10f43180);
393 WRITE(REG_A6XX_RB_2D_BLIT_CNTL
, 0x10f43180);
395 OUT_PKT4(ring
, REG_A6XX_RB_2D_SRC_SOLID_C0
, 4);
398 OUT_RING(ring
, 0xff);
401 DBG("%x %x %x %x\n", color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
403 struct pipe_surface
*psurf
= pfb
->cbufs
[0];
404 struct fd_resource
*rsc
= fd_resource(psurf
->texture
);
405 struct fd_resource_slice
*slice
= fd_resource_slice(rsc
, psurf
->u
.tex
.level
);
407 uint32_t offset
= fd_resource_offset(rsc
, psurf
->u
.tex
.level
,
408 psurf
->u
.tex
.first_layer
);
409 uint32_t stride
= slice
->pitch
* rsc
->cpp
;
411 enum a6xx_color_fmt format
= fd6_pipe2color(pfmt
);
412 OUT_PKT4(ring
, REG_A6XX_RB_2D_DST_INFO
, 9);
414 A6XX_RB_2D_DST_INFO_COLOR_FORMAT(format
) |
415 A6XX_RB_2D_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
416 A6XX_RB_2D_DST_INFO_COLOR_SWAP(WXYZ
));
417 OUT_RELOCW(ring
, rsc
->bo
, offset
, 0, 0); /* RB_2D_DST_LO/HI */
418 OUT_RING(ring
, A6XX_RB_2D_DST_SIZE_PITCH(stride
));
425 OUT_PKT4(ring
, REG_A6XX_GRAS_2D_SRC_TL_X
, 4);
431 OUT_PKT4(ring
, REG_A6XX_GRAS_2D_DST_TL
, 2);
433 A6XX_GRAS_2D_DST_TL_X(ctx
->batch
->max_scissor
.minx
) |
434 A6XX_GRAS_2D_DST_TL_Y(ctx
->batch
->max_scissor
.miny
));
436 A6XX_GRAS_2D_DST_BR_X(ctx
->batch
->max_scissor
.maxx
) |
437 A6XX_GRAS_2D_DST_BR_Y(ctx
->batch
->max_scissor
.maxy
));
439 OUT_PKT7(ring
, CP_BLIT
, 1);
440 OUT_RING(ring
, CP_BLIT_0_OP(BLIT_OP_SCALE
));
445 fd6_clear(struct fd_context
*ctx
, unsigned buffers
,
446 const union pipe_color_union
*color
, double depth
, unsigned stencil
)
448 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
449 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
450 struct fd_ringbuffer
*ring
= ctx
->batch
->draw
;
452 if ((buffers
& (PIPE_CLEAR_DEPTH
| PIPE_CLEAR_STENCIL
)) &&
453 is_z32(pfb
->zsbuf
->format
))
456 fd6_emit_render_cntl(ctx
, true, false);
458 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_SCISSOR_TL
, 2);
459 OUT_RING(ring
, A6XX_RB_BLIT_SCISSOR_TL_X(scissor
->minx
) |
460 A6XX_RB_BLIT_SCISSOR_TL_Y(scissor
->miny
));
461 OUT_RING(ring
, A6XX_RB_BLIT_SCISSOR_BR_X(scissor
->maxx
- 1) |
462 A6XX_RB_BLIT_SCISSOR_BR_Y(scissor
->maxy
- 1));
464 if (buffers
& PIPE_CLEAR_COLOR
) {
465 for (int i
= 0; i
< pfb
->nr_cbufs
; i
++) {
466 union util_color uc
= {0};
471 if (!(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
474 enum pipe_format pfmt
= pfb
->cbufs
[i
]->format
;
476 // XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP??
477 union pipe_color_union swapped
;
478 switch (fd6_pipe2swap(pfmt
)) {
480 swapped
.ui
[0] = color
->ui
[0];
481 swapped
.ui
[1] = color
->ui
[1];
482 swapped
.ui
[2] = color
->ui
[2];
483 swapped
.ui
[3] = color
->ui
[3];
486 swapped
.ui
[2] = color
->ui
[0];
487 swapped
.ui
[1] = color
->ui
[1];
488 swapped
.ui
[0] = color
->ui
[2];
489 swapped
.ui
[3] = color
->ui
[3];
492 swapped
.ui
[3] = color
->ui
[0];
493 swapped
.ui
[0] = color
->ui
[1];
494 swapped
.ui
[1] = color
->ui
[2];
495 swapped
.ui
[2] = color
->ui
[3];
498 swapped
.ui
[3] = color
->ui
[0];
499 swapped
.ui
[2] = color
->ui
[1];
500 swapped
.ui
[1] = color
->ui
[2];
501 swapped
.ui
[0] = color
->ui
[3];
505 if (util_format_is_pure_uint(pfmt
)) {
506 util_format_write_4ui(pfmt
, swapped
.ui
, 0, &uc
, 0, 0, 0, 1, 1);
507 } else if (util_format_is_pure_sint(pfmt
)) {
508 util_format_write_4i(pfmt
, swapped
.i
, 0, &uc
, 0, 0, 0, 1, 1);
510 util_pack_color(swapped
.f
, pfmt
, &uc
);
513 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_DST_INFO
, 1);
514 OUT_RING(ring
, A6XX_RB_BLIT_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
515 A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(fd6_pipe2color(pfmt
)));
517 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_INFO
, 1);
518 OUT_RING(ring
, A6XX_RB_BLIT_INFO_GMEM
|
519 A6XX_RB_BLIT_INFO_CLEAR_MASK(0xf));
521 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_BASE_GMEM
, 1);
522 OUT_RINGP(ring
, i
, &ctx
->batch
->gmem_patches
);
524 OUT_PKT4(ring
, REG_A6XX_RB_UNKNOWN_88D0
, 1);
527 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CLEAR_COLOR_DW0
, 4);
528 OUT_RING(ring
, uc
.ui
[0]);
529 OUT_RING(ring
, uc
.ui
[1]);
530 OUT_RING(ring
, uc
.ui
[2]);
531 OUT_RING(ring
, uc
.ui
[3]);
533 fd6_emit_blit(ctx
, ring
);
537 if (pfb
->zsbuf
&& (buffers
& (PIPE_CLEAR_DEPTH
| PIPE_CLEAR_STENCIL
))) {
538 enum pipe_format pfmt
= pfb
->zsbuf
->format
;
539 uint32_t clear
= util_pack_z_stencil(pfmt
, depth
, stencil
);
542 if (buffers
& PIPE_CLEAR_DEPTH
)
545 if (buffers
& PIPE_CLEAR_STENCIL
)
548 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_DST_INFO
, 1);
549 OUT_RING(ring
, A6XX_RB_BLIT_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
550 A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(fd6_pipe2color(pfmt
)));
552 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_INFO
, 1);
553 OUT_RING(ring
, A6XX_RB_BLIT_INFO_GMEM
|
554 // XXX UNK0 for separate stencil ??
555 A6XX_RB_BLIT_INFO_DEPTH
|
556 A6XX_RB_BLIT_INFO_CLEAR_MASK(mask
));
558 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_BASE_GMEM
, 1);
559 OUT_RINGP(ring
, MAX_RENDER_TARGETS
, &ctx
->batch
->gmem_patches
);
561 OUT_PKT4(ring
, REG_A6XX_RB_UNKNOWN_88D0
, 1);
564 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CLEAR_COLOR_DW0
, 1);
565 OUT_RING(ring
, clear
);
567 fd6_emit_blit(ctx
, ring
);
570 if (pfb
->zsbuf
&& (buffers
& PIPE_CLEAR_DEPTH
)) {
571 struct fd_resource
*zsbuf
= fd_resource(pfb
->zsbuf
->texture
);
573 zsbuf
->lrz_valid
= true;
574 fd6_clear_lrz(ctx
->batch
, zsbuf
, depth
);
584 fd6_draw_init(struct pipe_context
*pctx
)
586 struct fd_context
*ctx
= fd_context(pctx
);
587 ctx
->draw_vbo
= fd6_draw_vbo
;
588 ctx
->clear
= fd6_clear
;