summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp9
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp10
-rw-r--r--src/shader_recompiler/shader_info.h3
3 files changed, 16 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index 6f769fa10..7b6c6d22b 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -110,9 +110,12 @@ void EmitContext::DefineHelperFunctions() {
code += "uint CasFloatMax16x2(uint op_a,f16vec2 op_b){return "
"packFloat2x16(max(unpackFloat2x16(op_a),op_b));}\n";
}
- // TODO: Track this usage
- code += "uint CasMinS32(uint op_a,uint op_b){return uint(min(int(op_a),int(op_b)));}";
- code += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}";
+ if (info.uses_atomic_s32_min) {
+ code += "uint CasMinS32(uint op_a,uint op_b){return uint(min(int(op_a),int(op_b)));}";
+ }
+ if (info.uses_atomic_s32_max) {
+ code += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}";
+ }
}
} // namespace Shader::Backend::GLSL
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
index fb2031fc8..c22e5992a 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -687,9 +687,7 @@ void VisitUsages(Info& info, IR::Inst& inst) {
case IR::Opcode::LoadStorage32:
case IR::Opcode::WriteStorage32:
case IR::Opcode::StorageAtomicIAdd32:
- case IR::Opcode::StorageAtomicSMin32:
case IR::Opcode::StorageAtomicUMin32:
- case IR::Opcode::StorageAtomicSMax32:
case IR::Opcode::StorageAtomicUMax32:
case IR::Opcode::StorageAtomicAnd32:
case IR::Opcode::StorageAtomicOr32:
@@ -759,6 +757,14 @@ void VisitUsages(Info& info, IR::Inst& inst) {
info.used_storage_buffer_types |= IR::Type::U32;
info.uses_atomic_f32x2_max = true;
break;
+ case IR::Opcode::StorageAtomicSMin32:
+ info.used_storage_buffer_types |= IR::Type::U32;
+ info.uses_atomic_s32_min = true;
+ break;
+ case IR::Opcode::StorageAtomicSMax32:
+ info.used_storage_buffer_types |= IR::Type::U32;
+ info.uses_atomic_s32_max = true;
+ break;
case IR::Opcode::GlobalAtomicIAdd64:
case IR::Opcode::GlobalAtomicSMin64:
case IR::Opcode::GlobalAtomicUMin64:
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h
index be05eafcf..9f7f0b42c 100644
--- a/src/shader_recompiler/shader_info.h
+++ b/src/shader_recompiler/shader_info.h
@@ -189,8 +189,9 @@ struct Info {
bool uses_atomic_f32x2_add{};
bool uses_atomic_f32x2_min{};
bool uses_atomic_f32x2_max{};
+ bool uses_atomic_s32_min{};
+ bool uses_atomic_s32_max{};
bool uses_int64_bit_atomics{};
- bool uses_s32_atomics{};
bool uses_global_memory{};
bool uses_atomic_image_u32{};