summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>2021-05-31 01:41:37 +0530
committerMarge Bot <eric+marge@anholt.net>2021-05-30 23:32:01 +0000
commit5de49375ecd47ae0710307fa57c2b92d202e4a7d (patch)
tree61b8949f5c4ea0b46acfbd98c9088fa4afd22d52
parentacfeba4010f830399d0413fedf52dcaa04d60fbb (diff)
asahi: Expose PIPE_CAP_CLIP_HALFZ
Use the Zink lowering pass to handle the non-halfz case. Metal, like Vulkan, uses half-z (and Metal is not configurable, making r/e tricky). Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11084>
-rw-r--r--src/asahi/compiler/agx_compile.c7
-rw-r--r--src/asahi/compiler/agx_compile.h3
-rw-r--r--src/gallium/drivers/asahi/agx_pipe.c1
-rw-r--r--src/gallium/drivers/asahi/agx_state.c3
4 files changed, 12 insertions, 2 deletions
diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 6970e629648..7a38d63cdd5 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -1080,9 +1080,14 @@ agx_compile_shader_nir(nir_shader *nir,
glsl_get_natural_size_align_bytes);
NIR_PASS_V(nir, nir_lower_indirect_derefs, nir_var_function_temp, ~0);
- if (ctx->stage == MESA_SHADER_VERTEX)
+ if (ctx->stage == MESA_SHADER_VERTEX) {
agx_remap_varyings(nir);
+ /* Lower from OpenGL [-1, 1] to [0, 1] if half-z is not set */
+ if (!key->vs.clip_halfz)
+ NIR_PASS_V(nir, nir_lower_clip_halfz);
+ }
+
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
NIR_PASS_V(nir, nir_lower_var_copies);
diff --git a/src/asahi/compiler/agx_compile.h b/src/asahi/compiler/agx_compile.h
index 484d96e6fb9..70aed6e48a8 100644
--- a/src/asahi/compiler/agx_compile.h
+++ b/src/asahi/compiler/agx_compile.h
@@ -116,6 +116,9 @@ struct agx_vs_shader_key {
unsigned vbuf_strides[AGX_MAX_VBUFS];
struct agx_attribute attributes[AGX_MAX_ATTRIBS];
+
+ /* Set to true for clip coordinates to range [0, 1] instead of [-1, 1] */
+ bool clip_halfz : 1;
};
struct agx_fs_shader_key {
diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c
index e6c82733d71..fd61ef31f84 100644
--- a/src/gallium/drivers/asahi/agx_pipe.c
+++ b/src/gallium/drivers/asahi/agx_pipe.c
@@ -595,6 +595,7 @@ agx_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
+ case PIPE_CAP_CLIP_HALFZ:
return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c
index d11cddba6c5..8b8086bfecf 100644
--- a/src/gallium/drivers/asahi/agx_state.c
+++ b/src/gallium/drivers/asahi/agx_state.c
@@ -752,7 +752,8 @@ static bool
agx_update_vs(struct agx_context *ctx)
{
struct agx_vs_shader_key key = {
- .num_vbufs = util_last_bit(ctx->vb_mask)
+ .num_vbufs = util_last_bit(ctx->vb_mask),
+ .clip_halfz = ctx->rast->base.clip_halfz,
};
memcpy(key.attributes, ctx->attributes,