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/format/u_format.h" 29bf215546Sopenharmony_ci#include "util/u_helpers.h" 30bf215546Sopenharmony_ci#include "util/u_memory.h" 31bf215546Sopenharmony_ci#include "util/u_string.h" 32bf215546Sopenharmony_ci#include "util/u_viewport.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include "freedreno_query_hw.h" 35bf215546Sopenharmony_ci#include "freedreno_resource.h" 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci#include "fd5_blend.h" 38bf215546Sopenharmony_ci#include "fd5_blitter.h" 39bf215546Sopenharmony_ci#include "fd5_context.h" 40bf215546Sopenharmony_ci#include "fd5_emit.h" 41bf215546Sopenharmony_ci#include "fd5_format.h" 42bf215546Sopenharmony_ci#include "fd5_image.h" 43bf215546Sopenharmony_ci#include "fd5_program.h" 44bf215546Sopenharmony_ci#include "fd5_rasterizer.h" 45bf215546Sopenharmony_ci#include "fd5_screen.h" 46bf215546Sopenharmony_ci#include "fd5_texture.h" 47bf215546Sopenharmony_ci#include "fd5_zsa.h" 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define emit_const_user fd5_emit_const_user 50bf215546Sopenharmony_ci#define emit_const_bo fd5_emit_const_bo 51bf215546Sopenharmony_ci#include "ir3_const.h" 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci/* regid: base const register 54bf215546Sopenharmony_ci * prsc or dwords: buffer containing constant values 55bf215546Sopenharmony_ci * sizedwords: size of const value buffer 56bf215546Sopenharmony_ci */ 57bf215546Sopenharmony_cistatic void 58bf215546Sopenharmony_cifd5_emit_const_user(struct fd_ringbuffer *ring, 59bf215546Sopenharmony_ci const struct ir3_shader_variant *v, uint32_t regid, 60bf215546Sopenharmony_ci uint32_t sizedwords, const uint32_t *dwords) 61bf215546Sopenharmony_ci{ 62bf215546Sopenharmony_ci emit_const_asserts(ring, v, regid, sizedwords); 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + sizedwords); 65bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(regid / 4) | 66bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 67bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(v->type)) | 68bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(sizedwords / 4)); 69bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) | 70bf215546Sopenharmony_ci CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS)); 71bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 72bf215546Sopenharmony_ci for (int i = 0; i < sizedwords; i++) 73bf215546Sopenharmony_ci OUT_RING(ring, ((uint32_t *)dwords)[i]); 74bf215546Sopenharmony_ci} 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_cistatic void 77bf215546Sopenharmony_cifd5_emit_const_bo(struct fd_ringbuffer *ring, 78bf215546Sopenharmony_ci const struct ir3_shader_variant *v, uint32_t regid, 79bf215546Sopenharmony_ci uint32_t offset, uint32_t sizedwords, struct fd_bo *bo) 80bf215546Sopenharmony_ci{ 81bf215546Sopenharmony_ci uint32_t dst_off = regid / 4; 82bf215546Sopenharmony_ci assert(dst_off % 4 == 0); 83bf215546Sopenharmony_ci uint32_t num_unit = sizedwords / 4; 84bf215546Sopenharmony_ci assert(num_unit % 4 == 0); 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci emit_const_asserts(ring, v, regid, sizedwords); 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3); 89bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(dst_off) | 90bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_INDIRECT) | 91bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(v->type)) | 92bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(num_unit)); 93bf215546Sopenharmony_ci OUT_RELOC(ring, bo, offset, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS), 0); 94bf215546Sopenharmony_ci} 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_cistatic void 97bf215546Sopenharmony_cifd5_emit_const_ptrs(struct fd_ringbuffer *ring, gl_shader_stage type, 98bf215546Sopenharmony_ci uint32_t regid, uint32_t num, struct fd_bo **bos, 99bf215546Sopenharmony_ci uint32_t *offsets) 100bf215546Sopenharmony_ci{ 101bf215546Sopenharmony_ci uint32_t anum = align(num, 2); 102bf215546Sopenharmony_ci uint32_t i; 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci assert((regid % 4) == 0); 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + (2 * anum)); 107bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(regid / 4) | 108bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 109bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(fd4_stage2shadersb(type)) | 110bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(anum / 2)); 111bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_EXT_SRC_ADDR(0) | 112bf215546Sopenharmony_ci CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS)); 113bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci for (i = 0; i < num; i++) { 116bf215546Sopenharmony_ci if (bos[i]) { 117bf215546Sopenharmony_ci OUT_RELOC(ring, bos[i], offsets[i], 0, 0); 118bf215546Sopenharmony_ci } else { 119bf215546Sopenharmony_ci OUT_RING(ring, 0xbad00000 | (i << 16)); 120bf215546Sopenharmony_ci OUT_RING(ring, 0xbad00000 | (i << 16)); 121bf215546Sopenharmony_ci } 122bf215546Sopenharmony_ci } 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ci for (; i < anum; i++) { 125bf215546Sopenharmony_ci OUT_RING(ring, 0xffffffff); 126bf215546Sopenharmony_ci OUT_RING(ring, 0xffffffff); 127bf215546Sopenharmony_ci } 128bf215546Sopenharmony_ci} 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_cistatic bool 131bf215546Sopenharmony_ciis_stateobj(struct fd_ringbuffer *ring) 132bf215546Sopenharmony_ci{ 133bf215546Sopenharmony_ci return false; 134bf215546Sopenharmony_ci} 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_cistatic void 137bf215546Sopenharmony_ciemit_const_ptrs(struct fd_ringbuffer *ring, const struct ir3_shader_variant *v, 138bf215546Sopenharmony_ci uint32_t dst_offset, uint32_t num, struct fd_bo **bos, 139bf215546Sopenharmony_ci uint32_t *offsets) 140bf215546Sopenharmony_ci{ 141bf215546Sopenharmony_ci /* TODO inline this */ 142bf215546Sopenharmony_ci assert(dst_offset + num <= v->constlen * 4); 143bf215546Sopenharmony_ci fd5_emit_const_ptrs(ring, v->type, dst_offset, num, bos, offsets); 144bf215546Sopenharmony_ci} 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_civoid 147bf215546Sopenharmony_cifd5_emit_cs_consts(const struct ir3_shader_variant *v, 148bf215546Sopenharmony_ci struct fd_ringbuffer *ring, struct fd_context *ctx, 149bf215546Sopenharmony_ci const struct pipe_grid_info *info) 150bf215546Sopenharmony_ci{ 151bf215546Sopenharmony_ci ir3_emit_cs_consts(v, ring, ctx, info); 152bf215546Sopenharmony_ci} 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_ci/* Border color layout is diff from a4xx/a5xx.. if it turns out to be 155bf215546Sopenharmony_ci * the same as a6xx then move this somewhere common ;-) 156bf215546Sopenharmony_ci * 157bf215546Sopenharmony_ci * Entry layout looks like (total size, 0x60 bytes): 158bf215546Sopenharmony_ci */ 159bf215546Sopenharmony_ci 160bf215546Sopenharmony_cistruct PACKED bcolor_entry { 161bf215546Sopenharmony_ci uint32_t fp32[4]; 162bf215546Sopenharmony_ci uint16_t ui16[4]; 163bf215546Sopenharmony_ci int16_t si16[4]; 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_ci uint16_t fp16[4]; 166bf215546Sopenharmony_ci uint16_t rgb565; 167bf215546Sopenharmony_ci uint16_t rgb5a1; 168bf215546Sopenharmony_ci uint16_t rgba4; 169bf215546Sopenharmony_ci uint8_t __pad0[2]; 170bf215546Sopenharmony_ci uint8_t ui8[4]; 171bf215546Sopenharmony_ci int8_t si8[4]; 172bf215546Sopenharmony_ci uint32_t rgb10a2; 173bf215546Sopenharmony_ci uint32_t z24; /* also s8? */ 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_ci uint16_t 176bf215546Sopenharmony_ci srgb[4]; /* appears to duplicate fp16[], but clamped, used for srgb */ 177bf215546Sopenharmony_ci uint8_t __pad1[24]; 178bf215546Sopenharmony_ci}; 179bf215546Sopenharmony_ci 180bf215546Sopenharmony_ci#define FD5_BORDER_COLOR_SIZE 0x60 181bf215546Sopenharmony_ci#define FD5_BORDER_COLOR_UPLOAD_SIZE \ 182bf215546Sopenharmony_ci (2 * PIPE_MAX_SAMPLERS * FD5_BORDER_COLOR_SIZE) 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_cistatic void 185bf215546Sopenharmony_cisetup_border_colors(struct fd_texture_stateobj *tex, 186bf215546Sopenharmony_ci struct bcolor_entry *entries) 187bf215546Sopenharmony_ci{ 188bf215546Sopenharmony_ci unsigned i, j; 189bf215546Sopenharmony_ci STATIC_ASSERT(sizeof(struct bcolor_entry) == FD5_BORDER_COLOR_SIZE); 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci for (i = 0; i < tex->num_samplers; i++) { 192bf215546Sopenharmony_ci struct bcolor_entry *e = &entries[i]; 193bf215546Sopenharmony_ci struct pipe_sampler_state *sampler = tex->samplers[i]; 194bf215546Sopenharmony_ci union pipe_color_union *bc; 195bf215546Sopenharmony_ci 196bf215546Sopenharmony_ci if (!sampler) 197bf215546Sopenharmony_ci continue; 198bf215546Sopenharmony_ci 199bf215546Sopenharmony_ci bc = &sampler->border_color; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci /* 202bf215546Sopenharmony_ci * XXX HACK ALERT XXX 203bf215546Sopenharmony_ci * 204bf215546Sopenharmony_ci * The border colors need to be swizzled in a particular 205bf215546Sopenharmony_ci * format-dependent order. Even though samplers don't know about 206bf215546Sopenharmony_ci * formats, we can assume that with a GL state tracker, there's a 207bf215546Sopenharmony_ci * 1:1 correspondence between sampler and texture. Take advantage 208bf215546Sopenharmony_ci * of that knowledge. 209bf215546Sopenharmony_ci */ 210bf215546Sopenharmony_ci if ((i >= tex->num_textures) || !tex->textures[i]) 211bf215546Sopenharmony_ci continue; 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_ci enum pipe_format format = tex->textures[i]->format; 214bf215546Sopenharmony_ci const struct util_format_description *desc = 215bf215546Sopenharmony_ci util_format_description(format); 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci e->rgb565 = 0; 218bf215546Sopenharmony_ci e->rgb5a1 = 0; 219bf215546Sopenharmony_ci e->rgba4 = 0; 220bf215546Sopenharmony_ci e->rgb10a2 = 0; 221bf215546Sopenharmony_ci e->z24 = 0; 222bf215546Sopenharmony_ci 223bf215546Sopenharmony_ci for (j = 0; j < 4; j++) { 224bf215546Sopenharmony_ci int c = desc->swizzle[j]; 225bf215546Sopenharmony_ci int cd = c; 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ci /* 228bf215546Sopenharmony_ci * HACK: for PIPE_FORMAT_X24S8_UINT we end up w/ the 229bf215546Sopenharmony_ci * stencil border color value in bc->ui[0] but according 230bf215546Sopenharmony_ci * to desc->swizzle and desc->channel, the .x component 231bf215546Sopenharmony_ci * is NONE and the stencil value is in the y component. 232bf215546Sopenharmony_ci * Meanwhile the hardware wants this in the .x componetn. 233bf215546Sopenharmony_ci */ 234bf215546Sopenharmony_ci if ((format == PIPE_FORMAT_X24S8_UINT) || 235bf215546Sopenharmony_ci (format == PIPE_FORMAT_X32_S8X24_UINT)) { 236bf215546Sopenharmony_ci if (j == 0) { 237bf215546Sopenharmony_ci c = 1; 238bf215546Sopenharmony_ci cd = 0; 239bf215546Sopenharmony_ci } else { 240bf215546Sopenharmony_ci continue; 241bf215546Sopenharmony_ci } 242bf215546Sopenharmony_ci } 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_ci if (c >= 4) 245bf215546Sopenharmony_ci continue; 246bf215546Sopenharmony_ci 247bf215546Sopenharmony_ci if (desc->channel[c].pure_integer) { 248bf215546Sopenharmony_ci uint16_t clamped; 249bf215546Sopenharmony_ci switch (desc->channel[c].size) { 250bf215546Sopenharmony_ci case 2: 251bf215546Sopenharmony_ci assert(desc->channel[c].type == UTIL_FORMAT_TYPE_UNSIGNED); 252bf215546Sopenharmony_ci clamped = CLAMP(bc->ui[j], 0, 0x3); 253bf215546Sopenharmony_ci break; 254bf215546Sopenharmony_ci case 8: 255bf215546Sopenharmony_ci if (desc->channel[c].type == UTIL_FORMAT_TYPE_SIGNED) 256bf215546Sopenharmony_ci clamped = CLAMP(bc->i[j], -128, 127); 257bf215546Sopenharmony_ci else 258bf215546Sopenharmony_ci clamped = CLAMP(bc->ui[j], 0, 255); 259bf215546Sopenharmony_ci break; 260bf215546Sopenharmony_ci case 10: 261bf215546Sopenharmony_ci assert(desc->channel[c].type == UTIL_FORMAT_TYPE_UNSIGNED); 262bf215546Sopenharmony_ci clamped = CLAMP(bc->ui[j], 0, 0x3ff); 263bf215546Sopenharmony_ci break; 264bf215546Sopenharmony_ci case 16: 265bf215546Sopenharmony_ci if (desc->channel[c].type == UTIL_FORMAT_TYPE_SIGNED) 266bf215546Sopenharmony_ci clamped = CLAMP(bc->i[j], -32768, 32767); 267bf215546Sopenharmony_ci else 268bf215546Sopenharmony_ci clamped = CLAMP(bc->ui[j], 0, 65535); 269bf215546Sopenharmony_ci break; 270bf215546Sopenharmony_ci default: 271bf215546Sopenharmony_ci assert(!"Unexpected bit size"); 272bf215546Sopenharmony_ci case 32: 273bf215546Sopenharmony_ci clamped = 0; 274bf215546Sopenharmony_ci break; 275bf215546Sopenharmony_ci } 276bf215546Sopenharmony_ci e->fp32[cd] = bc->ui[j]; 277bf215546Sopenharmony_ci e->fp16[cd] = clamped; 278bf215546Sopenharmony_ci } else { 279bf215546Sopenharmony_ci float f = bc->f[j]; 280bf215546Sopenharmony_ci float f_u = CLAMP(f, 0, 1); 281bf215546Sopenharmony_ci float f_s = CLAMP(f, -1, 1); 282bf215546Sopenharmony_ci 283bf215546Sopenharmony_ci e->fp32[c] = fui(f); 284bf215546Sopenharmony_ci e->fp16[c] = _mesa_float_to_half(f); 285bf215546Sopenharmony_ci e->srgb[c] = _mesa_float_to_half(f_u); 286bf215546Sopenharmony_ci e->ui16[c] = f_u * 0xffff; 287bf215546Sopenharmony_ci e->si16[c] = f_s * 0x7fff; 288bf215546Sopenharmony_ci e->ui8[c] = f_u * 0xff; 289bf215546Sopenharmony_ci e->si8[c] = f_s * 0x7f; 290bf215546Sopenharmony_ci if (c == 1) 291bf215546Sopenharmony_ci e->rgb565 |= (int)(f_u * 0x3f) << 5; 292bf215546Sopenharmony_ci else if (c < 3) 293bf215546Sopenharmony_ci e->rgb565 |= (int)(f_u * 0x1f) << (c ? 11 : 0); 294bf215546Sopenharmony_ci if (c == 3) 295bf215546Sopenharmony_ci e->rgb5a1 |= (f_u > 0.5f) ? 0x8000 : 0; 296bf215546Sopenharmony_ci else 297bf215546Sopenharmony_ci e->rgb5a1 |= (int)(f_u * 0x1f) << (c * 5); 298bf215546Sopenharmony_ci if (c == 3) 299bf215546Sopenharmony_ci e->rgb10a2 |= (int)(f_u * 0x3) << 30; 300bf215546Sopenharmony_ci else 301bf215546Sopenharmony_ci e->rgb10a2 |= (int)(f_u * 0x3ff) << (c * 10); 302bf215546Sopenharmony_ci e->rgba4 |= (int)(f_u * 0xf) << (c * 4); 303bf215546Sopenharmony_ci if (c == 0) 304bf215546Sopenharmony_ci e->z24 = f_u * 0xffffff; 305bf215546Sopenharmony_ci } 306bf215546Sopenharmony_ci } 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci#ifdef DEBUG 309bf215546Sopenharmony_ci memset(&e->__pad0, 0, sizeof(e->__pad0)); 310bf215546Sopenharmony_ci memset(&e->__pad1, 0, sizeof(e->__pad1)); 311bf215546Sopenharmony_ci#endif 312bf215546Sopenharmony_ci } 313bf215546Sopenharmony_ci} 314bf215546Sopenharmony_ci 315bf215546Sopenharmony_cistatic void 316bf215546Sopenharmony_ciemit_border_color(struct fd_context *ctx, struct fd_ringbuffer *ring) assert_dt 317bf215546Sopenharmony_ci{ 318bf215546Sopenharmony_ci struct fd5_context *fd5_ctx = fd5_context(ctx); 319bf215546Sopenharmony_ci struct bcolor_entry *entries; 320bf215546Sopenharmony_ci unsigned off; 321bf215546Sopenharmony_ci void *ptr; 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_ci STATIC_ASSERT(sizeof(struct bcolor_entry) == FD5_BORDER_COLOR_SIZE); 324bf215546Sopenharmony_ci 325bf215546Sopenharmony_ci u_upload_alloc(fd5_ctx->border_color_uploader, 0, 326bf215546Sopenharmony_ci FD5_BORDER_COLOR_UPLOAD_SIZE, FD5_BORDER_COLOR_UPLOAD_SIZE, 327bf215546Sopenharmony_ci &off, &fd5_ctx->border_color_buf, &ptr); 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_ci entries = ptr; 330bf215546Sopenharmony_ci 331bf215546Sopenharmony_ci setup_border_colors(&ctx->tex[PIPE_SHADER_VERTEX], &entries[0]); 332bf215546Sopenharmony_ci setup_border_colors(&ctx->tex[PIPE_SHADER_FRAGMENT], 333bf215546Sopenharmony_ci &entries[ctx->tex[PIPE_SHADER_VERTEX].num_samplers]); 334bf215546Sopenharmony_ci 335bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_TP_BORDER_COLOR_BASE_ADDR_LO, 2); 336bf215546Sopenharmony_ci OUT_RELOC(ring, fd_resource(fd5_ctx->border_color_buf)->bo, off, 0, 0); 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_ci u_upload_unmap(fd5_ctx->border_color_uploader); 339bf215546Sopenharmony_ci} 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_cistatic bool 342bf215546Sopenharmony_ciemit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, 343bf215546Sopenharmony_ci enum a4xx_state_block sb, 344bf215546Sopenharmony_ci struct fd_texture_stateobj *tex) assert_dt 345bf215546Sopenharmony_ci{ 346bf215546Sopenharmony_ci bool needs_border = false; 347bf215546Sopenharmony_ci unsigned bcolor_offset = 348bf215546Sopenharmony_ci (sb == SB4_FS_TEX) ? ctx->tex[PIPE_SHADER_VERTEX].num_samplers : 0; 349bf215546Sopenharmony_ci unsigned i; 350bf215546Sopenharmony_ci 351bf215546Sopenharmony_ci if (tex->num_samplers > 0) { 352bf215546Sopenharmony_ci /* output sampler state: */ 353bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + (4 * tex->num_samplers)); 354bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(0) | 355bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 356bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(sb) | 357bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(tex->num_samplers)); 358bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_STATE_TYPE(ST4_SHADER) | 359bf215546Sopenharmony_ci CP_LOAD_STATE4_1_EXT_SRC_ADDR(0)); 360bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 361bf215546Sopenharmony_ci for (i = 0; i < tex->num_samplers; i++) { 362bf215546Sopenharmony_ci static const struct fd5_sampler_stateobj dummy_sampler = {}; 363bf215546Sopenharmony_ci const struct fd5_sampler_stateobj *sampler = 364bf215546Sopenharmony_ci tex->samplers[i] ? fd5_sampler_stateobj(tex->samplers[i]) 365bf215546Sopenharmony_ci : &dummy_sampler; 366bf215546Sopenharmony_ci OUT_RING(ring, sampler->texsamp0); 367bf215546Sopenharmony_ci OUT_RING(ring, sampler->texsamp1); 368bf215546Sopenharmony_ci OUT_RING(ring, sampler->texsamp2 | 369bf215546Sopenharmony_ci A5XX_TEX_SAMP_2_BCOLOR_OFFSET(bcolor_offset + i)); 370bf215546Sopenharmony_ci OUT_RING(ring, sampler->texsamp3); 371bf215546Sopenharmony_ci 372bf215546Sopenharmony_ci needs_border |= sampler->needs_border; 373bf215546Sopenharmony_ci } 374bf215546Sopenharmony_ci } 375bf215546Sopenharmony_ci 376bf215546Sopenharmony_ci if (tex->num_textures > 0) { 377bf215546Sopenharmony_ci unsigned num_textures = tex->num_textures; 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_ci /* emit texture state: */ 380bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + (12 * num_textures)); 381bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(0) | 382bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 383bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(sb) | 384bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(num_textures)); 385bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS) | 386bf215546Sopenharmony_ci CP_LOAD_STATE4_1_EXT_SRC_ADDR(0)); 387bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 388bf215546Sopenharmony_ci for (i = 0; i < tex->num_textures; i++) { 389bf215546Sopenharmony_ci static const struct fd5_pipe_sampler_view dummy_view = {}; 390bf215546Sopenharmony_ci const struct fd5_pipe_sampler_view *view = 391bf215546Sopenharmony_ci tex->textures[i] ? fd5_pipe_sampler_view(tex->textures[i]) 392bf215546Sopenharmony_ci : &dummy_view; 393bf215546Sopenharmony_ci enum a5xx_tile_mode tile_mode = TILE5_LINEAR; 394bf215546Sopenharmony_ci 395bf215546Sopenharmony_ci if (view->base.texture) 396bf215546Sopenharmony_ci tile_mode = fd_resource(view->base.texture)->layout.tile_mode; 397bf215546Sopenharmony_ci 398bf215546Sopenharmony_ci OUT_RING(ring, 399bf215546Sopenharmony_ci view->texconst0 | A5XX_TEX_CONST_0_TILE_MODE(tile_mode)); 400bf215546Sopenharmony_ci OUT_RING(ring, view->texconst1); 401bf215546Sopenharmony_ci OUT_RING(ring, view->texconst2); 402bf215546Sopenharmony_ci OUT_RING(ring, view->texconst3); 403bf215546Sopenharmony_ci if (view->base.texture) { 404bf215546Sopenharmony_ci struct fd_resource *rsc = fd_resource(view->base.texture); 405bf215546Sopenharmony_ci if (view->base.format == PIPE_FORMAT_X32_S8X24_UINT) 406bf215546Sopenharmony_ci rsc = rsc->stencil; 407bf215546Sopenharmony_ci OUT_RELOC(ring, rsc->bo, view->offset, 408bf215546Sopenharmony_ci (uint64_t)view->texconst5 << 32, 0); 409bf215546Sopenharmony_ci } else { 410bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 411bf215546Sopenharmony_ci OUT_RING(ring, view->texconst5); 412bf215546Sopenharmony_ci } 413bf215546Sopenharmony_ci OUT_RING(ring, view->texconst6); 414bf215546Sopenharmony_ci OUT_RING(ring, view->texconst7); 415bf215546Sopenharmony_ci OUT_RING(ring, view->texconst8); 416bf215546Sopenharmony_ci OUT_RING(ring, view->texconst9); 417bf215546Sopenharmony_ci OUT_RING(ring, view->texconst10); 418bf215546Sopenharmony_ci OUT_RING(ring, view->texconst11); 419bf215546Sopenharmony_ci } 420bf215546Sopenharmony_ci } 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci return needs_border; 423bf215546Sopenharmony_ci} 424bf215546Sopenharmony_ci 425bf215546Sopenharmony_cistatic void 426bf215546Sopenharmony_ciemit_ssbos(struct fd_context *ctx, struct fd_ringbuffer *ring, 427bf215546Sopenharmony_ci enum a4xx_state_block sb, struct fd_shaderbuf_stateobj *so, 428bf215546Sopenharmony_ci const struct ir3_shader_variant *v) 429bf215546Sopenharmony_ci{ 430bf215546Sopenharmony_ci unsigned count = util_last_bit(so->enabled_mask); 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + 2 * count); 433bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(0) | 434bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 435bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(sb) | 436bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(count)); 437bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS) | 438bf215546Sopenharmony_ci CP_LOAD_STATE4_1_EXT_SRC_ADDR(0)); 439bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 440bf215546Sopenharmony_ci 441bf215546Sopenharmony_ci for (unsigned i = 0; i < count; i++) { 442bf215546Sopenharmony_ci struct pipe_shader_buffer *buf = &so->sb[i]; 443bf215546Sopenharmony_ci unsigned sz = buf->buffer_size; 444bf215546Sopenharmony_ci 445bf215546Sopenharmony_ci /* Unlike a6xx, SSBO size is in bytes. */ 446bf215546Sopenharmony_ci OUT_RING(ring, A5XX_SSBO_1_0_WIDTH(sz & MASK(16))); 447bf215546Sopenharmony_ci OUT_RING(ring, A5XX_SSBO_1_1_HEIGHT(sz >> 16)); 448bf215546Sopenharmony_ci } 449bf215546Sopenharmony_ci 450bf215546Sopenharmony_ci OUT_PKT7(ring, CP_LOAD_STATE4, 3 + 2 * count); 451bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_0_DST_OFF(0) | 452bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_SRC(SS4_DIRECT) | 453bf215546Sopenharmony_ci CP_LOAD_STATE4_0_STATE_BLOCK(sb) | 454bf215546Sopenharmony_ci CP_LOAD_STATE4_0_NUM_UNIT(count)); 455bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_1_STATE_TYPE(ST4_UBO) | 456bf215546Sopenharmony_ci CP_LOAD_STATE4_1_EXT_SRC_ADDR(0)); 457bf215546Sopenharmony_ci OUT_RING(ring, CP_LOAD_STATE4_2_EXT_SRC_ADDR_HI(0)); 458bf215546Sopenharmony_ci for (unsigned i = 0; i < count; i++) { 459bf215546Sopenharmony_ci struct pipe_shader_buffer *buf = &so->sb[i]; 460bf215546Sopenharmony_ci 461bf215546Sopenharmony_ci if (buf->buffer) { 462bf215546Sopenharmony_ci struct fd_resource *rsc = fd_resource(buf->buffer); 463bf215546Sopenharmony_ci OUT_RELOC(ring, rsc->bo, buf->buffer_offset, 0, 0); 464bf215546Sopenharmony_ci } else { 465bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 466bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 467bf215546Sopenharmony_ci } 468bf215546Sopenharmony_ci } 469bf215546Sopenharmony_ci} 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_civoid 472bf215546Sopenharmony_cifd5_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd5_emit *emit) 473bf215546Sopenharmony_ci{ 474bf215546Sopenharmony_ci int32_t i, j; 475bf215546Sopenharmony_ci const struct fd_vertex_state *vtx = emit->vtx; 476bf215546Sopenharmony_ci const struct ir3_shader_variant *vp = fd5_emit_get_vp(emit); 477bf215546Sopenharmony_ci 478bf215546Sopenharmony_ci for (i = 0, j = 0; i <= vp->inputs_count; i++) { 479bf215546Sopenharmony_ci if (vp->inputs[i].sysval) 480bf215546Sopenharmony_ci continue; 481bf215546Sopenharmony_ci if (vp->inputs[i].compmask) { 482bf215546Sopenharmony_ci struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; 483bf215546Sopenharmony_ci const struct pipe_vertex_buffer *vb = 484bf215546Sopenharmony_ci &vtx->vertexbuf.vb[elem->vertex_buffer_index]; 485bf215546Sopenharmony_ci struct fd_resource *rsc = fd_resource(vb->buffer.resource); 486bf215546Sopenharmony_ci enum pipe_format pfmt = elem->src_format; 487bf215546Sopenharmony_ci enum a5xx_vtx_fmt fmt = fd5_pipe2vtx(pfmt); 488bf215546Sopenharmony_ci bool isint = util_format_is_pure_integer(pfmt); 489bf215546Sopenharmony_ci uint32_t off = vb->buffer_offset + elem->src_offset; 490bf215546Sopenharmony_ci uint32_t size = vb->buffer.resource->width0 - off; 491bf215546Sopenharmony_ci assert(fmt != VFMT5_NONE); 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_FETCH(j), 4); 494bf215546Sopenharmony_ci OUT_RELOC(ring, rsc->bo, off, 0, 0); 495bf215546Sopenharmony_ci OUT_RING(ring, size); /* VFD_FETCH[j].SIZE */ 496bf215546Sopenharmony_ci OUT_RING(ring, vb->stride); /* VFD_FETCH[j].STRIDE */ 497bf215546Sopenharmony_ci 498bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_DECODE(j), 2); 499bf215546Sopenharmony_ci OUT_RING( 500bf215546Sopenharmony_ci ring, 501bf215546Sopenharmony_ci A5XX_VFD_DECODE_INSTR_IDX(j) | A5XX_VFD_DECODE_INSTR_FORMAT(fmt) | 502bf215546Sopenharmony_ci COND(elem->instance_divisor, A5XX_VFD_DECODE_INSTR_INSTANCED) | 503bf215546Sopenharmony_ci A5XX_VFD_DECODE_INSTR_SWAP(fd5_pipe2swap(pfmt)) | 504bf215546Sopenharmony_ci A5XX_VFD_DECODE_INSTR_UNK30 | 505bf215546Sopenharmony_ci COND(!isint, A5XX_VFD_DECODE_INSTR_FLOAT)); 506bf215546Sopenharmony_ci OUT_RING( 507bf215546Sopenharmony_ci ring, 508bf215546Sopenharmony_ci MAX2(1, elem->instance_divisor)); /* VFD_DECODE[j].STEP_RATE */ 509bf215546Sopenharmony_ci 510bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_DEST_CNTL(j), 1); 511bf215546Sopenharmony_ci OUT_RING(ring, 512bf215546Sopenharmony_ci A5XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vp->inputs[i].compmask) | 513bf215546Sopenharmony_ci A5XX_VFD_DEST_CNTL_INSTR_REGID(vp->inputs[i].regid)); 514bf215546Sopenharmony_ci 515bf215546Sopenharmony_ci j++; 516bf215546Sopenharmony_ci } 517bf215546Sopenharmony_ci } 518bf215546Sopenharmony_ci 519bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_CONTROL_0, 1); 520bf215546Sopenharmony_ci OUT_RING(ring, A5XX_VFD_CONTROL_0_VTXCNT(j)); 521bf215546Sopenharmony_ci} 522bf215546Sopenharmony_ci 523bf215546Sopenharmony_civoid 524bf215546Sopenharmony_cifd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring, 525bf215546Sopenharmony_ci struct fd5_emit *emit) 526bf215546Sopenharmony_ci{ 527bf215546Sopenharmony_ci struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer; 528bf215546Sopenharmony_ci const struct ir3_shader_variant *vp = fd5_emit_get_vp(emit); 529bf215546Sopenharmony_ci const struct ir3_shader_variant *fp = fd5_emit_get_fp(emit); 530bf215546Sopenharmony_ci const enum fd_dirty_3d_state dirty = emit->dirty; 531bf215546Sopenharmony_ci bool needs_border = false; 532bf215546Sopenharmony_ci 533bf215546Sopenharmony_ci emit_marker5(ring, 5); 534bf215546Sopenharmony_ci 535bf215546Sopenharmony_ci if ((dirty & FD_DIRTY_FRAMEBUFFER) && !emit->binning_pass) { 536bf215546Sopenharmony_ci unsigned char mrt_comp[A5XX_MAX_RENDER_TARGETS] = {0}; 537bf215546Sopenharmony_ci 538bf215546Sopenharmony_ci for (unsigned i = 0; i < A5XX_MAX_RENDER_TARGETS; i++) { 539bf215546Sopenharmony_ci mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i]) ? 0xf : 0; 540bf215546Sopenharmony_ci } 541bf215546Sopenharmony_ci 542bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_RENDER_COMPONENTS, 1); 543bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_RENDER_COMPONENTS_RT0(mrt_comp[0]) | 544bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT1(mrt_comp[1]) | 545bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT2(mrt_comp[2]) | 546bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT3(mrt_comp[3]) | 547bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT4(mrt_comp[4]) | 548bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT5(mrt_comp[5]) | 549bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT6(mrt_comp[6]) | 550bf215546Sopenharmony_ci A5XX_RB_RENDER_COMPONENTS_RT7(mrt_comp[7])); 551bf215546Sopenharmony_ci } 552bf215546Sopenharmony_ci 553bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_FRAMEBUFFER)) { 554bf215546Sopenharmony_ci struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa); 555bf215546Sopenharmony_ci uint32_t rb_alpha_control = zsa->rb_alpha_control; 556bf215546Sopenharmony_ci 557bf215546Sopenharmony_ci if (util_format_is_pure_integer(pipe_surface_format(pfb->cbufs[0]))) 558bf215546Sopenharmony_ci rb_alpha_control &= ~A5XX_RB_ALPHA_CONTROL_ALPHA_TEST; 559bf215546Sopenharmony_ci 560bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_ALPHA_CONTROL, 1); 561bf215546Sopenharmony_ci OUT_RING(ring, rb_alpha_control); 562bf215546Sopenharmony_ci 563bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_STENCIL_CONTROL, 1); 564bf215546Sopenharmony_ci OUT_RING(ring, zsa->rb_stencil_control); 565bf215546Sopenharmony_ci } 566bf215546Sopenharmony_ci 567bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_BLEND | FD_DIRTY_PROG)) { 568bf215546Sopenharmony_ci struct fd5_blend_stateobj *blend = fd5_blend_stateobj(ctx->blend); 569bf215546Sopenharmony_ci struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa); 570bf215546Sopenharmony_ci 571bf215546Sopenharmony_ci if (pfb->zsbuf) { 572bf215546Sopenharmony_ci struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture); 573bf215546Sopenharmony_ci uint32_t gras_lrz_cntl = zsa->gras_lrz_cntl; 574bf215546Sopenharmony_ci 575bf215546Sopenharmony_ci if (emit->no_lrz_write || !rsc->lrz || !rsc->lrz_valid) 576bf215546Sopenharmony_ci gras_lrz_cntl = 0; 577bf215546Sopenharmony_ci else if (emit->binning_pass && blend->lrz_write && zsa->lrz_write) 578bf215546Sopenharmony_ci gras_lrz_cntl |= A5XX_GRAS_LRZ_CNTL_LRZ_WRITE; 579bf215546Sopenharmony_ci 580bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_LRZ_CNTL, 1); 581bf215546Sopenharmony_ci OUT_RING(ring, gras_lrz_cntl); 582bf215546Sopenharmony_ci } 583bf215546Sopenharmony_ci } 584bf215546Sopenharmony_ci 585bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_STENCIL_REF)) { 586bf215546Sopenharmony_ci struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa); 587bf215546Sopenharmony_ci struct pipe_stencil_ref *sr = &ctx->stencil_ref; 588bf215546Sopenharmony_ci 589bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_STENCILREFMASK, 2); 590bf215546Sopenharmony_ci OUT_RING(ring, zsa->rb_stencilrefmask | 591bf215546Sopenharmony_ci A5XX_RB_STENCILREFMASK_STENCILREF(sr->ref_value[0])); 592bf215546Sopenharmony_ci OUT_RING(ring, zsa->rb_stencilrefmask_bf | 593bf215546Sopenharmony_ci A5XX_RB_STENCILREFMASK_BF_STENCILREF(sr->ref_value[1])); 594bf215546Sopenharmony_ci } 595bf215546Sopenharmony_ci 596bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_RASTERIZER | FD_DIRTY_PROG)) { 597bf215546Sopenharmony_ci struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa); 598bf215546Sopenharmony_ci bool fragz = fp->no_earlyz || fp->has_kill || zsa->base.alpha_enabled || 599bf215546Sopenharmony_ci fp->writes_pos; 600bf215546Sopenharmony_ci 601bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_DEPTH_CNTL, 1); 602bf215546Sopenharmony_ci OUT_RING(ring, zsa->rb_depth_cntl); 603bf215546Sopenharmony_ci 604bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_DEPTH_PLANE_CNTL, 1); 605bf215546Sopenharmony_ci OUT_RING(ring, COND(fragz, A5XX_RB_DEPTH_PLANE_CNTL_FRAG_WRITES_Z) | 606bf215546Sopenharmony_ci COND(fragz && fp->fragcoord_compmask != 0, 607bf215546Sopenharmony_ci A5XX_RB_DEPTH_PLANE_CNTL_UNK1)); 608bf215546Sopenharmony_ci 609bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_DEPTH_PLANE_CNTL, 1); 610bf215546Sopenharmony_ci OUT_RING(ring, COND(fragz, A5XX_GRAS_SU_DEPTH_PLANE_CNTL_FRAG_WRITES_Z) | 611bf215546Sopenharmony_ci COND(fragz && fp->fragcoord_compmask != 0, 612bf215546Sopenharmony_ci A5XX_GRAS_SU_DEPTH_PLANE_CNTL_UNK1)); 613bf215546Sopenharmony_ci } 614bf215546Sopenharmony_ci 615bf215546Sopenharmony_ci /* NOTE: scissor enabled bit is part of rasterizer state: */ 616bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_SCISSOR | FD_DIRTY_RASTERIZER)) { 617bf215546Sopenharmony_ci struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx); 618bf215546Sopenharmony_ci 619bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0, 2); 620bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor->minx) | 621bf215546Sopenharmony_ci A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor->miny)); 622bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_X(scissor->maxx - 1) | 623bf215546Sopenharmony_ci A5XX_GRAS_SC_SCREEN_SCISSOR_TL_0_Y(scissor->maxy - 1)); 624bf215546Sopenharmony_ci 625bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0, 2); 626bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor->minx) | 627bf215546Sopenharmony_ci A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor->miny)); 628bf215546Sopenharmony_ci OUT_RING(ring, 629bf215546Sopenharmony_ci A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_X(scissor->maxx - 1) | 630bf215546Sopenharmony_ci A5XX_GRAS_SC_VIEWPORT_SCISSOR_TL_0_Y(scissor->maxy - 1)); 631bf215546Sopenharmony_ci 632bf215546Sopenharmony_ci ctx->batch->max_scissor.minx = 633bf215546Sopenharmony_ci MIN2(ctx->batch->max_scissor.minx, scissor->minx); 634bf215546Sopenharmony_ci ctx->batch->max_scissor.miny = 635bf215546Sopenharmony_ci MIN2(ctx->batch->max_scissor.miny, scissor->miny); 636bf215546Sopenharmony_ci ctx->batch->max_scissor.maxx = 637bf215546Sopenharmony_ci MAX2(ctx->batch->max_scissor.maxx, scissor->maxx); 638bf215546Sopenharmony_ci ctx->batch->max_scissor.maxy = 639bf215546Sopenharmony_ci MAX2(ctx->batch->max_scissor.maxy, scissor->maxy); 640bf215546Sopenharmony_ci } 641bf215546Sopenharmony_ci 642bf215546Sopenharmony_ci if (dirty & FD_DIRTY_VIEWPORT) { 643bf215546Sopenharmony_ci fd_wfi(ctx->batch, ring); 644bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_CL_VPORT_XOFFSET_0, 6); 645bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_XOFFSET_0(ctx->viewport.translate[0])); 646bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_XSCALE_0(ctx->viewport.scale[0])); 647bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_YOFFSET_0(ctx->viewport.translate[1])); 648bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_YSCALE_0(ctx->viewport.scale[1])); 649bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_ZOFFSET_0(ctx->viewport.translate[2])); 650bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_CL_VPORT_ZSCALE_0(ctx->viewport.scale[2])); 651bf215546Sopenharmony_ci } 652bf215546Sopenharmony_ci 653bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_PROG | FD_DIRTY_RASTERIZER_CLIP_PLANE_ENABLE)) 654bf215546Sopenharmony_ci fd5_program_emit(ctx, ring, emit); 655bf215546Sopenharmony_ci 656bf215546Sopenharmony_ci if (dirty & FD_DIRTY_RASTERIZER) { 657bf215546Sopenharmony_ci struct fd5_rasterizer_stateobj *rasterizer = 658bf215546Sopenharmony_ci fd5_rasterizer_stateobj(ctx->rasterizer); 659bf215546Sopenharmony_ci 660bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_CNTL, 1); 661bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_cntl | 662bf215546Sopenharmony_ci A5XX_GRAS_SU_CNTL_LINE_MODE(pfb->samples > 1 ? 663bf215546Sopenharmony_ci RECTANGULAR : BRESENHAM)); 664bf215546Sopenharmony_ci 665bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_POINT_MINMAX, 2); 666bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_point_minmax); 667bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_point_size); 668bf215546Sopenharmony_ci 669bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_POLY_OFFSET_SCALE, 3); 670bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_poly_offset_scale); 671bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_poly_offset_offset); 672bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_su_poly_offset_clamp); 673bf215546Sopenharmony_ci 674bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_RASTER_CNTL, 1); 675bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->pc_raster_cntl); 676bf215546Sopenharmony_ci 677bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_CL_CNTL, 1); 678bf215546Sopenharmony_ci OUT_RING(ring, rasterizer->gras_cl_clip_cntl); 679bf215546Sopenharmony_ci } 680bf215546Sopenharmony_ci 681bf215546Sopenharmony_ci /* note: must come after program emit.. because there is some overlap 682bf215546Sopenharmony_ci * in registers, ex. PC_PRIMITIVE_CNTL and we rely on some cached 683bf215546Sopenharmony_ci * values from fd5_program_emit() to avoid having to re-emit the prog 684bf215546Sopenharmony_ci * every time rast state changes. 685bf215546Sopenharmony_ci * 686bf215546Sopenharmony_ci * Since the primitive restart state is not part of a tracked object, we 687bf215546Sopenharmony_ci * re-emit this register every time. 688bf215546Sopenharmony_ci */ 689bf215546Sopenharmony_ci if (emit->info && ctx->rasterizer) { 690bf215546Sopenharmony_ci struct fd5_rasterizer_stateobj *rasterizer = 691bf215546Sopenharmony_ci fd5_rasterizer_stateobj(ctx->rasterizer); 692bf215546Sopenharmony_ci unsigned max_loc = fd5_context(ctx)->max_loc; 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_PRIMITIVE_CNTL, 1); 695bf215546Sopenharmony_ci OUT_RING(ring, 696bf215546Sopenharmony_ci rasterizer->pc_primitive_cntl | 697bf215546Sopenharmony_ci A5XX_PC_PRIMITIVE_CNTL_STRIDE_IN_VPC(max_loc) | 698bf215546Sopenharmony_ci COND(emit->info->primitive_restart && emit->info->index_size, 699bf215546Sopenharmony_ci A5XX_PC_PRIMITIVE_CNTL_PRIMITIVE_RESTART)); 700bf215546Sopenharmony_ci } 701bf215546Sopenharmony_ci 702bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_FRAMEBUFFER | FD_DIRTY_RASTERIZER | FD_DIRTY_PROG)) { 703bf215546Sopenharmony_ci uint32_t posz_regid = ir3_find_output_regid(fp, FRAG_RESULT_DEPTH); 704bf215546Sopenharmony_ci unsigned nr = pfb->nr_cbufs; 705bf215546Sopenharmony_ci 706bf215546Sopenharmony_ci if (emit->binning_pass) 707bf215546Sopenharmony_ci nr = 0; 708bf215546Sopenharmony_ci else if (ctx->rasterizer->rasterizer_discard) 709bf215546Sopenharmony_ci nr = 0; 710bf215546Sopenharmony_ci 711bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_FS_OUTPUT_CNTL, 1); 712bf215546Sopenharmony_ci OUT_RING(ring, 713bf215546Sopenharmony_ci A5XX_RB_FS_OUTPUT_CNTL_MRT(nr) | 714bf215546Sopenharmony_ci COND(fp->writes_pos, A5XX_RB_FS_OUTPUT_CNTL_FRAG_WRITES_Z)); 715bf215546Sopenharmony_ci 716bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_FS_OUTPUT_CNTL, 1); 717bf215546Sopenharmony_ci OUT_RING(ring, A5XX_SP_FS_OUTPUT_CNTL_MRT(nr) | 718bf215546Sopenharmony_ci A5XX_SP_FS_OUTPUT_CNTL_DEPTH_REGID(posz_regid) | 719bf215546Sopenharmony_ci A5XX_SP_FS_OUTPUT_CNTL_SAMPLEMASK_REGID(regid(63, 0))); 720bf215546Sopenharmony_ci } 721bf215546Sopenharmony_ci 722bf215546Sopenharmony_ci ir3_emit_vs_consts(vp, ring, ctx, emit->info, emit->indirect, emit->draw); 723bf215546Sopenharmony_ci if (!emit->binning_pass) 724bf215546Sopenharmony_ci ir3_emit_fs_consts(fp, ring, ctx); 725bf215546Sopenharmony_ci 726bf215546Sopenharmony_ci const struct ir3_stream_output_info *info = &vp->stream_output; 727bf215546Sopenharmony_ci if (info->num_outputs) { 728bf215546Sopenharmony_ci struct fd_streamout_stateobj *so = &ctx->streamout; 729bf215546Sopenharmony_ci 730bf215546Sopenharmony_ci for (unsigned i = 0; i < so->num_targets; i++) { 731bf215546Sopenharmony_ci struct fd_stream_output_target *target = 732bf215546Sopenharmony_ci fd_stream_output_target(so->targets[i]); 733bf215546Sopenharmony_ci 734bf215546Sopenharmony_ci if (!target) 735bf215546Sopenharmony_ci continue; 736bf215546Sopenharmony_ci 737bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_BASE_LO(i), 3); 738bf215546Sopenharmony_ci /* VPC_SO[i].BUFFER_BASE_LO: */ 739bf215546Sopenharmony_ci OUT_RELOC(ring, fd_resource(target->base.buffer)->bo, 0, 0, 0); 740bf215546Sopenharmony_ci OUT_RING(ring, target->base.buffer_size + target->base.buffer_offset); 741bf215546Sopenharmony_ci 742bf215546Sopenharmony_ci struct fd_bo *offset_bo = fd_resource(target->offset_buf)->bo; 743bf215546Sopenharmony_ci 744bf215546Sopenharmony_ci if (so->reset & (1 << i)) { 745bf215546Sopenharmony_ci assert(so->offsets[i] == 0); 746bf215546Sopenharmony_ci 747bf215546Sopenharmony_ci OUT_PKT7(ring, CP_MEM_WRITE, 3); 748bf215546Sopenharmony_ci OUT_RELOC(ring, offset_bo, 0, 0, 0); 749bf215546Sopenharmony_ci OUT_RING(ring, target->base.buffer_offset); 750bf215546Sopenharmony_ci 751bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_OFFSET(i), 1); 752bf215546Sopenharmony_ci OUT_RING(ring, target->base.buffer_offset); 753bf215546Sopenharmony_ci } else { 754bf215546Sopenharmony_ci OUT_PKT7(ring, CP_MEM_TO_REG, 3); 755bf215546Sopenharmony_ci OUT_RING(ring, 756bf215546Sopenharmony_ci CP_MEM_TO_REG_0_REG(REG_A5XX_VPC_SO_BUFFER_OFFSET(i)) | 757bf215546Sopenharmony_ci CP_MEM_TO_REG_0_SHIFT_BY_2 | CP_MEM_TO_REG_0_UNK31 | 758bf215546Sopenharmony_ci CP_MEM_TO_REG_0_CNT(0)); 759bf215546Sopenharmony_ci OUT_RELOC(ring, offset_bo, 0, 0, 0); 760bf215546Sopenharmony_ci } 761bf215546Sopenharmony_ci 762bf215546Sopenharmony_ci // After a draw HW would write the new offset to offset_bo 763bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_FLUSH_BASE_LO(i), 2); 764bf215546Sopenharmony_ci OUT_RELOC(ring, offset_bo, 0, 0, 0); 765bf215546Sopenharmony_ci 766bf215546Sopenharmony_ci so->reset &= ~(1 << i); 767bf215546Sopenharmony_ci 768bf215546Sopenharmony_ci emit->streamout_mask |= (1 << i); 769bf215546Sopenharmony_ci } 770bf215546Sopenharmony_ci } 771bf215546Sopenharmony_ci 772bf215546Sopenharmony_ci if (!emit->streamout_mask && info->num_outputs) { 773bf215546Sopenharmony_ci OUT_PKT7(ring, CP_CONTEXT_REG_BUNCH, 4); 774bf215546Sopenharmony_ci OUT_RING(ring, REG_A5XX_VPC_SO_CNTL); 775bf215546Sopenharmony_ci OUT_RING(ring, 0); 776bf215546Sopenharmony_ci OUT_RING(ring, REG_A5XX_VPC_SO_BUF_CNTL); 777bf215546Sopenharmony_ci OUT_RING(ring, 0); 778bf215546Sopenharmony_ci } else if (emit->streamout_mask && !(dirty & FD_DIRTY_PROG)) { 779bf215546Sopenharmony_ci /* reemit the program (if we haven't already) to re-enable streamout. We 780bf215546Sopenharmony_ci * really should switch to setting up program state at compile time so we 781bf215546Sopenharmony_ci * can separate the SO state from the rest, and not recompute all the 782bf215546Sopenharmony_ci * time. 783bf215546Sopenharmony_ci */ 784bf215546Sopenharmony_ci fd5_program_emit(ctx, ring, emit); 785bf215546Sopenharmony_ci } 786bf215546Sopenharmony_ci 787bf215546Sopenharmony_ci if (dirty & FD_DIRTY_BLEND) { 788bf215546Sopenharmony_ci struct fd5_blend_stateobj *blend = fd5_blend_stateobj(ctx->blend); 789bf215546Sopenharmony_ci uint32_t i; 790bf215546Sopenharmony_ci 791bf215546Sopenharmony_ci for (i = 0; i < A5XX_MAX_RENDER_TARGETS; i++) { 792bf215546Sopenharmony_ci enum pipe_format format = pipe_surface_format(pfb->cbufs[i]); 793bf215546Sopenharmony_ci bool is_int = util_format_is_pure_integer(format); 794bf215546Sopenharmony_ci bool has_alpha = util_format_has_alpha(format); 795bf215546Sopenharmony_ci uint32_t control = blend->rb_mrt[i].control; 796bf215546Sopenharmony_ci 797bf215546Sopenharmony_ci if (is_int) { 798bf215546Sopenharmony_ci control &= A5XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK; 799bf215546Sopenharmony_ci control |= A5XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY); 800bf215546Sopenharmony_ci } 801bf215546Sopenharmony_ci 802bf215546Sopenharmony_ci if (!has_alpha) { 803bf215546Sopenharmony_ci control &= ~A5XX_RB_MRT_CONTROL_BLEND2; 804bf215546Sopenharmony_ci } 805bf215546Sopenharmony_ci 806bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_MRT_CONTROL(i), 1); 807bf215546Sopenharmony_ci OUT_RING(ring, control); 808bf215546Sopenharmony_ci 809bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_MRT_BLEND_CONTROL(i), 1); 810bf215546Sopenharmony_ci OUT_RING(ring, blend->rb_mrt[i].blend_control); 811bf215546Sopenharmony_ci } 812bf215546Sopenharmony_ci 813bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_BLEND_CNTL, 1); 814bf215546Sopenharmony_ci OUT_RING(ring, blend->sp_blend_cntl); 815bf215546Sopenharmony_ci } 816bf215546Sopenharmony_ci 817bf215546Sopenharmony_ci if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_SAMPLE_MASK)) { 818bf215546Sopenharmony_ci struct fd5_blend_stateobj *blend = fd5_blend_stateobj(ctx->blend); 819bf215546Sopenharmony_ci 820bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_BLEND_CNTL, 1); 821bf215546Sopenharmony_ci OUT_RING(ring, blend->rb_blend_cntl | 822bf215546Sopenharmony_ci A5XX_RB_BLEND_CNTL_SAMPLE_MASK(ctx->sample_mask)); 823bf215546Sopenharmony_ci } 824bf215546Sopenharmony_ci 825bf215546Sopenharmony_ci if (dirty & FD_DIRTY_BLEND_COLOR) { 826bf215546Sopenharmony_ci struct pipe_blend_color *bcolor = &ctx->blend_color; 827bf215546Sopenharmony_ci 828bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_BLEND_RED, 8); 829bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_RED_FLOAT(bcolor->color[0]) | 830bf215546Sopenharmony_ci A5XX_RB_BLEND_RED_UINT(CLAMP(bcolor->color[0], 0.f, 1.f) * 0xff) | 831bf215546Sopenharmony_ci A5XX_RB_BLEND_RED_SINT(CLAMP(bcolor->color[0], -1.f, 1.f) * 0x7f)); 832bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_RED_F32(bcolor->color[0])); 833bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_GREEN_FLOAT(bcolor->color[1]) | 834bf215546Sopenharmony_ci A5XX_RB_BLEND_GREEN_UINT(CLAMP(bcolor->color[1], 0.f, 1.f) * 0xff) | 835bf215546Sopenharmony_ci A5XX_RB_BLEND_GREEN_SINT(CLAMP(bcolor->color[1], -1.f, 1.f) * 0x7f)); 836bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_RED_F32(bcolor->color[1])); 837bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_BLUE_FLOAT(bcolor->color[2]) | 838bf215546Sopenharmony_ci A5XX_RB_BLEND_BLUE_UINT(CLAMP(bcolor->color[2], 0.f, 1.f) * 0xff) | 839bf215546Sopenharmony_ci A5XX_RB_BLEND_BLUE_SINT(CLAMP(bcolor->color[2], -1.f, 1.f) * 0x7f)); 840bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_BLUE_F32(bcolor->color[2])); 841bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_ALPHA_FLOAT(bcolor->color[3]) | 842bf215546Sopenharmony_ci A5XX_RB_BLEND_ALPHA_UINT(CLAMP(bcolor->color[3], 0.f, 1.f) * 0xff) | 843bf215546Sopenharmony_ci A5XX_RB_BLEND_ALPHA_SINT(CLAMP(bcolor->color[3], -1.f, 1.f) * 0x7f)); 844bf215546Sopenharmony_ci OUT_RING(ring, A5XX_RB_BLEND_ALPHA_F32(bcolor->color[3])); 845bf215546Sopenharmony_ci } 846bf215546Sopenharmony_ci 847bf215546Sopenharmony_ci if (ctx->dirty_shader[PIPE_SHADER_VERTEX] & FD_DIRTY_SHADER_TEX) { 848bf215546Sopenharmony_ci needs_border |= 849bf215546Sopenharmony_ci emit_textures(ctx, ring, SB4_VS_TEX, &ctx->tex[PIPE_SHADER_VERTEX]); 850bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1); 851bf215546Sopenharmony_ci OUT_RING(ring, ctx->tex[PIPE_SHADER_VERTEX].num_textures); 852bf215546Sopenharmony_ci } 853bf215546Sopenharmony_ci 854bf215546Sopenharmony_ci if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_TEX) { 855bf215546Sopenharmony_ci needs_border |= 856bf215546Sopenharmony_ci emit_textures(ctx, ring, SB4_FS_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT]); 857bf215546Sopenharmony_ci } 858bf215546Sopenharmony_ci 859bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1); 860bf215546Sopenharmony_ci OUT_RING(ring, ctx->shaderimg[PIPE_SHADER_FRAGMENT].enabled_mask 861bf215546Sopenharmony_ci ? ~0 862bf215546Sopenharmony_ci : ctx->tex[PIPE_SHADER_FRAGMENT].num_textures); 863bf215546Sopenharmony_ci 864bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_CS_TEX_COUNT, 1); 865bf215546Sopenharmony_ci OUT_RING(ring, 0); 866bf215546Sopenharmony_ci 867bf215546Sopenharmony_ci if (needs_border) 868bf215546Sopenharmony_ci emit_border_color(ctx, ring); 869bf215546Sopenharmony_ci 870bf215546Sopenharmony_ci if (!emit->binning_pass) { 871bf215546Sopenharmony_ci if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_SSBO) 872bf215546Sopenharmony_ci emit_ssbos(ctx, ring, SB4_SSBO, &ctx->shaderbuf[PIPE_SHADER_FRAGMENT], 873bf215546Sopenharmony_ci fp); 874bf215546Sopenharmony_ci 875bf215546Sopenharmony_ci if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_IMAGE) 876bf215546Sopenharmony_ci fd5_emit_images(ctx, ring, PIPE_SHADER_FRAGMENT, fp); 877bf215546Sopenharmony_ci } 878bf215546Sopenharmony_ci} 879bf215546Sopenharmony_ci 880bf215546Sopenharmony_civoid 881bf215546Sopenharmony_cifd5_emit_cs_state(struct fd_context *ctx, struct fd_ringbuffer *ring, 882bf215546Sopenharmony_ci struct ir3_shader_variant *cp) 883bf215546Sopenharmony_ci{ 884bf215546Sopenharmony_ci enum fd_dirty_shader_state dirty = ctx->dirty_shader[PIPE_SHADER_COMPUTE]; 885bf215546Sopenharmony_ci 886bf215546Sopenharmony_ci if (dirty & FD_DIRTY_SHADER_TEX) { 887bf215546Sopenharmony_ci bool needs_border = false; 888bf215546Sopenharmony_ci needs_border |= 889bf215546Sopenharmony_ci emit_textures(ctx, ring, SB4_CS_TEX, &ctx->tex[PIPE_SHADER_COMPUTE]); 890bf215546Sopenharmony_ci 891bf215546Sopenharmony_ci if (needs_border) 892bf215546Sopenharmony_ci emit_border_color(ctx, ring); 893bf215546Sopenharmony_ci 894bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1); 895bf215546Sopenharmony_ci OUT_RING(ring, 0); 896bf215546Sopenharmony_ci 897bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_HS_TEX_COUNT, 1); 898bf215546Sopenharmony_ci OUT_RING(ring, 0); 899bf215546Sopenharmony_ci 900bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_DS_TEX_COUNT, 1); 901bf215546Sopenharmony_ci OUT_RING(ring, 0); 902bf215546Sopenharmony_ci 903bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_GS_TEX_COUNT, 1); 904bf215546Sopenharmony_ci OUT_RING(ring, 0); 905bf215546Sopenharmony_ci 906bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1); 907bf215546Sopenharmony_ci OUT_RING(ring, 0); 908bf215546Sopenharmony_ci } 909bf215546Sopenharmony_ci 910bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_CS_TEX_COUNT, 1); 911bf215546Sopenharmony_ci OUT_RING(ring, ctx->shaderimg[PIPE_SHADER_COMPUTE].enabled_mask 912bf215546Sopenharmony_ci ? ~0 913bf215546Sopenharmony_ci : ctx->tex[PIPE_SHADER_COMPUTE].num_textures); 914bf215546Sopenharmony_ci 915bf215546Sopenharmony_ci if (dirty & FD_DIRTY_SHADER_SSBO) 916bf215546Sopenharmony_ci emit_ssbos(ctx, ring, SB4_CS_SSBO, &ctx->shaderbuf[PIPE_SHADER_COMPUTE], 917bf215546Sopenharmony_ci cp); 918bf215546Sopenharmony_ci 919bf215546Sopenharmony_ci if (dirty & FD_DIRTY_SHADER_IMAGE) 920bf215546Sopenharmony_ci fd5_emit_images(ctx, ring, PIPE_SHADER_COMPUTE, cp); 921bf215546Sopenharmony_ci} 922bf215546Sopenharmony_ci 923bf215546Sopenharmony_ci/* emit setup at begin of new cmdstream buffer (don't rely on previous 924bf215546Sopenharmony_ci * state, there could have been a context switch between ioctls): 925bf215546Sopenharmony_ci */ 926bf215546Sopenharmony_civoid 927bf215546Sopenharmony_cifd5_emit_restore(struct fd_batch *batch, struct fd_ringbuffer *ring) 928bf215546Sopenharmony_ci{ 929bf215546Sopenharmony_ci struct fd_context *ctx = batch->ctx; 930bf215546Sopenharmony_ci 931bf215546Sopenharmony_ci fd5_set_render_mode(ctx, ring, BYPASS); 932bf215546Sopenharmony_ci fd5_cache_flush(batch, ring); 933bf215546Sopenharmony_ci 934bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_HLSQ_UPDATE_CNTL, 1); 935bf215546Sopenharmony_ci OUT_RING(ring, 0xfffff); 936bf215546Sopenharmony_ci 937bf215546Sopenharmony_ci /* 938bf215546Sopenharmony_ci t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords) 939bf215546Sopenharmony_ci 0000000500024048: 70d08003 00000000 001c5000 00000005 940bf215546Sopenharmony_ci t7 opcode: CP_PERFCOUNTER_ACTION (50) (4 dwords) 941bf215546Sopenharmony_ci 0000000500024058: 70d08003 00000010 001c7000 00000005 942bf215546Sopenharmony_ci 943bf215546Sopenharmony_ci t7 opcode: CP_WAIT_FOR_IDLE (26) (1 dwords) 944bf215546Sopenharmony_ci 0000000500024068: 70268000 945bf215546Sopenharmony_ci */ 946bf215546Sopenharmony_ci 947bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_RESTART_INDEX, 1); 948bf215546Sopenharmony_ci OUT_RING(ring, 0xffffffff); 949bf215546Sopenharmony_ci 950bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_RASTER_CNTL, 1); 951bf215546Sopenharmony_ci OUT_RING(ring, 0x00000012); 952bf215546Sopenharmony_ci 953bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_POINT_MINMAX, 2); 954bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_SU_POINT_MINMAX_MIN(1.0f) | 955bf215546Sopenharmony_ci A5XX_GRAS_SU_POINT_MINMAX_MAX(4092.0f)); 956bf215546Sopenharmony_ci OUT_RING(ring, A5XX_GRAS_SU_POINT_SIZE(0.5f)); 957bf215546Sopenharmony_ci 958bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL, 1); 959bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */ 960bf215546Sopenharmony_ci 961bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SC_SCREEN_SCISSOR_CNTL, 1); 962bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SC_SCREEN_SCISSOR_CNTL */ 963bf215546Sopenharmony_ci 964bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_VS_CONFIG_MAX_CONST, 1); 965bf215546Sopenharmony_ci OUT_RING(ring, 0); /* SP_VS_CONFIG_MAX_CONST */ 966bf215546Sopenharmony_ci 967bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_FS_CONFIG_MAX_CONST, 1); 968bf215546Sopenharmony_ci OUT_RING(ring, 0); /* SP_FS_CONFIG_MAX_CONST */ 969bf215546Sopenharmony_ci 970bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E292, 2); 971bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E292 */ 972bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E293 */ 973bf215546Sopenharmony_ci 974bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_MODE_CNTL, 1); 975bf215546Sopenharmony_ci OUT_RING(ring, 0x00000044); /* RB_MODE_CNTL */ 976bf215546Sopenharmony_ci 977bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_DBG_ECO_CNTL, 1); 978bf215546Sopenharmony_ci OUT_RING(ring, 0x00100000); /* RB_DBG_ECO_CNTL */ 979bf215546Sopenharmony_ci 980bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VFD_MODE_CNTL, 1); 981bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VFD_MODE_CNTL */ 982bf215546Sopenharmony_ci 983bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_MODE_CNTL, 1); 984bf215546Sopenharmony_ci OUT_RING(ring, 0x0000001f); /* PC_MODE_CNTL */ 985bf215546Sopenharmony_ci 986bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_MODE_CNTL, 1); 987bf215546Sopenharmony_ci OUT_RING(ring, 0x0000001e); /* SP_MODE_CNTL */ 988bf215546Sopenharmony_ci 989bf215546Sopenharmony_ci if (ctx->screen->gpu_id == 540) { 990bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_DBG_ECO_CNTL, 1); 991bf215546Sopenharmony_ci OUT_RING(ring, 0x800); /* SP_DBG_ECO_CNTL */ 992bf215546Sopenharmony_ci 993bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_HLSQ_DBG_ECO_CNTL, 1); 994bf215546Sopenharmony_ci OUT_RING(ring, 0x0); 995bf215546Sopenharmony_ci 996bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_DBG_ECO_CNTL, 1); 997bf215546Sopenharmony_ci OUT_RING(ring, 0x800400); 998bf215546Sopenharmony_ci } else { 999bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_DBG_ECO_CNTL, 1); 1000bf215546Sopenharmony_ci OUT_RING(ring, 0x40000800); /* SP_DBG_ECO_CNTL */ 1001bf215546Sopenharmony_ci } 1002bf215546Sopenharmony_ci 1003bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_MODE_CNTL, 1); 1004bf215546Sopenharmony_ci OUT_RING(ring, 0x00000544); /* TPL1_MODE_CNTL */ 1005bf215546Sopenharmony_ci 1006bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_HLSQ_TIMEOUT_THRESHOLD_0, 2); 1007bf215546Sopenharmony_ci OUT_RING(ring, 0x00000080); /* HLSQ_TIMEOUT_THRESHOLD_0 */ 1008bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* HLSQ_TIMEOUT_THRESHOLD_1 */ 1009bf215546Sopenharmony_ci 1010bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_DBG_ECO_CNTL, 1); 1011bf215546Sopenharmony_ci OUT_RING(ring, 0x00000400); /* VPC_DBG_ECO_CNTL */ 1012bf215546Sopenharmony_ci 1013bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_HLSQ_MODE_CNTL, 1); 1014bf215546Sopenharmony_ci OUT_RING(ring, 0x00000001); /* HLSQ_MODE_CNTL */ 1015bf215546Sopenharmony_ci 1016bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_MODE_CNTL, 1); 1017bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_MODE_CNTL */ 1018bf215546Sopenharmony_ci 1019bf215546Sopenharmony_ci /* we don't use this yet.. probably best to disable.. */ 1020bf215546Sopenharmony_ci OUT_PKT7(ring, CP_SET_DRAW_STATE, 3); 1021bf215546Sopenharmony_ci OUT_RING(ring, CP_SET_DRAW_STATE__0_COUNT(0) | 1022bf215546Sopenharmony_ci CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS | 1023bf215546Sopenharmony_ci CP_SET_DRAW_STATE__0_GROUP_ID(0)); 1024bf215546Sopenharmony_ci OUT_RING(ring, CP_SET_DRAW_STATE__1_ADDR_LO(0)); 1025bf215546Sopenharmony_ci OUT_RING(ring, CP_SET_DRAW_STATE__2_ADDR_HI(0)); 1026bf215546Sopenharmony_ci 1027bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_CONSERVATIVE_RAS_CNTL, 1); 1028bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SU_CONSERVATIVE_RAS_CNTL */ 1029bf215546Sopenharmony_ci 1030bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SC_BIN_CNTL, 1); 1031bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SC_BIN_CNTL */ 1032bf215546Sopenharmony_ci 1033bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SC_BIN_CNTL, 1); 1034bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SC_BIN_CNTL */ 1035bf215546Sopenharmony_ci 1036bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_FS_PRIMITIVEID_CNTL, 1); 1037bf215546Sopenharmony_ci OUT_RING(ring, 0x000000ff); /* VPC_FS_PRIMITIVEID_CNTL */ 1038bf215546Sopenharmony_ci 1039bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_OVERRIDE, 1); 1040bf215546Sopenharmony_ci OUT_RING(ring, A5XX_VPC_SO_OVERRIDE_SO_DISABLE); 1041bf215546Sopenharmony_ci 1042bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_BASE_LO(0), 3); 1043bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_BUFFER_BASE_LO_0 */ 1044bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_BUFFER_BASE_HI_0 */ 1045bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_BUFFER_SIZE_0 */ 1046bf215546Sopenharmony_ci 1047bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_FLUSH_BASE_LO(0), 2); 1048bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_FLUSH_BASE_LO_0 */ 1049bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_FLUSH_BASE_HI_0 */ 1050bf215546Sopenharmony_ci 1051bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_GS_PARAM, 1); 1052bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* PC_GS_PARAM */ 1053bf215546Sopenharmony_ci 1054bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_HS_PARAM, 1); 1055bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* PC_HS_PARAM */ 1056bf215546Sopenharmony_ci 1057bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_TP_FS_ROTATION_CNTL, 1); 1058bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* TPL1_TP_FS_ROTATION_CNTL */ 1059bf215546Sopenharmony_ci 1060bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E004, 1); 1061bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E004 */ 1062bf215546Sopenharmony_ci 1063bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_GRAS_SU_LAYERED, 1); 1064bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* GRAS_SU_LAYERED */ 1065bf215546Sopenharmony_ci 1066bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUF_CNTL, 1); 1067bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* VPC_SO_BUF_CNTL */ 1068bf215546Sopenharmony_ci 1069bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_OFFSET(0), 1); 1070bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E2AB */ 1071bf215546Sopenharmony_ci 1072bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_PC_GS_LAYERED, 1); 1073bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* PC_GS_LAYERED */ 1074bf215546Sopenharmony_ci 1075bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E5AB, 1); 1076bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E5AB */ 1077bf215546Sopenharmony_ci 1078bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E5C2, 1); 1079bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); /* UNKNOWN_E5C2 */ 1080bf215546Sopenharmony_ci 1081bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_BASE_LO(1), 3); 1082bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1083bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1084bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1085bf215546Sopenharmony_ci 1086bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_OFFSET(1), 6); 1087bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1088bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1089bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1090bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1091bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1092bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1093bf215546Sopenharmony_ci 1094bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_OFFSET(2), 6); 1095bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1096bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1097bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1098bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1099bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1100bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1101bf215546Sopenharmony_ci 1102bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_VPC_SO_BUFFER_OFFSET(3), 3); 1103bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1104bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1105bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1106bf215546Sopenharmony_ci 1107bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E5DB, 1); 1108bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1109bf215546Sopenharmony_ci 1110bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_HS_CTRL_REG0, 1); 1111bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1112bf215546Sopenharmony_ci 1113bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_SP_GS_CTRL_REG0, 1); 1114bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1115bf215546Sopenharmony_ci 1116bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 4); 1117bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1118bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1119bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1120bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1121bf215546Sopenharmony_ci 1122bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 2); 1123bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1124bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1125bf215546Sopenharmony_ci 1126bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7C0, 3); 1127bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1128bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1129bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1130bf215546Sopenharmony_ci 1131bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7C5, 3); 1132bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1133bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1134bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7CA, 3); 1137bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1138bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1139bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1140bf215546Sopenharmony_ci 1141bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7CF, 3); 1142bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1143bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1144bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1145bf215546Sopenharmony_ci 1146bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7D4, 3); 1147bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1148bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1149bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1150bf215546Sopenharmony_ci 1151bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_UNKNOWN_E7D9, 3); 1152bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1153bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1154bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1155bf215546Sopenharmony_ci 1156bf215546Sopenharmony_ci OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1); 1157bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1158bf215546Sopenharmony_ci} 1159bf215546Sopenharmony_ci 1160bf215546Sopenharmony_cistatic void 1161bf215546Sopenharmony_cifd5_mem_to_mem(struct fd_ringbuffer *ring, struct pipe_resource *dst, 1162bf215546Sopenharmony_ci unsigned dst_off, struct pipe_resource *src, unsigned src_off, 1163bf215546Sopenharmony_ci unsigned sizedwords) 1164bf215546Sopenharmony_ci{ 1165bf215546Sopenharmony_ci struct fd_bo *src_bo = fd_resource(src)->bo; 1166bf215546Sopenharmony_ci struct fd_bo *dst_bo = fd_resource(dst)->bo; 1167bf215546Sopenharmony_ci unsigned i; 1168bf215546Sopenharmony_ci 1169bf215546Sopenharmony_ci for (i = 0; i < sizedwords; i++) { 1170bf215546Sopenharmony_ci OUT_PKT7(ring, CP_MEM_TO_MEM, 5); 1171bf215546Sopenharmony_ci OUT_RING(ring, 0x00000000); 1172bf215546Sopenharmony_ci OUT_RELOC(ring, dst_bo, dst_off, 0, 0); 1173bf215546Sopenharmony_ci OUT_RELOC(ring, src_bo, src_off, 0, 0); 1174bf215546Sopenharmony_ci 1175bf215546Sopenharmony_ci dst_off += 4; 1176bf215546Sopenharmony_ci src_off += 4; 1177bf215546Sopenharmony_ci } 1178bf215546Sopenharmony_ci} 1179bf215546Sopenharmony_ci 1180bf215546Sopenharmony_civoid 1181bf215546Sopenharmony_cifd5_emit_init_screen(struct pipe_screen *pscreen) 1182bf215546Sopenharmony_ci{ 1183bf215546Sopenharmony_ci struct fd_screen *screen = fd_screen(pscreen); 1184bf215546Sopenharmony_ci screen->emit_ib = fd5_emit_ib; 1185bf215546Sopenharmony_ci screen->mem_to_mem = fd5_mem_to_mem; 1186bf215546Sopenharmony_ci} 1187bf215546Sopenharmony_ci 1188bf215546Sopenharmony_civoid 1189bf215546Sopenharmony_cifd5_emit_init(struct pipe_context *pctx) 1190bf215546Sopenharmony_ci{ 1191bf215546Sopenharmony_ci} 1192