summaryrefslogtreecommitdiffstats
path: root/tools/gfx
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-03-13 15:03:16 -0400
committerGitHub <noreply@github.com>2024-03-13 15:03:16 -0400
commit9fd74379c22af14f794d48fdc22e772d47f61ca3 (patch)
tree9d15b4139d8fdaa335197617b0bc6cab14ed42a3 /tools/gfx
parent6f7c8271710b43349d34b8f7569ceb6957400548 (diff)
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.
Diffstat (limited to 'tools/gfx')
-rw-r--r--tools/gfx/vulkan/vk-api.h36
-rw-r--r--tools/gfx/vulkan/vk-device.cpp17
2 files changed, 39 insertions, 14 deletions
diff --git a/tools/gfx/vulkan/vk-api.h b/tools/gfx/vulkan/vk-api.h
index f7523eb7f..27a19acfb 100644
--- a/tools/gfx/vulkan/vk-api.h
+++ b/tools/gfx/vulkan/vk-api.h
@@ -241,32 +241,43 @@ struct VulkanExtendedFeatureProperties
{
// 16 bit storage features
VkPhysicalDevice16BitStorageFeatures storage16BitFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR
+ };
// Atomic Float features
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomicFloatFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT
+ };
+ VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT atomicFloat2Features = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT
+ };
// Extended dynamic state features
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT
+ };
// Acceleration structure features
VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationStructureFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR
+ };
// Ray tracing pipeline features
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineFeatures = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR
};
// Ray query (inline ray-tracing) features
VkPhysicalDeviceRayQueryFeaturesKHR rayQueryFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR
+ };
// Inline uniform block features
VkPhysicalDeviceInlineUniformBlockFeaturesEXT inlineUniformBlockFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT
+ };
// Robustness2 features
VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT
+ };
VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV rayTracingInvocationReorderFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV
+ };
// Clock features
VkPhysicalDeviceShaderClockFeaturesKHR clockFeatures = {
@@ -280,15 +291,18 @@ struct VulkanExtendedFeatureProperties
// Multiview features
VkPhysicalDeviceMultiviewFeaturesKHR multiviewFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR };
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR
+ };
// Fragment shading rate features
VkPhysicalDeviceFragmentShadingRateFeaturesKHR fragmentShadingRateFeatures = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR };
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR
+ };
// Vulkan 1.2 features.
VkPhysicalDeviceVulkan12Features vulkan12Features = {
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES
+ };
};
struct VulkanApi
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,12 +567,19 @@ 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,
VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME,