diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 09:48:06 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 09:48:06 -0500 |
| commit | bf0ce0d062acede44535e62d48187cedf4b0c2b3 (patch) | |
| tree | dc0a3cdcf828a42a0b6465d6b103b95202983f5d /runtime | |
| parent | c034e448c37d8522978af94f3cb01ec3e903fcfc (diff) | |
| parent | eebf85b60f021ce567427ce766f4ec1c88b0f13a (diff) | |
Merge pull request #1706 from Ash Hopkins
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/shims/d3d12_vulkan_device.cpp | 61 | ||||
| -rw-r--r-- | runtime/src/vulkan13_features.h | 127 | ||||
| -rw-r--r-- | runtime/src/vulkan_backend.h | 6 | ||||
| -rw-r--r-- | runtime/test/vk_test_device.h | 66 |
4 files changed, 200 insertions, 60 deletions
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index a8a14a316..971b51303 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp | |||
| @@ -21,10 +21,10 @@ | |||
| 21 | #include "../src/shader_library.h" | 21 | #include "../src/shader_library.h" |
| 22 | #include "../src/vulkan_present.h" | 22 | #include "../src/vulkan_present.h" |
| 23 | #include "../src/vulkan_device_filter.h" | 23 | #include "../src/vulkan_device_filter.h" |
| 24 | #include "../src/vulkan13_features.h" | ||
| 24 | 25 | ||
| 25 | #include <vulkan/vulkan_win32.h> | 26 | #include <vulkan/vulkan_win32.h> |
| 26 | 27 | ||
| 27 | |||
| 28 | #include <algorithm> | 28 | #include <algorithm> |
| 29 | #include <atomic> | 29 | #include <atomic> |
| 30 | #include <cctype> | 30 | #include <cctype> |
| @@ -5775,7 +5775,8 @@ HRESULT create_dxgi_factory(ID3D12Device* device, REFIID riid, void** out) { | |||
| 5775 | i.queue_family, riid, out); | 5775 | i.queue_family, riid, out); |
| 5776 | } | 5776 | } |
| 5777 | 5777 | ||
| 5778 | // Creates its own Vulkan 1.3 instance and device. LEONIDA_VK_VALIDATION=1 adds VK_LAYER_KHRONOS_validation. | 5778 | // Creates its own Vulkan instance and a Vulkan 1.3 device, or a 1.2 device with VK_KHR_dynamic_rendering and |
| 5779 | // VK_KHR_synchronization2 (vulkan13_features.h). LEONIDA_VK_VALIDATION=1 adds VK_LAYER_KHRONOS_validation. | ||
| 5779 | HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | 5780 | HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { |
| 5780 | if (!out) return E_POINTER; | 5781 | if (!out) return E_POINTER; |
| 5781 | *out = nullptr; | 5782 | *out = nullptr; |
| @@ -5888,22 +5889,21 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 5888 | bool chosen_bc = false; | 5889 | bool chosen_bc = false; |
| 5889 | VkPhysicalDeviceFeatures chosen_features{}; | 5890 | VkPhysicalDeviceFeatures chosen_features{}; |
| 5890 | VkPhysicalDeviceVulkan12Features chosen12{}; | 5891 | VkPhysicalDeviceVulkan12Features chosen12{}; |
| 5891 | VkPhysicalDeviceVulkan13Features chosen13{}; | ||
| 5892 | bool chosen_draw_params = false; | 5892 | bool chosen_draw_params = false; |
| 5893 | leonida::Vulkan13Features v13, candidate13; | ||
| 5893 | for (VkPhysicalDevice candidate : physicals) { | 5894 | for (VkPhysicalDevice candidate : physicals) { |
| 5894 | VkPhysicalDeviceProperties props{}; | 5895 | VkPhysicalDeviceProperties props{}; |
| 5895 | vkGetPhysicalDeviceProperties(candidate, &props); | 5896 | vkGetPhysicalDeviceProperties(candidate, &props); |
| 5896 | if (props.apiVersion < VK_API_VERSION_1_3 || !leonida::vulkan_device_wanted(props.deviceName)) continue; | 5897 | if (!leonida::vulkan_device_wanted(props.deviceName)) continue; |
| 5897 | VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | 5898 | candidate13.query(candidate, props.apiVersion, vkGetPhysicalDeviceFeatures2, vkEnumerateDeviceExtensionProperties); |
| 5898 | VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &f13}; | 5899 | if (!candidate13.usable()) continue; |
| 5900 | VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES}; | ||
| 5899 | VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &f11}; | 5901 | VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &f11}; |
| 5900 | VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f12}; | 5902 | VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f12}; |
| 5901 | vkGetPhysicalDeviceFeatures2(candidate, &features); | 5903 | vkGetPhysicalDeviceFeatures2(candidate, &features); |
| 5902 | const bool bc = features.features.textureCompressionBC; | 5904 | const bool bc = features.features.textureCompressionBC; |
| 5903 | const bool draw_params = f11.shaderDrawParameters; | 5905 | const bool draw_params = f11.shaderDrawParameters; |
| 5904 | if (!f13.dynamicRendering || !f13.synchronization2 || !f12.timelineSemaphore || | 5906 | if (!f12.timelineSemaphore || !f12.separateDepthStencilLayouts || !f12.bufferDeviceAddress) continue; |
| 5905 | !f12.separateDepthStencilLayouts || !f12.bufferDeviceAddress) | ||
| 5906 | continue; | ||
| 5907 | std::uint32_t family_count = 0; | 5907 | std::uint32_t family_count = 0; |
| 5908 | vkGetPhysicalDeviceQueueFamilyProperties(candidate, &family_count, nullptr); | 5908 | vkGetPhysicalDeviceQueueFamilyProperties(candidate, &family_count, nullptr); |
| 5909 | std::vector<VkQueueFamilyProperties> families(family_count); | 5909 | std::vector<VkQueueFamilyProperties> families(family_count); |
| @@ -5917,18 +5917,22 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 5917 | chosen_bc = bc; | 5917 | chosen_bc = bc; |
| 5918 | chosen_features = features.features; | 5918 | chosen_features = features.features; |
| 5919 | chosen12 = f12; | 5919 | chosen12 = f12; |
| 5920 | chosen13 = f13; | ||
| 5921 | chosen_draw_params = draw_params; | 5920 | chosen_draw_params = draw_params; |
| 5921 | v13.choose(candidate13); | ||
| 5922 | } | 5922 | } |
| 5923 | break; | 5923 | break; |
| 5924 | } | 5924 | } |
| 5925 | } | 5925 | } |
| 5926 | if (!info.physical) | 5926 | if (!info.physical) |
| 5927 | return fail(leonida::vulkan_device_filter().empty() | 5927 | return fail(leonida::vulkan_device_filter().empty() |
| 5928 | ? "no Vulkan 1.3 GPU with dynamicRendering, synchronization2, timelineSemaphore and " | 5928 | ? "no Vulkan 1.3 GPU (or 1.2 with VK_KHR_dynamic_rendering and VK_KHR_synchronization2) with " |
| 5929 | "separateDepthStencilLayouts" | 5929 | "dynamicRendering, synchronization2, timelineSemaphore and separateDepthStencilLayouts" |
| 5930 | : "no GPU named by LEONIDA_VK_DEVICE has Vulkan 1.3 with dynamicRendering, synchronization2, " | 5930 | : "no GPU named by LEONIDA_VK_DEVICE has Vulkan 1.3 (or 1.2 with VK_KHR_dynamic_rendering and " |
| 5931 | "timelineSemaphore and separateDepthStencilLayouts"); | 5931 | "VK_KHR_synchronization2) with dynamicRendering, synchronization2, timelineSemaphore and " |
| 5932 | "separateDepthStencilLayouts"); | ||
| 5933 | if (!v13.core) | ||
| 5934 | std::fprintf(stderr, "[rt] d3d12: Vulkan 1.2 device: dynamicRendering and synchronization2 through their KHR " | ||
| 5935 | "extensions\n"); | ||
| 5932 | 5936 | ||
| 5933 | // VK_EXT_conditional_rendering for SetPredication, VK_KHR_swapchain for DXGI presentation, and optional | 5937 | // VK_EXT_conditional_rendering for SetPredication, VK_KHR_swapchain for DXGI presentation, and optional |
| 5934 | // VK_KHR_acceleration_structure + VK_KHR_ray_query for hardware BVH builds (BLAS + TLAS). | 5938 | // VK_KHR_acceleration_structure + VK_KHR_ray_query for hardware BVH builds (BLAS + TLAS). |
| @@ -5998,17 +6002,13 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 5998 | ext_chain = &enable_conditional; | 6002 | ext_chain = &enable_conditional; |
| 5999 | } | 6003 | } |
| 6000 | 6004 | ||
| 6001 | VkPhysicalDeviceVulkan13Features enable13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, ext_chain}; | ||
| 6002 | enable13.dynamicRendering = VK_TRUE; | ||
| 6003 | enable13.synchronization2 = VK_TRUE; | ||
| 6004 | // Subgroup size control: a pipeline stage asks for the size its shader was translated for (src/subgroup_size.h). | 6005 | // Subgroup size control: a pipeline stage asks for the size its shader was translated for (src/subgroup_size.h). |
| 6005 | enable13.subgroupSizeControl = chosen13.subgroupSizeControl; | 6006 | leonida::query_subgroup_size_caps(vkGetPhysicalDeviceProperties2, info.physical, v13.subgroup_size_control, |
| 6006 | enable13.computeFullSubgroups = chosen13.computeFullSubgroups; | 6007 | v13.compute_full_subgroups, info.subgroup); |
| 6007 | leonida::query_subgroup_size_caps(vkGetPhysicalDeviceProperties2, info.physical, chosen13.subgroupSizeControl, | ||
| 6008 | chosen13.computeFullSubgroups, info.subgroup); | ||
| 6009 | // Translated vertex shaders read BaseVertex / BaseInstance (SPIR-V DrawParameters) to give v0 / v3 the | 6008 | // Translated vertex shaders read BaseVertex / BaseInstance (SPIR-V DrawParameters) to give v0 / v3 the |
| 6010 | // hardware's zero-based vertex and instance ids (docs/design.md, Inputs and outputs). | 6009 | // hardware's zero-based vertex and instance ids (docs/design.md, Inputs and outputs). |
| 6011 | VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &enable13}; | 6010 | VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, |
| 6011 | v13.enable(ext_chain)}; | ||
| 6012 | enable11.shaderDrawParameters = chosen_draw_params ? VK_TRUE : VK_FALSE; | 6012 | enable11.shaderDrawParameters = chosen_draw_params ? VK_TRUE : VK_FALSE; |
| 6013 | if (!chosen_draw_params) std::fprintf(stderr, "[rt] d3d12: the GPU has no shaderDrawParameters\n"); | 6013 | if (!chosen_draw_params) std::fprintf(stderr, "[rt] d3d12: the GPU has no shaderDrawParameters\n"); |
| 6014 | VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; | 6014 | VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; |
| @@ -6081,8 +6081,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 6081 | vkGetPhysicalDeviceFeatures2(info.physical, &query); | 6081 | vkGetPhysicalDeviceFeatures2(info.physical, &query); |
| 6082 | info.image_view_min_lod = min_lod.minLod == VK_TRUE; | 6082 | info.image_view_min_lod = min_lod.minLod == VK_TRUE; |
| 6083 | if (info.image_view_min_lod) { | 6083 | if (info.image_view_min_lod) { |
| 6084 | min_lod.pNext = enable13.pNext; | 6084 | min_lod.pNext = *v13.next(); |
| 6085 | enable13.pNext = &min_lod; | 6085 | *v13.next() = &min_lod; |
| 6086 | } | 6086 | } |
| 6087 | } | 6087 | } |
| 6088 | VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT}; | 6088 | VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT}; |
| @@ -6093,8 +6093,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 6093 | const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; | 6093 | const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; |
| 6094 | info.host_image_copy = has_host_image_copy && host_copy.hostImageCopy; | 6094 | info.host_image_copy = has_host_image_copy && host_copy.hostImageCopy; |
| 6095 | if (info.host_image_copy) { | 6095 | if (info.host_image_copy) { |
| 6096 | host_copy.pNext = enable13.pNext; // after the conditional rendering features, if any | 6096 | host_copy.pNext = *v13.next(); // after the conditional rendering features, if any |
| 6097 | enable13.pNext = &host_copy; | 6097 | *v13.next() = &host_copy; |
| 6098 | } else { | 6098 | } else { |
| 6099 | std::fprintf(stderr, "[rt] d3d12: no VK_EXT_host_image_copy; CPU texture copies use a staging submit\n"); | 6099 | std::fprintf(stderr, "[rt] d3d12: no VK_EXT_host_image_copy; CPU texture copies use a staging submit\n"); |
| 6100 | } | 6100 | } |
| @@ -6111,8 +6111,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 6111 | vkGetPhysicalDeviceFeatures2(info.physical, &query); | 6111 | vkGetPhysicalDeviceFeatures2(info.physical, &query); |
| 6112 | info.shader_fma = shader_fma.shaderFmaFloat32 == VK_TRUE; | 6112 | info.shader_fma = shader_fma.shaderFmaFloat32 == VK_TRUE; |
| 6113 | if (info.shader_fma) { | 6113 | if (info.shader_fma) { |
| 6114 | shader_fma.pNext = enable13.pNext; | 6114 | shader_fma.pNext = *v13.next(); |
| 6115 | enable13.pNext = &shader_fma; | 6115 | *v13.next() = &shader_fma; |
| 6116 | } | 6116 | } |
| 6117 | } | 6117 | } |
| 6118 | #endif | 6118 | #endif |
| @@ -6164,8 +6164,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 6164 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; | 6164 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; |
| 6165 | vkGetPhysicalDeviceFeatures2(info.physical, &query); | 6165 | vkGetPhysicalDeviceFeatures2(info.physical, &query); |
| 6166 | if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { | 6166 | if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { |
| 6167 | swapchain_m1.pNext = enable13.pNext; | 6167 | swapchain_m1.pNext = *v13.next(); |
| 6168 | enable13.pNext = &swapchain_m1; | 6168 | *v13.next() = &swapchain_m1; |
| 6169 | } else { | 6169 | } else { |
| 6170 | swapchain_m1_name = nullptr; | 6170 | swapchain_m1_name = nullptr; |
| 6171 | } | 6171 | } |
| @@ -6179,6 +6179,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { | |||
| 6179 | device_info.pQueueCreateInfos = &queue_info; | 6179 | device_info.pQueueCreateInfos = &queue_info; |
| 6180 | device_info.pEnabledFeatures = &enable; | 6180 | device_info.pEnabledFeatures = &enable; |
| 6181 | std::vector<const char*> device_extensions; | 6181 | std::vector<const char*> device_extensions; |
| 6182 | v13.add_extensions(device_extensions); | ||
| 6182 | if (info.image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); | 6183 | if (info.image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); |
| 6183 | if (info.conditional_rendering) device_extensions.push_back(conditional_extension); | 6184 | if (info.conditional_rendering) device_extensions.push_back(conditional_extension); |
| 6184 | if (info.host_image_copy) device_extensions.push_back(host_image_copy_name); | 6185 | if (info.host_image_copy) device_extensions.push_back(host_image_copy_name); |
diff --git a/runtime/src/vulkan13_features.h b/runtime/src/vulkan13_features.h new file mode 100644 index 000000000..2057d953b --- /dev/null +++ b/runtime/src/vulkan13_features.h | |||
| @@ -0,0 +1,127 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | // dynamicRendering and synchronization2, the two Vulkan 1.3 features the D3D12 layer needs, on a Vulkan 1.3 device | ||
| 4 | // or on a Vulkan 1.2 device through VK_KHR_dynamic_rendering and VK_KHR_synchronization2. CrossOver's MoltenVK on | ||
| 5 | // macOS is such a 1.2 device (1.2.10: Vulkan 1.2 with both extensions); the extension structs, functions and | ||
| 6 | // behaviour are the core ones under another name, so the rest of the layer does not see the difference. | ||
| 7 | // | ||
| 8 | // leonida::Vulkan13Features v13; | ||
| 9 | // v13.query(physical, props.apiVersion, get_features2, enumerate_extensions); // per candidate | ||
| 10 | // if (!v13.usable()) continue; | ||
| 11 | // enable12.pNext = v13.enable(chain); // chain: what came after VkPhysicalDeviceVulkan13Features | ||
| 12 | // ... v13.next() is where later feature structs go (it used to be enable13.pNext) | ||
| 13 | // v13.add_extensions(device_extensions); | ||
| 14 | // fn = leonida::device_proc_or_khr(get_device_proc, device, "vkCmdPipelineBarrier2"); | ||
| 15 | |||
| 16 | #include <vulkan/vulkan.h> | ||
| 17 | |||
| 18 | #include <cstdint> | ||
| 19 | #include <cstring> | ||
| 20 | #include <string> | ||
| 21 | #include <vector> | ||
| 22 | |||
| 23 | namespace leonida { | ||
| 24 | |||
| 25 | class Vulkan13Features { | ||
| 26 | public: | ||
| 27 | Vulkan13Features() = default; | ||
| 28 | Vulkan13Features(const Vulkan13Features&) = delete; // enable() links pointers into this object | ||
| 29 | Vulkan13Features& operator=(const Vulkan13Features&) = delete; | ||
| 30 | |||
| 31 | bool core = false; // a Vulkan 1.3 device: the features are core | ||
| 32 | bool dynamic_rendering = false; // supported, as a core feature or through VK_KHR_dynamic_rendering | ||
| 33 | bool synchronization2 = false; // supported, as a core feature or through VK_KHR_synchronization2 | ||
| 34 | // Optional 1.3 core features, enabled where supported; on a 1.2 device they stay off (no required subgroup size). | ||
| 35 | bool subgroup_size_control = false; | ||
| 36 | bool compute_full_subgroups = false; | ||
| 37 | |||
| 38 | bool usable() const { return dynamic_rendering && synchronization2; } | ||
| 39 | |||
| 40 | // Fills the flags above for one physical device. A device older than 1.2 never qualifies. | ||
| 41 | void query(VkPhysicalDevice physical, std::uint32_t api_version, PFN_vkGetPhysicalDeviceFeatures2 features2, | ||
| 42 | PFN_vkEnumerateDeviceExtensionProperties enumerate_extensions) { | ||
| 43 | core = api_version >= VK_API_VERSION_1_3; | ||
| 44 | dynamic_rendering = synchronization2 = subgroup_size_control = compute_full_subgroups = false; | ||
| 45 | if (!features2) return; | ||
| 46 | if (core) { | ||
| 47 | VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | ||
| 48 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f13}; | ||
| 49 | features2(physical, &query); | ||
| 50 | dynamic_rendering = f13.dynamicRendering == VK_TRUE; | ||
| 51 | synchronization2 = f13.synchronization2 == VK_TRUE; | ||
| 52 | subgroup_size_control = f13.subgroupSizeControl == VK_TRUE; | ||
| 53 | compute_full_subgroups = f13.computeFullSubgroups == VK_TRUE; | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | if (api_version < VK_API_VERSION_1_2 || !enumerate_extensions) return; | ||
| 57 | std::uint32_t count = 0; | ||
| 58 | enumerate_extensions(physical, nullptr, &count, nullptr); | ||
| 59 | std::vector<VkExtensionProperties> extensions(count); | ||
| 60 | enumerate_extensions(physical, nullptr, &count, extensions.data()); | ||
| 61 | bool has_dynamic_rendering = false, has_synchronization2 = false; | ||
| 62 | for (const auto& e : extensions) { | ||
| 63 | has_dynamic_rendering |= std::strcmp(e.extensionName, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME) == 0; | ||
| 64 | has_synchronization2 |= std::strcmp(e.extensionName, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME) == 0; | ||
| 65 | } | ||
| 66 | if (!has_dynamic_rendering || !has_synchronization2) return; | ||
| 67 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR}; | ||
| 68 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering{ | ||
| 69 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR, &sync2}; | ||
| 70 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &rendering}; | ||
| 71 | features2(physical, &query); | ||
| 72 | dynamic_rendering = rendering.dynamicRendering == VK_TRUE; | ||
| 73 | synchronization2 = sync2.synchronization2 == VK_TRUE; | ||
| 74 | } | ||
| 75 | |||
| 76 | // Copies the flags of the device query() chose (a later query() for another candidate overwrites them). | ||
| 77 | void choose(const Vulkan13Features& from) { | ||
| 78 | core = from.core; | ||
| 79 | dynamic_rendering = from.dynamic_rendering; | ||
| 80 | synchronization2 = from.synchronization2; | ||
| 81 | subgroup_size_control = from.subgroup_size_control; | ||
| 82 | compute_full_subgroups = from.compute_full_subgroups; | ||
| 83 | } | ||
| 84 | |||
| 85 | // The structs that enable both features, ahead of `chain`; returns their head for VkPhysicalDeviceVulkan12Features' | ||
| 86 | // pNext. Call once, after query() or choose(). | ||
| 87 | void* enable(void* chain) { | ||
| 88 | if (core) { | ||
| 89 | enable13_.pNext = chain; | ||
| 90 | enable13_.dynamicRendering = VK_TRUE; | ||
| 91 | enable13_.synchronization2 = VK_TRUE; | ||
| 92 | enable13_.subgroupSizeControl = subgroup_size_control ? VK_TRUE : VK_FALSE; | ||
| 93 | enable13_.computeFullSubgroups = compute_full_subgroups ? VK_TRUE : VK_FALSE; | ||
| 94 | return &enable13_; | ||
| 95 | } | ||
| 96 | sync2_.pNext = chain; | ||
| 97 | sync2_.synchronization2 = VK_TRUE; | ||
| 98 | rendering_.pNext = &sync2_; | ||
| 99 | rendering_.dynamicRendering = VK_TRUE; | ||
| 100 | return &rendering_; | ||
| 101 | } | ||
| 102 | |||
| 103 | // Where a feature struct goes to follow these: insert with `s.pNext = *next(); *next() = &s;`. | ||
| 104 | void** next() { return core ? &enable13_.pNext : &sync2_.pNext; } | ||
| 105 | |||
| 106 | // The device extensions a 1.2 device needs for both features; none on 1.3. | ||
| 107 | void add_extensions(std::vector<const char*>& extensions) const { | ||
| 108 | if (core) return; | ||
| 109 | extensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); | ||
| 110 | extensions.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); | ||
| 111 | } | ||
| 112 | |||
| 113 | private: | ||
| 114 | VkPhysicalDeviceVulkan13Features enable13_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | ||
| 115 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR}; | ||
| 116 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR}; | ||
| 117 | }; | ||
| 118 | |||
| 119 | // A device function by its core name, or by its KHR name where the core one is null: a Vulkan 1.2 device returns | ||
| 120 | // null for Vulkan 1.3 core names (vkCmdPipelineBarrier2, vkCmdBeginRendering, ...) and serves the enabled | ||
| 121 | // extension's vkCmdPipelineBarrier2KHR and the like, which have the same signatures. | ||
| 122 | inline PFN_vkVoidFunction device_proc_or_khr(PFN_vkGetDeviceProcAddr get, VkDevice device, const char* name) { | ||
| 123 | if (const PFN_vkVoidFunction function = get(device, name)) return function; | ||
| 124 | return get(device, (std::string(name) + "KHR").c_str()); | ||
| 125 | } | ||
| 126 | |||
| 127 | } // namespace leonida | ||
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index e577e6af0..814f53549 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -3,7 +3,8 @@ | |||
| 3 | // The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker, | 3 | // The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker, |
| 4 | // image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in | 4 | // image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in |
| 5 | // shims/d3d12_com.cpp are thin wrappers over these. Needs Vulkan 1.2 timeline semaphores; rectangle clears and | 5 | // shims/d3d12_com.cpp are thin wrappers over these. Needs Vulkan 1.2 timeline semaphores; rectangle clears and |
| 6 | // enhanced barriers need the Vulkan 1.3 functions (dynamicRendering, synchronization2) to be enabled. | 6 | // enhanced barriers need the Vulkan 1.3 functions (dynamicRendering, synchronization2) to be enabled, as core |
| 7 | // features or through their KHR extensions on a 1.2 device (vulkan13_features.h). | ||
| 7 | 8 | ||
| 8 | #ifndef VK_NO_PROTOTYPES | 9 | #ifndef VK_NO_PROTOTYPES |
| 9 | #define VK_NO_PROTOTYPES | 10 | #define VK_NO_PROTOTYPES |
| @@ -12,6 +13,7 @@ | |||
| 12 | #include "occlusion_sum_spirv.h" | 13 | #include "occlusion_sum_spirv.h" |
| 13 | #include "retire_tickets.h" | 14 | #include "retire_tickets.h" |
| 14 | #include "statistics_sum_spirv.h" | 15 | #include "statistics_sum_spirv.h" |
| 16 | #include "vulkan13_features.h" | ||
| 15 | #include "vulkan_depth24.h" | 17 | #include "vulkan_depth24.h" |
| 16 | #include "vulkan_scratch.h" | 18 | #include "vulkan_scratch.h" |
| 17 | #include "vulkan_replay.h" | 19 | #include "vulkan_replay.h" |
| @@ -84,7 +86,7 @@ struct VulkanDeviceFunctions { | |||
| 84 | // extension is not enabled, and the query functions are optional (a list that uses queries without them is | 86 | // extension is not enabled, and the query functions are optional (a list that uses queries without them is |
| 85 | // unsupported). The compute and descriptor functions are needed for normalized or summed occlusion results. | 87 | // unsupported). The compute and descriptor functions are needed for normalized or summed occlusion results. |
| 86 | bool load(PFN_vkGetDeviceProcAddr get, VkDevice device) { | 88 | bool load(PFN_vkGetDeviceProcAddr get, VkDevice device) { |
| 87 | #define LEONIDA_VK_LOAD(name) name = reinterpret_cast<PFN_##name>(get(device, #name)); | 89 | #define LEONIDA_VK_LOAD(name) name = reinterpret_cast<PFN_##name>(leonida::device_proc_or_khr(get, device, #name)); |
| 88 | LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_LOAD) | 90 | LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_LOAD) |
| 89 | #undef LEONIDA_VK_LOAD | 91 | #undef LEONIDA_VK_LOAD |
| 90 | return vkCreateCommandPool && vkDestroyCommandPool && vkAllocateCommandBuffers && vkResetCommandBuffer && | 92 | return vkCreateCommandPool && vkDestroyCommandPool && vkAllocateCommandBuffers && vkResetCommandBuffer && |
diff --git a/runtime/test/vk_test_device.h b/runtime/test/vk_test_device.h index 635a3107b..6d12ff159 100644 --- a/runtime/test/vk_test_device.h +++ b/runtime/test/vk_test_device.h | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | // Shared setup for the GPU tests of the D3D12 layer: a Vulkan 1.3 device with dynamicRendering, synchronization2, | 1 | // Shared setup for the GPU tests of the D3D12 layer: a Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and |
| 2 | // timelineSemaphore and separateDepthStencilLayouts, images, buffers and one-shot submissions. | 2 | // VK_KHR_synchronization2) with dynamicRendering, synchronization2, timelineSemaphore and |
| 3 | // separateDepthStencilLayouts, images, buffers and one-shot submissions. | ||
| 3 | // Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation; Device::validation_errors() counts errors. | 4 | // Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation; Device::validation_errors() counts errors. |
| 4 | #pragma once | 5 | #pragma once |
| 5 | 6 | ||
| 6 | #include "vulkan_loader.h" | 7 | #include "vulkan_loader.h" |
| 7 | #include "../src/vulkan_device_filter.h" | 8 | #include "../src/vulkan_device_filter.h" |
| 9 | #include "../src/vulkan13_features.h" | ||
| 8 | #include "vk_device_pick.h" | 10 | #include "vk_device_pick.h" |
| 9 | #include "../src/subgroup_size.h" | 11 | #include "../src/subgroup_size.h" |
| 10 | 12 | ||
| @@ -134,9 +136,10 @@ public: | |||
| 134 | reinterpret_cast<PFN_vkDestroyInstance>(instance_proc(instance, "vkDestroyInstance"))(instance, nullptr); | 136 | reinterpret_cast<PFN_vkDestroyInstance>(instance_proc(instance, "vkDestroyInstance"))(instance, nullptr); |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 139 | // A Vulkan 1.3 function falls back to its KHR name on a 1.2 device. | ||
| 137 | template<typename F> | 140 | template<typename F> |
| 138 | F fn(const char* name) const { | 141 | F fn(const char* name) const { |
| 139 | return reinterpret_cast<F>(device_proc(device, name)); | 142 | return reinterpret_cast<F>(leonida::device_proc_or_khr(device_proc, device, name)); |
| 140 | } | 143 | } |
| 141 | 144 | ||
| 142 | template<typename F> | 145 | template<typename F> |
| @@ -263,10 +266,16 @@ public: | |||
| 263 | if (result != VK_SUCCESS) return failure("vkEnumeratePhysicalDevices", result); | 266 | if (result != VK_SUCCESS) return failure("vkEnumeratePhysicalDevices", result); |
| 264 | VkPhysicalDeviceProperties chosen{}; | 267 | VkPhysicalDeviceProperties chosen{}; |
| 265 | int best_rank = -1; | 268 | int best_rank = -1; |
| 269 | const auto features2_of = instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2"); | ||
| 270 | const auto device_extensions_of = | ||
| 271 | instance_fn<PFN_vkEnumerateDeviceExtensionProperties>("vkEnumerateDeviceExtensionProperties"); | ||
| 272 | leonida::Vulkan13Features candidate13; | ||
| 266 | for (auto candidate : devices) { | 273 | for (auto candidate : devices) { |
| 267 | VkPhysicalDeviceProperties props{}; | 274 | VkPhysicalDeviceProperties props{}; |
| 268 | properties_of(candidate, &props); | 275 | properties_of(candidate, &props); |
| 269 | if (props.apiVersion < VK_API_VERSION_1_3 || !leonida::vulkan_device_wanted(props.deviceName)) continue; | 276 | if (!leonida::vulkan_device_wanted(props.deviceName)) continue; |
| 277 | candidate13.query(candidate, props.apiVersion, features2_of, device_extensions_of); | ||
| 278 | if (!candidate13.usable()) continue; | ||
| 270 | std::uint32_t family_count = 0; | 279 | std::uint32_t family_count = 0; |
| 271 | families_of(candidate, &family_count, nullptr); | 280 | families_of(candidate, &family_count, nullptr); |
| 272 | std::vector<VkQueueFamilyProperties> families(family_count); | 281 | std::vector<VkQueueFamilyProperties> families(family_count); |
| @@ -279,6 +288,7 @@ public: | |||
| 279 | family = i; | 288 | family = i; |
| 280 | chosen = props; | 289 | chosen = props; |
| 281 | best_rank = rank; | 290 | best_rank = rank; |
| 291 | v13_.choose(candidate13); | ||
| 282 | } | 292 | } |
| 283 | break; | 293 | break; |
| 284 | } | 294 | } |
| @@ -286,22 +296,25 @@ public: | |||
| 286 | if (!physical) { | 296 | if (!physical) { |
| 287 | if (const std::string filter = leonida::vulkan_device_filter(); !filter.empty()) { | 297 | if (const std::string filter = leonida::vulkan_device_filter(); !filter.empty()) { |
| 288 | // A filter that matches nothing fails the test instead of skipping it. | 298 | // A filter that matches nothing fails the test instead of skipping it. |
| 289 | std::fprintf(stderr, "LEONIDA_VK_DEVICE=%s: no Vulkan 1.3 device with a graphics queue matches\n", | 299 | std::fprintf(stderr, |
| 300 | "LEONIDA_VK_DEVICE=%s: no Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and " | ||
| 301 | "VK_KHR_synchronization2) with a graphics queue matches\n", | ||
| 290 | filter.c_str()); | 302 | filter.c_str()); |
| 291 | return DeviceStatus::failed; | 303 | return DeviceStatus::failed; |
| 292 | } | 304 | } |
| 293 | std::fprintf(stderr, "no Vulkan 1.3 device with a graphics queue\n"); | 305 | std::fprintf(stderr, "no Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and " |
| 306 | "VK_KHR_synchronization2) with a graphics queue\n"); | ||
| 294 | return DeviceStatus::unavailable; | 307 | return DeviceStatus::unavailable; |
| 295 | } | 308 | } |
| 296 | std::printf("device: %s%s\n", chosen.deviceName, validation ? " (validation on)" : ""); | 309 | std::printf("device: %s%s%s\n", chosen.deviceName, v13_.core ? "" : " (Vulkan 1.2 + KHR extensions)", |
| 310 | validation ? " (validation on)" : ""); | ||
| 297 | 311 | ||
| 298 | VkPhysicalDeviceVulkan13Features features13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | 312 | VkPhysicalDeviceVulkan11Features features11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES}; |
| 299 | VkPhysicalDeviceVulkan11Features features11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &features13}; | ||
| 300 | VkPhysicalDeviceVulkan12Features features12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &features11}; | 313 | VkPhysicalDeviceVulkan12Features features12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &features11}; |
| 301 | VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &features12}; | 314 | VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &features12}; |
| 302 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &features); | 315 | features2_of(physical, &features); |
| 303 | if (!features13.dynamicRendering || !features13.synchronization2 || !features12.timelineSemaphore || | 316 | if (!features12.timelineSemaphore || !features12.separateDepthStencilLayouts || |
| 304 | !features12.separateDepthStencilLayouts || !features12.bufferDeviceAddress) { | 317 | !features12.bufferDeviceAddress) { |
| 305 | std::fprintf(stderr, "the device lacks dynamicRendering, synchronization2, timelineSemaphore or " | 318 | std::fprintf(stderr, "the device lacks dynamicRendering, synchronization2, timelineSemaphore or " |
| 306 | "separateDepthStencilLayouts\n"); | 319 | "separateDepthStencilLayouts\n"); |
| 307 | return DeviceStatus::unavailable; | 320 | return DeviceStatus::unavailable; |
| @@ -327,14 +340,8 @@ public: | |||
| 327 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT}; | 340 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT}; |
| 328 | enable_conditional.conditionalRendering = VK_TRUE; | 341 | enable_conditional.conditionalRendering = VK_TRUE; |
| 329 | 342 | ||
| 330 | VkPhysicalDeviceVulkan13Features enable13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, | ||
| 331 | conditional_rendering ? &enable_conditional : nullptr}; | ||
| 332 | enable13.dynamicRendering = VK_TRUE; | ||
| 333 | enable13.synchronization2 = VK_TRUE; | ||
| 334 | enable13.subgroupSizeControl = features13.subgroupSizeControl; | ||
| 335 | enable13.computeFullSubgroups = features13.computeFullSubgroups; | ||
| 336 | leonida::query_subgroup_size_caps(instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"), | 343 | leonida::query_subgroup_size_caps(instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"), |
| 337 | physical, features13.subgroupSizeControl, features13.computeFullSubgroups, | 344 | physical, v13_.subgroup_size_control, v13_.compute_full_subgroups, |
| 338 | subgroup); | 345 | subgroup); |
| 339 | std::printf("subgroup sizes: %u..%u (default %u), requirable in stages 0x%x, subgroupSizeControl %s, " | 346 | std::printf("subgroup sizes: %u..%u (default %u), requirable in stages 0x%x, subgroupSizeControl %s, " |
| 340 | "computeFullSubgroups %s\n", | 347 | "computeFullSubgroups %s\n", |
| @@ -342,7 +349,8 @@ public: | |||
| 342 | subgroup.subgroup_size_control ? "on" : "off", subgroup.compute_full_subgroups ? "on" : "off"); | 349 | subgroup.subgroup_size_control ? "on" : "off", subgroup.compute_full_subgroups ? "on" : "off"); |
| 343 | // shaderDrawParameters, where available: translated vertex shaders will read BaseVertex and BaseInstance once PR 436 | 350 | // shaderDrawParameters, where available: translated vertex shaders will read BaseVertex and BaseInstance once PR 436 |
| 344 | // (zero-based VS ids) is in; harmless before. | 351 | // (zero-based VS ids) is in; harmless before. |
| 345 | VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &enable13}; | 352 | VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, |
| 353 | v13_.enable(conditional_rendering ? &enable_conditional : nullptr)}; | ||
| 346 | enable11.shaderDrawParameters = features11.shaderDrawParameters; | 354 | enable11.shaderDrawParameters = features11.shaderDrawParameters; |
| 347 | VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; | 355 | VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; |
| 348 | enable12.timelineSemaphore = VK_TRUE; | 356 | enable12.timelineSemaphore = VK_TRUE; |
| @@ -399,8 +407,8 @@ public: | |||
| 399 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); | 407 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); |
| 400 | image_view_min_lod = min_lod.minLod == VK_TRUE; | 408 | image_view_min_lod = min_lod.minLod == VK_TRUE; |
| 401 | if (image_view_min_lod) { | 409 | if (image_view_min_lod) { |
| 402 | min_lod.pNext = enable13.pNext; | 410 | min_lod.pNext = *v13_.next(); |
| 403 | enable13.pNext = &min_lod; | 411 | *v13_.next() = &min_lod; |
| 404 | } | 412 | } |
| 405 | } | 413 | } |
| 406 | VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{ | 414 | VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{ |
| @@ -413,8 +421,8 @@ public: | |||
| 413 | } | 421 | } |
| 414 | const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; | 422 | const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; |
| 415 | if (host_image_copy) { | 423 | if (host_image_copy) { |
| 416 | host_copy.pNext = enable13.pNext; // after the conditional rendering features, if any | 424 | host_copy.pNext = *v13_.next(); // after the conditional rendering features, if any |
| 417 | enable13.pNext = &host_copy; | 425 | *v13_.next() = &host_copy; |
| 418 | } | 426 | } |
| 419 | 427 | ||
| 420 | #ifdef VK_KHR_SHADER_FMA_EXTENSION_NAME | 428 | #ifdef VK_KHR_SHADER_FMA_EXTENSION_NAME |
| @@ -427,8 +435,8 @@ public: | |||
| 427 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); | 435 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); |
| 428 | shader_fma = fma_features.shaderFmaFloat32 == VK_TRUE; | 436 | shader_fma = fma_features.shaderFmaFloat32 == VK_TRUE; |
| 429 | if (shader_fma) { | 437 | if (shader_fma) { |
| 430 | fma_features.pNext = enable13.pNext; | 438 | fma_features.pNext = *v13_.next(); |
| 431 | enable13.pNext = &fma_features; | 439 | *v13_.next() = &fma_features; |
| 432 | } | 440 | } |
| 433 | } | 441 | } |
| 434 | #endif | 442 | #endif |
| @@ -442,6 +450,7 @@ public: | |||
| 442 | device_info.pEnabledFeatures = &enable; | 450 | device_info.pEnabledFeatures = &enable; |
| 443 | enabled = enable; | 451 | enabled = enable; |
| 444 | std::vector<const char*> device_extensions; | 452 | std::vector<const char*> device_extensions; |
| 453 | v13_.add_extensions(device_extensions); | ||
| 445 | if (image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); | 454 | if (image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); |
| 446 | if (conditional_rendering) device_extensions.push_back(conditional_extension); | 455 | if (conditional_rendering) device_extensions.push_back(conditional_extension); |
| 447 | if (host_image_copy) device_extensions.push_back(host_image_copy_name); | 456 | if (host_image_copy) device_extensions.push_back(host_image_copy_name); |
| @@ -462,8 +471,8 @@ public: | |||
| 462 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; | 471 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; |
| 463 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); | 472 | instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); |
| 464 | if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { | 473 | if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { |
| 465 | swapchain_m1.pNext = enable13.pNext; | 474 | swapchain_m1.pNext = *v13_.next(); |
| 466 | enable13.pNext = &swapchain_m1; | 475 | *v13_.next() = &swapchain_m1; |
| 467 | device_extensions.push_back(name); | 476 | device_extensions.push_back(name); |
| 468 | swapchain_maintenance1 = true; | 477 | swapchain_maintenance1 = true; |
| 469 | } | 478 | } |
| @@ -628,6 +637,7 @@ private: | |||
| 628 | VkDebugUtilsMessengerEXT messenger_ = VK_NULL_HANDLE; | 637 | VkDebugUtilsMessengerEXT messenger_ = VK_NULL_HANDLE; |
| 629 | VkCommandPool pool_ = VK_NULL_HANDLE; | 638 | VkCommandPool pool_ = VK_NULL_HANDLE; |
| 630 | VkPhysicalDeviceMemoryProperties memory_{}; | 639 | VkPhysicalDeviceMemoryProperties memory_{}; |
| 640 | leonida::Vulkan13Features v13_; // the chosen device's dynamicRendering/synchronization2 path | ||
| 631 | std::vector<std::pair<VkImage, VkDeviceMemory>> images_; | 641 | std::vector<std::pair<VkImage, VkDeviceMemory>> images_; |
| 632 | std::vector<std::pair<VkBuffer, VkDeviceMemory>> buffers_; | 642 | std::vector<std::pair<VkBuffer, VkDeviceMemory>> buffers_; |
| 633 | }; | 643 | }; |