glsl: Track S32 atomics

This commit is contained in:
ameerj 2021-05-25 22:13:50 -04:00
parent b95716e543
commit 5399906c26
3 changed files with 16 additions and 6 deletions

View File

@ -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
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

View File

@ -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:

View File

@ -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{};