[PATCH vkd3d 5/5] vkd3d-shader: Handle non-contiguous destination write masks in vkd3d_dxbc_compiler_emit_store().

Henri Verbeet hverbeet at codeweavers.com
Thu Aug 20 14:09:45 CDT 2020


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 libs/vkd3d-shader/spirv.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index c677963..14ff7f4 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -3379,7 +3379,7 @@ static void vkd3d_dxbc_compiler_emit_store(struct vkd3d_dxbc_compiler *compiler,
     struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
     unsigned int component_count, dst_component_count;
     uint32_t components[VKD3D_VEC4_SIZE];
-    unsigned int i, component_idx;
+    unsigned int i, src_idx, dst_idx;
     uint32_t type_id, dst_val_id;
 
     assert(write_mask);
@@ -3409,12 +3409,15 @@ static void vkd3d_dxbc_compiler_emit_store(struct vkd3d_dxbc_compiler *compiler,
 
         assert(component_count <= ARRAY_SIZE(components));
 
-        for (i = 0, component_idx = 0; i < dst_component_count; ++i)
+        for (i = 0, src_idx = 0, dst_idx = 0; dst_idx < VKD3D_VEC4_SIZE; ++dst_idx)
         {
-            if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
-                components[i] = dst_component_count + component_idx++;
+            if (write_mask & (VKD3DSP_WRITEMASK_0 << dst_idx))
+                components[i] = dst_component_count + src_idx++;
             else
                 components[i] = i;
+
+            if (dst_write_mask & (VKD3DSP_WRITEMASK_0 << dst_idx))
+                ++i;
         }
 
         val_id = vkd3d_spirv_build_op_vector_shuffle(builder,
-- 
2.11.0




More information about the wine-devel mailing list