From 06128bdc212778f0471f65a421cf2a1df3616ff8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Feb 2017 09:07:30 +0000 Subject: glsl: correct compute shader checks for memoryBarrier functions As per the spec - "The functions memoryBarrierShared() and groupMemoryBarrier() are available only in compute shaders; the other functions are available in all shader types." Conform to this by adding another delegate to check for compute shader support instead of only whether the current stage is compute This allows some fragment shaders in Dirt Rally to compile Cc: "17.0" Reviewed-by: Anuj Phogat Reviewed-by: Kenneth Graunke (cherry picked from commit 21efe2528cd88cb09ba9f69222f69a8ee47611c9) --- src/compiler/glsl/builtin_functions.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 6d3b950572a..ac746368597 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -537,6 +537,12 @@ compute_shader(const _mesa_glsl_parse_state *state) return state->stage == MESA_SHADER_COMPUTE; } +static bool +compute_shader_supported(const _mesa_glsl_parse_state *state) +{ + return state->has_compute_shader(); +} + static bool buffer_atomics_supported(const _mesa_glsl_parse_state *state) { @@ -1098,15 +1104,15 @@ builtin_builder::create_intrinsics() ir_intrinsic_group_memory_barrier), NULL); add_function("__intrinsic_memory_barrier_atomic_counter", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_atomic_counter), NULL); add_function("__intrinsic_memory_barrier_buffer", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_buffer), NULL); add_function("__intrinsic_memory_barrier_image", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_image), NULL); add_function("__intrinsic_memory_barrier_shared", @@ -2958,15 +2964,15 @@ builtin_builder::create_builtins() NULL); add_function("memoryBarrierAtomicCounter", _memory_barrier("__intrinsic_memory_barrier_atomic_counter", - compute_shader), + compute_shader_supported), NULL); add_function("memoryBarrierBuffer", _memory_barrier("__intrinsic_memory_barrier_buffer", - compute_shader), + compute_shader_supported), NULL); add_function("memoryBarrierImage", _memory_barrier("__intrinsic_memory_barrier_image", - compute_shader), + compute_shader_supported), NULL); add_function("memoryBarrierShared", _memory_barrier("__intrinsic_memory_barrier_shared", -- cgit v1.2.3