[Mesa-dev] [PATCH] panfrost: Enable helper invocations when texturing
Jason Ekstrand
jason at jlekstrand.net
Sat Jun 8 12:57:52 UTC 2019
On June 7, 2019 18:04:40 Alyssa Rosenzweig
<alyssa.rosenzweig at collabora.com> wrote:
> it turns out we have explicit control over helper invocations; if a
> particular bit in the fragment shader descriptor is set, helper
> invocations are launched; if it clear, they are not. Helper invocations
> are required whenever computing derivatives, whether explicitly
> (dFdx/dFdy) *or* implicitly (any texturing). Accordingly, we set this
> bit when texturing to fix edge case behaviour (literally, haha).
Hehe
> Thank you to Jason Ekstrand and Ilia Mirkin for pointing out the
> representative dEQP test failed along triangle edges and for suggesting
> helper invocations / derivatives as a list of suspect pieces (which led
> to discovering the helper invocations enable bit in the first place).
>
>
> Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
> ---
> .../drivers/panfrost/ci/expected-failures.txt | 72 -------------------
> .../drivers/panfrost/include/panfrost-job.h | 14 +++-
> src/gallium/drivers/panfrost/pan_context.c | 12 +++-
> .../drivers/panfrost/pandecode/decode.c | 3 +-
> 4 files changed, 25 insertions(+), 76 deletions(-)
>
>
> diff --git a/src/gallium/drivers/panfrost/ci/expected-failures.txt
> b/src/gallium/drivers/panfrost/ci/expected-failures.txt
> index 9cbea0c6bfd..bb679e31934 100644
> --- a/src/gallium/drivers/panfrost/ci/expected-failures.txt
> +++ b/src/gallium/drivers/panfrost/ci/expected-failures.txt
> @@ -425,44 +425,6 @@
> dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_nearest_nearest_repeat_
> dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_nearest_nearest_repeat_rgb888
> dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_nearest_nearest_repeat_rgba4444
> dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_nearest_nearest_repeat_rgba8888
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_l8_npot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgb888_npot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgba4444_npot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgba8888_npot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_clamp_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_mirror_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_mirror_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_mirror_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_mirror_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_mirror_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_repeat_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_repeat_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_repeat_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_repeat_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.linear_nearest_repeat_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_l8_npot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgb888_npot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgba4444_npot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgba8888_npot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_clamp_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_mirror_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_mirror_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_mirror_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_mirror_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_mirror_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_repeat_etc1
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_repeat_l8_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_repeat_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_repeat_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.2d.nearest_linear_repeat_rgba8888_pot
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_linear_linear_clamp_etc1
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_linear_linear_clamp_rgba8888
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_linear_linear_mirror_etc1
> @@ -493,40 +455,6 @@
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_nearest_nearest_repeat
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_nearest_nearest_repeat_rgb888
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_nearest_nearest_repeat_rgba4444
> dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_nearest_nearest_repeat_rgba8888
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_etc1
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_l8_npot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgb888_npot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgba4444_npot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgba8888_npot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_clamp_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_mirror_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_mirror_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_mirror_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_mirror_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_repeat_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_repeat_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_repeat_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.linear_nearest_repeat_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_etc1
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_l8_npot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgb888_npot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgba4444_npot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgba8888_npot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_clamp_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_mirror_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_mirror_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_mirror_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_mirror_rgba8888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_repeat_l8_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_repeat_rgb888_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_repeat_rgba4444_pot
> -dEQP-GLES2.functional.texture.filtering.cube.nearest_linear_repeat_rgba8888_pot
> dEQP-GLES2.functional.texture.filtering.cube.nearest_mipmap_linear_linear_clamp_etc1
> dEQP-GLES2.functional.texture.filtering.cube.nearest_mipmap_linear_linear_clamp_rgba8888
> dEQP-GLES2.functional.texture.filtering.cube.nearest_mipmap_linear_linear_mirror_rgba8888
> diff --git a/src/gallium/drivers/panfrost/include/panfrost-job.h
> b/src/gallium/drivers/panfrost/include/panfrost-job.h
> index fd23499a00c..a154e5ca207 100644
> --- a/src/gallium/drivers/panfrost/include/panfrost-job.h
> +++ b/src/gallium/drivers/panfrost/include/panfrost-job.h
> @@ -402,7 +402,19 @@ enum mali_format {
> #define MALI_GET_ALPHA_COVERAGE(nibble) ((float) nibble / 15.0f)
>
> /* Applies to unknown1 */
> -#define MALI_NO_ALPHA_TO_COVERAGE (1 << 10)
> +
> +/* Should the hardware perform early-Z testing? Normally should be set
> + * for performance reasons. Clear if you use: discard,
> + * alpha-to-coverage... * It's also possible this disables
The * in this line makes me think like wrapping went wrong somewhere.
> + * forward-pixel kill; we're not quite sure which bit is which yet.
> + * TODO: How does this interact with blending?*/
> +
> +#define MALI_EARLY_Z (1 << 10)
Really not my call but IMO this patch is conflating to things and is
personally make it to patches. Then again, maybe you consider this to be a
larger, "I figured out more bits" patch but the committee message doesn't
indicate that.
> +
> +/* Should the hardware calculate derivatives (via helper invocations)? Set
> in a
> + * fragment shader that uses texturing or derivative functions */
> +
> +#define MALI_HELPER_INVOCATIONS (1 << 11)
>
> /* Flags denoting the fragment shader's use of tilebuffer readback. If the
> * shader might read any part of the tilebuffer, set MALI_READS_TILEBUFFER. If
> diff --git a/src/gallium/drivers/panfrost/pan_context.c
> b/src/gallium/drivers/panfrost/pan_context.c
> index b08f50291fb..90f60f35581 100644
> --- a/src/gallium/drivers/panfrost/pan_context.c
> +++ b/src/gallium/drivers/panfrost/pan_context.c
> @@ -1037,7 +1037,15 @@ panfrost_emit_for_draw(struct panfrost_context *ctx,
> bool with_vertex_data)
>
> /* Set late due to depending on render state */
> /* The one at the end seems to mean "1 UBO" */
> - ctx->fragment_shader_core.midgard1.unknown1 =
> MALI_NO_ALPHA_TO_COVERAGE | 0x200 | 0x2201;
> + unsigned flags = MALI_EARLY_Z | 0x200 | 0x2000 | 0x1;
> +
> + /* Any time texturing is used, derivatives are implicitly
> + * calculated, so we need to enable helper invocations */
> +
> + if (ctx->sampler_view_count[PIPE_SHADER_FRAGMENT])
> + flags |= MALI_HELPER_INVOCATIONS;
I wrote a NIR pass for figuring this out more exactly yesterday. If you've
got some sort of way to pass the information thought to here, it's likely
better to just use the new NIR thing. Among other things, it'll save you
the pain of having to find this again when you go to implement derivatives.
> +
> + ctx->fragment_shader_core.midgard1.unknown1 = flags;
>
> /* Assign texture/sample count right before upload */
> ctx->fragment_shader_core.texture_count =
> ctx->sampler_view_count[PIPE_SHADER_FRAGMENT];
> @@ -1056,7 +1064,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx,
> bool with_vertex_data)
>
> if (variant->can_discard) {
> ctx->fragment_shader_core.unknown2_3 |= MALI_CAN_DISCARD;
> - ctx->fragment_shader_core.midgard1.unknown1 &=
> ~MALI_NO_ALPHA_TO_COVERAGE;
> + ctx->fragment_shader_core.midgard1.unknown1 &=
> ~MALI_EARLY_Z;
> ctx->fragment_shader_core.midgard1.unknown1 |= 0x4000;
> ctx->fragment_shader_core.midgard1.unknown1 = 0x4200;
> }
> diff --git a/src/gallium/drivers/panfrost/pandecode/decode.c
> b/src/gallium/drivers/panfrost/pandecode/decode.c
> index 00678a4c5ed..06bd3b225f9 100644
> --- a/src/gallium/drivers/panfrost/pandecode/decode.c
> +++ b/src/gallium/drivers/panfrost/pandecode/decode.c
> @@ -223,7 +223,8 @@ static const struct pandecode_flag_info
> mfbd_extra_flag_info[] = {
>
> #define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
> static const struct pandecode_flag_info shader_unknown1_flag_info [] = {
> - FLAG_INFO(NO_ALPHA_TO_COVERAGE),
> + FLAG_INFO(EARLY_Z),
> + FLAG_INFO(HELPER_INVOCATIONS),
> FLAG_INFO(READS_TILEBUFFER),
> FLAG_INFO(READS_ZS),
> {}
> --
> 2.20.1
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list