radv: advertise VK_EXT_shader_atomic_float
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 20 Jul 2020 16:38:17 +0000 (18:38 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 22 Jul 2020 08:20:58 +0000 (10:20 +0200)
No hw support for float atomic add for buffer and (sparse) images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6000>

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_extensions.py
src/amd/vulkan/radv_formats.c
src/amd/vulkan/radv_shader.c

index b9969e4e5eb441ea925fb95e22dc40f767b2abd2..c474c78eb21b165ebfa4190375ba87dfea371938 100644 (file)
@@ -1340,6 +1340,24 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->robustImageAccess = true;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: {
+                       VkPhysicalDeviceShaderAtomicFloatFeaturesEXT *features =
+                               (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT *)ext;
+                       features->shaderBufferFloat32Atomics = true;
+                       features->shaderBufferFloat32AtomicAdd = false;
+                       features->shaderBufferFloat64Atomics = true;
+                       features->shaderBufferFloat64AtomicAdd = false;
+                       features->shaderSharedFloat32Atomics = true;
+                       features->shaderSharedFloat32AtomicAdd = pdevice->rad_info.chip_class >= GFX8 &&
+                                                                (!pdevice->use_llvm || LLVM_VERSION_MAJOR >= 10);
+                       features->shaderSharedFloat64Atomics = true;
+                       features->shaderSharedFloat64AtomicAdd = false;
+                       features->shaderImageFloat32Atomics = true;
+                       features->shaderImageFloat32AtomicAdd = false;
+                       features->sparseImageFloat32Atomics = false;
+                       features->sparseImageFloat32AtomicAdd = false;
+                       break;
+               }
                default:
                        break;
                }
index 90b5ef41e8371d6546ac5778269b65a98533d7b7..2a3e995e309db84c81a47796de51a0cd50344f35 100644 (file)
@@ -153,6 +153,7 @@ EXTENSIONS = [
     Extension('VK_EXT_sample_locations',                  1, 'device->rad_info.chip_class < GFX10'),
     Extension('VK_EXT_sampler_filter_minmax',             1, True),
     Extension('VK_EXT_scalar_block_layout',               1, 'device->rad_info.chip_class >= GFX7'),
+    Extension('VK_EXT_shader_atomic_float',               1, True),
     Extension('VK_EXT_shader_demote_to_helper_invocation',1, 'LLVM_VERSION_MAJOR >= 9 || !device->use_llvm'),
     Extension('VK_EXT_shader_viewport_index_layer',       1, True),
     Extension('VK_EXT_shader_stencil_export',             1, True),
index 2e753f47be84eb7ab7fb2b6eee4c837d6b123c78..9360fb31bcc986eb051c7f70ce43bdce5f978e0f 100644 (file)
@@ -749,7 +749,9 @@ radv_physical_device_get_format_properties(struct radv_physical_device *physical
                          VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
        }
 
-       if (format == VK_FORMAT_R32_UINT || format == VK_FORMAT_R32_SINT) {
+       if (format == VK_FORMAT_R32_UINT ||
+           format == VK_FORMAT_R32_SINT ||
+           format == VK_FORMAT_R32_SFLOAT) {
                buffer |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
                linear |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
                tiled |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
index 072201fe66b4ce5531b59fe68f1a89ec59fb101b..3af15d4e8446b92217c370eac13811e127174977 100644 (file)
@@ -377,6 +377,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
                                .draw_parameters = true,
                                .float_controls = true,
                                .float16 = device->physical_device->rad_info.has_packed_math_16bit,
+                               .float32_atomic_add = true,
                                .float64 = true,
                                .geometry_streams = true,
                                .image_ms_array = true,