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 <alyssa@rosenzweig.io> Reviewed-by: Ryan Houdek <Sonicadvance1@gmail.com>
This commit is contained in:
parent
50382df728
commit
3645c781ab
|
@ -228,12 +228,6 @@ struct mali_blend_equation {
|
||||||
/* Corresponds to MALI_MASK_* above and glColorMask arguments */
|
/* Corresponds to MALI_MASK_* above and glColorMask arguments */
|
||||||
|
|
||||||
unsigned color_mask : 4;
|
unsigned color_mask : 4;
|
||||||
|
|
||||||
/* Attached constant for CONSTANT_ALPHA, etc */
|
|
||||||
|
|
||||||
#ifndef BIFROST
|
|
||||||
float constant;
|
|
||||||
#endif
|
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
/* Used with channel swizzling */
|
/* Used with channel swizzling */
|
||||||
|
@ -420,7 +414,11 @@ enum mali_format {
|
||||||
|
|
||||||
union midgard_blend {
|
union midgard_blend {
|
||||||
mali_ptr shader;
|
mali_ptr shader;
|
||||||
|
|
||||||
|
struct {
|
||||||
struct mali_blend_equation equation;
|
struct mali_blend_equation equation;
|
||||||
|
float constant;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* On MRT Midgard systems (using an MFBD), each render target gets its own
|
/* On MRT Midgard systems (using an MFBD), each render target gets its own
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "pan_blending.h"
|
#include "pan_blending.h"
|
||||||
|
#include "pan_context.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implements fixed-function blending on Midgard.
|
* Implements fixed-function blending on Midgard.
|
||||||
|
@ -360,12 +361,14 @@ static const struct pipe_rt_blend_state default_blend = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
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 no blending is enabled, default back on `replace` mode */
|
||||||
|
|
||||||
if (!blend->blend_enable)
|
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
|
/* We have room only for a single float32 constant between the four
|
||||||
* components. If we need more, spill to the programmable pipeline. */
|
* 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,
|
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;
|
return false;
|
||||||
|
|
||||||
unsigned rgb_mode = 0;
|
unsigned rgb_mode = 0;
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include <panfrost-job.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
|
#endif
|
||||||
|
|
|
@ -1009,6 +1009,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
|
|
||||||
if (!ctx->blend->has_blend_shader) {
|
if (!ctx->blend->has_blend_shader) {
|
||||||
ctx->fragment_shader_core.blend.equation = ctx->blend->equation;
|
ctx->fragment_shader_core.blend.equation = ctx->blend->equation;
|
||||||
|
ctx->fragment_shader_core.blend.constant = ctx->blend->constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!no_blending) {
|
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) {
|
for (unsigned i = 0; i < 1; ++i) {
|
||||||
rts[i].flags = blend_count;
|
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;
|
rts[i].blend.shader = ctx->blend->blend_shader;
|
||||||
else
|
} else {
|
||||||
rts[i].blend.equation = ctx->blend->equation;
|
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);
|
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 */
|
/* 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;
|
return so;
|
||||||
|
|
||||||
/* If we can't, compile a blend shader instead */
|
/* If we can't, compile a blend shader instead */
|
||||||
|
|
|
@ -240,6 +240,7 @@ struct panfrost_blend_state {
|
||||||
|
|
||||||
/* Compiled fixed function command */
|
/* Compiled fixed function command */
|
||||||
struct mali_blend_equation equation;
|
struct mali_blend_equation equation;
|
||||||
|
float constant;
|
||||||
|
|
||||||
/* Compiled blend shader */
|
/* Compiled blend shader */
|
||||||
mali_ptr 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_G) ? "G" : "",
|
||||||
(eq.color_mask & MALI_MASK_B) ? "B" : "",
|
(eq.color_mask & MALI_MASK_B) ? "B" : "",
|
||||||
(eq.color_mask & MALI_MASK_A) ? "A" : "");
|
(eq.color_mask & MALI_MASK_A) ? "A" : "");
|
||||||
|
|
||||||
printf("Constant: %f\n", eq.constant);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue