vkd3d: Support null address for SRV/UAV root descriptors.

This commit is contained in:
Conor McCarthy 2023-04-17 13:00:36 +10:00 committed by Alexandre Julliard
parent 963e5e26dc
commit 0526f232cd
Notes: Alexandre Julliard 2023-04-19 22:11:46 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/163
3 changed files with 18 additions and 4 deletions

View File

@ -4556,13 +4556,13 @@ static void d3d12_command_list_set_root_descriptor(struct d3d12_command_list *li
assert(root_parameter->parameter_type != D3D12_ROOT_PARAMETER_TYPE_CBV);
/* FIXME: Re-use buffer views. */
if (!vkd3d_create_raw_buffer_view(list->device, gpu_address, &vk_buffer_view))
if (!vkd3d_create_raw_buffer_view(list->device, gpu_address, root_parameter->parameter_type, &vk_buffer_view))
{
ERR("Failed to create buffer view.\n");
return;
}
if (!(d3d12_command_allocator_add_buffer_view(list->allocator, vk_buffer_view)))
if (vk_buffer_view && !(d3d12_command_allocator_add_buffer_view(list->allocator, vk_buffer_view)))
{
ERR("Failed to add buffer view.\n");
VK_CALL(vkDestroyBufferView(vk_device, vk_buffer_view, NULL));

View File

@ -3282,12 +3282,26 @@ void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *d
}
bool vkd3d_create_raw_buffer_view(struct d3d12_device *device,
D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view)
D3D12_GPU_VIRTUAL_ADDRESS gpu_address, D3D12_ROOT_PARAMETER_TYPE parameter_type, VkBufferView *vk_buffer_view)
{
const struct vkd3d_format *format;
struct d3d12_resource *resource;
format = vkd3d_get_format(device, DXGI_FORMAT_R32_UINT, false);
if (!gpu_address)
{
if (device->vk_info.EXT_robustness2)
{
*vk_buffer_view = VK_NULL_HANDLE;
return true;
}
WARN("Creating null buffer view.\n");
return vkd3d_create_vk_buffer_view(device, parameter_type == D3D12_ROOT_PARAMETER_TYPE_UAV
? device->null_resources.vk_storage_buffer : device->null_resources.vk_buffer,
format, 0, VK_WHOLE_SIZE, vk_buffer_view);
}
resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, gpu_address);
assert(d3d12_resource_is_buffer(resource));
return vkd3d_create_vk_buffer_view(device, resource->u.vk_buffer, format,

View File

@ -762,7 +762,7 @@ void d3d12_desc_create_sampler(struct d3d12_desc *sampler, struct d3d12_device *
void d3d12_desc_write_atomic(struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_device *device);
bool vkd3d_create_raw_buffer_view(struct d3d12_device *device,
D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view);
D3D12_GPU_VIRTUAL_ADDRESS gpu_address, D3D12_ROOT_PARAMETER_TYPE parameter_type, VkBufferView *vk_buffer_view);
HRESULT vkd3d_create_static_sampler(struct d3d12_device *device,
const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler);