[Mesa-dev] [PATCH 23/25] glsl: Implement the required built-in functions when OES_shader_image_atomic is enabled.

Francisco Jerez currojerez at riseup.net
Mon Aug 17 09:46:02 PDT 2015


This is basically just the same atomic functions exposed by
ARB_shader_image_load_store, with one exception:

    "highp float imageAtomicExchange(
         coherent IMAGE_PARAMS,
         float data);"

There's no float atomic exchange overload in the original
ARB_shader_image_load_store or GL 4.2, so this seems like new
functionality that requires specific back-end support and a separate
availability condition in the built-in function generator.
---
 src/glsl/builtin_functions.cpp | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index c53858e..444d0ee 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -401,8 +401,16 @@ shader_image_load_store(const _mesa_glsl_parse_state *state)
 static bool
 shader_image_atomic(const _mesa_glsl_parse_state *state)
 {
-   return (state->is_version(420, 0) ||
-           state->ARB_shader_image_load_store_enable);
+   return (state->is_version(420, 320) ||
+           state->ARB_shader_image_load_store_enable ||
+           state->OES_shader_image_atomic_enable);
+}
+
+static bool
+shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state)
+{
+   return (state->is_version(450, 320) ||
+           state->OES_shader_image_atomic_enable);
 }
 
 static bool
@@ -506,7 +514,8 @@ private:
       IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),
       IMAGE_FUNCTION_READ_ONLY = (1 << 4),
       IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
-      IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6)
+      IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
+      IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 7)
    };
 
    /**
@@ -2650,7 +2659,9 @@ builtin_builder::add_image_functions(bool glsl)
 
    add_image_function((glsl ? "imageAtomicExchange" :
                        "__intrinsic_image_atomic_exchange"),
-                      "__intrinsic_image_atomic_exchange", 1, atom_flags);
+                      "__intrinsic_image_atomic_exchange", 1,
+                      (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
+                       IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE));
 
    add_image_function((glsl ? "imageAtomicCompSwap" :
                        "__intrinsic_image_atomic_comp_swap"),
@@ -4798,7 +4809,11 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
       glsl_type::ivec(image_type->coordinate_components()), "coord");
 
    const builtin_available_predicate avail =
-      (flags & IMAGE_FUNCTION_AVAIL_ATOMIC ? shader_image_atomic :
+      (((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE) &&
+        image_type->sampler_type == GLSL_TYPE_FLOAT) ?
+       shader_image_atomic_exchange_float :
+       flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
+                IMAGE_FUNCTION_AVAIL_ATOMIC) ? shader_image_atomic :
        shader_image_load_store);
    ir_function_signature *sig = new_sig(ret_type, avail, 2, image, coord);
 
-- 
2.4.6



More information about the mesa-dev mailing list