From bf6d548787091cc31f80e8e2e1c0d6995cca5afc Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 18 Aug 2020 18:15:45 -0400 Subject: [PATCH] panfrost: XMLify blend equation Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- src/gallium/drivers/panfrost/pan_blend.h | 4 +-- src/gallium/drivers/panfrost/pan_blend_cso.c | 12 +++---- src/gallium/drivers/panfrost/pan_blending.c | 21 ++++++------ src/gallium/drivers/panfrost/pan_blending.h | 2 +- src/gallium/drivers/panfrost/pan_cmdstream.c | 6 ++-- src/panfrost/include/panfrost-job.h | 16 ++------- src/panfrost/lib/decode.c | 34 ++------------------ src/panfrost/lib/midgard.xml | 6 ++++ src/panfrost/lib/pan_blit.c | 19 ++++++----- 9 files changed, 42 insertions(+), 78 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_blend.h b/src/gallium/drivers/panfrost/pan_blend.h index a37d571c7d6..df1227bfd01 100644 --- a/src/gallium/drivers/panfrost/pan_blend.h +++ b/src/gallium/drivers/panfrost/pan_blend.h @@ -66,7 +66,7 @@ struct panfrost_blend_shader_final { }; struct panfrost_blend_equation_final { - struct mali_blend_equation *equation; + struct mali_blend_equation_packed equation; float constant; }; @@ -75,7 +75,7 @@ struct panfrost_blend_rt { * fixed-function configuration for this blend state */ bool has_fixed_function; - struct mali_blend_equation equation; + struct mali_blend_equation_packed equation; /* Mask of blend color components read */ unsigned constant_mask; diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c index d600292e8a0..4d90101366a 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.c +++ b/src/gallium/drivers/panfrost/pan_blend_cso.c @@ -129,12 +129,8 @@ panfrost_create_blend_state(struct pipe_context *pipe, &rt->equation, &rt->constant_mask); - if (rt->has_fixed_function) { - rt->opaque = - (rt->equation.rgb_mode == 0x122) && - (rt->equation.alpha_mode == 0x122) && - (rt->equation.color_mask == 0xf); - } + if (rt->has_fixed_function) + rt->opaque = (rt->equation.opaque[0] == 0xf0122122); rt->load_dest = util_blend_uses_dest(pipe) || pipe.colormask != 0xF; @@ -241,12 +237,12 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti) rt->constant_mask)) { struct panfrost_blend_final final = { .equation = { - .equation = &rt->equation, + .equation = rt->equation, .constant = constant }, .load_dest = rt->load_dest, .opaque = rt->opaque, - .no_colour = (rt->equation.color_mask == 0x0) + .no_colour = rt->no_colour }; return final; diff --git a/src/gallium/drivers/panfrost/pan_blending.c b/src/gallium/drivers/panfrost/pan_blending.c index e1122880594..5a94975230d 100644 --- a/src/gallium/drivers/panfrost/pan_blending.c +++ b/src/gallium/drivers/panfrost/pan_blending.c @@ -342,19 +342,17 @@ panfrost_constant_mask(unsigned *factors, unsigned num_factors) bool panfrost_make_fixed_blend_mode( struct pipe_rt_blend_state blend, - struct mali_blend_equation *out, + struct mali_blend_equation_packed *out, unsigned *constant_mask) { - /* Gallium and Mali represent colour masks identically. XXX: Static - * assert for future proof */ - - out->color_mask = blend.colormask; - /* If no blending is enabled, default back on `replace` mode */ if (!blend.blend_enable) { - out->rgb_mode = 0x122; - out->alpha_mode = 0x122; + pan_pack(out, BLEND_EQUATION, cfg) { + cfg.color_mask = blend.colormask; + cfg.rgb_mode = cfg.alpha_mode = 0x122; + } + return true; } @@ -384,8 +382,11 @@ panfrost_make_fixed_blend_mode( &alpha_mode)) return false; - out->rgb_mode = rgb_mode; - out->alpha_mode = alpha_mode; + pan_pack(out, BLEND_EQUATION, cfg) { + cfg.color_mask = blend.colormask; + cfg.rgb_mode = rgb_mode; + cfg.alpha_mode = alpha_mode; + } return true; } diff --git a/src/gallium/drivers/panfrost/pan_blending.h b/src/gallium/drivers/panfrost/pan_blending.h index 123b1d13bf4..c466e8d665a 100644 --- a/src/gallium/drivers/panfrost/pan_blending.h +++ b/src/gallium/drivers/panfrost/pan_blending.h @@ -34,7 +34,7 @@ struct panfrost_blend_state; bool panfrost_make_fixed_blend_mode( const struct pipe_rt_blend_state blend, - struct mali_blend_equation *out, + struct mali_blend_equation_packed *out, unsigned *constant_mask); bool diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 33a7b7abd3d..99a119c4ed7 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -610,7 +610,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, blend[0].is_shader); if (!blend[0].is_shader) { - fragmeta->blend.equation = *blend[0].equation.equation; + fragmeta->blend.equation = blend[0].equation.equation; fragmeta->blend.constant = blend[0].equation.constant; } @@ -684,7 +684,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, const struct util_format_description *format_desc; format_desc = util_format_description(format); - brts[i].equation = *blend[i].equation.equation; + brts[i].equation = blend[i].equation.equation; /* TODO: this is a bit more complicated */ brts[i].constant = blend[i].equation.constant; @@ -705,7 +705,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, if (blend[i].is_shader) { mrts[i].blend.shader = blend[i].shader.gpu | blend[i].shader.first_tag; } else { - mrts[i].blend.equation = *blend[i].equation.equation; + mrts[i].blend.equation = blend[i].equation.equation; mrts[i].blend.constant = blend[i].equation.constant; } } diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 3f227fdc8b7..d5a48fd344b 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -135,18 +135,6 @@ struct mali_blend_mode { unsigned complement_dominant : 1; } __attribute__((packed)); -struct mali_blend_equation { - /* Of type mali_blend_mode */ - unsigned rgb_mode : 12; - unsigned alpha_mode : 12; - - unsigned zero1 : 4; - - /* Corresponds to MALI_MASK_* above and glColorMask arguments */ - - unsigned color_mask : 4; -} __attribute__((packed)); - /* Compressed per-pixel formats. Each of these formats expands to one to four * floating-point or integer numbers, as defined by the OpenGL specification. * There are various places in OpenGL where the user can specify a compressed @@ -281,7 +269,7 @@ union midgard_blend { mali_ptr shader; struct { - struct mali_blend_equation equation; + struct mali_blend_equation_packed equation; float constant; }; }; @@ -324,7 +312,7 @@ struct bifrost_blend_rt { */ u16 constant; - struct mali_blend_equation equation; + struct mali_blend_equation_packed equation; /* * - 0x19 normally diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index d8567f41d7a..e7716aeb11c 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -228,16 +228,6 @@ static const struct pandecode_flag_info clear_flag_info[] = { }; #undef FLAG_INFO -#define FLAG_INFO(flag) { MALI_MASK_##flag, "MALI_MASK_" #flag } -static const struct pandecode_flag_info mask_flag_info[] = { - FLAG_INFO(R), - FLAG_INFO(G), - FLAG_INFO(B), - FLAG_INFO(A), - {} -}; -#undef FLAG_INFO - #define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag } static const struct pandecode_flag_info u3_flag_info[] = { FLAG_INFO(HAS_MSAA), @@ -1147,26 +1137,6 @@ pandecode_shader_address(const char *name, mali_ptr ptr) return shader_ptr; } -static void -pandecode_blend_equation(const struct mali_blend_equation *blend) -{ - if (blend->zero1) - pandecode_msg("XXX: blend zero tripped: %X\n", blend->zero1); - - pandecode_log(".equation = {\n"); - pandecode_indent++; - - pandecode_prop("rgb_mode = 0x%X", blend->rgb_mode); - pandecode_prop("alpha_mode = 0x%X", blend->alpha_mode); - - pandecode_log(".color_mask = "); - pandecode_log_decoded_flags(mask_flag_info, blend->color_mask); - pandecode_log_cont(",\n"); - - pandecode_indent--; - pandecode_log("},\n"); -} - /* Decodes a Bifrost blend constant. See the notes in bifrost_blend_rt */ static unsigned @@ -1192,7 +1162,7 @@ pandecode_bifrost_blend(void *descs, int job_no, int rt_no) b->constant, decode_bifrost_constant(b->constant)); /* TODO figure out blend shader enable bit */ - pandecode_blend_equation(&b->equation); + DUMP_CL("Equation", BLEND_EQUATION, &b->equation, 2); pandecode_prop("unk2 = 0x%" PRIx16, b->unk2); pandecode_prop("index = 0x%" PRIx16, b->index); @@ -1258,7 +1228,7 @@ pandecode_midgard_blend(union midgard_blend *blend, bool is_shader) if (is_shader) { pandecode_shader_address("shader", blend->shader); } else { - pandecode_blend_equation(&blend->equation); + DUMP_CL("Equation", BLEND_EQUATION, &blend->equation, 2); pandecode_prop("constant = %f", blend->constant); } diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 0a3b6b15f7f..60782ae301e 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -256,6 +256,12 @@ + + + + + + diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c index 0676b85f25f..a9e6d6d0f0c 100644 --- a/src/panfrost/lib/pan_blit.c +++ b/src/panfrost/lib/pan_blit.c @@ -216,12 +216,18 @@ panfrost_load_midg( cfg.depth_pass = MALI_STENCIL_OP_REPLACE; }; + struct mali_blend_equation_packed eq; + + pan_pack(&eq, BLEND_EQUATION, cfg) { + cfg.rgb_mode = 0x122; + cfg.alpha_mode = 0x122; + + if (loc < FRAG_RESULT_DATA0) + cfg.color_mask = 0x0; + } + union midgard_blend replace = { - .equation = { - .rgb_mode = 0x122, - .alpha_mode = 0x122, - .color_mask = MALI_MASK_R | MALI_MASK_G | MALI_MASK_B | MALI_MASK_A, - } + .equation = eq }; if (blend_shader) @@ -269,9 +275,6 @@ panfrost_load_midg( if (pool->dev->quirks & MIDGARD_SFBD) { shader_meta.unknown2_4 |= (0x10 | MALI_NO_DITHER); shader_meta.blend = replace; - - if (loc < FRAG_RESULT_DATA0) - shader_meta.blend.equation.color_mask = 0x0; } if (loc == FRAG_RESULT_DEPTH) { -- 2.30.2