[PATCH vkd3d v3 11/12] vkd3d-shader/hlsl: Handle mipmap level for texture arrays in sm4 ld instruction.

Francisco Casas fcasas at codeweavers.com
Fri Dec 17 13:12:53 CST 2021


Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
---
 libs/vkd3d-shader/hlsl_sm4.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 1b8d9c25..f5c3dd6d 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1287,6 +1287,7 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
 {
     struct sm4_instruction instr;
     unsigned int writemask;
+    unsigned int dim_count;
 
     memset(&instr, 0, sizeof(instr));
     instr.opcode = VKD3D_SM4_OP_LD;
@@ -1299,23 +1300,11 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
 
     /* Mipmap level is in the last component in the IR, but needs to be in the W
      * component in the instruction. */
-    switch (resource_type->sampler_dim)
-    {
-        case HLSL_SAMPLER_DIM_1D:
-            instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4);
-            break;
-
-        case HLSL_SAMPLER_DIM_2D:
-            instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4);
-            break;
-
-        case HLSL_SAMPLER_DIM_3D:
-        case HLSL_SAMPLER_DIM_CUBE:
-            break;
-
-        default:
-            assert(0);
-    }
+    dim_count = sampler_dim_count(resource_type->sampler_dim);
+    if (dim_count == 1)
+        instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4);
+    if (dim_count == 2)
+        instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4);
 
     sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask, &instr.srcs[1].swizzle_type,
             resource, resource_type);
-- 
2.25.1




More information about the wine-devel mailing list