vkd3d: Implement register spaces.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-05-26 15:16:46 -05:00 committed by Alexandre Julliard
parent 87364057da
commit 4bf22c6c27

View File

@ -308,13 +308,6 @@ static bool vk_binding_from_d3d12_descriptor_range(struct VkDescriptorSetLayoutB
binding_desc->descriptorType binding_desc->descriptorType
= vk_descriptor_type_from_d3d12_range_type(descriptor_range->RangeType, is_buffer); = vk_descriptor_type_from_d3d12_range_type(descriptor_range->RangeType, is_buffer);
binding_desc->descriptorCount = 1; binding_desc->descriptorCount = 1;
if (descriptor_range->RegisterSpace)
{
FIXME("Unhandled register space %u.\n", descriptor_range->RegisterSpace);
return false;
}
binding_desc->stageFlags = stage_flags_from_visibility(shader_visibility); binding_desc->stageFlags = stage_flags_from_visibility(shader_visibility);
binding_desc->pImmutableSamplers = NULL; binding_desc->pImmutableSamplers = NULL;
@ -495,12 +488,6 @@ static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signat
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS) if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
continue; continue;
if (p->u.Constants.RegisterSpace)
{
FIXME("Unhandled register space %u for parameter %u.\n", p->u.Constants.RegisterSpace, i);
return E_NOTIMPL;
}
idx = push_constant_count == 1 ? 0 : p->ShaderVisibility; idx = push_constant_count == 1 ? 0 : p->ShaderVisibility;
offset = push_constants_offset[idx]; offset = push_constants_offset[idx];
push_constants_offset[idx] += p->u.Constants.Num32BitValues * sizeof(uint32_t); push_constants_offset[idx] += p->u.Constants.Num32BitValues * sizeof(uint32_t);
@ -510,7 +497,7 @@ static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signat
? push_constants[0].stageFlags : stage_flags_from_visibility(p->ShaderVisibility); ? push_constants[0].stageFlags : stage_flags_from_visibility(p->ShaderVisibility);
root_constant->offset = offset; root_constant->offset = offset;
root_signature->root_constants[j].register_space = 0; root_signature->root_constants[j].register_space = p->u.Constants.RegisterSpace;
root_signature->root_constants[j].register_index = p->u.Constants.ShaderRegister; root_signature->root_constants[j].register_index = p->u.Constants.ShaderRegister;
root_signature->root_constants[j].shader_visibility root_signature->root_constants[j].shader_visibility
= vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility); = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
@ -534,7 +521,7 @@ struct vkd3d_descriptor_set_context
}; };
static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *root_signature, static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *root_signature,
enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_idx, enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space, unsigned int register_idx,
bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility,
struct vkd3d_descriptor_set_context *context) struct vkd3d_descriptor_set_context *context)
{ {
@ -542,7 +529,7 @@ static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *
= &root_signature->descriptor_mapping[context->descriptor_index++]; = &root_signature->descriptor_mapping[context->descriptor_index++];
mapping->type = descriptor_type; mapping->type = descriptor_type;
mapping->register_space = 0; mapping->register_space = register_space;
mapping->register_index = register_idx; mapping->register_index = register_idx;
mapping->shader_visibility = shader_visibility; mapping->shader_visibility = shader_visibility;
mapping->flags = buffer_descriptor ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE; mapping->flags = buffer_descriptor ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
@ -551,7 +538,7 @@ static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *
} }
static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signature *root_signature, static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signature *root_signature,
enum vkd3d_shader_descriptor_type descriptor_type, unsigned int base_register_idx, enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space, unsigned int base_register_idx,
unsigned int binding_count, bool is_buffer_descriptor, bool duplicate_descriptors, unsigned int binding_count, bool is_buffer_descriptor, bool duplicate_descriptors,
enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context) enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
{ {
@ -567,10 +554,10 @@ static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signat
for (i = 0; i < binding_count; ++i) for (i = 0; i < binding_count; ++i)
{ {
if (duplicate_descriptors) if (duplicate_descriptors)
d3d12_root_signature_append_vk_binding(root_signature, descriptor_type, d3d12_root_signature_append_vk_binding(root_signature, descriptor_type, register_space,
base_register_idx + i, true, shader_visibility, context); base_register_idx + i, true, shader_visibility, context);
d3d12_root_signature_append_vk_binding(root_signature, descriptor_type, d3d12_root_signature_append_vk_binding(root_signature, descriptor_type, register_space,
base_register_idx + i, is_buffer_descriptor, shader_visibility, context); base_register_idx + i, is_buffer_descriptor, shader_visibility, context);
} }
return first_binding; return first_binding;
@ -627,7 +614,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
vk_binding = d3d12_root_signature_assign_vk_bindings(root_signature, vk_binding = d3d12_root_signature_assign_vk_bindings(root_signature,
vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType), vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType),
range->BaseShaderRegister, range->NumDescriptors, false, true, range->RegisterSpace, range->BaseShaderRegister, range->NumDescriptors, false, true,
vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context); vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context);
/* Unroll descriptor range. */ /* Unroll descriptor range. */
@ -685,15 +672,9 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
root_signature->push_descriptor_mask |= 1u << i; root_signature->push_descriptor_mask |= 1u << i;
if (p->u.Descriptor.RegisterSpace)
{
FIXME("Unhandled register space %u for parameter %u.\n", p->u.Descriptor.RegisterSpace, i);
return E_NOTIMPL;
}
cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature, cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature,
vkd3d_descriptor_type_from_d3d12_root_parameter_type(p->ParameterType), vkd3d_descriptor_type_from_d3d12_root_parameter_type(p->ParameterType),
p->u.Descriptor.ShaderRegister, 1, true, false, p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, 1, true, false,
vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context); vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context);
cur_binding->descriptorType = vk_descriptor_type_from_d3d12_root_parameter(p->ParameterType); cur_binding->descriptorType = vk_descriptor_type_from_d3d12_root_parameter(p->ParameterType);
cur_binding->descriptorCount = 1; cur_binding->descriptorCount = 1;
@ -723,14 +704,11 @@ static HRESULT d3d12_root_signature_init_static_samplers(struct d3d12_root_signa
{ {
const D3D12_STATIC_SAMPLER_DESC *s = &desc->pStaticSamplers[i]; const D3D12_STATIC_SAMPLER_DESC *s = &desc->pStaticSamplers[i];
if (s->RegisterSpace)
FIXME("Unhandled register space %u for static sampler %u.\n", s->RegisterSpace, i);
if (FAILED(hr = vkd3d_create_static_sampler(device, s, &root_signature->static_samplers[i]))) if (FAILED(hr = vkd3d_create_static_sampler(device, s, &root_signature->static_samplers[i])))
return hr; return hr;
cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature, cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature,
VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->ShaderRegister, 1, false, false, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->RegisterSpace, s->ShaderRegister, 1, false, false,
vkd3d_shader_visibility_from_d3d12(s->ShaderVisibility), context); vkd3d_shader_visibility_from_d3d12(s->ShaderVisibility), context);
cur_binding->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; cur_binding->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
cur_binding->descriptorCount = 1; cur_binding->descriptorCount = 1;