summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2021-01-16 01:10:24 -0500
committerMarge Bot <eric+marge@anholt.net>2021-01-16 18:21:03 +0000
commita0f4affcf64cfd13a27f1e3cc24f98ef220b691b (patch)
treedf753af4bc72f99377fac78121b78dbe07bcf695
parent6638b58ccf17ce3a00a8ecbf5f39b5bedef238ed (diff)
glsl: only expose int64 atomics when extension is enabled
This limits the exposure of these functions to when the extension is available. Prevents crashes otherwise, as the rest of the infrastructure doesn't necessarily expect these functions when the extension is not available. Fixes: 40c1f9883e5 ("mesa,glsl: add support for GL_NV_shader_atomic_int64") Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8533>
-rw-r--r--src/compiler/glsl/builtin_functions.cpp59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index b8e3f2b780b..86ad82ba27e 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -765,6 +765,13 @@ buffer_atomics_supported(const _mesa_glsl_parse_state *state)
}
static bool
+buffer_int64_atomics_supported(const _mesa_glsl_parse_state *state)
+{
+ return state->NV_shader_atomic_int64_enable &&
+ buffer_atomics_supported(state);
+}
+
+static bool
barrier_supported(const _mesa_glsl_parse_state *state)
{
return compute_shader(state) ||
@@ -1368,7 +1375,7 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(NV_shader_atomic_float_supported,
glsl_type::float_type,
ir_intrinsic_generic_atomic_add),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_add),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1384,10 +1391,10 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
glsl_type::float_type,
ir_intrinsic_generic_atomic_min),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::uint64_t_type,
ir_intrinsic_generic_atomic_min),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_min),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1403,10 +1410,10 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
glsl_type::float_type,
ir_intrinsic_generic_atomic_max),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::uint64_t_type,
ir_intrinsic_generic_atomic_max),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_max),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1419,10 +1426,10 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_and),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::uint64_t_type,
ir_intrinsic_generic_atomic_and),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_and),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1435,10 +1442,10 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_or),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::uint64_t_type,
ir_intrinsic_generic_atomic_or),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_or),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1451,10 +1458,10 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_xor),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::uint64_t_type,
ir_intrinsic_generic_atomic_xor),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_xor),
_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
@@ -1467,7 +1474,7 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_exchange),
- _atomic_intrinsic2(buffer_atomics_supported,
+ _atomic_intrinsic2(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_exchange),
_atomic_intrinsic2(NV_shader_atomic_float_supported,
@@ -1483,7 +1490,7 @@ builtin_builder::create_intrinsics()
_atomic_intrinsic3(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_comp_swap),
- _atomic_intrinsic3(buffer_atomics_supported,
+ _atomic_intrinsic3(buffer_int64_atomics_supported,
glsl_type::int64_t_type,
ir_intrinsic_generic_atomic_comp_swap),
_atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported,
@@ -4103,7 +4110,7 @@ builtin_builder::create_builtins()
shader_atomic_float_add,
glsl_type::float_type),
_atomic_op2("__intrinsic_atomic_add",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicMin",
@@ -4117,10 +4124,10 @@ builtin_builder::create_builtins()
shader_atomic_float_minmax,
glsl_type::float_type),
_atomic_op2("__intrinsic_atomic_min",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::uint64_t_type),
_atomic_op2("__intrinsic_atomic_min",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicMax",
@@ -4134,10 +4141,10 @@ builtin_builder::create_builtins()
shader_atomic_float_minmax,
glsl_type::float_type),
_atomic_op2("__intrinsic_atomic_max",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::uint64_t_type),
_atomic_op2("__intrinsic_atomic_max",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicAnd",
@@ -4148,10 +4155,10 @@ builtin_builder::create_builtins()
buffer_atomics_supported,
glsl_type::int_type),
_atomic_op2("__intrinsic_atomic_and",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::uint64_t_type),
_atomic_op2("__intrinsic_atomic_and",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicOr",
@@ -4162,10 +4169,10 @@ builtin_builder::create_builtins()
buffer_atomics_supported,
glsl_type::int_type),
_atomic_op2("__intrinsic_atomic_or",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::uint64_t_type),
_atomic_op2("__intrinsic_atomic_or",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicXor",
@@ -4176,10 +4183,10 @@ builtin_builder::create_builtins()
buffer_atomics_supported,
glsl_type::int_type),
_atomic_op2("__intrinsic_atomic_xor",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::uint64_t_type),
_atomic_op2("__intrinsic_atomic_xor",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
NULL);
add_function("atomicExchange",
@@ -4190,7 +4197,7 @@ builtin_builder::create_builtins()
buffer_atomics_supported,
glsl_type::int_type),
_atomic_op2("__intrinsic_atomic_exchange",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
_atomic_op2("__intrinsic_atomic_exchange",
shader_atomic_float_exchange,
@@ -4204,7 +4211,7 @@ builtin_builder::create_builtins()
buffer_atomics_supported,
glsl_type::int_type),
_atomic_op3("__intrinsic_atomic_comp_swap",
- buffer_atomics_supported,
+ buffer_int64_atomics_supported,
glsl_type::int64_t_type),
_atomic_op3("__intrinsic_atomic_comp_swap",
shader_atomic_float_minmax,