| 1 |
/* |
| 2 |
* Copyright © 2012 Rob Clark <[email protected]> |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
* |
| 5 |
* Authors: |
| 6 |
* Rob Clark <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "pipe/p_state.h" |
| 10 |
#include "util/u_inlines.h" |
| 11 |
#include "util/u_memory.h" |
| 12 |
#include "util/u_string.h" |
| 13 |
|
| 14 |
#include "freedreno_draw.h" |
| 15 |
#include "freedreno_resource.h" |
| 16 |
#include "freedreno_state.h" |
| 17 |
|
| 18 |
#include "ir2/instr-a2xx.h" |
| 19 |
#include "fd2_context.h" |
| 20 |
#include "fd2_draw.h" |
| 21 |
#include "fd2_emit.h" |
| 22 |
#include "fd2_gmem.h" |
| 23 |
#include "fd2_program.h" |
| 24 |
#include "fd2_util.h" |
| 25 |
#include "fd2_zsa.h" |
| 26 |
|
| 27 |
static uint32_t |
| 28 |
fmt2swap(enum pipe_format format) |
| 29 |
{ |
| 30 |
switch (format) { |
| 31 |
case PIPE_FORMAT_B8G8R8A8_UNORM: |
| 32 |
case PIPE_FORMAT_B8G8R8X8_UNORM: |
| 33 |
case PIPE_FORMAT_B5G6R5_UNORM: |
| 34 |
case PIPE_FORMAT_B5G5R5A1_UNORM: |
| 35 |
case PIPE_FORMAT_B5G5R5X1_UNORM: |
| 36 |
case PIPE_FORMAT_B4G4R4A4_UNORM: |
| 37 |
case PIPE_FORMAT_B4G4R4X4_UNORM: |
| 38 |
case PIPE_FORMAT_B2G3R3_UNORM: |
| 39 |
return 1; |
| 40 |
default: |
| 41 |
return 0; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
static bool |
| 46 |
use_hw_binning(struct fd_batch *batch) |
| 47 |
{ |
| 48 |
const struct fd_gmem_stateobj *gmem = batch->gmem_state; |
| 49 |
|
| 50 |
/* we hardcoded a limit of 8 "pipes", we can increase this limit |
| 51 |
* at the cost of a slightly larger command stream |
| 52 |
* however very few cases will need more than 8 |
| 53 |
* gmem->num_vsc_pipes == 0 means empty batch (TODO: does it still happen?) |
| 54 |
*/ |
| 55 |
if (gmem->num_vsc_pipes > 8 || !gmem->num_vsc_pipes) |
| 56 |
return false; |
| 57 |
|
| 58 |
/* only a20x hw binning is implement |
| 59 |
* a22x is more like a3xx, but perhaps the a20x works? (TODO) |
| 60 |
*/ |
| 61 |
if (!is_a20x(batch->ctx->screen)) |
| 62 |
return false; |
| 63 |
|
| 64 |
return fd_binning_enabled && ((gmem->nbins_x * gmem->nbins_y) > 2); |
| 65 |
} |
| 66 |
|
| 67 |
/* transfer from gmem to system memory (ie. normal RAM) */ |
| 68 |
|
| 69 |
static void |
| 70 |
emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, |
| 71 |
struct pipe_surface *psurf) |
| 72 |
{ |
| 73 |
struct fd_ringbuffer *ring = batch->tile_store; |
| 74 |
struct fd_resource *rsc = fd_resource(psurf->texture); |
| 75 |
uint32_t offset = |
| 76 |
fd_resource_offset(rsc, psurf->level, psurf->first_layer); |
| 77 |
enum pipe_format format = fd_gmem_restore_format(psurf->format); |
| 78 |
uint32_t pitch = fdl2_pitch_pixels(&rsc->layout, psurf->level); |
| 79 |
|
| 80 |
assert((pitch & 31) == 0); |
| 81 |
assert((offset & 0xfff) == 0); |
| 82 |
|
| 83 |
if (!rsc->valid) |
| 84 |
return; |
| 85 |
|
| 86 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 87 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); |
| 88 |
OUT_RING(ring, A2XX_RB_COLOR_INFO_BASE(base) | |
| 89 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format))); |
| 90 |
|
| 91 |
OUT_PKT3(ring, CP_SET_CONSTANT, 5); |
| 92 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COPY_CONTROL)); |
| 93 |
OUT_RING(ring, 0x00000000); /* RB_COPY_CONTROL */ |
| 94 |
OUT_RELOC(ring, rsc->bo, offset, 0, 0); /* RB_COPY_DEST_BASE */ |
| 95 |
OUT_RING(ring, pitch >> 5); /* RB_COPY_DEST_PITCH */ |
| 96 |
OUT_RING(ring, /* RB_COPY_DEST_INFO */ |
| 97 |
A2XX_RB_COPY_DEST_INFO_FORMAT(fd2_pipe2color(format)) | |
| 98 |
COND(!rsc->layout.tile_mode, A2XX_RB_COPY_DEST_INFO_LINEAR) | |
| 99 |
A2XX_RB_COPY_DEST_INFO_WRITE_RED | |
| 100 |
A2XX_RB_COPY_DEST_INFO_WRITE_GREEN | |
| 101 |
A2XX_RB_COPY_DEST_INFO_WRITE_BLUE | |
| 102 |
A2XX_RB_COPY_DEST_INFO_WRITE_ALPHA); |
| 103 |
|
| 104 |
if (!is_a20x(batch->ctx->screen)) { |
| 105 |
OUT_WFI(ring); |
| 106 |
|
| 107 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 108 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_MAX_VTX_INDX)); |
| 109 |
OUT_RING(ring, 3); /* VGT_MAX_VTX_INDX */ |
| 110 |
OUT_RING(ring, 0); /* VGT_MIN_VTX_INDX */ |
| 111 |
} |
| 112 |
|
| 113 |
fd_draw(batch, ring, DI_PT_RECTLIST, IGNORE_VISIBILITY, |
| 114 |
DI_SRC_SEL_AUTO_INDEX, 3, 0, INDEX_SIZE_IGN, 0, 0, NULL); |
| 115 |
} |
| 116 |
|
| 117 |
static void |
| 118 |
prepare_tile_fini_ib(struct fd_batch *batch) assert_dt |
| 119 |
{ |
| 120 |
struct fd_context *ctx = batch->ctx; |
| 121 |
struct fd2_context *fd2_ctx = fd2_context(ctx); |
| 122 |
const struct fd_gmem_stateobj *gmem = batch->gmem_state; |
| 123 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 124 |
struct fd_ringbuffer *ring; |
| 125 |
|
| 126 |
batch->tile_store = |
| 127 |
fd_submit_new_ringbuffer(batch->submit, 0x1000, FD_RINGBUFFER_STREAMING); |
| 128 |
ring = batch->tile_store; |
| 129 |
|
| 130 |
fd2_emit_vertex_bufs(ring, 0x9c, |
| 131 |
(struct fd2_vertex_buf[]){ |
| 132 |
{.prsc = fd2_ctx->solid_vertexbuf, .size = 36}, |
| 133 |
}, |
| 134 |
1); |
| 135 |
|
| 136 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 137 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_WINDOW_OFFSET)); |
| 138 |
OUT_RING(ring, 0x00000000); /* PA_SC_WINDOW_OFFSET */ |
| 139 |
|
| 140 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 141 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_INDX_OFFSET)); |
| 142 |
OUT_RING(ring, 0); |
| 143 |
|
| 144 |
if (!is_a20x(ctx->screen)) { |
| 145 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 146 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_VERTEX_REUSE_BLOCK_CNTL)); |
| 147 |
OUT_RING(ring, 0x0000028f); |
| 148 |
} |
| 149 |
|
| 150 |
fd2_program_emit(ctx, ring, &ctx->solid_prog); |
| 151 |
|
| 152 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 153 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_AA_MASK)); |
| 154 |
OUT_RING(ring, 0x0000ffff); |
| 155 |
|
| 156 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 157 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_DEPTHCONTROL)); |
| 158 |
OUT_RING(ring, A2XX_RB_DEPTHCONTROL_EARLY_Z_ENABLE); |
| 159 |
|
| 160 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 161 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SU_SC_MODE_CNTL)); |
| 162 |
OUT_RING( |
| 163 |
ring, |
| 164 |
A2XX_PA_SU_SC_MODE_CNTL_PROVOKING_VTX_LAST | /* PA_SU_SC_MODE_CNTL */ |
| 165 |
A2XX_PA_SU_SC_MODE_CNTL_FRONT_PTYPE(PC_DRAW_TRIANGLES) | |
| 166 |
A2XX_PA_SU_SC_MODE_CNTL_BACK_PTYPE(PC_DRAW_TRIANGLES)); |
| 167 |
|
| 168 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 169 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_WINDOW_SCISSOR_TL)); |
| 170 |
OUT_RING(ring, xy2d(0, 0)); /* PA_SC_WINDOW_SCISSOR_TL */ |
| 171 |
OUT_RING(ring, xy2d(pfb->width, pfb->height)); /* PA_SC_WINDOW_SCISSOR_BR */ |
| 172 |
|
| 173 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 174 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_CLIP_CNTL)); |
| 175 |
OUT_RING(ring, 0x00000000); |
| 176 |
|
| 177 |
OUT_PKT3(ring, CP_SET_CONSTANT, 5); |
| 178 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_VPORT_XSCALE)); |
| 179 |
OUT_RING(ring, fui((float)gmem->bin_w / 2.0f)); /* XSCALE */ |
| 180 |
OUT_RING(ring, fui((float)gmem->bin_w / 2.0f)); /* XOFFSET */ |
| 181 |
OUT_RING(ring, fui((float)gmem->bin_h / 2.0f)); /* YSCALE */ |
| 182 |
OUT_RING(ring, fui((float)gmem->bin_h / 2.0f)); /* YOFFSET */ |
| 183 |
|
| 184 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 185 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_MODECONTROL)); |
| 186 |
OUT_RING(ring, A2XX_RB_MODECONTROL_EDRAM_MODE(EDRAM_COPY)); |
| 187 |
|
| 188 |
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) |
| 189 |
emit_gmem2mem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf); |
| 190 |
|
| 191 |
if (batch->resolve & FD_BUFFER_COLOR) |
| 192 |
emit_gmem2mem_surf(batch, gmem->cbuf_base[0], &pfb->cbufs[0]); |
| 193 |
|
| 194 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 195 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_MODECONTROL)); |
| 196 |
OUT_RING(ring, A2XX_RB_MODECONTROL_EDRAM_MODE(COLOR_DEPTH)); |
| 197 |
|
| 198 |
if (!is_a20x(ctx->screen)) { |
| 199 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 200 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_VERTEX_REUSE_BLOCK_CNTL)); |
| 201 |
OUT_RING(ring, 0x0000003b); |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
static void |
| 206 |
fd2_emit_tile_gmem2mem(struct fd_batch *batch, const struct fd_tile *tile) |
| 207 |
{ |
| 208 |
fd2_emit_ib(batch->gmem, batch->tile_store); |
| 209 |
} |
| 210 |
|
| 211 |
/* transfer from system memory to gmem */ |
| 212 |
|
| 213 |
static void |
| 214 |
emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base, |
| 215 |
struct pipe_surface *psurf) |
| 216 |
{ |
| 217 |
struct fd_ringbuffer *ring = batch->gmem; |
| 218 |
struct fd_resource *rsc = fd_resource(psurf->texture); |
| 219 |
uint32_t offset = |
| 220 |
fd_resource_offset(rsc, psurf->level, psurf->first_layer); |
| 221 |
enum pipe_format format = fd_gmem_restore_format(psurf->format); |
| 222 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 223 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); |
| 224 |
OUT_RING(ring, A2XX_RB_COLOR_INFO_BASE(base) | |
| 225 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format))); |
| 226 |
|
| 227 |
/* emit fb as a texture: */ |
| 228 |
OUT_PKT3(ring, CP_SET_CONSTANT, 7); |
| 229 |
OUT_RING(ring, 0x00010000); |
| 230 |
OUT_RING(ring, A2XX_SQ_TEX_0_CLAMP_X(SQ_TEX_WRAP) | |
| 231 |
A2XX_SQ_TEX_0_CLAMP_Y(SQ_TEX_WRAP) | |
| 232 |
A2XX_SQ_TEX_0_CLAMP_Z(SQ_TEX_WRAP) | |
| 233 |
A2XX_SQ_TEX_0_PITCH( |
| 234 |
fdl2_pitch_pixels(&rsc->layout, psurf->level))); |
| 235 |
OUT_RELOC(ring, rsc->bo, offset, |
| 236 |
A2XX_SQ_TEX_1_FORMAT(fd2_pipe2surface(format).format) | |
| 237 |
A2XX_SQ_TEX_1_CLAMP_POLICY(SQ_TEX_CLAMP_POLICY_OGL), |
| 238 |
0); |
| 239 |
OUT_RING(ring, A2XX_SQ_TEX_2_WIDTH(pipe_surface_width(psurf) - 1) | |
| 240 |
A2XX_SQ_TEX_2_HEIGHT(pipe_surface_height(psurf) - 1)); |
| 241 |
OUT_RING(ring, A2XX_SQ_TEX_3_MIP_FILTER(SQ_TEX_FILTER_BASEMAP) | |
| 242 |
A2XX_SQ_TEX_3_SWIZ_X(0) | A2XX_SQ_TEX_3_SWIZ_Y(1) | |
| 243 |
A2XX_SQ_TEX_3_SWIZ_Z(2) | A2XX_SQ_TEX_3_SWIZ_W(3) | |
| 244 |
A2XX_SQ_TEX_3_XY_MAG_FILTER(SQ_TEX_FILTER_POINT) | |
| 245 |
A2XX_SQ_TEX_3_XY_MIN_FILTER(SQ_TEX_FILTER_POINT)); |
| 246 |
OUT_RING(ring, 0x00000000); |
| 247 |
OUT_RING(ring, A2XX_SQ_TEX_5_DIMENSION(SQ_TEX_DIMENSION_2D)); |
| 248 |
|
| 249 |
if (!is_a20x(batch->ctx->screen)) { |
| 250 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 251 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_MAX_VTX_INDX)); |
| 252 |
OUT_RING(ring, 3); /* VGT_MAX_VTX_INDX */ |
| 253 |
OUT_RING(ring, 0); /* VGT_MIN_VTX_INDX */ |
| 254 |
} |
| 255 |
|
| 256 |
fd_draw(batch, ring, DI_PT_RECTLIST, IGNORE_VISIBILITY, |
| 257 |
DI_SRC_SEL_AUTO_INDEX, 3, 0, INDEX_SIZE_IGN, 0, 0, NULL); |
| 258 |
} |
| 259 |
|
| 260 |
static void |
| 261 |
fd2_emit_tile_mem2gmem(struct fd_batch *batch, |
| 262 |
const struct fd_tile *tile) assert_dt |
| 263 |
{ |
| 264 |
struct fd_context *ctx = batch->ctx; |
| 265 |
struct fd2_context *fd2_ctx = fd2_context(ctx); |
| 266 |
const struct fd_gmem_stateobj *gmem = batch->gmem_state; |
| 267 |
struct fd_ringbuffer *ring = batch->gmem; |
| 268 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 269 |
unsigned bin_w = tile->bin_w; |
| 270 |
unsigned bin_h = tile->bin_h; |
| 271 |
float x0, y0, x1, y1; |
| 272 |
|
| 273 |
fd2_emit_vertex_bufs( |
| 274 |
ring, 0x9c, |
| 275 |
(struct fd2_vertex_buf[]){ |
| 276 |
{.prsc = fd2_ctx->solid_vertexbuf, .size = 36}, |
| 277 |
{.prsc = fd2_ctx->solid_vertexbuf, .size = 24, .offset = 36}, |
| 278 |
}, |
| 279 |
2); |
| 280 |
|
| 281 |
/* write texture coordinates to vertexbuf: */ |
| 282 |
x0 = ((float)tile->xoff) / ((float)pfb->width); |
| 283 |
x1 = ((float)tile->xoff + bin_w) / ((float)pfb->width); |
| 284 |
y0 = ((float)tile->yoff) / ((float)pfb->height); |
| 285 |
y1 = ((float)tile->yoff + bin_h) / ((float)pfb->height); |
| 286 |
OUT_PKT3(ring, CP_MEM_WRITE, 7); |
| 287 |
OUT_RELOC(ring, fd_resource(fd2_ctx->solid_vertexbuf)->bo, 36, 0, 0); |
| 288 |
OUT_RING(ring, fui(x0)); |
| 289 |
OUT_RING(ring, fui(y0)); |
| 290 |
OUT_RING(ring, fui(x1)); |
| 291 |
OUT_RING(ring, fui(y0)); |
| 292 |
OUT_RING(ring, fui(x0)); |
| 293 |
OUT_RING(ring, fui(y1)); |
| 294 |
|
| 295 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 296 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_INDX_OFFSET)); |
| 297 |
OUT_RING(ring, 0); |
| 298 |
|
| 299 |
fd2_program_emit(ctx, ring, &ctx->blit_prog[0]); |
| 300 |
|
| 301 |
OUT_PKT0(ring, REG_A2XX_TC_CNTL_STATUS, 1); |
| 302 |
OUT_RING(ring, A2XX_TC_CNTL_STATUS_L2_INVALIDATE); |
| 303 |
|
| 304 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 305 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_DEPTHCONTROL)); |
| 306 |
OUT_RING(ring, A2XX_RB_DEPTHCONTROL_EARLY_Z_ENABLE); |
| 307 |
|
| 308 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 309 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SU_SC_MODE_CNTL)); |
| 310 |
OUT_RING(ring, A2XX_PA_SU_SC_MODE_CNTL_PROVOKING_VTX_LAST | |
| 311 |
A2XX_PA_SU_SC_MODE_CNTL_FRONT_PTYPE(PC_DRAW_TRIANGLES) | |
| 312 |
A2XX_PA_SU_SC_MODE_CNTL_BACK_PTYPE(PC_DRAW_TRIANGLES)); |
| 313 |
|
| 314 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 315 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_AA_MASK)); |
| 316 |
OUT_RING(ring, 0x0000ffff); |
| 317 |
|
| 318 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 319 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLORCONTROL)); |
| 320 |
OUT_RING(ring, A2XX_RB_COLORCONTROL_ALPHA_FUNC(FUNC_ALWAYS) | |
| 321 |
A2XX_RB_COLORCONTROL_BLEND_DISABLE | |
| 322 |
A2XX_RB_COLORCONTROL_ROP_CODE(12) | |
| 323 |
A2XX_RB_COLORCONTROL_DITHER_MODE(DITHER_DISABLE) | |
| 324 |
A2XX_RB_COLORCONTROL_DITHER_TYPE(DITHER_PIXEL)); |
| 325 |
|
| 326 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 327 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_BLEND_CONTROL)); |
| 328 |
OUT_RING(ring, A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND(FACTOR_ONE) | |
| 329 |
A2XX_RB_BLEND_CONTROL_COLOR_COMB_FCN(BLEND2_DST_PLUS_SRC) | |
| 330 |
A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND(FACTOR_ZERO) | |
| 331 |
A2XX_RB_BLEND_CONTROL_ALPHA_SRCBLEND(FACTOR_ONE) | |
| 332 |
A2XX_RB_BLEND_CONTROL_ALPHA_COMB_FCN(BLEND2_DST_PLUS_SRC) | |
| 333 |
A2XX_RB_BLEND_CONTROL_ALPHA_DESTBLEND(FACTOR_ZERO)); |
| 334 |
|
| 335 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 336 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_WINDOW_SCISSOR_TL)); |
| 337 |
OUT_RING(ring, A2XX_PA_SC_WINDOW_OFFSET_DISABLE | |
| 338 |
xy2d(0, 0)); /* PA_SC_WINDOW_SCISSOR_TL */ |
| 339 |
OUT_RING(ring, xy2d(bin_w, bin_h)); /* PA_SC_WINDOW_SCISSOR_BR */ |
| 340 |
|
| 341 |
OUT_PKT3(ring, CP_SET_CONSTANT, 5); |
| 342 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_VPORT_XSCALE)); |
| 343 |
OUT_RING(ring, fui((float)bin_w / 2.0f)); /* PA_CL_VPORT_XSCALE */ |
| 344 |
OUT_RING(ring, fui((float)bin_w / 2.0f)); /* PA_CL_VPORT_XOFFSET */ |
| 345 |
OUT_RING(ring, fui(-(float)bin_h / 2.0f)); /* PA_CL_VPORT_YSCALE */ |
| 346 |
OUT_RING(ring, fui((float)bin_h / 2.0f)); /* PA_CL_VPORT_YOFFSET */ |
| 347 |
|
| 348 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 349 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_VTE_CNTL)); |
| 350 |
OUT_RING(ring, A2XX_PA_CL_VTE_CNTL_VTX_XY_FMT | |
| 351 |
A2XX_PA_CL_VTE_CNTL_VTX_Z_FMT | // XXX check this??? |
| 352 |
A2XX_PA_CL_VTE_CNTL_VPORT_X_SCALE_ENA | |
| 353 |
A2XX_PA_CL_VTE_CNTL_VPORT_X_OFFSET_ENA | |
| 354 |
A2XX_PA_CL_VTE_CNTL_VPORT_Y_SCALE_ENA | |
| 355 |
A2XX_PA_CL_VTE_CNTL_VPORT_Y_OFFSET_ENA); |
| 356 |
|
| 357 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 358 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_CLIP_CNTL)); |
| 359 |
OUT_RING(ring, 0x00000000); |
| 360 |
|
| 361 |
if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) |
| 362 |
emit_mem2gmem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf); |
| 363 |
|
| 364 |
if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_COLOR)) |
| 365 |
emit_mem2gmem_surf(batch, gmem->cbuf_base[0], &pfb->cbufs[0]); |
| 366 |
|
| 367 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 368 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_VTE_CNTL)); |
| 369 |
OUT_RING(ring, A2XX_PA_CL_VTE_CNTL_VTX_W0_FMT | |
| 370 |
A2XX_PA_CL_VTE_CNTL_VPORT_X_SCALE_ENA | |
| 371 |
A2XX_PA_CL_VTE_CNTL_VPORT_X_OFFSET_ENA | |
| 372 |
A2XX_PA_CL_VTE_CNTL_VPORT_Y_SCALE_ENA | |
| 373 |
A2XX_PA_CL_VTE_CNTL_VPORT_Y_OFFSET_ENA | |
| 374 |
A2XX_PA_CL_VTE_CNTL_VPORT_Z_SCALE_ENA | |
| 375 |
A2XX_PA_CL_VTE_CNTL_VPORT_Z_OFFSET_ENA); |
| 376 |
|
| 377 |
/* TODO blob driver seems to toss in a CACHE_FLUSH after each DRAW_INDX.. */ |
| 378 |
} |
| 379 |
|
| 380 |
static void |
| 381 |
patch_draws(struct fd_batch *batch, enum pc_di_vis_cull_mode vismode) |
| 382 |
{ |
| 383 |
unsigned i; |
| 384 |
|
| 385 |
if (!is_a20x(batch->ctx->screen)) { |
| 386 |
/* identical to a3xx */ |
| 387 |
for (i = 0; i < fd_patch_num_elements(&batch->draw_patches); i++) { |
| 388 |
struct fd_cs_patch *patch = fd_patch_element(&batch->draw_patches, i); |
| 389 |
*patch->cs = patch->val | DRAW(0, 0, 0, vismode, 0); |
| 390 |
} |
| 391 |
util_dynarray_clear(&batch->draw_patches); |
| 392 |
return; |
| 393 |
} |
| 394 |
|
| 395 |
if (vismode == USE_VISIBILITY) |
| 396 |
return; |
| 397 |
|
| 398 |
for (i = 0; i < batch->draw_patches.size / sizeof(uint32_t *); i++) { |
| 399 |
uint32_t *ptr = |
| 400 |
*util_dynarray_element(&batch->draw_patches, uint32_t *, i); |
| 401 |
unsigned cnt = ptr[0] >> 16 & 0xfff; /* 5 with idx buffer, 3 without */ |
| 402 |
|
| 403 |
/* convert CP_DRAW_INDX_BIN to a CP_DRAW_INDX |
| 404 |
* replace first two DWORDS with NOP and move the rest down |
| 405 |
* (we don't want to have to move the idx buffer reloc) |
| 406 |
*/ |
| 407 |
ptr[0] = CP_TYPE3_PKT | (CP_NOP << 8); |
| 408 |
ptr[1] = 0x00000000; |
| 409 |
|
| 410 |
ptr[4] = ptr[2] & ~(1 << 14 | 1 << 15); /* remove cull_enable bits */ |
| 411 |
ptr[2] = CP_TYPE3_PKT | ((cnt - 2) << 16) | (CP_DRAW_INDX << 8); |
| 412 |
ptr[3] = 0x00000000; |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
static void |
| 417 |
fd2_emit_sysmem_prep(struct fd_batch *batch) |
| 418 |
{ |
| 419 |
struct fd_context *ctx = batch->ctx; |
| 420 |
struct fd_ringbuffer *ring = batch->gmem; |
| 421 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 422 |
struct pipe_surface *psurf = &pfb->cbufs[0]; |
| 423 |
|
| 424 |
if (!psurf->texture) |
| 425 |
return; |
| 426 |
|
| 427 |
struct fd_resource *rsc = fd_resource(psurf->texture); |
| 428 |
uint32_t offset = |
| 429 |
fd_resource_offset(rsc, psurf->level, psurf->first_layer); |
| 430 |
uint32_t pitch = fdl2_pitch_pixels(&rsc->layout, psurf->level); |
| 431 |
|
| 432 |
assert((pitch & 31) == 0); |
| 433 |
assert((offset & 0xfff) == 0); |
| 434 |
|
| 435 |
fd2_emit_restore(ctx, ring); |
| 436 |
|
| 437 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 438 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_SURFACE_INFO)); |
| 439 |
OUT_RING(ring, A2XX_RB_SURFACE_INFO_SURFACE_PITCH(pitch)); |
| 440 |
|
| 441 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 442 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); |
| 443 |
OUT_RELOC(ring, rsc->bo, offset, |
| 444 |
COND(!rsc->layout.tile_mode, A2XX_RB_COLOR_INFO_LINEAR) | |
| 445 |
A2XX_RB_COLOR_INFO_SWAP(fmt2swap(psurf->format)) | |
| 446 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(psurf->format)), |
| 447 |
0); |
| 448 |
|
| 449 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 450 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_SCREEN_SCISSOR_TL)); |
| 451 |
OUT_RING(ring, A2XX_PA_SC_SCREEN_SCISSOR_TL_WINDOW_OFFSET_DISABLE); |
| 452 |
OUT_RING(ring, A2XX_PA_SC_SCREEN_SCISSOR_BR_X(pfb->width) | |
| 453 |
A2XX_PA_SC_SCREEN_SCISSOR_BR_Y(pfb->height)); |
| 454 |
|
| 455 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 456 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_WINDOW_OFFSET)); |
| 457 |
OUT_RING(ring, |
| 458 |
A2XX_PA_SC_WINDOW_OFFSET_X(0) | A2XX_PA_SC_WINDOW_OFFSET_Y(0)); |
| 459 |
|
| 460 |
patch_draws(batch, IGNORE_VISIBILITY); |
| 461 |
util_dynarray_clear(&batch->draw_patches); |
| 462 |
util_dynarray_clear(&batch->shader_patches); |
| 463 |
} |
| 464 |
|
| 465 |
/* before first tile */ |
| 466 |
static void |
| 467 |
fd2_emit_tile_init(struct fd_batch *batch) assert_dt |
| 468 |
{ |
| 469 |
struct fd_context *ctx = batch->ctx; |
| 470 |
struct fd_ringbuffer *ring = batch->gmem; |
| 471 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 472 |
const struct fd_gmem_stateobj *gmem = batch->gmem_state; |
| 473 |
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]); |
| 474 |
uint32_t reg; |
| 475 |
|
| 476 |
fd2_emit_restore(ctx, ring); |
| 477 |
|
| 478 |
prepare_tile_fini_ib(batch); |
| 479 |
|
| 480 |
OUT_PKT3(ring, CP_SET_CONSTANT, 4); |
| 481 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_SURFACE_INFO)); |
| 482 |
OUT_RING(ring, gmem->bin_w); /* RB_SURFACE_INFO */ |
| 483 |
OUT_RING(ring, A2XX_RB_COLOR_INFO_SWAP(fmt2swap(format)) | |
| 484 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format))); |
| 485 |
reg = A2XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]); |
| 486 |
if (pfb->zsbuf.texture) |
| 487 |
reg |= A2XX_RB_DEPTH_INFO_DEPTH_FORMAT(fd_pipe2depth(pfb->zsbuf.format)); |
| 488 |
OUT_RING(ring, reg); /* RB_DEPTH_INFO */ |
| 489 |
|
| 490 |
/* fast clear patches */ |
| 491 |
int depth_size = -1; |
| 492 |
int color_size = -1; |
| 493 |
|
| 494 |
if (pfb->cbufs[0].texture) |
| 495 |
color_size = util_format_get_blocksizebits(format) == 32 ? 4 : 2; |
| 496 |
|
| 497 |
if (pfb->zsbuf.texture) |
| 498 |
depth_size = fd_pipe2depth(pfb->zsbuf.format) == 1 ? 4 : 2; |
| 499 |
|
| 500 |
for (int i = 0; i < fd_patch_num_elements(&batch->gmem_patches); i++) { |
| 501 |
struct fd_cs_patch *patch = fd_patch_element(&batch->gmem_patches, i); |
| 502 |
uint32_t color_base = 0, depth_base = gmem->zsbuf_base[0]; |
| 503 |
uint32_t size, lines; |
| 504 |
|
| 505 |
/* note: 1 "line" is 512 bytes in both color/depth areas (1K total) */ |
| 506 |
switch (patch->val) { |
| 507 |
case GMEM_PATCH_FASTCLEAR_COLOR: |
| 508 |
size = align(gmem->bin_w * gmem->bin_h * color_size, 0x8000); |
| 509 |
lines = size / 1024; |
| 510 |
depth_base = size / 2; |
| 511 |
break; |
| 512 |
case GMEM_PATCH_FASTCLEAR_DEPTH: |
| 513 |
size = align(gmem->bin_w * gmem->bin_h * depth_size, 0x8000); |
| 514 |
lines = size / 1024; |
| 515 |
color_base = depth_base; |
| 516 |
depth_base = depth_base + size / 2; |
| 517 |
break; |
| 518 |
case GMEM_PATCH_FASTCLEAR_COLOR_DEPTH: |
| 519 |
lines = |
| 520 |
align(gmem->bin_w * gmem->bin_h * color_size * 2, 0x8000) / 1024; |
| 521 |
break; |
| 522 |
case GMEM_PATCH_RESTORE_INFO: |
| 523 |
patch->cs[0] = gmem->bin_w; |
| 524 |
patch->cs[1] = A2XX_RB_COLOR_INFO_SWAP(fmt2swap(format)) | |
| 525 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format)); |
| 526 |
patch->cs[2] = A2XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]); |
| 527 |
if (pfb->zsbuf.texture) |
| 528 |
patch->cs[2] |= A2XX_RB_DEPTH_INFO_DEPTH_FORMAT( |
| 529 |
fd_pipe2depth(pfb->zsbuf.format)); |
| 530 |
continue; |
| 531 |
default: |
| 532 |
continue; |
| 533 |
} |
| 534 |
|
| 535 |
patch->cs[0] = A2XX_PA_SC_SCREEN_SCISSOR_BR_X(32) | |
| 536 |
A2XX_PA_SC_SCREEN_SCISSOR_BR_Y(lines); |
| 537 |
patch->cs[4] = A2XX_RB_COLOR_INFO_BASE(color_base) | |
| 538 |
A2XX_RB_COLOR_INFO_FORMAT(COLORX_8_8_8_8); |
| 539 |
patch->cs[5] = A2XX_RB_DEPTH_INFO_DEPTH_BASE(depth_base) | |
| 540 |
A2XX_RB_DEPTH_INFO_DEPTH_FORMAT(1); |
| 541 |
} |
| 542 |
util_dynarray_clear(&batch->gmem_patches); |
| 543 |
|
| 544 |
/* set to zero, for some reason hardware doesn't like certain values */ |
| 545 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 546 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_CURRENT_BIN_ID_MIN)); |
| 547 |
OUT_RING(ring, 0); |
| 548 |
|
| 549 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 550 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_CURRENT_BIN_ID_MAX)); |
| 551 |
OUT_RING(ring, 0); |
| 552 |
|
| 553 |
if (use_hw_binning(batch)) { |
| 554 |
/* patch out unneeded memory exports by changing EXEC CF to EXEC_END |
| 555 |
* |
| 556 |
* in the shader compiler, we guarantee that the shader ends with |
| 557 |
* a specific pattern of ALLOC/EXEC CF pairs for the hw binning exports |
| 558 |
* |
| 559 |
* the since patches point only to dwords and CFs are 1.5 dwords |
| 560 |
* the patch is aligned and might point to a ALLOC CF |
| 561 |
*/ |
| 562 |
for (int i = 0; i < batch->shader_patches.size / sizeof(void *); i++) { |
| 563 |
instr_cf_t *cf = |
| 564 |
*util_dynarray_element(&batch->shader_patches, instr_cf_t *, i); |
| 565 |
if (cf->opc == ALLOC) |
| 566 |
cf++; |
| 567 |
assert(cf->opc == EXEC); |
| 568 |
assert(cf[ctx->screen->info->num_vsc_pipes * 2 - 2].opc == EXEC_END); |
| 569 |
cf[2 * (gmem->num_vsc_pipes - 1)].opc = EXEC_END; |
| 570 |
} |
| 571 |
|
| 572 |
patch_draws(batch, USE_VISIBILITY); |
| 573 |
|
| 574 |
/* initialize shader constants for the binning memexport */ |
| 575 |
OUT_PKT3(ring, CP_SET_CONSTANT, 1 + gmem->num_vsc_pipes * 4); |
| 576 |
OUT_RING(ring, 0x0000000C); |
| 577 |
|
| 578 |
for (int i = 0; i < gmem->num_vsc_pipes; i++) { |
| 579 |
/* allocate in 64k increments to avoid reallocs */ |
| 580 |
uint32_t bo_size = align(batch->num_vertices, 0x10000); |
| 581 |
if (!ctx->vsc_pipe_bo[i] || |
| 582 |
fd_bo_size(ctx->vsc_pipe_bo[i]) < bo_size) { |
| 583 |
if (ctx->vsc_pipe_bo[i]) |
| 584 |
fd_bo_del(ctx->vsc_pipe_bo[i]); |
| 585 |
ctx->vsc_pipe_bo[i] = |
| 586 |
fd_bo_new(ctx->dev, bo_size, 0, "vsc_pipe[%u]", i); |
| 587 |
assert(ctx->vsc_pipe_bo[i]); |
| 588 |
} |
| 589 |
|
| 590 |
/* memory export address (export32): |
| 591 |
* .x: (base_address >> 2) | 0x40000000 (?) |
| 592 |
* .y: index (float) - set by shader |
| 593 |
* .z: 0x4B00D000 (?) |
| 594 |
* .w: 0x4B000000 (?) | max_index (?) |
| 595 |
*/ |
| 596 |
OUT_RELOC(ring, ctx->vsc_pipe_bo[i], 0, 0x40000000, -2); |
| 597 |
OUT_RING(ring, 0x00000000); |
| 598 |
OUT_RING(ring, 0x4B00D000); |
| 599 |
OUT_RING(ring, 0x4B000000 | bo_size); |
| 600 |
} |
| 601 |
|
| 602 |
OUT_PKT3(ring, CP_SET_CONSTANT, 1 + gmem->num_vsc_pipes * 8); |
| 603 |
OUT_RING(ring, 0x0000018C); |
| 604 |
|
| 605 |
for (int i = 0; i < gmem->num_vsc_pipes; i++) { |
| 606 |
const struct fd_vsc_pipe *pipe = &gmem->vsc_pipe[i]; |
| 607 |
float off_x, off_y, mul_x, mul_y; |
| 608 |
|
| 609 |
/* const to tranform from [-1,1] to bin coordinates for this pipe |
| 610 |
* for x/y, [0,256/2040] = 0, [256/2040,512/2040] = 1, etc |
| 611 |
* 8 possible values on x/y axis, |
| 612 |
* to clip at binning stage: only use center 6x6 |
| 613 |
* TODO: set the z parameters too so that hw binning |
| 614 |
* can clip primitives in Z too |
| 615 |
*/ |
| 616 |
|
| 617 |
mul_x = 1.0f / (float)(gmem->bin_w * 8); |
| 618 |
mul_y = 1.0f / (float)(gmem->bin_h * 8); |
| 619 |
off_x = -pipe->x * (1.0f / 8.0f) + 0.125f - mul_x * gmem->minx; |
| 620 |
off_y = -pipe->y * (1.0f / 8.0f) + 0.125f - mul_y * gmem->miny; |
| 621 |
|
| 622 |
OUT_RING(ring, fui(off_x * (256.0f / 255.0f))); |
| 623 |
OUT_RING(ring, fui(off_y * (256.0f / 255.0f))); |
| 624 |
OUT_RING(ring, 0x3f000000); |
| 625 |
OUT_RING(ring, fui(0.0f)); |
| 626 |
|
| 627 |
OUT_RING(ring, fui(mul_x * (256.0f / 255.0f))); |
| 628 |
OUT_RING(ring, fui(mul_y * (256.0f / 255.0f))); |
| 629 |
OUT_RING(ring, fui(0.0f)); |
| 630 |
OUT_RING(ring, fui(0.0f)); |
| 631 |
} |
| 632 |
|
| 633 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 634 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_VERTEX_REUSE_BLOCK_CNTL)); |
| 635 |
OUT_RING(ring, 0); |
| 636 |
|
| 637 |
fd2_emit_ib(ring, batch->binning); |
| 638 |
|
| 639 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 640 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_VERTEX_REUSE_BLOCK_CNTL)); |
| 641 |
OUT_RING(ring, 0x00000002); |
| 642 |
} else { |
| 643 |
patch_draws(batch, IGNORE_VISIBILITY); |
| 644 |
} |
| 645 |
|
| 646 |
util_dynarray_clear(&batch->draw_patches); |
| 647 |
util_dynarray_clear(&batch->shader_patches); |
| 648 |
} |
| 649 |
|
| 650 |
/* before mem2gmem */ |
| 651 |
static void |
| 652 |
fd2_emit_tile_prep(struct fd_batch *batch, const struct fd_tile *tile) |
| 653 |
{ |
| 654 |
struct fd_ringbuffer *ring = batch->gmem; |
| 655 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 656 |
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]); |
| 657 |
|
| 658 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 659 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); |
| 660 |
OUT_RING(ring, A2XX_RB_COLOR_INFO_SWAP(1) | /* RB_COLOR_INFO */ |
| 661 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format))); |
| 662 |
|
| 663 |
/* setup screen scissor for current tile (same for mem2gmem): */ |
| 664 |
OUT_PKT3(ring, CP_SET_CONSTANT, 3); |
| 665 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_SCREEN_SCISSOR_TL)); |
| 666 |
OUT_RING(ring, A2XX_PA_SC_SCREEN_SCISSOR_TL_X(0) | |
| 667 |
A2XX_PA_SC_SCREEN_SCISSOR_TL_Y(0)); |
| 668 |
OUT_RING(ring, A2XX_PA_SC_SCREEN_SCISSOR_BR_X(tile->bin_w) | |
| 669 |
A2XX_PA_SC_SCREEN_SCISSOR_BR_Y(tile->bin_h)); |
| 670 |
} |
| 671 |
|
| 672 |
/* before IB to rendering cmds: */ |
| 673 |
static void |
| 674 |
fd2_emit_tile_renderprep(struct fd_batch *batch, |
| 675 |
const struct fd_tile *tile) assert_dt |
| 676 |
{ |
| 677 |
struct fd_context *ctx = batch->ctx; |
| 678 |
struct fd2_context *fd2_ctx = fd2_context(ctx); |
| 679 |
struct fd_ringbuffer *ring = batch->gmem; |
| 680 |
struct pipe_framebuffer_state *pfb = &batch->framebuffer; |
| 681 |
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]); |
| 682 |
|
| 683 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 684 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); |
| 685 |
OUT_RING(ring, A2XX_RB_COLOR_INFO_SWAP(fmt2swap(format)) | |
| 686 |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format))); |
| 687 |
|
| 688 |
/* setup window scissor and offset for current tile (different |
| 689 |
* from mem2gmem): |
| 690 |
*/ |
| 691 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 692 |
OUT_RING(ring, CP_REG(REG_A2XX_PA_SC_WINDOW_OFFSET)); |
| 693 |
OUT_RING(ring, A2XX_PA_SC_WINDOW_OFFSET_X(-tile->xoff) | |
| 694 |
A2XX_PA_SC_WINDOW_OFFSET_Y(-tile->yoff)); |
| 695 |
|
| 696 |
/* write SCISSOR_BR to memory so fast clear path can restore from it */ |
| 697 |
OUT_PKT3(ring, CP_MEM_WRITE, 2); |
| 698 |
OUT_RELOC(ring, fd_resource(fd2_ctx->solid_vertexbuf)->bo, 60, 0, 0); |
| 699 |
OUT_RING(ring, A2XX_PA_SC_SCREEN_SCISSOR_BR_X(tile->bin_w) | |
| 700 |
A2XX_PA_SC_SCREEN_SCISSOR_BR_Y(tile->bin_h)); |
| 701 |
|
| 702 |
/* set the copy offset for gmem2mem */ |
| 703 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 704 |
OUT_RING(ring, CP_REG(REG_A2XX_RB_COPY_DEST_OFFSET)); |
| 705 |
OUT_RING(ring, A2XX_RB_COPY_DEST_OFFSET_X(tile->xoff) | |
| 706 |
A2XX_RB_COPY_DEST_OFFSET_Y(tile->yoff)); |
| 707 |
|
| 708 |
/* tile offset for gl_FragCoord on a20x (C64 in fragment shader) */ |
| 709 |
if (is_a20x(ctx->screen)) { |
| 710 |
OUT_PKT3(ring, CP_SET_CONSTANT, 5); |
| 711 |
OUT_RING(ring, 0x00000580); |
| 712 |
OUT_RING(ring, fui(tile->xoff)); |
| 713 |
OUT_RING(ring, fui(tile->yoff)); |
| 714 |
OUT_RING(ring, fui(0.0f)); |
| 715 |
OUT_RING(ring, fui(0.0f)); |
| 716 |
} |
| 717 |
|
| 718 |
if (use_hw_binning(batch)) { |
| 719 |
struct fd_bo *pipe_bo = ctx->vsc_pipe_bo[tile->p]; |
| 720 |
|
| 721 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 722 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_CURRENT_BIN_ID_MIN)); |
| 723 |
OUT_RING(ring, tile->n); |
| 724 |
|
| 725 |
OUT_PKT3(ring, CP_SET_CONSTANT, 2); |
| 726 |
OUT_RING(ring, CP_REG(REG_A2XX_VGT_CURRENT_BIN_ID_MAX)); |
| 727 |
OUT_RING(ring, tile->n); |
| 728 |
|
| 729 |
/* TODO only emit this when tile->p changes */ |
| 730 |
OUT_PKT3(ring, CP_SET_DRAW_INIT_FLAGS, 1); |
| 731 |
OUT_RELOC(ring, pipe_bo, 0, 0, 0); |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
void |
| 736 |
fd2_gmem_init(struct pipe_context *pctx) disable_thread_safety_analysis |
| 737 |
{ |
| 738 |
struct fd_context *ctx = fd_context(pctx); |
| 739 |
|
| 740 |
ctx->emit_sysmem_prep = fd2_emit_sysmem_prep; |
| 741 |
ctx->emit_tile_init = fd2_emit_tile_init; |
| 742 |
ctx->emit_tile_prep = fd2_emit_tile_prep; |
| 743 |
ctx->emit_tile_mem2gmem = fd2_emit_tile_mem2gmem; |
| 744 |
ctx->emit_tile_renderprep = fd2_emit_tile_renderprep; |
| 745 |
ctx->emit_tile_gmem2mem = fd2_emit_tile_gmem2mem; |
| 746 |
} |