1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci * 23bf215546Sopenharmony_ci * Authors: 24bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 25bf215546Sopenharmony_ci */ 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "pipe/p_state.h" 28bf215546Sopenharmony_ci#include "util/u_memory.h" 29bf215546Sopenharmony_ci#include "util/u_prim.h" 30bf215546Sopenharmony_ci#include "util/u_string.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "freedreno_resource.h" 33bf215546Sopenharmony_ci#include "freedreno_state.h" 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "fd5_context.h" 36bf215546Sopenharmony_ci#include "fd5_draw.h" 37bf215546Sopenharmony_ci#include "fd5_emit.h" 38bf215546Sopenharmony_ci#include "fd5_format.h" 39bf215546Sopenharmony_ci#include "fd5_program.h" 40bf215546Sopenharmony_ci#include "fd5_zsa.h" 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_cistatic void 43bf215546Sopenharmony_cidraw_impl(struct fd_context *ctx, struct fd_ringbuffer *ring, 44bf215546Sopenharmony_ci struct fd5_emit *emit, unsigned index_offset) assert_dt 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci const struct pipe_draw_info *info = emit->info; 47bf215546Sopenharmony_ci enum pc_di_primtype primtype = ctx->screen->primtypes[info->mode]; 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci fd5_emit_state(ctx, ring, emit); 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci if (emit->dirty & (FD_DIRTY_VTXBUF | FD_DIRTY_VTXSTATE)) 52bf215546Sopenharmony_ci fd5_emit_vertex_bufs(ring, emit); 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_INDEX_OFFSET, 2); 55bf215546Sopenharmony_ci OUT_RING(ring, info->index_size ? emit->draw->index_bias 56bf215546Sopenharmony_ci : emit->draw->start); /* VFD_INDEX_OFFSET */ 57bf215546Sopenharmony_ci OUT_RING(ring, info->start_instance); /* VFD_INSTANCE_START_OFFSET */ 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_RESTART_INDEX, 1); 60bf215546Sopenharmony_ci OUT_RING(ring, info->primitive_restart ? /* PC_RESTART_INDEX */ 61bf215546Sopenharmony_ci info->restart_index 62bf215546Sopenharmony_ci : 0xffffffff); 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci fd5_emit_render_cntl(ctx, false, emit->binning_pass); 65bf215546Sopenharmony_ci fd5_draw_emit(ctx->batch, ring, primtype, 66bf215546Sopenharmony_ci emit->binning_pass ? IGNORE_VISIBILITY : USE_VISIBILITY, info, 67bf215546Sopenharmony_ci emit->indirect, emit->draw, index_offset); 68bf215546Sopenharmony_ci} 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_cistatic bool 71bf215546Sopenharmony_cifd5_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, 72bf215546Sopenharmony_ci unsigned drawid_offset, 73bf215546Sopenharmony_ci const struct pipe_draw_indirect_info *indirect, 74bf215546Sopenharmony_ci const struct pipe_draw_start_count_bias *draw, 75bf215546Sopenharmony_ci unsigned index_offset) in_dt 76bf215546Sopenharmony_ci{ 77bf215546Sopenharmony_ci struct fd5_emit emit = { 78bf215546Sopenharmony_ci .debug = &ctx->debug, 79bf215546Sopenharmony_ci .vtx = &ctx->vtx, 80bf215546Sopenharmony_ci .info = info, 81bf215546Sopenharmony_ci .drawid_offset = drawid_offset, 82bf215546Sopenharmony_ci .indirect = indirect, 83bf215546Sopenharmony_ci .draw = draw, 84bf215546Sopenharmony_ci .key = { 85bf215546Sopenharmony_ci .vs = ctx->prog.vs, 86bf215546Sopenharmony_ci .fs = ctx->prog.fs, 87bf215546Sopenharmony_ci .key = { 88bf215546Sopenharmony_ci .rasterflat = ctx->rasterizer->flatshade, 89bf215546Sopenharmony_ci }, 90bf215546Sopenharmony_ci .clip_plane_enable = ctx->rasterizer->clip_plane_enable, 91bf215546Sopenharmony_ci }, 92bf215546Sopenharmony_ci .rasterflat = ctx->rasterizer->flatshade, 93bf215546Sopenharmony_ci .sprite_coord_enable = ctx->rasterizer->sprite_coord_enable, 94bf215546Sopenharmony_ci .sprite_coord_mode = ctx->rasterizer->sprite_coord_mode, 95bf215546Sopenharmony_ci }; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci ir3_fixup_shader_state(&ctx->base, &emit.key.key); 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ci unsigned dirty = ctx->dirty; 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci emit.prog = fd5_program_state( 102bf215546Sopenharmony_ci ir3_cache_lookup(ctx->shader_cache, &emit.key, &ctx->debug)); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci /* bail if compile failed: */ 105bf215546Sopenharmony_ci if (!emit.prog) 106bf215546Sopenharmony_ci return false; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci const struct ir3_shader_variant *vp = fd5_emit_get_vp(&emit); 109bf215546Sopenharmony_ci const struct ir3_shader_variant *fp = fd5_emit_get_fp(&emit); 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci ir3_update_max_tf_vtx(ctx, vp); 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ci /* do regular pass first: */ 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci if (unlikely(ctx->stats_users > 0)) { 116bf215546Sopenharmony_ci ctx->stats.vs_regs += ir3_shader_halfregs(vp); 117bf215546Sopenharmony_ci ctx->stats.fs_regs += ir3_shader_halfregs(fp); 118bf215546Sopenharmony_ci } 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci /* figure out whether we need to disable LRZ write for binning 121bf215546Sopenharmony_ci * pass using draw pass's fp: 122bf215546Sopenharmony_ci */ 123bf215546Sopenharmony_ci emit.no_lrz_write = fp->writes_pos || fp->no_earlyz || fp->has_kill; 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci emit.binning_pass = false; 126bf215546Sopenharmony_ci emit.dirty = dirty; 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ci draw_impl(ctx, ctx->batch->draw, &emit, index_offset); 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci /* and now binning pass: */ 131bf215546Sopenharmony_ci emit.binning_pass = true; 132bf215546Sopenharmony_ci emit.dirty = dirty & ~(FD_DIRTY_BLEND); 133bf215546Sopenharmony_ci emit.vs = NULL; /* we changed key so need to refetch vp */ 134bf215546Sopenharmony_ci emit.fs = NULL; 135bf215546Sopenharmony_ci draw_impl(ctx, ctx->batch->binning, &emit, index_offset); 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci if (emit.streamout_mask) { 138bf215546Sopenharmony_ci struct fd_ringbuffer *ring = ctx->batch->draw; 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_ci for (unsigned i = 0; i < PIPE_MAX_SO_BUFFERS; i++) { 141bf215546Sopenharmony_ci if (emit.streamout_mask & (1 << i)) { 142bf215546Sopenharmony_ci fd5_event_write(ctx->batch, ring, FLUSH_SO_0 + i, false); 143bf215546Sopenharmony_ci } 144bf215546Sopenharmony_ci } 145bf215546Sopenharmony_ci } 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_ci fd_context_all_clean(ctx); 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_ci return true; 150bf215546Sopenharmony_ci} 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_cistatic bool 153bf215546Sopenharmony_ciis_z32(enum pipe_format format) 154bf215546Sopenharmony_ci{ 155bf215546Sopenharmony_ci switch (format) { 156bf215546Sopenharmony_ci case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: 157bf215546Sopenharmony_ci case PIPE_FORMAT_Z32_UNORM: 158bf215546Sopenharmony_ci case PIPE_FORMAT_Z32_FLOAT: 159bf215546Sopenharmony_ci return true; 160bf215546Sopenharmony_ci default: 161bf215546Sopenharmony_ci return false; 162bf215546Sopenharmony_ci } 163bf215546Sopenharmony_ci} 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_cistatic void 166bf215546Sopenharmony_cifd5_clear_lrz(struct fd_batch *batch, struct fd_resource *zsbuf, double depth) 167bf215546Sopenharmony_ci{ 168bf215546Sopenharmony_ci struct fd_ringbuffer *ring; 169bf215546Sopenharmony_ci uint32_t clear = util_pack_z(PIPE_FORMAT_Z16_UNORM, depth); 170bf215546Sopenharmony_ci 171bf215546Sopenharmony_ci ring = fd_batch_get_prologue(batch); 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_ci OUT_WFI5(ring); 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CCU_CNTL, 1); 176bf215546Sopenharmony_ci OUT_RING(ring, 0x10000000); 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_HLSQ_UPDATE_CNTL, 1); 179bf215546Sopenharmony_ci OUT_RING(ring, 0x20fffff); 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_CNTL, 1); 182bf215546Sopenharmony_ci OUT_RING(ring, 183bf215546Sopenharmony_ci A5XX_GRAS_SU_CNTL_LINEHALFWIDTH(0.0f) | 184bf215546Sopenharmony_ci A5XX_GRAS_SU_CNTL_LINE_MODE(zsbuf->b.b.nr_samples > 1 ? 185bf215546Sopenharmony_ci RECTANGULAR : BRESENHAM)); 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_CNTL, 1); 188bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 189bf215546Sopenharmony_ci 190bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_CL_CNTL, 1); 191bf215546Sopenharmony_ci OUT_RING(ring, 0x00000181); 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_LRZ_CNTL, 1); 194bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 195bf215546Sopenharmony_ci 196bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_MRT_BUF_INFO(0), 5); 197bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_MRT_BUF_INFO_COLOR_FORMAT(RB5_R16_UNORM) | 198bf215546Sopenharmony_ci A5XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(TILE5_LINEAR) | 199bf215546Sopenharmony_ci A5XX_RB_MRT_BUF_INFO_COLOR_SWAP(WZYX)); 200bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_MRT_PITCH(zsbuf->lrz_pitch * 2)); 201bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(fd_bo_size(zsbuf->lrz))); 202bf215546Sopenharmony_ci OUT_RELOC(ring, zsbuf->lrz, 0x1000, 0, 0); 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_RENDER_CNTL, 1); 205bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 206bf215546Sopenharmony_ci 207bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_DEST_MSAA_CNTL, 1); 208bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_DEST_MSAA_CNTL_SAMPLES(MSAA_ONE)); 209bf215546Sopenharmony_ci 210bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1); 211bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLIT_CNTL_BUF(BLIT_MRT0)); 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1); 214bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_CLEAR_CNTL_FAST_CLEAR | A5XX_RB_CLEAR_CNTL_MASK(0xf)); 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_COLOR_DW0, 1); 217bf215546Sopenharmony_ci OUT_RING(ring, clear); /* RB_CLEAR_COLOR_DW0 */ 218bf215546Sopenharmony_ci 219bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VSC_RESOLVE_CNTL, 2); 220bf215546Sopenharmony_ci OUT_RING(ring, A5XX_VSC_RESOLVE_CNTL_X(zsbuf->lrz_width) | 221bf215546Sopenharmony_ci A5XX_VSC_RESOLVE_CNTL_Y(zsbuf->lrz_height)); 222bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); // XXX UNKNOWN_0CDE 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CNTL, 1); 225bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_CNTL_BYPASS); 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_RESOLVE_CNTL_1, 2); 228bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_RESOLVE_CNTL_1_X(0) | A5XX_RB_RESOLVE_CNTL_1_Y(0)); 229bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_RESOLVE_CNTL_2_X(zsbuf->lrz_width - 1) | 230bf215546Sopenharmony_ci A5XX_RB_RESOLVE_CNTL_2_Y(zsbuf->lrz_height - 1)); 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci fd5_emit_blit(batch, ring); 233bf215546Sopenharmony_ci} 234bf215546Sopenharmony_ci 235bf215546Sopenharmony_cistatic bool 236bf215546Sopenharmony_cifd5_clear(struct fd_context *ctx, unsigned buffers, 237bf215546Sopenharmony_ci const union pipe_color_union *color, double depth, 238bf215546Sopenharmony_ci unsigned stencil) assert_dt 239bf215546Sopenharmony_ci{ 240bf215546Sopenharmony_ci struct fd_ringbuffer *ring = ctx->batch->draw; 241bf215546Sopenharmony_ci struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer; 242bf215546Sopenharmony_ci 243bf215546Sopenharmony_ci if ((buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) && 244bf215546Sopenharmony_ci is_z32(pfb->zsbuf->format)) 245bf215546Sopenharmony_ci return false; 246bf215546Sopenharmony_ci 247bf215546Sopenharmony_ci fd5_emit_render_cntl(ctx, true, false); 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_ci if (buffers & PIPE_CLEAR_COLOR) { 250bf215546Sopenharmony_ci for (int i = 0; i < pfb->nr_cbufs; i++) { 251bf215546Sopenharmony_ci union util_color uc = {0}; 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_ci if (!pfb->cbufs[i]) 254bf215546Sopenharmony_ci continue; 255bf215546Sopenharmony_ci 256bf215546Sopenharmony_ci if (!(buffers & (PIPE_CLEAR_COLOR0 << i))) 257bf215546Sopenharmony_ci continue; 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci enum pipe_format pfmt = pfb->cbufs[i]->format; 260bf215546Sopenharmony_ci 261bf215546Sopenharmony_ci // XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP?? 262bf215546Sopenharmony_ci union pipe_color_union swapped; 263bf215546Sopenharmony_ci switch (fd5_pipe2swap(pfmt)) { 264bf215546Sopenharmony_ci case WZYX: 265bf215546Sopenharmony_ci swapped.ui[0] = color->ui[0]; 266bf215546Sopenharmony_ci swapped.ui[1] = color->ui[1]; 267bf215546Sopenharmony_ci swapped.ui[2] = color->ui[2]; 268bf215546Sopenharmony_ci swapped.ui[3] = color->ui[3]; 269bf215546Sopenharmony_ci break; 270bf215546Sopenharmony_ci case WXYZ: 271bf215546Sopenharmony_ci swapped.ui[2] = color->ui[0]; 272bf215546Sopenharmony_ci swapped.ui[1] = color->ui[1]; 273bf215546Sopenharmony_ci swapped.ui[0] = color->ui[2]; 274bf215546Sopenharmony_ci swapped.ui[3] = color->ui[3]; 275bf215546Sopenharmony_ci break; 276bf215546Sopenharmony_ci case ZYXW: 277bf215546Sopenharmony_ci swapped.ui[3] = color->ui[0]; 278bf215546Sopenharmony_ci swapped.ui[0] = color->ui[1]; 279bf215546Sopenharmony_ci swapped.ui[1] = color->ui[2]; 280bf215546Sopenharmony_ci swapped.ui[2] = color->ui[3]; 281bf215546Sopenharmony_ci break; 282bf215546Sopenharmony_ci case XYZW: 283bf215546Sopenharmony_ci swapped.ui[3] = color->ui[0]; 284bf215546Sopenharmony_ci swapped.ui[2] = color->ui[1]; 285bf215546Sopenharmony_ci swapped.ui[1] = color->ui[2]; 286bf215546Sopenharmony_ci swapped.ui[0] = color->ui[3]; 287bf215546Sopenharmony_ci break; 288bf215546Sopenharmony_ci } 289bf215546Sopenharmony_ci 290bf215546Sopenharmony_ci util_pack_color_union(pfmt, &uc, &swapped); 291bf215546Sopenharmony_ci 292bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1); 293bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLIT_CNTL_BUF(BLIT_MRT0 + i)); 294bf215546Sopenharmony_ci 295bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1); 296bf215546Sopenharmony_ci OUT_RING(ring, 297bf215546Sopenharmony_ci A5XX_RB_CLEAR_CNTL_FAST_CLEAR | A5XX_RB_CLEAR_CNTL_MASK(0xf)); 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_COLOR_DW0, 4); 300bf215546Sopenharmony_ci OUT_RING(ring, uc.ui[0]); /* RB_CLEAR_COLOR_DW0 */ 301bf215546Sopenharmony_ci OUT_RING(ring, uc.ui[1]); /* RB_CLEAR_COLOR_DW1 */ 302bf215546Sopenharmony_ci OUT_RING(ring, uc.ui[2]); /* RB_CLEAR_COLOR_DW2 */ 303bf215546Sopenharmony_ci OUT_RING(ring, uc.ui[3]); /* RB_CLEAR_COLOR_DW3 */ 304bf215546Sopenharmony_ci 305bf215546Sopenharmony_ci fd5_emit_blit(ctx->batch, ring); 306bf215546Sopenharmony_ci } 307bf215546Sopenharmony_ci } 308bf215546Sopenharmony_ci 309bf215546Sopenharmony_ci if (pfb->zsbuf && (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) { 310bf215546Sopenharmony_ci uint32_t clear = util_pack_z_stencil(pfb->zsbuf->format, depth, stencil); 311bf215546Sopenharmony_ci uint32_t mask = 0; 312bf215546Sopenharmony_ci 313bf215546Sopenharmony_ci if (buffers & PIPE_CLEAR_DEPTH) 314bf215546Sopenharmony_ci mask |= 0x1; 315bf215546Sopenharmony_ci 316bf215546Sopenharmony_ci if (buffers & PIPE_CLEAR_STENCIL) 317bf215546Sopenharmony_ci mask |= 0x2; 318bf215546Sopenharmony_ci 319bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1); 320bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLIT_CNTL_BUF(BLIT_ZS)); 321bf215546Sopenharmony_ci 322bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1); 323bf215546Sopenharmony_ci OUT_RING(ring, 324bf215546Sopenharmony_ci A5XX_RB_CLEAR_CNTL_FAST_CLEAR | A5XX_RB_CLEAR_CNTL_MASK(mask)); 325bf215546Sopenharmony_ci 326bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_COLOR_DW0, 1); 327bf215546Sopenharmony_ci OUT_RING(ring, clear); /* RB_CLEAR_COLOR_DW0 */ 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_ci fd5_emit_blit(ctx->batch, ring); 330bf215546Sopenharmony_ci 331bf215546Sopenharmony_ci if (pfb->zsbuf && (buffers & PIPE_CLEAR_DEPTH)) { 332bf215546Sopenharmony_ci struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture); 333bf215546Sopenharmony_ci if (zsbuf->lrz) { 334bf215546Sopenharmony_ci zsbuf->lrz_valid = true; 335bf215546Sopenharmony_ci fd5_clear_lrz(ctx->batch, zsbuf, depth); 336bf215546Sopenharmony_ci } 337bf215546Sopenharmony_ci } 338bf215546Sopenharmony_ci } 339bf215546Sopenharmony_ci 340bf215546Sopenharmony_ci /* disable fast clear to not interfere w/ gmem->mem, etc.. */ 341bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1); 342bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* RB_CLEAR_CNTL */ 343bf215546Sopenharmony_ci 344bf215546Sopenharmony_ci return true; 345bf215546Sopenharmony_ci} 346bf215546Sopenharmony_ci 347bf215546Sopenharmony_civoid 348bf215546Sopenharmony_cifd5_draw_init(struct pipe_context *pctx) disable_thread_safety_analysis 349bf215546Sopenharmony_ci{ 350bf215546Sopenharmony_ci struct fd_context *ctx = fd_context(pctx); 351bf215546Sopenharmony_ci ctx->draw_vbo = fd5_draw_vbo; 352bf215546Sopenharmony_ci ctx->clear = fd5_clear; 353bf215546Sopenharmony_ci} 354