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 struct pipe_resource
*idx_buffer
= NULL
;
85 enum a4xx_index_size idx_type
;
86 enum pc_di_src_sel src_sel
;
87 uint32_t idx_size
, idx_offset
;
89 if (info
->index_size
) {
90 assert(!info
->has_user_indices
);
92 idx_buffer
= info
->index
.resource
;
93 idx_type
= fd4_size2indextype(info
->index_size
);
94 idx_size
= info
->index_size
* info
->count
;
95 idx_offset
= index_offset
+ info
->start
* info
->index_size
;
96 src_sel
= DI_SRC_SEL_DMA
;
99 idx_type
= INDEX4_SIZE_32_BIT
;
102 src_sel
= DI_SRC_SEL_AUTO_INDEX
;
105 OUT_PKT7(ring
, CP_DRAW_INDX_OFFSET
, idx_buffer
? 7 : 3);
106 if (vismode
== USE_VISIBILITY
) {
107 /* leave vis mode blank for now, it will be patched up when
108 * we know if we are binning or not
110 OUT_RINGP(ring
, DRAW4(primtype
, src_sel
, idx_type
, 0) | 0x2000,
111 &batch
->draw_patches
);
113 OUT_RING(ring
, DRAW4(primtype
, src_sel
, idx_type
, vismode
) | 0x2000);
115 OUT_RING(ring
, info
->instance_count
); /* NumInstances */
116 OUT_RING(ring
, info
->count
); /* NumIndices */
118 OUT_RING(ring
, 0x0); /* XXX */
119 OUT_RELOC(ring
, fd_resource(idx_buffer
)->bo
, idx_offset
, 0, 0);
120 OUT_RING (ring
, idx_size
);
125 draw_impl(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
,
126 struct fd6_emit
*emit
, unsigned index_offset
)
128 const struct pipe_draw_info
*info
= emit
->info
;
129 enum pc_di_primtype primtype
= ctx
->primtypes
[info
->mode
];
131 fd6_emit_state(ctx
, ring
, emit
);
133 if (emit
->dirty
& (FD_DIRTY_VTXBUF
| FD_DIRTY_VTXSTATE
))
134 fd6_emit_vertex_bufs(ring
, emit
);
136 OUT_PKT4(ring
, REG_A6XX_VFD_INDEX_OFFSET
, 2);
137 OUT_RING(ring
, info
->index_size
? info
->index_bias
: info
->start
); /* VFD_INDEX_OFFSET */
138 OUT_RING(ring
, info
->start_instance
); /* VFD_INSTANCE_START_OFFSET */
140 OUT_PKT4(ring
, REG_A6XX_PC_RESTART_INDEX
, 1);
141 OUT_RING(ring
, info
->primitive_restart
? /* PC_RESTART_INDEX */
142 info
->restart_index
: 0xffffffff);
144 fd6_emit_render_cntl(ctx
, false, emit
->key
.binning_pass
);
146 /* for debug after a lock up, write a unique counter value
147 * to scratch7 for each draw, to make it easier to match up
148 * register dumps to cmdstream. The combination of IB
149 * (scratch6) and DRAW is enough to "triangulate" the
150 * particular draw that caused lockup.
152 emit_marker6(ring
, 7);
154 if (info
->indirect
) {
155 draw_emit_indirect(ctx
->batch
, ring
, primtype
,
156 emit
->key
.binning_pass
? IGNORE_VISIBILITY
: USE_VISIBILITY
,
159 draw_emit(ctx
->batch
, ring
, primtype
,
160 emit
->key
.binning_pass
? IGNORE_VISIBILITY
: USE_VISIBILITY
,
164 emit_marker6(ring
, 7);
165 fd_reset_wfi(ctx
->batch
);
168 /* fixup dirty shader state in case some "unrelated" (from the state-
169 * tracker's perspective) state change causes us to switch to a
173 fixup_shader_state(struct fd_context
*ctx
, struct ir3_shader_key
*key
)
175 struct fd6_context
*fd6_ctx
= fd6_context(ctx
);
176 struct ir3_shader_key
*last_key
= &fd6_ctx
->last_key
;
178 if (!ir3_shader_key_equal(last_key
, key
)) {
179 if (ir3_shader_key_changes_fs(last_key
, key
)) {
180 ctx
->dirty_shader
[PIPE_SHADER_FRAGMENT
] |= FD_DIRTY_SHADER_PROG
;
181 ctx
->dirty
|= FD_DIRTY_PROG
;
184 if (ir3_shader_key_changes_vs(last_key
, key
)) {
185 ctx
->dirty_shader
[PIPE_SHADER_VERTEX
] |= FD_DIRTY_SHADER_PROG
;
186 ctx
->dirty
|= FD_DIRTY_PROG
;
189 fd6_ctx
->last_key
= *key
;
194 fd6_draw_vbo(struct fd_context
*ctx
, const struct pipe_draw_info
*info
,
195 unsigned index_offset
)
197 struct fd6_context
*fd6_ctx
= fd6_context(ctx
);
198 struct fd6_emit emit
= {
199 .debug
= &ctx
->debug
,
204 .color_two_side
= ctx
->rasterizer
->light_twoside
,
205 .vclamp_color
= ctx
->rasterizer
->clamp_vertex_color
,
206 .fclamp_color
= ctx
->rasterizer
->clamp_fragment_color
,
207 .rasterflat
= ctx
->rasterizer
->flatshade
,
208 .half_precision
= ctx
->in_blit
&&
209 fd_half_precision(&ctx
->batch
->framebuffer
),
210 .ucp_enables
= ctx
->rasterizer
->clip_plane_enable
,
211 .has_per_samp
= (fd6_ctx
->fsaturate
|| fd6_ctx
->vsaturate
||
212 fd6_ctx
->fastc_srgb
|| fd6_ctx
->vastc_srgb
),
213 .vsaturate_s
= fd6_ctx
->vsaturate_s
,
214 .vsaturate_t
= fd6_ctx
->vsaturate_t
,
215 .vsaturate_r
= fd6_ctx
->vsaturate_r
,
216 .fsaturate_s
= fd6_ctx
->fsaturate_s
,
217 .fsaturate_t
= fd6_ctx
->fsaturate_t
,
218 .fsaturate_r
= fd6_ctx
->fsaturate_r
,
219 .vastc_srgb
= fd6_ctx
->vastc_srgb
,
220 .fastc_srgb
= fd6_ctx
->fastc_srgb
,
221 .vsamples
= ctx
->tex
[PIPE_SHADER_VERTEX
].samples
,
222 .fsamples
= ctx
->tex
[PIPE_SHADER_FRAGMENT
].samples
,
224 .rasterflat
= ctx
->rasterizer
->flatshade
,
225 .sprite_coord_enable
= ctx
->rasterizer
->sprite_coord_enable
,
226 .sprite_coord_mode
= ctx
->rasterizer
->sprite_coord_mode
,
229 fixup_shader_state(ctx
, &emit
.key
);
231 unsigned dirty
= ctx
->dirty
;
232 const struct ir3_shader_variant
*vp
= fd6_emit_get_vp(&emit
);
233 const struct ir3_shader_variant
*fp
= fd6_emit_get_fp(&emit
);
235 /* do regular pass first, since that is more likely to fail compiling: */
240 ctx
->stats
.vs_regs
+= ir3_shader_halfregs(vp
);
241 ctx
->stats
.fs_regs
+= ir3_shader_halfregs(fp
);
243 /* figure out whether we need to disable LRZ write for binning
244 * pass using draw pass's fp:
246 emit
.no_lrz_write
= fp
->writes_pos
|| fp
->has_kill
;
248 emit
.key
.binning_pass
= false;
251 draw_impl(ctx
, ctx
->batch
->draw
, &emit
, index_offset
);
253 /* and now binning pass: */
254 emit
.key
.binning_pass
= true;
255 emit
.dirty
= dirty
& ~(FD_DIRTY_BLEND
);
256 emit
.vp
= NULL
; /* we changed key so need to refetch vp */
258 draw_impl(ctx
, ctx
->batch
->binning
, &emit
, index_offset
);
260 if (emit
.streamout_mask
) {
261 struct fd_ringbuffer
*ring
= ctx
->batch
->draw
;
263 for (unsigned i
= 0; i
< PIPE_MAX_SO_BUFFERS
; i
++) {
264 if (emit
.streamout_mask
& (1 << i
)) {
265 OUT_PKT7(ring
, CP_EVENT_WRITE
, 1);
266 OUT_RING(ring
, FLUSH_SO_0
+ i
);
271 fd_context_all_clean(ctx
);
276 static bool is_z32(enum pipe_format format
)
279 case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
:
280 case PIPE_FORMAT_Z32_UNORM
:
281 case PIPE_FORMAT_Z32_FLOAT
:
290 fd6_clear_lrz(struct fd_batch
*batch
, struct fd_resource
*zsbuf
, double depth
)
292 struct fd_ringbuffer
*ring
;
293 uint32_t clear
= util_pack_z(PIPE_FORMAT_Z16_UNORM
, depth
);
295 // TODO mid-frame clears (ie. app doing crazy stuff)?? Maybe worth
296 // splitting both clear and lrz clear out into their own rb's. And
297 // just throw away any draws prior to clear. (Anything not fullscreen
298 // clear, just fallback to generic path that treats it as a normal
301 if (!batch
->lrz_clear
) {
302 batch
->lrz_clear
= fd_ringbuffer_new(batch
->ctx
->pipe
, 0x1000);
303 fd_ringbuffer_set_parent(batch
->lrz_clear
, batch
->gmem
);
306 ring
= batch
->lrz_clear
;
310 OUT_PKT4(ring
, REG_A6XX_RB_CCU_CNTL
, 1);
311 OUT_RING(ring
, 0x10000000);
313 OUT_PKT4(ring
, REG_A6XX_HLSQ_UPDATE_CNTL
, 1);
314 OUT_RING(ring
, 0x20fffff);
316 OUT_PKT4(ring
, REG_A6XX_GRAS_SU_CNTL
, 1);
317 OUT_RING(ring
, A6XX_GRAS_SU_CNTL_LINEHALFWIDTH(0.0));
319 OUT_PKT4(ring
, REG_A6XX_GRAS_CNTL
, 1);
320 OUT_RING(ring
, 0x00000000);
322 OUT_PKT4(ring
, REG_A6XX_GRAS_CL_CNTL
, 1);
323 OUT_RING(ring
, 0x00000181);
325 OUT_PKT4(ring
, REG_A6XX_GRAS_LRZ_CNTL
, 1);
326 OUT_RING(ring
, 0x00000000);
328 OUT_PKT4(ring
, REG_A6XX_RB_MRT_BUF_INFO(0), 5);
329 OUT_RING(ring
, A6XX_RB_MRT_BUF_INFO_COLOR_FORMAT(RB5_R16_UNORM
) |
330 A6XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(TILE6_LINEAR
) |
331 A6XX_RB_MRT_BUF_INFO_COLOR_SWAP(WZYX
));
332 OUT_RING(ring
, A6XX_RB_MRT_PITCH(zsbuf
->lrz_pitch
* 2));
333 OUT_RING(ring
, A6XX_RB_MRT_ARRAY_PITCH(fd_bo_size(zsbuf
->lrz
)));
334 OUT_RELOCW(ring
, zsbuf
->lrz
, 0x1000, 0, 0);
336 OUT_PKT4(ring
, REG_A6XX_RB_RENDER_CNTL
, 1);
337 OUT_RING(ring
, 0x00000000);
339 OUT_PKT4(ring
, REG_A6XX_RB_DEST_MSAA_CNTL
, 1);
340 OUT_RING(ring
, A6XX_RB_DEST_MSAA_CNTL_SAMPLES(MSAA_ONE
));
342 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CNTL
, 1);
343 OUT_RING(ring
, A6XX_RB_BLIT_CNTL_BUF(BLIT_MRT0
));
345 OUT_PKT4(ring
, REG_A6XX_RB_CLEAR_CNTL
, 1);
346 OUT_RING(ring
, A6XX_RB_CLEAR_CNTL_FAST_CLEAR
|
347 A6XX_RB_CLEAR_CNTL_MASK(0xf));
349 OUT_PKT4(ring
, REG_A6XX_RB_CLEAR_COLOR_DW0
, 1);
350 OUT_RING(ring
, clear
); /* RB_CLEAR_COLOR_DW0 */
352 OUT_PKT4(ring
, REG_A6XX_VSC_RESOLVE_CNTL
, 2);
353 OUT_RING(ring
, A6XX_VSC_RESOLVE_CNTL_X(zsbuf
->lrz_width
) |
354 A6XX_VSC_RESOLVE_CNTL_Y(zsbuf
->lrz_height
));
355 OUT_RING(ring
, 0x00000000); // XXX UNKNOWN_0CDE
357 OUT_PKT4(ring
, REG_A6XX_RB_CNTL
, 1);
358 OUT_RING(ring
, A6XX_RB_CNTL_BYPASS
);
360 OUT_PKT4(ring
, REG_A6XX_RB_RESOLVE_CNTL_1
, 2);
361 OUT_RING(ring
, A6XX_RB_RESOLVE_CNTL_1_X(0) |
362 A6XX_RB_RESOLVE_CNTL_1_Y(0));
363 OUT_RING(ring
, A6XX_RB_RESOLVE_CNTL_2_X(zsbuf
->lrz_width
- 1) |
364 A6XX_RB_RESOLVE_CNTL_2_Y(zsbuf
->lrz_height
- 1));
366 fd6_emit_blit(batch
->ctx
, ring
);
373 /* Clear with CP_BLIT */
374 WRITE(REG_A6XX_GRAS_2D_BLIT_CNTL
, 0x10f43180);
376 OUT_PKT4(ring
, REG_A6XX_SP_PS_2D_SRC_INFO
, 7);
385 WRITE(0xacc0, 0xf181);
386 WRITE(0xacc0, 0xf181);
388 WRITE(REG_A6XX_GRAS_2D_BLIT_CNTL
, 0x10f43180);
389 WRITE(REG_A6XX_RB_2D_BLIT_CNTL
, 0x10f43180);
391 OUT_PKT4(ring
, REG_A6XX_RB_2D_SRC_SOLID_C0
, 4);
394 OUT_RING(ring
, 0xff);
397 DBG("%x %x %x %x\n", color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
399 struct pipe_surface
*psurf
= pfb
->cbufs
[0];
400 struct fd_resource
*rsc
= fd_resource(psurf
->texture
);
401 struct fd_resource_slice
*slice
= fd_resource_slice(rsc
, psurf
->u
.tex
.level
);
403 uint32_t offset
= fd_resource_offset(rsc
, psurf
->u
.tex
.level
,
404 psurf
->u
.tex
.first_layer
);
405 uint32_t stride
= slice
->pitch
* rsc
->cpp
;
407 enum a6xx_color_fmt format
= fd6_pipe2color(pfmt
);
408 OUT_PKT4(ring
, REG_A6XX_RB_2D_DST_INFO
, 9);
410 A6XX_RB_2D_DST_INFO_COLOR_FORMAT(format
) |
411 A6XX_RB_2D_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
412 A6XX_RB_2D_DST_INFO_COLOR_SWAP(WXYZ
));
413 OUT_RELOCW(ring
, rsc
->bo
, offset
, 0, 0); /* RB_2D_DST_LO/HI */
414 OUT_RING(ring
, A6XX_RB_2D_DST_SIZE_PITCH(stride
));
421 OUT_PKT4(ring
, REG_A6XX_GRAS_2D_SRC_TL_X
, 4);
427 OUT_PKT4(ring
, REG_A6XX_GRAS_2D_DST_TL
, 2);
429 A6XX_GRAS_2D_DST_TL_X(ctx
->batch
->max_scissor
.minx
) |
430 A6XX_GRAS_2D_DST_TL_Y(ctx
->batch
->max_scissor
.miny
));
432 A6XX_GRAS_2D_DST_BR_X(ctx
->batch
->max_scissor
.maxx
) |
433 A6XX_GRAS_2D_DST_BR_Y(ctx
->batch
->max_scissor
.maxy
));
435 OUT_PKT7(ring
, CP_BLIT
, 1);
436 OUT_RING(ring
, CP_BLIT_0_OP(BLIT_OP_SCALE
));
441 fd6_clear(struct fd_context
*ctx
, unsigned buffers
,
442 const union pipe_color_union
*color
, double depth
, unsigned stencil
)
444 struct pipe_framebuffer_state
*pfb
= &ctx
->batch
->framebuffer
;
445 struct pipe_scissor_state
*scissor
= fd_context_get_scissor(ctx
);
446 struct fd_ringbuffer
*ring
= ctx
->batch
->draw
;
448 if ((buffers
& (PIPE_CLEAR_DEPTH
| PIPE_CLEAR_STENCIL
)) &&
449 is_z32(pfb
->zsbuf
->format
))
452 fd6_emit_render_cntl(ctx
, true, false);
454 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_SCISSOR_TL
, 2);
455 OUT_RING(ring
, A6XX_RB_BLIT_SCISSOR_TL_X(scissor
->minx
) |
456 A6XX_RB_BLIT_SCISSOR_TL_Y(scissor
->miny
));
457 OUT_RING(ring
, A6XX_RB_BLIT_SCISSOR_BR_X(scissor
->maxx
- 1) |
458 A6XX_RB_BLIT_SCISSOR_BR_Y(scissor
->maxy
- 1));
460 if (buffers
& PIPE_CLEAR_COLOR
) {
461 for (int i
= 0; i
< pfb
->nr_cbufs
; i
++) {
462 union util_color uc
= {0};
467 if (!(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
470 enum pipe_format pfmt
= pfb
->cbufs
[i
]->format
;
472 // XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP??
473 union pipe_color_union swapped
;
474 switch (fd6_pipe2swap(pfmt
)) {
476 swapped
.ui
[0] = color
->ui
[0];
477 swapped
.ui
[1] = color
->ui
[1];
478 swapped
.ui
[2] = color
->ui
[2];
479 swapped
.ui
[3] = color
->ui
[3];
482 swapped
.ui
[2] = color
->ui
[0];
483 swapped
.ui
[1] = color
->ui
[1];
484 swapped
.ui
[0] = color
->ui
[2];
485 swapped
.ui
[3] = color
->ui
[3];
488 swapped
.ui
[3] = color
->ui
[0];
489 swapped
.ui
[0] = color
->ui
[1];
490 swapped
.ui
[1] = color
->ui
[2];
491 swapped
.ui
[2] = color
->ui
[3];
494 swapped
.ui
[3] = color
->ui
[0];
495 swapped
.ui
[2] = color
->ui
[1];
496 swapped
.ui
[1] = color
->ui
[2];
497 swapped
.ui
[0] = color
->ui
[3];
501 if (util_format_is_pure_uint(pfmt
)) {
502 util_format_write_4ui(pfmt
, swapped
.ui
, 0, &uc
, 0, 0, 0, 1, 1);
503 } else if (util_format_is_pure_sint(pfmt
)) {
504 util_format_write_4i(pfmt
, swapped
.i
, 0, &uc
, 0, 0, 0, 1, 1);
506 util_pack_color(swapped
.f
, pfmt
, &uc
);
509 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_DST_INFO
, 1);
510 OUT_RING(ring
, A6XX_RB_BLIT_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
511 A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(fd6_pipe2color(pfmt
)));
513 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_INFO
, 1);
514 OUT_RING(ring
, A6XX_RB_BLIT_INFO_GMEM
|
515 A6XX_RB_BLIT_INFO_CLEAR_MASK(0xf));
517 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_BASE_GMEM
, 1);
518 OUT_RINGP(ring
, i
, &ctx
->batch
->gmem_patches
);
520 OUT_PKT4(ring
, REG_A6XX_RB_UNKNOWN_88D0
, 1);
523 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CLEAR_COLOR_DW0
, 4);
524 OUT_RING(ring
, uc
.ui
[0]);
525 OUT_RING(ring
, uc
.ui
[1]);
526 OUT_RING(ring
, uc
.ui
[2]);
527 OUT_RING(ring
, uc
.ui
[3]);
529 fd6_emit_blit(ctx
, ring
);
533 if (pfb
->zsbuf
&& (buffers
& (PIPE_CLEAR_DEPTH
| PIPE_CLEAR_STENCIL
))) {
534 enum pipe_format pfmt
= pfb
->zsbuf
->format
;
535 uint32_t clear
= util_pack_z_stencil(pfmt
, depth
, stencil
);
538 if (buffers
& PIPE_CLEAR_DEPTH
)
541 if (buffers
& PIPE_CLEAR_STENCIL
)
544 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_DST_INFO
, 1);
545 OUT_RING(ring
, A6XX_RB_BLIT_DST_INFO_TILE_MODE(TILE6_LINEAR
) |
546 A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(fd6_pipe2color(pfmt
)));
548 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_INFO
, 1);
549 OUT_RING(ring
, A6XX_RB_BLIT_INFO_GMEM
|
550 // XXX UNK0 for separate stencil ??
551 A6XX_RB_BLIT_INFO_DEPTH
|
552 A6XX_RB_BLIT_INFO_CLEAR_MASK(mask
));
554 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_BASE_GMEM
, 1);
555 OUT_RINGP(ring
, MAX_RENDER_TARGETS
, &ctx
->batch
->gmem_patches
);
557 OUT_PKT4(ring
, REG_A6XX_RB_UNKNOWN_88D0
, 1);
560 OUT_PKT4(ring
, REG_A6XX_RB_BLIT_CLEAR_COLOR_DW0
, 1);
561 OUT_RING(ring
, clear
);
563 fd6_emit_blit(ctx
, ring
);
566 if (pfb
->zsbuf
&& (buffers
& PIPE_CLEAR_DEPTH
)) {
567 struct fd_resource
*zsbuf
= fd_resource(pfb
->zsbuf
->texture
);
569 zsbuf
->lrz_valid
= true;
570 fd6_clear_lrz(ctx
->batch
, zsbuf
, depth
);
580 fd6_draw_init(struct pipe_context
*pctx
)
582 struct fd_context
*ctx
= fd_context(pctx
);
583 ctx
->draw_vbo
= fd6_draw_vbo
;
584 ctx
->clear
= fd6_clear
;