=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Use result type for bitfield instructions source parameters.

Alexandre Julliard julliard at winehq.org
Tue Jan 15 14:20:15 CST 2019


Module: vkd3d
Branch: master
Commit: bb7d1046da80f6ec928710d80b006af0fbdba1a3
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=bb7d1046da80f6ec928710d80b006af0fbdba1a3

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Tue Jan 15 12:09:46 2019 +0100

vkd3d-shader: Use result type for bitfield instructions source parameters.

Fixes SPIR-V validation errors:

  Expected Base Type to be equal to Result Type: BitFieldSExtract

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/spirv.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index a15bc32..82a9f62 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4988,6 +4988,7 @@ static void vkd3d_dxbc_compiler_emit_bitfield_instruction(struct vkd3d_dxbc_comp
     struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
     const struct vkd3d_shader_dst_param *dst = instruction->dst;
     const struct vkd3d_shader_src_param *src = instruction->src;
+    enum vkd3d_component_type component_type;
     unsigned int i, j, k, src_count;
     DWORD write_mask;
     SpvOp op;
@@ -4995,7 +4996,8 @@ static void vkd3d_dxbc_compiler_emit_bitfield_instruction(struct vkd3d_dxbc_comp
     src_count = instruction->src_count;
     assert(2 <= src_count && src_count <= ARRAY_SIZE(src_ids));
 
-    type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_UINT, 1);
+    component_type = vkd3d_component_type_from_data_type(dst->reg.data_type);
+    type_id = vkd3d_spirv_get_type_id(builder, component_type, 1);
     mask_id = vkd3d_dxbc_compiler_get_constant_uint(compiler, 0x1f);
 
     switch (instruction->handler_idx)
@@ -5014,20 +5016,22 @@ static void vkd3d_dxbc_compiler_emit_bitfield_instruction(struct vkd3d_dxbc_comp
             continue;
 
         for (j = 0; j < src_count; ++j)
-            src_ids[src_count - j - 1] = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[j], write_mask);
+        {
+            src_ids[src_count - j - 1] = vkd3d_dxbc_compiler_emit_load_src_with_type(compiler,
+                    &src[j], write_mask, component_type);
+        }
 
+        /* In SPIR-V, the last two operands are Offset and Count. */
         for (j = src_count - 2; j < src_count; ++j)
         {
-            uint32_t int_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_INT, 1);
-            src_ids[j] = vkd3d_spirv_build_op_and(builder, int_type_id, src_ids[j], mask_id);
+            src_ids[j] = vkd3d_spirv_build_op_and(builder, type_id, src_ids[j], mask_id);
         }
 
         constituents[k++] = vkd3d_spirv_build_op_trv(builder, &builder->function_stream,
                 op, type_id, src_ids, src_count);
     }
 
-    vkd3d_dxbc_compiler_emit_store_dst_components(compiler,
-            dst, vkd3d_component_type_from_data_type(dst->reg.data_type), constituents);
+    vkd3d_dxbc_compiler_emit_store_dst_components(compiler, dst, component_type, constituents);
 }
 
 static void vkd3d_dxbc_compiler_emit_f16tof32(struct vkd3d_dxbc_compiler *compiler,




More information about the wine-cvs mailing list