vkd3d: Enable raw SSBOs for root descriptors on supported hardware.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
parent
4841630876
commit
544a6184e9
|
@ -5214,23 +5214,29 @@ static void d3d12_command_list_set_root_descriptor(struct d3d12_command_list *li
|
|||
struct vkd3d_root_descriptor_info *descriptor;
|
||||
struct d3d12_resource *resource;
|
||||
VkBufferView vk_buffer_view;
|
||||
bool null_descriptors;
|
||||
bool null_descriptors, ssbo;
|
||||
VkDeviceSize max_range;
|
||||
|
||||
ssbo = d3d12_device_use_ssbo_root_descriptors(list->device);
|
||||
root_parameter = root_signature_get_root_descriptor(root_signature, index);
|
||||
descriptor = &bindings->root_descriptors[root_parameter->descriptor.packed_descriptor];
|
||||
null_descriptors = list->device->device_info.robustness2_features.nullDescriptor;
|
||||
|
||||
if (root_parameter->parameter_type == D3D12_ROOT_PARAMETER_TYPE_CBV)
|
||||
if (ssbo || root_parameter->parameter_type == D3D12_ROOT_PARAMETER_TYPE_CBV)
|
||||
{
|
||||
descriptor->vk_descriptor_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
descriptor->vk_descriptor_type = root_parameter->parameter_type == D3D12_ROOT_PARAMETER_TYPE_CBV
|
||||
? VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
|
||||
if (gpu_address)
|
||||
{
|
||||
max_range = descriptor->vk_descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
|
||||
? vk_info->device_limits.maxUniformBufferRange
|
||||
: vk_info->device_limits.maxStorageBufferRange;
|
||||
|
||||
resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, gpu_address);
|
||||
descriptor->info.buffer.buffer = resource->vk_buffer;
|
||||
descriptor->info.buffer.offset = gpu_address - resource->gpu_address;
|
||||
descriptor->info.buffer.range = min(resource->desc.Width - descriptor->info.buffer.offset,
|
||||
vk_info->device_limits.maxUniformBufferRange);
|
||||
descriptor->info.buffer.range = min(resource->desc.Width - descriptor->info.buffer.offset, max_range);
|
||||
}
|
||||
else if (null_descriptors)
|
||||
{
|
||||
|
|
|
@ -211,15 +211,17 @@ static enum vkd3d_shader_visibility vkd3d_shader_visibility_from_d3d12(D3D12_SHA
|
|||
}
|
||||
}
|
||||
|
||||
static VkDescriptorType vk_descriptor_type_from_d3d12_root_parameter(D3D12_ROOT_PARAMETER_TYPE type)
|
||||
static VkDescriptorType vk_descriptor_type_from_d3d12_root_parameter(struct d3d12_device *device, D3D12_ROOT_PARAMETER_TYPE type)
|
||||
{
|
||||
bool use_ssbo = d3d12_device_use_ssbo_root_descriptors(device);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
/* SRV and UAV root parameters are buffer views. */
|
||||
case D3D12_ROOT_PARAMETER_TYPE_SRV:
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
return use_ssbo ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER : VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
case D3D12_ROOT_PARAMETER_TYPE_UAV:
|
||||
return VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
|
||||
return use_ssbo ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER : VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
|
||||
case D3D12_ROOT_PARAMETER_TYPE_CBV:
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
default:
|
||||
|
@ -635,7 +637,7 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
|
|||
|
||||
vk_binding = &vk_binding_info[j++];
|
||||
vk_binding->binding = context->vk_binding;
|
||||
vk_binding->descriptorType = vk_descriptor_type_from_d3d12_root_parameter(p->ParameterType);
|
||||
vk_binding->descriptorType = vk_descriptor_type_from_d3d12_root_parameter(root_signature->device, p->ParameterType);
|
||||
vk_binding->descriptorCount = 1;
|
||||
vk_binding->stageFlags = stage_flags_from_visibility(p->ShaderVisibility);
|
||||
vk_binding->pImmutableSamplers = NULL;
|
||||
|
@ -652,6 +654,9 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
|
|||
binding->binding.binding = context->vk_binding;
|
||||
binding->binding.set = context->vk_set;
|
||||
|
||||
if (vk_binding->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
binding->flags |= VKD3D_SHADER_BINDING_FLAG_RAW_SSBO;
|
||||
|
||||
param = &root_signature->parameters[i];
|
||||
param->parameter_type = p->ParameterType;
|
||||
param->descriptor.binding = binding;
|
||||
|
|
|
@ -1974,6 +1974,13 @@ static inline VkDeviceSize d3d12_device_get_ssbo_alignment(struct d3d12_device *
|
|||
: ~0ull;
|
||||
}
|
||||
|
||||
static inline bool d3d12_device_use_ssbo_root_descriptors(struct d3d12_device *device)
|
||||
{
|
||||
/* We only know the VA of root SRV/UAVs, so we cannot
|
||||
* make any better assumptions about the alignment */
|
||||
return d3d12_device_get_ssbo_alignment(device) <= 4;
|
||||
}
|
||||
|
||||
/* ID3DBlob */
|
||||
struct d3d_blob
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue