5

For OpenGL, the Nvidia extension NV_shader_atomic_float [1] exists which enables atomic read-modify-write operations to buffer or texture memory with floating-point components in GLSL shaders.

Does this functionality also exist with Vulkan? I couldn't find information about any extension which would enable that. Is that functionality not provided via a Vulkan extension?

[1] https://www.khronos.org/registry/OpenGL/extensions/NV/NV_shader_atomic_float.txt

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
j00hi
  • 5,420
  • 3
  • 45
  • 82
  • 1
    Thanks for the links. However, it is not clear to me that there is also support for atomic *floats*. If I'm not mistaken, there is native atomic int support in OpenGL. But what about Vulkan - is the native support also limited to atomic int or does it also natively support atomic floats? If so, wouldn't that also mean that all devices supporting Vulkan would have to support atomic floats? I can't find any clear statement on this. – j00hi Dec 05 '18 at 23:17

2 Answers2

5

No, there is no Vulkan extension that provides atomic floating-point operations (yet?). Presumably Nvidia could create such an extension if they saw enough developer demand for it.

SPIR-V supports atomic instructions with floating-point types, but SPIR-V modules that contain those are currently forbidden by Vulkan's SPIR-V environment spec:

Atomic instructions must declare a scalar 32-bit integer type, or a scalar 64-bit integer type if the Int64Atomics capability is enabled, for the value pointed to by Pointer.

Jesse Hall
  • 6,441
  • 23
  • 29
  • Are you sure that atomic floating-point operations aren't supported in Vulkan? What about the description of atomics in the official Vulkan specifications? It doesn't state anywhere that atomic floats would be supported, but it doesn't state that they aren't either. – j00hi Dec 06 '18 at 10:26
  • 2
    If a spec doesn't explicitly state that something is supported then it's safe to assume it isn't. – solidpixel Dec 06 '18 at 11:16
  • 5
    The Vulkan SPIR-V environment spec forbids it: "Atomic instructions must declare a scalar 32-bit integer type, or a scalar 64-bit integer type if the Int64Atomics capability is enabled, for the value pointed to by Pointer." There would need to be an extension to relax this. – Jesse Hall Dec 06 '18 at 23:20
4

Here it is: VK_EXT_shader_atomic_float
The extension has been added in July 2020 by NVIDIA and is compatible with all Vulkan versions.

Citing the spec. description:

This extension allows a shader to contain floating-point atomic operations on buffer, workgroup, and image memory. It also advertises the SPIR-V AtomicFloat32AddEXT and AtomicFloat64AddEXT capabilities that allows atomic addition on floating-points numbers. The supported operations include OpAtomicFAddEXT, OpAtomicExchange, OpAtomicLoad and OpAtomicStore.

There are already some entries on gpuinfo.org indicating support for the extension. Applears like NVIDIA drivers 451.79.0.0 or later are required.

j00hi
  • 5,420
  • 3
  • 45
  • 82