summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2022-03-10 13:07:37 +1000
committerEric Engestrom <eric@engestrom.ch>2022-03-10 23:24:02 +0000
commitbb8f6811add88b455f29aeed4ce003a5fea8b62f (patch)
tree7a2639e3b5269fe0cda460ba154405310030679b
parentde9ad8b0de64fbbdcf25f574d969f5819bf31d12 (diff)
zink: workaround depth texture mode alpha.
Since spir-v only has single channel depth sampling, it breaks with the old school GL_ALPHA depth mode swizzle, so just detect that case and smash all the channels. Cc: mesa-stable Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15297> (cherry picked from commit 30cb63bead12ad0d7ff66a6a267400c3a07c4f86)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/zink/zink_context.c22
2 files changed, 19 insertions, 5 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 1afc019dfd3..30908dd55c1 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -58,7 +58,7 @@
"description": "zink: workaround depth texture mode alpha.",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 2babcf3b207..e29d2c810b6 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -745,10 +745,24 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
ivci.subresourceRange.aspectMask = sampler_aspect_from_format(state->format);
/* samplers for stencil aspects of packed formats need to always use stencil swizzle */
if (ivci.subresourceRange.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
- ivci.components.r = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_r));
- ivci.components.g = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_g));
- ivci.components.b = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_b));
- ivci.components.a = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_a));
+ if (sampler_view->base.swizzle_r == PIPE_SWIZZLE_0 &&
+ sampler_view->base.swizzle_g == PIPE_SWIZZLE_0 &&
+ sampler_view->base.swizzle_b == PIPE_SWIZZLE_0 &&
+ sampler_view->base.swizzle_a == PIPE_SWIZZLE_X) {
+ /*
+ * When the state tracker asks for 000x swizzles, this is depth mode GL_ALPHA,
+ * however with the single dref fetch this will fail, so just spam all the channels.
+ */
+ ivci.components.r = VK_COMPONENT_SWIZZLE_R;
+ ivci.components.g = VK_COMPONENT_SWIZZLE_R;
+ ivci.components.b = VK_COMPONENT_SWIZZLE_R;
+ ivci.components.a = VK_COMPONENT_SWIZZLE_R;
+ } else {
+ ivci.components.r = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_r));
+ ivci.components.g = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_g));
+ ivci.components.b = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_b));
+ ivci.components.a = zink_component_mapping(clamp_zs_swizzle(sampler_view->base.swizzle_a));
+ }
} else {
/* if we have e.g., R8G8B8X8, then we have to ignore alpha since we're just emulating
* these formats