[PATCH vkd3d v2 1/6] vkd3d-shader: Find bindings for descriptor arrays.

Conor McCarthy conor.mccarthy6 at bigpond.com
Sun Jul 18 23:47:40 CDT 2021


From: Conor McCarthy <cmccarthy at codeweavers.com>

Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
 libs/vkd3d-shader/spirv.c | 22 ++++++++++------------
 tests/d3d12.c             |  1 +
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index bd231124..6576aca4 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2463,9 +2463,10 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_dxbc_compiler_error(struct vkd3d_dxbc_
 static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor_binding(
         struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg,
         const struct vkd3d_shader_register_range *range, enum vkd3d_shader_resource_type resource_type,
-        bool is_uav_counter)
+        bool is_uav_counter, unsigned int *binding_base_idx)
 {
     const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface;
+    unsigned int register_last = (range->last == ~0u) ? range->first : range->last;
     enum vkd3d_shader_descriptor_type descriptor_type;
     enum vkd3d_shader_binding_flag resource_type_flag;
     struct vkd3d_shader_descriptor_binding binding;
@@ -2519,6 +2520,7 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
                         range->first, range->space, current->binding.count);
             }
 
+            *binding_base_idx = current->register_index;
             return current->binding;
         }
         if (shader_interface->uav_counter_count)
@@ -2541,18 +2543,11 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
                 continue;
 
             if (current->type != descriptor_type || current->register_space != range->space
-                    || current->register_index != range->first)
+                    || current->register_index > range->first
+                    || current->binding.count <= register_last - current->register_index)
                 continue;
 
-            if (current->binding.count != 1)
-            {
-                FIXME("Descriptor arrays are not supported.\n");
-                vkd3d_dxbc_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_INVALID_DESCRIPTOR_BINDING,
-                        "Descriptor binding for type %#x, space %u, register %u, "
-                        "shader type %#x has unsupported ‘count’ %u.",
-                        descriptor_type, range->space, range->first, compiler->shader_type, current->binding.count);
-            }
-
+            *binding_base_idx = current->register_index;
             return current->binding;
         }
         if (shader_interface->binding_count)
@@ -2566,6 +2561,7 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
     }
 
 done:
+    *binding_base_idx = range->first;
     binding.set = 0;
     binding.count = 1;
     binding.binding = compiler->binding_idx++;
@@ -2586,8 +2582,10 @@ static void vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(struct vkd3d_dxb
         enum vkd3d_shader_resource_type resource_type, bool is_uav_counter)
 {
     struct vkd3d_shader_descriptor_binding binding;
+    unsigned int binding_base_idx; /* Value not used. */
 
-    binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, range, resource_type, is_uav_counter);
+    binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, range,
+            resource_type, is_uav_counter, &binding_base_idx);
     vkd3d_dxbc_compiler_emit_descriptor_binding(compiler, variable_id, &binding);
 }
 
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 3892c1db..a84a8e28 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -34103,6 +34103,7 @@ static void test_resource_arrays(void)
                 get_cpu_descriptor_handle(&context, heap, ARRAY_SIZE(input_buffers) + i));
     }
 
+    todo
     context.pipeline_state = create_compute_pipeline_state(device, context.root_signature,
             shader_bytecode(cs_code, sizeof(cs_code)));
     if (!context.pipeline_state)
-- 
2.31.1




More information about the wine-devel mailing list