Module: Mesa
Branch: staging/23.0
Commit: 53f0dd5362b74c91f68bf0041baee38f59efe17a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53f0dd5362b74c91f68bf0041baee38f59efe17a

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Mar 28 14:54:28 2023 -0400

zink: don't bitcast bool deref loads/stores

a bool can only be a bool, and OpBitCast requires the src type to be
different than the dst type, so this is illegal

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22577>
(cherry picked from commit 9bf4db8ebb4d12a867edbf0740b55cc920fef712)

---

 .pick_status.json                                    | 2 +-
 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 987f774f8c1..0d7889cff71 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2674,7 +2674,7 @@
         "description": "zink: don't bitcast bool deref loads/stores",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c 
b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 9756447e026..17be6d9e43d 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2477,7 +2477,8 @@ emit_load_deref(struct ntv_context *ctx, 
nir_intrinsic_instr *intr)
       result = spirv_builder_emit_load(&ctx->builder, type, ptr);
    unsigned num_components = nir_dest_num_components(intr->dest);
    unsigned bit_size = nir_dest_bit_size(intr->dest);
-   result = bitcast_to_uvec(ctx, result, bit_size, num_components);
+   if (bit_size > 1)
+      result = bitcast_to_uvec(ctx, result, bit_size, num_components);
    store_dest(ctx, &intr->dest, result, nir_type_uint);
 }
 
@@ -2526,6 +2527,8 @@ emit_store_deref(struct ntv_context *ctx, 
nir_intrinsic_instr *intr)
       src = emit_bitcast(ctx, type, src);
       /* SampleMask is always an array in spirv, so we need to construct it 
into one */
       result = spirv_builder_emit_composite_construct(&ctx->builder, 
ctx->sample_mask_type, &src, 1);
+   } else if (glsl_get_base_type(glsl_without_array(gtype)) == GLSL_TYPE_BOOL) 
{
+      result = src;
    } else
       result = emit_bitcast(ctx, type, src);
    if (nir_intrinsic_access(intr) & ACCESS_COHERENT)

Reply via email to