Commit 3645c781 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

panfrost: Hoist blend constant into Midgard-specific struct

This eliminates one major source of #ifdef parity between Midgard and
Bifrost, better representing how the struct acts on Midgard and allowing
proper decodes on Bifrost.
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Ryan Houdek's avatarRyan Houdek <Sonicadvance1@gmail.com>
parent 50382df7
......@@ -228,12 +228,6 @@ struct mali_blend_equation {
/* Corresponds to MALI_MASK_* above and glColorMask arguments */
unsigned color_mask : 4;
/* Attached constant for CONSTANT_ALPHA, etc */
#ifndef BIFROST
float constant;
#endif
} __attribute__((packed));
/* Used with channel swizzling */
......@@ -420,7 +414,11 @@ enum mali_format {
union midgard_blend {
mali_ptr shader;
struct mali_blend_equation equation;
struct {
struct mali_blend_equation equation;
float constant;
};
};
/* On MRT Midgard systems (using an MFBD), each render target gets its own
......
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include "pan_blending.h"
#include "pan_context.h"
/*
* Implements fixed-function blending on Midgard.
......@@ -360,12 +361,14 @@ static const struct pipe_rt_blend_state default_blend = {
};
bool
panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct mali_blend_equation *out, unsigned colormask, const struct pipe_blend_color *blend_color)
panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct panfrost_blend_state *so, unsigned colormask, const struct pipe_blend_color *blend_color)
{
struct mali_blend_equation *out = &so->equation;
/* If no blending is enabled, default back on `replace` mode */
if (!blend->blend_enable)
return panfrost_make_fixed_blend_mode(&default_blend, out, colormask, blend_color);
return panfrost_make_fixed_blend_mode(&default_blend, so, colormask, blend_color);
/* We have room only for a single float32 constant between the four
* components. If we need more, spill to the programmable pipeline. */
......@@ -375,7 +378,7 @@ panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct m
blend->alpha_src_factor, blend->alpha_dst_factor,
};
if (!panfrost_make_constant(factors, ARRAY_SIZE(factors), blend_color, &out->constant))
if (!panfrost_make_constant(factors, ARRAY_SIZE(factors), blend_color, &so->constant))
return false;
unsigned rgb_mode = 0;
......
......@@ -29,6 +29,8 @@
#include "pipe/p_defines.h"
#include <panfrost-job.h>
bool panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct mali_blend_equation *out, unsigned colormask, const struct pipe_blend_color *blend_color);
struct panfrost_blend_state;
bool panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state *blend, struct panfrost_blend_state *so, unsigned colormask, const struct pipe_blend_color *blend_color);
#endif
......@@ -1009,6 +1009,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
if (!ctx->blend->has_blend_shader) {
ctx->fragment_shader_core.blend.equation = ctx->blend->equation;
ctx->fragment_shader_core.blend.constant = ctx->blend->constant;
}
if (!no_blending) {
......@@ -1050,10 +1051,12 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
for (unsigned i = 0; i < 1; ++i) {
rts[i].flags = blend_count;
if (ctx->blend->has_blend_shader)
if (ctx->blend->has_blend_shader) {
rts[i].blend.shader = ctx->blend->blend_shader;
else
} else {
rts[i].blend.equation = ctx->blend->equation;
rts[i].blend.constant = ctx->blend->constant;
}
}
memcpy(transfer.cpu + sizeof(struct mali_shader_meta), rts, sizeof(rts[0]) * 1);
......@@ -2160,7 +2163,7 @@ panfrost_create_blend_state(struct pipe_context *pipe,
/* Compile the blend state, first as fixed-function if we can */
if (panfrost_make_fixed_blend_mode(&blend->rt[0], &so->equation, blend->rt[0].colormask, &ctx->blend_color))
if (panfrost_make_fixed_blend_mode(&blend->rt[0], so, blend->rt[0].colormask, &ctx->blend_color))
return so;
/* If we can't, compile a blend shader instead */
......
......@@ -240,6 +240,7 @@ struct panfrost_blend_state {
/* Compiled fixed function command */
struct mali_blend_equation equation;
float constant;
/* Compiled blend shader */
mali_ptr blend_shader;
......
......@@ -222,6 +222,4 @@ panfrost_print_blend_equation(struct mali_blend_equation eq)
(eq.color_mask & MALI_MASK_G) ? "G" : "",
(eq.color_mask & MALI_MASK_B) ? "B" : "",
(eq.color_mask & MALI_MASK_A) ? "A" : "");
printf("Constant: %f\n", eq.constant);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment