aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost
diff options
context:
space:
mode:
authorBoris Brezillon <[email protected]>2020-01-31 10:55:49 +0100
committerMarge Bot <[email protected]>2020-02-05 15:41:55 +0000
commit38c20696a5358d6898c4ee96fb127d603c1e1404 (patch)
treeca2eb54fdb5eeec2162e0478628d04568be999a3 /src/gallium/drivers/panfrost
parent8ed94d38b4169e18bf81e956241d1c8674cc2ec6 (diff)
panfrost: Set the MALI_WRITES_{Z,S} flags when needed
In order to make Z/S writes from fragment shaders effective, we need to set the MALI_WRITES_{Z,S} flags when the shader has a FRAG_RESULT_{DEPTH,STENCIL} output variable. Now that shaders can change the S value, we can expose the STENCIL_EXPORT cap. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3697>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r--src/gallium/drivers/panfrost/pan_assemble.c4
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c9
-rw-r--r--src/gallium/drivers/panfrost/pan_context.h2
-rw-r--r--src/gallium/drivers/panfrost/pan_screen.c3
4 files changed, 17 insertions, 1 deletions
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c
index fb5cb4cb7e2..03ca63ccc32 100644
--- a/src/gallium/drivers/panfrost/pan_assemble.c
+++ b/src/gallium/drivers/panfrost/pan_assemble.c
@@ -114,6 +114,10 @@ panfrost_shader_compile(
case MESA_SHADER_FRAGMENT:
meta->attribute_count = 0;
meta->varying_count = util_bitcount64(s->info.inputs_read);
+ if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
+ state->writes_depth = true;
+ if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL))
+ state->writes_stencil = true;
break;
case MESA_SHADER_COMPUTE:
/* TODO: images */
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index faa56ee33ff..417c900c961 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -961,7 +961,14 @@ 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_lo, MALI_EARLY_Z, !variant->can_discard);
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo, MALI_EARLY_Z,
+ !variant->can_discard && !variant->writes_depth);
+
+ /* Add the writes Z/S flags if needed. */
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_lo,
+ MALI_WRITES_Z, variant->writes_depth);
+ SET_BIT(ctx->fragment_shader_core.midgard1.flags_hi,
+ MALI_WRITES_S, variant->writes_stencil);
/* Any time texturing is used, derivatives are implicitly
* calculated, so we need to enable helper invocations */
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 98d327cfde4..79d082da11f 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -210,6 +210,8 @@ struct panfrost_shader_state {
int uniform_count;
bool can_discard;
bool writes_point_size;
+ bool writes_depth;
+ bool writes_stencil;
bool reads_point_coord;
bool reads_face;
bool reads_frag_coord;
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index 0fe6062df91..19d646bf7e7 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -245,6 +245,9 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
return (int)(system_memory >> 20);
}
+ case PIPE_CAP_SHADER_STENCIL_EXPORT:
+ return 1;
+
case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
return 4;