From 75018f649568fb65865e1b7f43f674c7fbb79077 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Mon, 6 Jul 2020 19:40:05 +1200 Subject: [PATCH] panfrost: Add rt formats to shader state load_output lowering will depend on the framebuffer formats. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 2 ++ src/gallium/drivers/panfrost/pan_context.c | 10 ++++++++++ src/gallium/drivers/panfrost/pan_context.h | 2 ++ src/panfrost/util/pan_ir.h | 3 +++ 4 files changed, 17 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 37c9c69..d398d21 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -165,6 +165,8 @@ panfrost_shader_compile(struct panfrost_context *ctx, .alpha_ref = state->alpha_state.ref_value }; + memcpy(program.rt_formats, state->rt_formats, sizeof(program.rt_formats)); + if (dev->quirks & IS_BIFROST) { bifrost_compile_shader_nir(s, &program, dev->gpu_id); } else { diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index d55cbd0..7c438f6 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -777,6 +777,16 @@ panfrost_bind_shader_state( if (type == PIPE_SHADER_FRAGMENT) { v->alpha_state = ctx->depth_stencil->alpha; + struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer; + for (unsigned i = 0; i < fb->nr_cbufs; ++i) { + enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM; + + if ((fb->nr_cbufs > i) && fb->cbufs[i]) + fmt = fb->cbufs[i]->format; + + v->rt_formats[i] = fmt; + } + /* Point sprites are TODO on Bifrost */ if (ctx->rasterizer && !(dev->quirks & IS_BIFROST)) { v->point_sprite_mask = ctx->rasterizer->base.sprite_coord_enable; diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index adf4ada..2feb08f 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -224,6 +224,8 @@ struct panfrost_shader_state { unsigned first_tag; struct panfrost_bo *bo; + + enum pipe_format rt_formats[8]; }; /* A collection of varyings (the CSO) */ diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index aa0eb79..99a8e5b 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -110,6 +110,9 @@ typedef struct { /* IN: For a fragment shader with a lowered alpha test, the ref value */ float alpha_ref; + + /* IN: Render target formats for output load/store lowering */ + enum pipe_format rt_formats[8]; } panfrost_program; typedef struct pan_block { -- 2.7.4