Mercurial > games > semicongine
changeset 981:c81541f55d9c
add: check for uniform buffer layout, seem not be available on some older devices
author | sam <sam@basx.dev> |
---|---|
date | Sat, 06 Apr 2024 16:41:26 +0700 |
parents | 1ba0e5dfbf68 |
children | a40bb0a48e07 |
files | semicongine/resources.nim semicongine/vulkan/descriptor.nim semicongine/vulkan/device.nim |
diffstat | 3 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 = ""
--- 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
--- 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,