diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-02 06:34:52 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-10 06:12:05 -0700 |
commit | e7551c1bff8ee3a3c2df793dd2905479d5b08c6b (patch) | |
tree | ac001f6e29c2122c410215d2d0394ede19f525fe /src | |
parent | 74fd914a8932883d7bd6f7add51a41da994f5ec8 (diff) |
panfrost: Pipe framebuffer format around
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
5 files changed, 21 insertions, 7 deletions
diff --git a/src/gallium/drivers/panfrost/midgard/nir_lower_blend.h b/src/gallium/drivers/panfrost/midgard/nir_lower_blend.h index 2805ca25d97..7a2df6e5e29 100644 --- a/src/gallium/drivers/panfrost/midgard/nir_lower_blend.h +++ b/src/gallium/drivers/panfrost/midgard/nir_lower_blend.h @@ -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 diff --git a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c index f5182ca7394..85bb6488e69 100644 --- a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c +++ b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c index 640ddc86847..91c8fb89688 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.c +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c @@ -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 */ diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.h b/src/gallium/drivers/panfrost/pan_blend_shaders.h index 1a914772673..23acd39581a 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.h +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.h @@ -31,6 +31,10 @@ #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 diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 82cd2ea6a48..be5d0a14cf5 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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; } |