From fc0a2e5d017dcb9e7f236d69745dff89e116b92e Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 12 Jul 2019 16:38:44 +0200 Subject: [PATCH] glsl: add EXT_shader_image_load_store new image functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This extension has 2 functions that are missing from the ARB versions: - imageAtomicIncWrap - imageAtomicDecWrap Reviewed-by: Marek Olšák --- src/compiler/glsl/builtin_functions.cpp | 12 ++++++++++++ src/compiler/glsl/ir.h | 2 ++ src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 095eb84055a..95d45033a01 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -4423,6 +4423,18 @@ builtin_builder::add_image_functions(bool glsl) flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | IMAGE_FUNCTION_MS_ONLY, ir_intrinsic_image_samples); + + /* EXT_shader_image_load_store */ + add_image_function(glsl ? "imageAtomicIncWrap" : "__intrinsic_image_atomic_inc_wrap", + "__intrinsic_image_atomic_inc_wrap", + &builtin_builder::_image_prototype, 1, + (atom_flags | IMAGE_FUNCTION_EXT_ONLY), + ir_intrinsic_image_atomic_inc_wrap); + add_image_function(glsl ? "imageAtomicDecWrap" : "__intrinsic_image_atomic_dec_wrap", + "__intrinsic_image_atomic_dec_wrap", + &builtin_builder::_image_prototype, 1, + (atom_flags | IMAGE_FUNCTION_EXT_ONLY), + ir_intrinsic_image_atomic_dec_wrap); } ir_variable * diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 6f7b4542b1d..441500ec31e 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -1106,6 +1106,8 @@ enum ir_intrinsic_id { ir_intrinsic_image_atomic_comp_swap, ir_intrinsic_image_size, ir_intrinsic_image_samples, + ir_intrinsic_image_atomic_inc_wrap, + ir_intrinsic_image_atomic_dec_wrap, ir_intrinsic_ssbo_load, ir_intrinsic_ssbo_store = MAKE_INTRINSIC_FOR_TYPE(store, ssbo), diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index ad5c2f5e623..ff2ec0726e8 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3938,6 +3938,12 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir) case ir_intrinsic_image_atomic_comp_swap: opcode = TGSI_OPCODE_ATOMCAS; break; + case ir_intrinsic_image_atomic_inc_wrap: + opcode = TGSI_OPCODE_ATOMINC_WRAP; + break; + case ir_intrinsic_image_atomic_dec_wrap: + opcode = TGSI_OPCODE_ATOMDEC_WRAP; + break; default: assert(!"Unexpected intrinsic"); return; @@ -4063,6 +4069,8 @@ glsl_to_tgsi_visitor::visit(ir_call *ir) case ir_intrinsic_image_atomic_comp_swap: case ir_intrinsic_image_size: case ir_intrinsic_image_samples: + case ir_intrinsic_image_atomic_inc_wrap: + case ir_intrinsic_image_atomic_dec_wrap: visit_image_intrinsic(ir); return; -- 2.30.2