This lets us move emitting SP_FS_MRT_REG back to fd4_program_emit.
Signed-off-by: Rob Clark <robclark@freedesktop.org>
fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
{
struct fd4_context *fd4_ctx = fd4_context(ctx);
+ struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
struct fd4_emit emit = {
.vtx = &ctx->vtx,
.prog = &ctx->prog,
/* do binning pass first: */
.binning_pass = true,
.color_two_side = ctx->rasterizer ? ctx->rasterizer->light_twoside : false,
- .alpha = util_format_is_alpha(pipe_surface_format(ctx->framebuffer.cbufs[0])),
+ .alpha = util_format_is_alpha(pipe_surface_format(pfb->cbufs[0])),
// TODO set .half_precision based on render target format,
// ie. float16 and smaller use half, float32 use full..
.half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF),
.fsaturate_t = fd4_ctx->fsaturate_t,
.fsaturate_r = fd4_ctx->fsaturate_r,
},
+ .format = fd4_emit_format(pfb->cbufs[0]),
.rasterflat = ctx->rasterizer && ctx->rasterizer->flatshade,
};
unsigned dirty;
.key = {
.half_precision = true,
},
+ .format = fd4_emit_format(pfb->cbufs[0]),
};
uint32_t colr = 0;
if (dirty & FD_DIRTY_PROG)
fd4_program_emit(ring, emit);
- if (dirty & (FD_DIRTY_PROG | FD_DIRTY_FRAMEBUFFER)) {
- struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
- uint32_t color_regid = ir3_find_output_regid(fp,
- ir3_semantic_name(TGSI_SEMANTIC_COLOR, 0));
- enum a4xx_color_fmt format = 0;
-
- if (pfb->cbufs[0])
- format = fd4_pipe2color(pfb->cbufs[0]->format);
-
- OUT_PKT0(ring, REG_A4XX_SP_FS_MRT_REG(0), 8);
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(color_regid) |
- A4XX_SP_FS_MRT_REG_MRTFORMAT(format) |
- COND(fp->key.half_precision, A4XX_SP_FS_MRT_REG_HALF_PRECISION));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- }
-
if ((dirty & (FD_DIRTY_PROG | FD_DIRTY_CONSTBUF)) &&
/* evil hack to deal sanely with clear path: */
(emit->prog == &ctx->prog)) {
const struct fd_program_stateobj *prog;
const struct pipe_draw_info *info;
struct ir3_shader_key key;
+ enum a4xx_color_fmt format;
uint32_t dirty;
bool rasterflat;
/* TODO: other shader stages.. */
};
+static inline enum a4xx_color_fmt fd4_emit_format(struct pipe_surface *surf)
+{
+ if (!surf)
+ return 0;
+ return fd4_pipe2color(surf->format);
+}
+
static inline struct ir3_shader_variant *
fd4_emit_get_vp(struct fd4_emit *emit)
{
.vtx = &fd4_ctx->solid_vbuf_state,
.prog = &ctx->solid_prog,
.key = key,
+ .format = fd4_emit_format(pfb->cbufs[0]),
};
OUT_PKT0(ring, REG_A4XX_RB_DEPTH_CONTROL, 1);
/* transfer from system memory to gmem */
static void
-emit_mem2gmem_surf(struct fd_context *ctx, struct fd4_emit *emit,
- uint32_t base, struct pipe_surface *psurf, uint32_t bin_w)
+emit_mem2gmem_surf(struct fd_context *ctx, uint32_t base,
+ struct pipe_surface *psurf, uint32_t bin_w)
{
- struct ir3_shader_variant *fp = fd4_emit_get_fp(emit);
struct fd_ringbuffer *ring = ctx->ring;
- uint32_t color_regid = ir3_find_output_regid(fp,
- ir3_semantic_name(TGSI_SEMANTIC_COLOR, 0));
-
- OUT_PKT0(ring, REG_A4XX_SP_FS_MRT_REG(0), 8);
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(color_regid) |
- A4XX_SP_FS_MRT_REG_MRTFORMAT(fd4_pipe2color(psurf->format)) |
- COND(fp->key.half_precision, A4XX_SP_FS_MRT_REG_HALF_PRECISION));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
- OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
emit_mrt(ring, 1, &psurf, &base, bin_w);
.vtx = &fd4_ctx->blit_vbuf_state,
.prog = &ctx->blit_prog,
.key = key,
+ .format = fd4_emit_format(pfb->cbufs[0]),
};
float x0, y0, x1, y1;
unsigned bin_w = tile->bin_w;
bin_h = gmem->bin_h;
if (fd_gmem_needs_restore(ctx, tile, FD_BUFFER_DEPTH | FD_BUFFER_STENCIL))
- emit_mem2gmem_surf(ctx, &emit, depth_base(ctx), pfb->zsbuf, bin_w);
+ emit_mem2gmem_surf(ctx, depth_base(ctx), pfb->zsbuf, bin_w);
if (fd_gmem_needs_restore(ctx, tile, FD_BUFFER_COLOR))
- emit_mem2gmem_surf(ctx, &emit, 0, pfb->cbufs[0], bin_w);
+ emit_mem2gmem_surf(ctx, 0, pfb->cbufs[0], bin_w);
OUT_PKT0(ring, REG_A4XX_GRAS_SC_CONTROL, 1);
OUT_RING(ring, A4XX_GRAS_SC_CONTROL_RENDER_MODE(RB_RENDERING_PASS) |
OUT_RING(ring, 0x00000001);
}
+ OUT_PKT0(ring, REG_A4XX_SP_FS_MRT_REG(0), 8);
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(color_regid) |
+ A4XX_SP_FS_MRT_REG_MRTFORMAT(emit->format) |
+ COND(emit->key.half_precision, A4XX_SP_FS_MRT_REG_HALF_PRECISION));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+ OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(0));
+
if (emit->key.binning_pass) {
OUT_PKT0(ring, REG_A4XX_VPC_ATTR, 2);
OUT_RING(ring, A4XX_VPC_ATTR_THRDASSIGN(1) |