From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d_d3d12.idl | 1 + libs/vkd3d/device.c | 34 ++++++++++++++++++++++++++++------ libs/vkd3d/utils.c | 5 ----- libs/vkd3d/vkd3d_main.c | 6 ------ libs/vkd3d/vkd3d_private.h | 3 ++- 5 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/include/vkd3d_d3d12.idl b/include/vkd3d_d3d12.idl index a1f87b22e87e..53874141dd12 100644 --- a/include/vkd3d_d3d12.idl +++ b/include/vkd3d_d3d12.idl @@ -45,6 +45,7 @@ const UINT D3D12_DEFAULT_STENCIL_WRITE_MASK = 0xff; const UINT D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND = 0xffffffff; cpp_quote("#define D3D12_FLOAT32_MAX (3.402823466e+38f)") const UINT D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32; +const UINT D3D12_UAV_SLOT_COUNT = 64; const UINT D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; const UINT D3D12_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; const UINT D3D12_REQ_MIP_LEVELS = 15; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 193a36cb2ee3..fa59593bbdef 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -853,9 +853,11 @@ static void vkd3d_trace_physical_device_features(const VkPhysicalDeviceFeatures2 } }
-static void vkd3d_check_feature_level_11_requirements(const struct vkd3d_vulkan_info *vk_info, +static void vkd3d_init_feature_level(struct vkd3d_vulkan_info *vk_info, const VkPhysicalDeviceFeatures *features) { + bool have_11_0 = true; + #define CHECK_MIN_REQUIREMENT(name, value) \ if (vk_info->device_limits.name < value) \ WARN(#name " does not meet feature level 11_0 requirements.\n"); @@ -864,7 +866,10 @@ static void vkd3d_check_feature_level_11_requirements(const struct vkd3d_vulkan_ WARN(#name " does not meet feature level 11_0 requirements.\n"); #define CHECK_FEATURE(name) \ if (!features->name) \ - WARN(#name " is not supported.\n"); + { \ + WARN(#name " is not supported.\n"); \ + have_11_0 = false; \ + }
CHECK_MIN_REQUIREMENT(maxPushConstantsSize, D3D12_MAX_ROOT_COST * sizeof(uint32_t)); CHECK_MIN_REQUIREMENT(maxComputeSharedMemorySize, D3D12_CS_TGSM_REGISTER_COUNT * sizeof(uint32_t)); @@ -906,6 +911,17 @@ static void vkd3d_check_feature_level_11_requirements(const struct vkd3d_vulkan_ #undef CHECK_MIN_REQUIREMENT #undef CHECK_MAX_REQUIREMENT #undef CHECK_FEATURE + + vk_info->max_feature_level = D3D_FEATURE_LEVEL_11_0; + + if (have_11_0 + && features->logicOp + && features->vertexPipelineStoresAndAtomics + && vk_info->device_limits.maxPerStageDescriptorStorageBuffers >= D3D12_UAV_SLOT_COUNT + && vk_info->device_limits.maxPerStageDescriptorStorageImages >= D3D12_UAV_SLOT_COUNT) + vk_info->max_feature_level = D3D_FEATURE_LEVEL_11_1; + + TRACE("Max feature level: %#x.\n", vk_info->max_feature_level); }
static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, @@ -1030,12 +1046,17 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, vulkan_info->vertex_attrib_zero_divisor = false; }
- vkd3d_check_feature_level_11_requirements(vulkan_info, features); + vkd3d_free(vk_extensions); + + vkd3d_init_feature_level(vulkan_info, features); + if (vulkan_info->max_feature_level < create_info->minimum_feature_level) + { + WARN("Feature level %#x is not supported.\n", create_info->minimum_feature_level); + return E_INVALIDARG; + }
features->shaderTessellationAndGeometryPointSize = VK_FALSE;
- vkd3d_free(vk_extensions); - return S_OK; }
@@ -1874,6 +1895,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device *
case D3D12_FEATURE_FEATURE_LEVELS: { + struct vkd3d_vulkan_info *vulkan_info = &device->vk_info; D3D12_FEATURE_DATA_FEATURE_LEVELS *data = feature_data; unsigned int i;
@@ -1889,7 +1911,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device * for (i = 0; i < data->NumFeatureLevels; ++i) { D3D_FEATURE_LEVEL fl = data->pFeatureLevelsRequested[i]; - if (data->MaxSupportedFeatureLevel < fl && check_feature_level_support(fl)) + if (data->MaxSupportedFeatureLevel < fl && fl <= vulkan_info->max_feature_level) data->MaxSupportedFeatureLevel = fl; } return S_OK; diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 666319e46d90..1c10450d1ea9 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -245,11 +245,6 @@ bool is_valid_feature_level(D3D_FEATURE_LEVEL feature_level) return false; }
-bool check_feature_level_support(D3D_FEATURE_LEVEL feature_level) -{ - return feature_level <= D3D_FEATURE_LEVEL_11_0; -} - bool is_write_resource_state(D3D12_RESOURCE_STATES state) { return state & (D3D12_RESOURCE_STATE_RENDER_TARGET diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index c65a4abcac55..5e93a2a77407 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -55,12 +55,6 @@ HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info, return E_INVALIDARG; }
- if (!check_feature_level_support(create_info->minimum_feature_level)) - { - FIXME("Unsupported feature level %#x.\n", create_info->minimum_feature_level); - return E_INVALIDARG; - } - if ((instance = create_info->instance)) { vkd3d_instance_incref(instance); diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index fa2c4609600c..3292e31bae5a 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -100,6 +100,8 @@ struct vkd3d_vulkan_info
VkPhysicalDeviceLimits device_limits; VkPhysicalDeviceSparseProperties sparse_properties; + + D3D_FEATURE_LEVEL max_feature_level; };
struct vkd3d_instance @@ -994,7 +996,6 @@ VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *d VkSampleCountFlagBits vk_samples_from_sample_count(unsigned int sample_count) DECLSPEC_HIDDEN;
bool is_valid_feature_level(D3D_FEATURE_LEVEL feature_level) DECLSPEC_HIDDEN; -bool check_feature_level_support(D3D_FEATURE_LEVEL feature_level) DECLSPEC_HIDDEN;
bool is_valid_resource_state(D3D12_RESOURCE_STATES state) DECLSPEC_HIDDEN; bool is_write_resource_state(D3D12_RESOURCE_STATES state) DECLSPEC_HIDDEN;