#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
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
}
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);
}
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 */
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 */
#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
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;
}