From 3a586c9ffcd37cb43176c553446d76b5cb305f4d Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Mon, 25 May 2020 20:07:08 +0430 Subject: [PATCH] vkd3d: Implement support for D3D12_FEATURE_D3D12_OPTIONS4. Signed-off-by: Conor McCarthy Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/vkd3d_d3d12.idl | 14 +++++++++++ libs/vkd3d/device.c | 51 ++++++++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 1 + 3 files changed, 66 insertions(+) diff --git a/include/vkd3d_d3d12.idl b/include/vkd3d_d3d12.idl index a8aaf95c..e7e05fe0 100644 --- a/include/vkd3d_d3d12.idl +++ b/include/vkd3d_d3d12.idl @@ -220,6 +220,12 @@ typedef enum D3D12_VIEW_INSTANCING_TIER D3D12_VIEW_INSTANCING_TIER_3 = 0x3, } D3D12_VIEW_INSTANCING_TIER; +typedef enum D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER +{ + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0 = 0x0, + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_1 = 0x1, +} D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER; + interface ID3D12Fence; interface ID3D12RootSignature; interface ID3D12Heap; @@ -1702,6 +1708,13 @@ typedef struct D3D12_FEATURE_DATA_EXISTING_HEAPS BOOL Supported; } D3D12_FEATURE_DATA_EXISTING_HEAPS; +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4 +{ + BOOL MSAA64KBAlignedTextureSupported; + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; + BOOL Native16BitShaderOpsSupported; +} D3D12_FEATURE_DATA_D3D12_OPTIONS4; + typedef enum D3D12_FEATURE { D3D12_FEATURE_D3D12_OPTIONS = 0, @@ -1720,6 +1733,7 @@ typedef enum D3D12_FEATURE D3D12_FEATURE_COMMAND_QUEUE_PRIORITY = 20, D3D12_FEATURE_D3D12_OPTIONS3 = 21, D3D12_FEATURE_EXISTING_HEAPS = 22, + D3D12_FEATURE_D3D12_OPTIONS4 = 23, } D3D12_FEATURE; typedef struct D3D12_MEMCPY_DEST diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index c0f1b39b..878ca747 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1356,6 +1356,12 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, device->feature_options3.ViewInstancingTier = D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED; device->feature_options3.BarycentricsSupported = FALSE; + device->feature_options4.MSAA64KBAlignedTextureSupported = FALSE; + device->feature_options4.SharedResourceCompatibilityTier = D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0; + /* An SM 6.2 feature. This would require features->shaderInt16 and + * VK_KHR_shader_float16_int8. */ + device->feature_options4.Native16BitShaderOpsSupported = FALSE; + if ((vr = VK_CALL(vkEnumerateDeviceExtensionProperties(physical_device, NULL, &count, NULL))) < 0) { ERR("Failed to enumerate device extensions, vr %d.\n", vr); @@ -1704,6 +1710,31 @@ static HRESULT vkd3d_select_queues(const struct vkd3d_instance *vkd3d_instance, return S_OK; } +/* The 4 MiB alignment requirement for MSAA resources was lowered to 64KB on + * hardware that supports it. This is distinct from the small MSAA requirement + * which applies to resources of a total size of 4 MiB or less. */ +static bool d3d12_is_64k_msaa_supported(struct d3d12_device *device) +{ + D3D12_RESOURCE_ALLOCATION_INFO info; + D3D12_RESOURCE_DESC resource_desc; + + memset(&resource_desc, 0, sizeof(resource_desc)); + resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + resource_desc.Width = 1024; + resource_desc.Height = 1025; + resource_desc.DepthOrArraySize = 1; + resource_desc.MipLevels = 1; + resource_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + resource_desc.SampleDesc.Count = 4; + resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + + /* FIXME: in some cases Vulkan requires 0x20000 or more for non-MSAA + * resources, which must have 0x10000 in their description, so we might + * reasonably return true here for 0x20000 or 0x40000. */ + return SUCCEEDED(vkd3d_get_image_allocation_info(device, &resource_desc, &info)) + && info.Alignment <= 0x10000; +} + static HRESULT vkd3d_create_vk_device(struct d3d12_device *device, const struct vkd3d_device_create_info *create_info) { @@ -1801,6 +1832,8 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device, return hr; } + device->feature_options4.MSAA64KBAlignedTextureSupported = d3d12_is_64k_msaa_supported(device); + TRACE("Created Vulkan device %p.\n", vk_device); return hr; @@ -2858,6 +2891,24 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device * return S_OK; } + case D3D12_FEATURE_D3D12_OPTIONS4: + { + D3D12_FEATURE_DATA_D3D12_OPTIONS4 *data = feature_data; + + if (feature_data_size != sizeof(*data)) + { + WARN("Invalid size %u.\n", feature_data_size); + return E_INVALIDARG; + } + + *data = device->feature_options4; + + TRACE("64 KiB aligned MSAA textures %#x.\n", data->MSAA64KBAlignedTextureSupported); + TRACE("Shared resource compatibility tier %#x.\n", data->SharedResourceCompatibilityTier); + TRACE("Native 16-bit shader ops %#x.\n", data->Native16BitShaderOpsSupported); + return S_OK; + } + default: FIXME("Unhandled feature %#x.\n", feature); return E_NOTIMPL; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 20134a8d..da3e3fe4 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1134,6 +1134,7 @@ struct d3d12_device D3D12_FEATURE_DATA_D3D12_OPTIONS1 feature_options1; D3D12_FEATURE_DATA_D3D12_OPTIONS2 feature_options2; D3D12_FEATURE_DATA_D3D12_OPTIONS3 feature_options3; + D3D12_FEATURE_DATA_D3D12_OPTIONS4 feature_options4; struct vkd3d_vulkan_info vk_info;