From: Boris Brezillon Date: Fri, 31 Jan 2020 11:37:38 +0000 (+0100) Subject: panfrost: Add the MALI_WRITES_{Z,S} flags X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ed94d38b4169e18bf81e956241d1c8674cc2ec6;p=mesa.git panfrost: Add the MALI_WRITES_{Z,S} flags We discovered 2 new shader flags used when a fragment shader updates the depth/stencil value through a ZS writeout. If those flags are not set, the depth/stencil value stored in the depth/stencil tilebuffer remain unchanged. While at it, rename unknown2 into flags_hi and rename flags into flags_lo. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index acb688651e6..fb5cb4cb7e2 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -136,7 +136,7 @@ panfrost_shader_compile( /* Separate as primary uniform count is truncated */ state->uniform_count = program.uniform_count; - meta->midgard1.unknown2 = 8; /* XXX */ + meta->midgard1.flags_hi = 8; /* XXX */ unsigned default_vec1_swizzle = panfrost_get_default_swizzle(1); unsigned default_vec2_swizzle = panfrost_get_default_swizzle(2); diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 169e5956c2f..faa56ee33ff 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -843,7 +843,7 @@ panfrost_patch_shader_state(struct panfrost_context *ctx, ss->tripipe->texture_count = ctx->sampler_view_count[stage]; ss->tripipe->sampler_count = ctx->sampler_count[stage]; - ss->tripipe->midgard1.flags = 0x220; + ss->tripipe->midgard1.flags_lo = 0x220; unsigned ubo_count = panfrost_ubo_count(ctx, stage); ss->tripipe->midgard1.uniform_buffer_count = ubo_count; @@ -935,8 +935,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) COPY(midgard1.uniform_count); COPY(midgard1.uniform_buffer_count); COPY(midgard1.work_count); - COPY(midgard1.flags); - COPY(midgard1.unknown2); + COPY(midgard1.flags_lo); + COPY(midgard1.flags_hi); #undef COPY @@ -961,12 +961,12 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) /* Depending on whether it's legal to in the given shader, we * try to enable early-z testing (or forward-pixel kill?) */ - SET_BIT(ctx->fragment_shader_core.midgard1.flags, MALI_EARLY_Z, !variant->can_discard); + SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, MALI_EARLY_Z, !variant->can_discard); /* Any time texturing is used, derivatives are implicitly * calculated, so we need to enable helper invocations */ - SET_BIT(ctx->fragment_shader_core.midgard1.flags, MALI_HELPER_INVOCATIONS, variant->helper_invocations); + SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, MALI_HELPER_INVOCATIONS, variant->helper_invocations); /* Assign the stencil refs late */ @@ -985,7 +985,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) */ SET_BIT(ctx->fragment_shader_core.unknown2_3, MALI_CAN_DISCARD, variant->can_discard); - SET_BIT(ctx->fragment_shader_core.midgard1.flags, 0x400, variant->can_discard); + SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, 0x400, variant->can_discard); /* Even on MFBD, the shader descriptor gets blend shaders. It's * *also* copied to the blend_meta appended (by convention), diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 0861d10e509..1a59f4c77c8 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -384,7 +384,10 @@ enum mali_format { #define MALI_ALPHA_COVERAGE(clampf) ((uint16_t) (int) (clampf * 15.0f)) #define MALI_GET_ALPHA_COVERAGE(nibble) ((float) nibble / 15.0f) -/* Applies to midgard1.flags */ +/* Applies to midgard1.flags_lo */ + +/* Should be set when the fragment shader updates the depth value. */ +#define MALI_WRITES_Z (1 << 4) /* Should the hardware perform early-Z testing? Normally should be set * for performance reasons. Clear if you use: discard, @@ -406,6 +409,11 @@ enum mali_format { #define MALI_READS_ZS (1 << 8) #define MALI_READS_TILEBUFFER (1 << 12) +/* Applies to midgard1.flags_hi */ + +/* Should be set when the fragment shader updates the stencil value. */ +#define MALI_WRITES_S (1 << 2) + /* The raw Midgard blend payload can either be an equation or a shader * address, depending on the context */ @@ -534,12 +542,12 @@ struct mali_shader_meta { } bifrost1; struct { unsigned uniform_buffer_count : 4; - unsigned flags : 12; + unsigned flags_lo : 12; /* vec4 units */ unsigned work_count : 5; unsigned uniform_count : 5; - unsigned unknown2 : 6; + unsigned flags_hi : 6; } midgard1; }; diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index 32a6ba42a7a..dc755fcc364 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -263,12 +263,18 @@ static const struct pandecode_flag_info mfbd_extra_flag_lo_info[] = { #undef FLAG_INFO #define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag } -static const struct pandecode_flag_info shader_midgard1_flag_info [] = { +static const struct pandecode_flag_info shader_midgard1_flag_lo_info [] = { + FLAG_INFO(WRITES_Z), FLAG_INFO(EARLY_Z), FLAG_INFO(READS_TILEBUFFER), FLAG_INFO(READS_ZS), {} }; + +static const struct pandecode_flag_info shader_midgard1_flag_hi_info [] = { + FLAG_INFO(WRITES_S), + {} +}; #undef FLAG_INFO #define FLAG_INFO(flag) { MALI_MFBD_##flag, "MALI_MFBD_" #flag } @@ -2213,19 +2219,21 @@ pandecode_vertex_tiler_postfix_pre( if (is_bifrost) { pandecode_prop("bifrost1.unk1 = 0x%" PRIx32, s->bifrost1.unk1); } else { - bool helpers = s->midgard1.flags & MALI_HELPER_INVOCATIONS; - s->midgard1.flags &= ~MALI_HELPER_INVOCATIONS; + bool helpers = s->midgard1.flags_lo & MALI_HELPER_INVOCATIONS; + s->midgard1.flags_lo &= ~MALI_HELPER_INVOCATIONS; if (helpers != info.helper_invocations) { pandecode_msg("XXX: expected helpers %u but got %u\n", info.helper_invocations, helpers); } - pandecode_log(".midgard1.flags = "); - pandecode_log_decoded_flags(shader_midgard1_flag_info, s->midgard1.flags); + pandecode_log(".midgard1.flags_lo = "); + pandecode_log_decoded_flags(shader_midgard1_flag_lo_info, s->midgard1.flags_lo); pandecode_log_cont(",\n"); - pandecode_prop("midgard1.unknown2 = 0x%" PRIx32, s->midgard1.unknown2); + pandecode_log(".midgard1.flags_hi = "); + pandecode_log_decoded_flags(shader_midgard1_flag_hi_info, s->midgard1.flags_hi); + pandecode_log_cont(",\n"); } if (s->depth_units || s->depth_factor) {