We will need this for shader model 5.1 resource arrays. However, for the time being any count other than '1' is unsupported.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- include/vkd3d_shader.h | 1 + libs/vkd3d-shader/spirv.c | 47 ++++++++++++++++++++++++++++---- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + libs/vkd3d/state.c | 3 ++ 4 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index f437b24..1f2a9c2 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -100,6 +100,7 @@ struct vkd3d_shader_descriptor_binding { unsigned int set; unsigned int binding; + unsigned int count; /* This must be 1 in this version of vkd3d-shader. */ };
enum vkd3d_shader_binding_flag diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 70bcf95..ea696a2 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2424,11 +2424,26 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->shader_visibility)) continue;
+ if (current->register_space != register_space || current->register_index != reg_idx) + continue; + if (current->offset) + { FIXME("Atomic counter offsets are not supported yet.\n"); + vkd3d_dxbc_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_INVALID_DESCRIPTOR_BINDING, + "Descriptor binding for UAV counter %u, space %u has unsupported ‘offset’ %u.", + reg_idx, register_space, current->offset); + }
- if (current->register_space == register_space && current->register_index == reg_idx) - return current->binding; + 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 UAV counter %u, space %u has unsupported ‘count’ %u.", + reg_idx, register_space, current->binding.count); + } + + return current->binding; } if (shader_interface->uav_counter_count) { @@ -2449,9 +2464,20 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->shader_visibility)) continue;
- if (current->type == descriptor_type && current->register_space == register_space - && current->register_index == reg_idx) - return current->binding; + if (current->type != descriptor_type || current->register_space != register_space + || current->register_index != reg_idx) + 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, register_space, reg_idx, compiler->shader_type, current->binding.count); + } + + return current->binding; } if (shader_interface->binding_count) { @@ -2465,6 +2491,7 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
done: binding.set = 0; + binding.count = 1; binding.binding = compiler->binding_idx++; return binding; } @@ -5327,6 +5354,16 @@ static void vkd3d_dxbc_compiler_emit_combined_sampler_declarations(struct vkd3d_ if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->shader_visibility)) 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, + "Combined descriptor binding for resource %u, space %u, " + "and sampler %u, space %u has unsupported ‘count’ %u.", + resource_index, resource_space, current->sampler_index, + current->sampler_space, current->binding.count); + } + d = vkd3d_dxbc_compiler_get_descriptor_info(compiler, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, current->sampler_space, current->sampler_index); depth = current->sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 51e1dd6..77b07e4 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -72,6 +72,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND = 2000, VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_TYPE = 2001, + VKD3D_SHADER_ERROR_SPV_INVALID_DESCRIPTOR_BINDING = 2002,
VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY = 3000, VKD3D_SHADER_ERROR_RS_INVALID_VERSION = 3001, diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index a64d17f..81f3343 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -535,6 +535,7 @@ static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature * mapping->flags = buffer_descriptor ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE; mapping->binding.set = context->set_index; mapping->binding.binding = context->descriptor_binding++; + mapping->binding.count = 1; }
static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signature *root_signature, @@ -1478,6 +1479,7 @@ static HRESULT d3d12_pipeline_state_init_compute_uav_counters(struct d3d12_pipel state->uav_counters[j].shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE; state->uav_counters[j].binding.set = context.set_index; state->uav_counters[j].binding.binding = context.descriptor_binding; + state->uav_counters[j].binding.count = 1;
/* FIXME: For the graphics pipeline we have to take the shader * visibility into account. */ @@ -2954,6 +2956,7 @@ HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d binding.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE; binding.binding.set = 0; binding.binding.binding = 0; + binding.binding.count = 1;
push_constant_range.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; push_constant_range.offset = 0;