From eb8eba02bdd78bf170a986266b70c6599bb6604c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 19 Sep 2017 17:29:20 +0200 Subject: [PATCH] libs/vkd3d: Implement d3d12_command_list_SetComputeRootShaderResourceView(). --- libs/vkd3d/command.c | 28 +++++++++++++++++++++------- libs/vkd3d/resource.c | 2 +- libs/vkd3d/vkd3d_private.h | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index a9e1454f..da155300 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2916,7 +2916,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootConstantBufferVi d3d12_command_list_set_root_cbv(list, VK_PIPELINE_BIND_POINT_GRAPHICS, root_parameter_index, address); } -static void d3d12_command_list_set_root_uav(struct d3d12_command_list *list, +static void d3d12_command_list_set_root_descriptor(struct d3d12_command_list *list, VkPipelineBindPoint bind_point, unsigned int index, D3D12_GPU_VIRTUAL_ADDRESS gpu_address) { struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point]; @@ -2926,13 +2926,20 @@ static void d3d12_command_list_set_root_uav(struct d3d12_command_list *list, const struct d3d12_root_descriptor *root_descriptor; struct VkWriteDescriptorSet descriptor_write; VkDevice vk_device = list->device->vk_device; + VkDescriptorType descriptor_type; VkBufferView vk_buffer_view; - assert(root_signature->parameters[index].parameter_type == D3D12_ROOT_PARAMETER_TYPE_UAV); + assert(root_signature->parameters[index].parameter_type == D3D12_ROOT_PARAMETER_TYPE_SRV + || root_signature->parameters[index].parameter_type == D3D12_ROOT_PARAMETER_TYPE_UAV); root_descriptor = &root_signature->parameters[index].u.descriptor; + if (root_signature->parameters[index].parameter_type == D3D12_ROOT_PARAMETER_TYPE_SRV) + descriptor_type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; + else + descriptor_type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + /* FIXME: Re-use buffer views. */ - if (!vkd3d_create_raw_buffer_uav(list->device, gpu_address, &vk_buffer_view)) + if (!vkd3d_create_raw_buffer_view(list->device, gpu_address, &vk_buffer_view)) { ERR("Failed to create buffer view.\n"); return; @@ -2954,7 +2961,7 @@ static void d3d12_command_list_set_root_uav(struct d3d12_command_list *list, descriptor_write.dstBinding = root_descriptor->binding; descriptor_write.dstArrayElement = 0; descriptor_write.descriptorCount = 1; - descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + descriptor_write.descriptorType = descriptor_type; descriptor_write.pImageInfo = NULL; descriptor_write.pBufferInfo = NULL; descriptor_write.pTexelBufferView = &vk_buffer_view; @@ -2973,8 +2980,13 @@ static void d3d12_command_list_set_root_uav(struct d3d12_command_list *list, static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootShaderResourceView( ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { - FIXME("iface %p, root_parameter_index %u, address %#"PRIx64" stub!\n", + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface); + + TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n", iface, root_parameter_index, address); + + d3d12_command_list_set_root_descriptor(list, VK_PIPELINE_BIND_POINT_COMPUTE, + root_parameter_index, address); } static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootShaderResourceView( @@ -2992,7 +3004,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootUnorderedAccessVi TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n", iface, root_parameter_index, address); - d3d12_command_list_set_root_uav(list, VK_PIPELINE_BIND_POINT_COMPUTE, root_parameter_index, address); + d3d12_command_list_set_root_descriptor(list, VK_PIPELINE_BIND_POINT_COMPUTE, + root_parameter_index, address); } static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootUnorderedAccessView( @@ -3003,7 +3016,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootUnorderedAccessV TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n", iface, root_parameter_index, address); - d3d12_command_list_set_root_uav(list, VK_PIPELINE_BIND_POINT_GRAPHICS, root_parameter_index, address); + d3d12_command_list_set_root_descriptor(list, VK_PIPELINE_BIND_POINT_GRAPHICS, + root_parameter_index, address); } static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(ID3D12GraphicsCommandList *iface, diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index e2c1ac31..b419e5bb 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -1230,7 +1230,7 @@ void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *d } } -bool vkd3d_create_raw_buffer_uav(struct d3d12_device *device, +bool vkd3d_create_raw_buffer_view(struct d3d12_device *device, D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view) { const struct vkd3d_format *format; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index d31bd8b5..b8cd2f5b 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -224,7 +224,7 @@ void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *d void d3d12_desc_create_sampler(struct d3d12_desc *sampler, struct d3d12_device *device, const D3D12_SAMPLER_DESC *desc) DECLSPEC_HIDDEN; -bool vkd3d_create_raw_buffer_uav(struct d3d12_device *device, +bool vkd3d_create_raw_buffer_view(struct d3d12_device *device, D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view) DECLSPEC_HIDDEN; HRESULT vkd3d_create_static_sampler(struct d3d12_device *device, const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler) DECLSPEC_HIDDEN;