OSDN Git Service

panfrost: Pipe framebuffer format around
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 2 Jul 2019 13:34:52 +0000 (06:34 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 13:12:05 +0000 (06:12 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/midgard/nir_lower_blend.h
src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
src/gallium/drivers/panfrost/pan_blend_shaders.c
src/gallium/drivers/panfrost/pan_blend_shaders.h
src/gallium/drivers/panfrost/pan_context.c

index 2805ca2..7a2df6e 100644 (file)
@@ -26,6 +26,7 @@
 #define NIR_BLEND_H
 
 #include "compiler/nir/nir.h"
+#include "pipe/p_format.h"
 
 /* These structs encapsulates the blend state such that it can be lowered
  * cleanly
@@ -54,6 +55,6 @@ typedef struct {
 void nir_lower_blend(nir_shader *shader, nir_lower_blend_options options);
 
 void
-nir_lower_framebuffer(nir_shader *shader);
+nir_lower_framebuffer(nir_shader *shader, enum pipe_format format);
 
 #endif
index f5182ca..85bb648 100644 (file)
@@ -99,12 +99,11 @@ nir_native_to_float(nir_builder *b,
 }
 
 void
-nir_lower_framebuffer(nir_shader *shader)
+nir_lower_framebuffer(nir_shader *shader, enum pipe_format format)
 {
    /* Blend shaders are represented as special fragment shaders */
    assert(shader->info.stage == MESA_SHADER_FRAGMENT);
 
-   enum pipe_format format = PIPE_FORMAT_R8G8B8A8_UNORM;
    const struct util_format_description *format_desc =
       util_format_description(format);
 
index 640ddc8..91c8fb8 100644 (file)
@@ -115,7 +115,11 @@ nir_make_options(const struct pipe_blend_state *blend, unsigned nr_cbufs)
 }
 
 void
-panfrost_make_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *cso, const struct pipe_blend_color *blend_color)
+panfrost_make_blend_shader(
+                struct panfrost_context *ctx,
+                struct panfrost_blend_state *cso,
+                const struct pipe_blend_color *blend_color,
+                enum pipe_format format)
 {
         /* Build the shader */
 
@@ -149,7 +153,7 @@ panfrost_make_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_s
                 nir_make_options(&cso->base, 1);
         NIR_PASS_V(shader, nir_lower_blend, options);
 
-        NIR_PASS_V(shader, nir_lower_framebuffer);
+        NIR_PASS_V(shader, nir_lower_framebuffer, format);
 
         /* Compile the built shader */
 
index 1a91477..23acd39 100644 (file)
 #include "pan_context.h"
 
 void
-panfrost_make_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *cso, const struct pipe_blend_color *blend_color);
+panfrost_make_blend_shader(
+                struct panfrost_context *ctx,
+                struct panfrost_blend_state *cso,
+                const struct pipe_blend_color *blend_color,
+                enum pipe_format format);
 
 #endif
index 82cd2ea..be5d0a1 100644 (file)
@@ -2381,9 +2381,15 @@ panfrost_create_blend_state(struct pipe_context *pipe,
         if (panfrost_make_fixed_blend_mode(&blend->rt[0], so, blend->rt[0].colormask, &ctx->blend_color))
                 return so;
 
+        /* TODO: Key against framebuffer. TODO: MRT explicitly */
+        if (!ctx->pipe_framebuffer.nr_cbufs)
+                return so;
+
+        enum pipe_format format = ctx->pipe_framebuffer.cbufs[0]->format;
+
         /* If we can't, compile a blend shader instead */
 
-        panfrost_make_blend_shader(ctx, so, &ctx->blend_color);
+        panfrost_make_blend_shader(ctx, so, &ctx->blend_color, format);
 
         return so;
 }