Conor McCarthy : vkd3d: Send typed UAV unknown format read support info to vkd3d-shader.

Alexandre Julliard julliard at winehq.org
Tue Aug 9 15:17:46 CDT 2022


Module: vkd3d
Branch: master
Commit: 4afe69d04afdb9c76422c69791e5520fc02fd8fb
URL:    https://gitlab.winehq.org/wine/vkd3d/-/commit/4afe69d04afdb9c76422c69791e5520fc02fd8fb

Author: Conor McCarthy <cmccarthy at codeweavers.com>
Date:   Mon Aug  8 23:49:17 2022 +1000

vkd3d: Send typed UAV unknown format read support info to vkd3d-shader.

Fixes reflections in Control appearing with only their red component.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52146
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>

---

 libs/vkd3d/device.c        |  1 +
 libs/vkd3d/state.c         | 17 +++++++++++++----
 libs/vkd3d/vkd3d_private.h |  2 ++
 tests/d3d12.c              | 18 +++++++++++++++++-
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index ec6bb57c..1c29bdc1 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -1464,6 +1464,7 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device,
     vulkan_info->sparse_properties = physical_device_info->properties2.properties.sparseProperties;
     vulkan_info->rasterization_stream = physical_device_info->xfb_properties.transformFeedbackRasterizationStreamSelect;
     vulkan_info->transform_feedback_queries = physical_device_info->xfb_properties.transformFeedbackQueries;
+    vulkan_info->uav_read_without_format = features->shaderStorageImageReadWithoutFormat;
     vulkan_info->max_vertex_attrib_divisor = max(physical_device_info->vertex_divisor_properties.maxVertexAttribDivisor, 1);
 
     device->feature_options.DoublePrecisionFloatShaderOps = features->shaderFloat64;
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 7a29ade8..895a5a2e 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -1944,6 +1944,13 @@ struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12Pipeline
     return impl_from_ID3D12PipelineState(iface);
 }
 
+static inline unsigned int typed_uav_compile_option(const struct d3d12_device *device)
+{
+    return device->vk_info.uav_read_without_format
+            ? VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_UNKNOWN
+            : VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_R32;
+}
+
 static HRESULT create_shader_stage(struct d3d12_device *device,
         struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage,
         const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface)
@@ -1955,9 +1962,10 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
     VkResult vr;
     int ret;
 
-    static const struct vkd3d_shader_compile_option options[] =
+    const struct vkd3d_shader_compile_option options[] =
     {
         {VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_4},
+        {VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
     };
 
     stage_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -2001,14 +2009,15 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
     return S_OK;
 }
 
-static int vkd3d_scan_dxbc(const D3D12_SHADER_BYTECODE *code,
+static int vkd3d_scan_dxbc(const struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code,
         struct vkd3d_shader_scan_descriptor_info *descriptor_info)
 {
     struct vkd3d_shader_compile_info compile_info;
 
-    static const struct vkd3d_shader_compile_option options[] =
+    const struct vkd3d_shader_compile_option options[] =
     {
         {VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_4},
+        {VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
     };
 
     compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
@@ -2170,7 +2179,7 @@ static HRESULT d3d12_pipeline_state_find_and_init_uav_counters(struct d3d12_pipe
 
     shader_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO;
     shader_info.next = NULL;
-    if ((ret = vkd3d_scan_dxbc(code, &shader_info)) < 0)
+    if ((ret = vkd3d_scan_dxbc(device, code, &shader_info)) < 0)
     {
         WARN("Failed to scan shader bytecode, stage %#x, vkd3d result %d.\n", stage_flags, ret);
         return hresult_from_vkd3d_result(ret);
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index d2ab8857..8bbb4838 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -143,6 +143,8 @@ struct vkd3d_vulkan_info
     bool rasterization_stream;
     bool transform_feedback_queries;
 
+    bool uav_read_without_format;
+
     bool vertex_attrib_zero_divisor;
     unsigned int max_vertex_attrib_divisor;
 
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 7a0e33a4..9fc199bc 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -590,6 +590,21 @@ static bool is_stencil_ref_export_supported(ID3D12Device *device)
     return options.PSSpecifiedStencilRefSupported;
 }
 
+static bool are_typed_uav_load_additional_formats_supported(ID3D12Device *device)
+{
+    D3D12_FEATURE_DATA_D3D12_OPTIONS options;
+    HRESULT hr;
+
+    if (FAILED(hr = ID3D12Device_CheckFeatureSupport(device,
+            D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options))))
+    {
+        trace("Failed to check feature support, hr %#x.\n", hr);
+        return false;
+    }
+
+    return options.TypedUAVLoadAdditionalFormats;
+}
+
 #define create_cb_root_signature(a, b, c, e) create_cb_root_signature_(__LINE__, a, b, c, e)
 static ID3D12RootSignature *create_cb_root_signature_(unsigned int line,
         ID3D12Device *device, unsigned int reg_idx, D3D12_SHADER_VISIBILITY shader_visibility,
@@ -21094,7 +21109,8 @@ static void test_typed_buffer_uav(void)
             D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
 
     get_buffer_readback_with_command_list(resource, uav_desc.Format, &rb, queue, command_list);
-    todo check_readback_data_vec4(&rb.rb, NULL, &expected_ld, 0);
+    todo_if(!are_typed_uav_load_additional_formats_supported(device))
+    check_readback_data_vec4(&rb.rb, NULL, &expected_ld, 0);
     release_resource_readback(&rb);
 
     ID3D12Resource_Release(resource);




More information about the wine-cvs mailing list