summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2018-03-29 15:16:38 -0700
committerIan Romanick <[email protected]>2018-08-22 20:31:32 -0700
commit88b6c7bc14f378f40edee617af50092e1b72a919 (patch)
treeb5efa00925c8e78754703c3a1eb3baf95b59815c /src/compiler
parent9527bb4e704e3d9229cb7977ae598ed207a0502d (diff)
glsl: Add built-in functions for NV_shader_atomic_float
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index e7b78c01587..88a6ccecb75 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -570,7 +570,14 @@ shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state)
{
return (state->is_version(450, 320) ||
state->ARB_ES3_1_compatibility_enable ||
- state->OES_shader_image_atomic_enable);
+ state->OES_shader_image_atomic_enable ||
+ state->NV_shader_atomic_float_enable);
+}
+
+static bool
+shader_image_atomic_add_float(const _mesa_glsl_parse_state *state)
+{
+ return state->NV_shader_atomic_float_enable;
}
static bool
@@ -653,6 +660,24 @@ integer_functions_supported(const _mesa_glsl_parse_state *state)
{
return state->extensions->MESA_shader_integer_functions;
}
+
+static bool
+NV_shader_atomic_float_supported(const _mesa_glsl_parse_state *state)
+{
+ return state->extensions->NV_shader_atomic_float;
+}
+
+static bool
+shader_atomic_float_add(const _mesa_glsl_parse_state *state)
+{
+ return state->NV_shader_atomic_float_enable;
+}
+
+static bool
+shader_atomic_float_exchange(const _mesa_glsl_parse_state *state)
+{
+ return state->NV_shader_atomic_float_enable;
+}
/** @} */
/******************************************************************************/
@@ -1031,7 +1056,8 @@ enum image_function_flags {
IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
IMAGE_FUNCTION_MS_ONLY = (1 << 7),
- IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8)
+ IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),
+ IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9),
};
} /* anonymous namespace */
@@ -1139,6 +1165,9 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_add),
+ _atomic_intrinsic2(NV_shader_atomic_float_supported,
+ glsl_type::float_type,
+ ir_intrinsic_generic_atomic_add),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
ir_intrinsic_atomic_counter_add),
NULL);
@@ -1199,6 +1228,9 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_exchange),
+ _atomic_intrinsic2(NV_shader_atomic_float_supported,
+ glsl_type::float_type,
+ ir_intrinsic_generic_atomic_exchange),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
ir_intrinsic_atomic_counter_exchange),
NULL);
@@ -3143,6 +3175,9 @@ builtin_builder::create_builtins()
_atomic_op2("__intrinsic_atomic_add",
buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_op2("__intrinsic_atomic_add",
+ shader_atomic_float_add,
+ glsl_type::float_type),
NULL);
add_function("atomicMin",
_atomic_op2("__intrinsic_atomic_min",
@@ -3191,6 +3226,9 @@ builtin_builder::create_builtins()
_atomic_op2("__intrinsic_atomic_exchange",
buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_op2("__intrinsic_atomic_exchange",
+ shader_atomic_float_exchange,
+ glsl_type::float_type),
NULL);
add_function("atomicCompSwap",
_atomic_op3("__intrinsic_atomic_comp_swap",
@@ -3514,7 +3552,9 @@ builtin_builder::add_image_functions(bool glsl)
add_image_function(glsl ? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
"__intrinsic_image_atomic_add",
- &builtin_builder::_image_prototype, 1, atom_flags,
+ &builtin_builder::_image_prototype, 1,
+ (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |
+ IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),
ir_intrinsic_image_atomic_add);
add_image_function(glsl ? "imageAtomicMin" : "__intrinsic_image_atomic_min",
@@ -6039,7 +6079,12 @@ get_image_available_predicate(const glsl_type *type, unsigned flags)
type->sampled_type == GLSL_TYPE_FLOAT)
return shader_image_atomic_exchange_float;
+ if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_ADD) &&
+ type->sampled_type == GLSL_TYPE_FLOAT)
+ return shader_image_atomic_add_float;
+
else if (flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |
+ IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |
IMAGE_FUNCTION_AVAIL_ATOMIC))
return shader_image_atomic;