Mesa (master): panfrost: Add rt formats to shader state

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 14:04:06 UTC 2020


Module: Mesa
Branch: master
Commit: 75018f649568fb65865e1b7f43f674c7fbb79077
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=75018f649568fb65865e1b7f43f674c7fbb79077

Author: Icecream95 <ixn at keemail.me>
Date:   Mon Jul  6 19:40:05 2020 +1200

panfrost: Add rt formats to shader state

load_output lowering will depend on the framebuffer formats.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>

---

 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 37c9c690996..d398d21ec54 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 d55cbd098db..7c438f61c14 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 adf4adada97..2feb08fe302 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 aa0eb7904ce..99a8e5ba70f 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 {



More information about the mesa-commit mailing list