11 VkPhysicalDeviceExtendedDynamicState3FeaturesEXT vk13EXTfeatures{};
12 vk13EXTfeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT;
13 vk13EXTfeatures.extendedDynamicState3ColorBlendEnable =
true;
14 vk13EXTfeatures.extendedDynamicState3ColorBlendEquation =
true;
15 vk13EXTfeatures.extendedDynamicState3ColorWriteMask =
true;
17 VkPhysicalDeviceVulkan13Features vk13features{};
18 vk13features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
19 vk13features.pNext = &vk13EXTfeatures;
21 vk13features.synchronization2 =
true;
22 vk13features.dynamicRendering =
true;
23 vk13features.maintenance4 =
true;
24 VkPhysicalDeviceVulkan12Features vk12features{};
25 vk12features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
26 vk12features.samplerMirrorClampToEdge =
true;
27 vk12features.timelineSemaphore =
true;
28 vk12features.descriptorBindingPartiallyBound =
true;
29 vk12features.descriptorBindingUniformBufferUpdateAfterBind =
true;
30 vk12features.descriptorBindingSampledImageUpdateAfterBind =
true;
31 vk12features.descriptorBindingStorageImageUpdateAfterBind =
true;
32 vk12features.descriptorBindingStorageBufferUpdateAfterBind =
true;
33 vk12features.descriptorBindingUpdateUnusedWhilePending =
true;
34 vk12features.shaderSampledImageArrayNonUniformIndexing =
true;
35 vk12features.runtimeDescriptorArray =
true;
36 vk12features.descriptorBindingVariableDescriptorCount =
true;
37 VkPhysicalDeviceVulkan11Features vk11features{};
38 vk11features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
39 vk11features.shaderDrawParameters =
true;
40 VkPhysicalDeviceFeatures vk10features{};
41 vk10features.independentBlend =
true;
42 vk10features.imageCubeArray =
true;
43 vk10features.geometryShader =
true;
44 vk10features.tessellationShader =
true;
45 vk10features.multiDrawIndirect =
true;
46 vk10features.drawIndirectFirstInstance =
true;
47 vk10features.depthClamp =
true;
48 vk10features.depthBiasClamp =
true;
49 vk10features.fillModeNonSolid =
true;
50 vk10features.depthBounds =
true;
51 vk10features.samplerAnisotropy =
true;
52 vk10features.sampleRateShading =
true;
54 vk10features.textureCompressionBC =
true;
55 vk10features.shaderClipDistance =
true;
56 vk10features.shaderCullDistance =
true;
58 vkb::PhysicalDeviceSelector selector{ instance };
61 .set_surface( targetSurface )
62 .prefer_gpu_device_type( vkb::PreferredDeviceType::discrete )
63 .add_required_extension( VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME )
64 .set_required_features( vk10features )
65 .set_required_features_11( vk11features )
66 .set_required_features_12( vk12features )
67 .set_required_features_13( vk13features )
70 if ( !physicalDeviceSelection )
79 VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME,
80 VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME,
81 VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME
87 auto vkbDevice = deviceBuilder.build();
96 if ( extension == VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME )
98 supportsDynamicExtension3(
true);
100 else if ( extension == VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME )
102 supportsPushDescriptors(
true);
104 else if ( extension == VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME )
106 supportsDescriptorBuffers(
true);
113 const auto presentIndex =
_device.get_queue_index(vkb::QueueType::present);
135 if ( queue._pool != VK_NULL_HANDLE )
137 vkDestroyCommandPool(
getVKDevice(), queue._pool,
nullptr );
141 if (
_device.device != VK_NULL_HANDLE )
143 vkb::destroy_device(
_device );
161 constexpr const char* QueueName[] = {
"Graphics",
"Compute",
"Transfer" };
162 constexpr vkb::QueueType VKBQueueType[] = {vkb::QueueType::graphics, vkb::QueueType::compute, vkb::QueueType::transfer};
166 if ( getDevice() ==
nullptr )
177 const vkb::QueueType vkbType = VKBQueueType[
to_base(type)];
180 const auto index = dedicated ? _device.get_dedicated_queue_index( vkbType ) : _device.get_queue_index( vkbType );
192 return dedicated ? getQueueInternal(type,
false) : ret;
195 ret._index = index.value();
197 ret._pool = createCommandPool( ret._index, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT );
198 vkGetDeviceQueue( _device.device, ret._index, 0u, &ret._queue );
228 cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
229 cmdPoolInfo.flags = createFlags;
230 VkCommandPool cmdPool;
250 return vkQueuePresentKHR(
_queues[
to_base( queue )]._queue, &presentInfo );
#define PROFILE_SCOPE_AUTO(CATEGORY)
const vkb::PhysicalDevice & getPhysicalDevice() const noexcept
VkCommandPool createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags=VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) const
std::array< Mutex, to_base(QueueType::COUNT)> _queueLocks
U32 getPresentQueueIndex() const noexcept
std::array< VKQueue, to_base(QueueType::COUNT) > _queues
void submitToQueue(QueueType queue, const VkSubmitInfo &submitInfo, VkFence &fence) const
VkPhysicalDevice getVKPhysicalDevice() const noexcept
VKDevice(vkb::Instance &instance, VkSurfaceKHR targetSurface)
VKQueue getQueue(QueueType type) const noexcept
const vkb::Device & getDevice() const noexcept
VKQueue getQueueInternal(QueueType type, bool dedicated) const noexcept
vkb::PhysicalDevice _physicalDevice
VkResult queuePresent(QueueType queue, const VkPresentInfoKHR &presentInfo) const
VkDevice getVKDevice() const noexcept
constexpr unsigned char MINIMUM_VULKAN_MINOR_VERSION
constexpr Optick::Category::Type Graphics
VkCommandPoolCreateInfo commandPoolCreateInfo()
Handle console commands that start with a forward slash.
std::lock_guard< mutex > LockGuard
constexpr auto to_base(const Type value) -> Type
static NO_INLINE void errorfn(const char *format, T &&... args)
static NO_INLINE void warnfn(const char *format, T &&... args)