# HG changeset patch # User sam # Date 1712396486 -25200 # Node ID 450b8a5042cd0d853bc26221db63aeb7946e8d60 # Parent 8abbcdd4d58cb59b10feef69d5a16c6d74bf1dfe add: check for uniform buffer layout, seem not be available on some older devices diff -r 8abbcdd4d58c -r 450b8a5042cd semicongine/resources.nim --- a/semicongine/resources.nim Sat Apr 06 15:46:41 2024 +0700 +++ b/semicongine/resources.nim Sat Apr 06 16:41:26 2024 +0700 @@ -121,7 +121,6 @@ import std/compilesettings import std/tables - import std/sequtils const BUILD_RESOURCEROOT* {.strdefine.}: string = "" diff -r 8abbcdd4d58c -r 450b8a5042cd semicongine/vulkan/descriptor.nim --- a/semicongine/vulkan/descriptor.nim Sat Apr 06 15:46:41 2024 +0700 +++ b/semicongine/vulkan/descriptor.nim Sat Apr 06 16:41:26 2024 +0700 @@ -70,7 +70,6 @@ descriptorSetLayout.device.vk.vkDestroyDescriptorSetLayout(descriptorSetLayout.vk, nil) descriptorSetLayout.vk.reset - proc createDescriptorSetPool*(device: Device, counts: seq[(VkDescriptorType, uint32)], maxSets = 1000): DescriptorPool = assert device.vk.valid diff -r 8abbcdd4d58c -r 450b8a5042cd semicongine/vulkan/device.nim --- a/semicongine/vulkan/device.nim Sat Apr 06 15:46:41 2024 +0700 +++ b/semicongine/vulkan/device.nim Sat Apr 06 16:41:26 2024 +0700 @@ -32,9 +32,14 @@ assert queueFamilies.len > 0 result.physicalDevice = physicalDevice - var allExtensions = enabledExtensions & @["VK_KHR_swapchain", "VK_KHR_uniform_buffer_standard_layout"] + let hasUniformBufferStandardLayout = "VK_KHR_uniform_buffer_standard_layout" in physicalDevice.getExtensions() + + var allExtensions = enabledExtensions & @["VK_KHR_swapchain"] + if hasUniformBufferStandardLayout: + allExtensions.add "VK_KHR_uniform_buffer_standard_layout" for extension in allExtensions: instance.vk.loadExtension(extension) + var enabledExtensionsC = allocCStringArray(allExtensions) priority = 1'f32 @@ -55,7 +60,7 @@ var features2 = VkPhysicalDeviceFeatures2( stype: VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, features: result.enabledFeatures, - pnext: addr uniformBufferLayoutFeature, + pnext: if hasUniformBufferStandardLayout: addr uniformBufferLayoutFeature else: nil, ) var createInfo = VkDeviceCreateInfo( sType: VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,