panfrost: Remove MRT indirection in blend shaders
Since we have a separate blend shader for each render target, let's simplify this structure and reduce the options memory footprint by 88% or something goofy like that. Should also enable separate blending per render target. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
67fe2afa51
commit
8f4b15636b
|
@ -175,7 +175,7 @@ nir_blend(
|
|||
for (unsigned c = 0; c < 4; ++c) {
|
||||
/* Decide properties based on channel */
|
||||
nir_lower_blend_channel chan =
|
||||
(c < 3) ? options.rt[0].rgb : options.rt[0].alpha;
|
||||
(c < 3) ? options.rgb : options.alpha;
|
||||
|
||||
nir_ssa_def *psrc = nir_channel(b, src, c);
|
||||
nir_ssa_def *pdst = nir_channel(b, dst, c);
|
||||
|
@ -197,7 +197,7 @@ nir_blend(
|
|||
|
||||
/* Then just recombine with an applied colormask */
|
||||
nir_ssa_def *blended = nir_vec(b, channels, 4);
|
||||
return nir_color_mask(b, options.rt[0].colormask, blended, dst);
|
||||
return nir_color_mask(b, options.colormask, blended, dst);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -214,8 +214,8 @@ static bool
|
|||
nir_is_blend_replace(nir_lower_blend_options options)
|
||||
{
|
||||
return
|
||||
nir_is_blend_channel_replace(options.rt[0].rgb) &&
|
||||
nir_is_blend_channel_replace(options.rt[0].alpha);
|
||||
nir_is_blend_channel_replace(options.rgb) &&
|
||||
nir_is_blend_channel_replace(options.alpha);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -43,13 +43,11 @@ typedef struct {
|
|||
} nir_lower_blend_channel;
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
nir_lower_blend_channel rgb;
|
||||
nir_lower_blend_channel alpha;
|
||||
nir_lower_blend_channel rgb;
|
||||
nir_lower_blend_channel alpha;
|
||||
|
||||
/* 4-bit colormask. 0x0 for none, 0xF for RGBA, 0x1 for R */
|
||||
unsigned colormask;
|
||||
} rt[8];
|
||||
/* 4-bit colormask. 0x0 for none, 0xF for RGBA, 0x1 for R */
|
||||
unsigned colormask;
|
||||
} nir_lower_blend_options;
|
||||
|
||||
void nir_lower_blend(nir_shader *shader, nir_lower_blend_options options);
|
||||
|
|
|
@ -85,43 +85,41 @@
|
|||
*/
|
||||
|
||||
static nir_lower_blend_options
|
||||
nir_make_options(const struct pipe_blend_state *blend, unsigned nr_cbufs)
|
||||
nir_make_options(const struct pipe_blend_state *blend, unsigned i)
|
||||
{
|
||||
nir_lower_blend_options options;
|
||||
|
||||
for (unsigned i = 0; i < nr_cbufs; ++i) {
|
||||
/* If blend is disabled, we just use replace mode */
|
||||
/* If blend is disabled, we just use replace mode */
|
||||
|
||||
nir_lower_blend_channel rgb = {
|
||||
.func = BLEND_FUNC_ADD,
|
||||
.src_factor = BLEND_FACTOR_ZERO,
|
||||
.invert_src_factor = true,
|
||||
.dst_factor = BLEND_FACTOR_ZERO,
|
||||
.invert_dst_factor = false
|
||||
};
|
||||
nir_lower_blend_channel rgb = {
|
||||
.func = BLEND_FUNC_ADD,
|
||||
.src_factor = BLEND_FACTOR_ZERO,
|
||||
.invert_src_factor = true,
|
||||
.dst_factor = BLEND_FACTOR_ZERO,
|
||||
.invert_dst_factor = false
|
||||
};
|
||||
|
||||
nir_lower_blend_channel alpha = rgb;
|
||||
nir_lower_blend_channel alpha = rgb;
|
||||
|
||||
if (blend->rt[i].blend_enable) {
|
||||
rgb.func = util_blend_func_to_shader(blend->rt[i].rgb_func);
|
||||
rgb.src_factor = util_blend_factor_to_shader(blend->rt[i].rgb_src_factor);
|
||||
rgb.dst_factor = util_blend_factor_to_shader(blend->rt[i].rgb_dst_factor);
|
||||
rgb.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_src_factor);
|
||||
rgb.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_dst_factor);
|
||||
if (blend->rt[i].blend_enable) {
|
||||
rgb.func = util_blend_func_to_shader(blend->rt[i].rgb_func);
|
||||
rgb.src_factor = util_blend_factor_to_shader(blend->rt[i].rgb_src_factor);
|
||||
rgb.dst_factor = util_blend_factor_to_shader(blend->rt[i].rgb_dst_factor);
|
||||
rgb.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_src_factor);
|
||||
rgb.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_dst_factor);
|
||||
|
||||
alpha.func = util_blend_func_to_shader(blend->rt[i].alpha_func);
|
||||
alpha.src_factor = util_blend_factor_to_shader(blend->rt[i].alpha_src_factor);
|
||||
alpha.dst_factor = util_blend_factor_to_shader(blend->rt[i].alpha_dst_factor);
|
||||
alpha.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_src_factor);
|
||||
alpha.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_dst_factor);
|
||||
}
|
||||
|
||||
options.rt[i].rgb = rgb;
|
||||
options.rt[i].alpha = alpha;
|
||||
|
||||
options.rt[i].colormask = blend->rt[i].colormask;
|
||||
alpha.func = util_blend_func_to_shader(blend->rt[i].alpha_func);
|
||||
alpha.src_factor = util_blend_factor_to_shader(blend->rt[i].alpha_src_factor);
|
||||
alpha.dst_factor = util_blend_factor_to_shader(blend->rt[i].alpha_dst_factor);
|
||||
alpha.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_src_factor);
|
||||
alpha.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_dst_factor);
|
||||
}
|
||||
|
||||
options.rgb = rgb;
|
||||
options.alpha = alpha;
|
||||
|
||||
options.colormask = blend->rt[i].colormask;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
@ -166,7 +164,7 @@ panfrost_compile_blend_shader(
|
|||
nir_store_var(b, c_out, s_src, 0xFF);
|
||||
|
||||
nir_lower_blend_options options =
|
||||
nir_make_options(cso, 1);
|
||||
nir_make_options(cso, rt);
|
||||
NIR_PASS_V(shader, nir_lower_blend, options);
|
||||
|
||||
NIR_PASS_V(shader, nir_lower_framebuffer, format, screen->gpu_id);
|
||||
|
|
|
@ -1454,6 +1454,7 @@ disassemble_midgard(uint8_t *code, size_t size, unsigned gpu_id, gl_shader_stage
|
|||
uint32_t *words = (uint32_t *) code;
|
||||
unsigned num_words = size / 4;
|
||||
int tabs = 0;
|
||||
num_words = MIN2(num_words, 100);
|
||||
|
||||
bool prefetch_flag = false;
|
||||
|
||||
|
@ -1470,6 +1471,7 @@ disassemble_midgard(uint8_t *code, size_t size, unsigned gpu_id, gl_shader_stage
|
|||
while (i < num_words) {
|
||||
unsigned tag = words[i] & 0xF;
|
||||
unsigned next_tag = (words[i] >> 4) & 0xF;
|
||||
printf("\t%X -> %X\n", tag, next_tag);
|
||||
unsigned num_quad_words = midgard_word_size[tag];
|
||||
|
||||
if (midg_tags[i] && midg_tags[i] != tag) {
|
||||
|
@ -1544,12 +1546,14 @@ disassemble_midgard(uint8_t *code, size_t size, unsigned gpu_id, gl_shader_stage
|
|||
|
||||
/* Break based on instruction prefetch flag */
|
||||
|
||||
#if 0
|
||||
if (i < num_words && next == 1) {
|
||||
prefetch_flag = true;
|
||||
|
||||
if (midgard_word_types[words[i] & 0xF] != midgard_word_type_alu)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
i += 4 * num_quad_words;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue