From 9fd74379c22af14f794d48fdc22e772d47f61ca3 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:03:16 -0400 Subject: Implement glsl atomic's [non image or memory scope] with optional extension(s); resolves #3587 for GLSL & SPIR-V targets (#3755) The following commit implements atomic operations & types associated with OpenGL 4.6, GL_EXT_vulkan_glsl_relaxed, GLSL_EXT_shader_atomic_float, GLSL_EXT_shader_atomic_float2, for GLSL & SPIR-V targets. Fully implements all functions, and built-in type's, resolves https://github.com/shader-slang/slang/issues/3560 for GLSL & SPRI-V targets. [Atomic extensions for GLSL can be found here](https://github.com/KhronosGroup/GLSL/tree/main) Notes of worth: * atomic_uint is well defined in GLSL->OpenGL, although was removed in GLSL->VK unless a compiler extension is supported (GL_EXT_vulkan_glsl_relaxed). This support entails transforming all atomic_uint operations and references into a storage buffer. SPIR-V has AtomicCounter+AtomicStorage (atomic_uint parallel) but does not implement these capabilities for SPIR-V->VK in any scenario. Due to the case we transform atomic_uint ourselves (GLSL_Syntax->Slang_IR) to accommodate transforming atomic_uint into valid syntax. * GLSL_EXT_shader_atomic_float2 (all float16_t & some float/double operations) support is minimal and worth watching out for if enabling the tests. --- tools/gfx/vulkan/vk-device.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tools/gfx/vulkan/vk-device.cpp') diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index 2a914b86b..1b046d8f2 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -476,13 +476,17 @@ Result DeviceImpl::initVulkanInstanceAndDevice( extendedFeatures.clockFeatures.pNext = deviceFeatures2.pNext; deviceFeatures2.pNext = &extendedFeatures.clockFeatures; - // Atomic Float + // Atomic Float // To detect atomic float we need // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPhysicalDeviceShaderAtomicFloatFeaturesEXT.html extendedFeatures.atomicFloatFeatures.pNext = deviceFeatures2.pNext; deviceFeatures2.pNext = &extendedFeatures.atomicFloatFeatures; + // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT.html + extendedFeatures.atomicFloat2Features.pNext = deviceFeatures2.pNext; + deviceFeatures2.pNext = &extendedFeatures.atomicFloat2Features; + // mesh shader features extendedFeatures.meshShaderFeatures.pNext = deviceFeatures2.pNext; deviceFeatures2.pNext = &extendedFeatures.meshShaderFeatures; @@ -543,7 +547,7 @@ Result DeviceImpl::initVulkanInstanceAndDevice( // SIMPLE_EXTENSION_FEATURE(struct, feature member name, extension // name, features...) will check for the presence of the boolean // feature member in struct and the availability of the extensions. If - // they are both present then the extensions are addded, the struct + // they are both present then the extensions are added, the struct // linked into the deviceCreateInfo chain and the features added to the // supported features list. #define SIMPLE_EXTENSION_FEATURE(s, m, e, ...) \ @@ -563,11 +567,18 @@ Result DeviceImpl::initVulkanInstanceAndDevice( SIMPLE_EXTENSION_FEATURE( extendedFeatures.atomicFloatFeatures, - shaderBufferFloat32AtomicAdd, + shaderBufferFloat32Atomics, VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, "atomic-float" ); + SIMPLE_EXTENSION_FEATURE( + extendedFeatures.atomicFloat2Features, + shaderBufferFloat16Atomics, + VK_EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME, + "atomic-float-2" + ); + SIMPLE_EXTENSION_FEATURE( extendedFeatures.extendedDynamicStateFeatures, extendedDynamicState, -- cgit v1.2.3