summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-22 23:03:27 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commitac7b0ebcb77f6c99d054e9d10412e669eefa0de6 (patch)
tree322952f22d0c1cac6c4ae6423e73aeb124403498 /src/shader_recompiler/backend/glsl
parentglsl: FP function fixes (diff)
downloadyuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.gz
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.xz
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.zip
glsl: More FP fixes
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp15
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp10
2 files changed, 16 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index da379360a..67772c46d 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -48,11 +48,16 @@ void EmitContext::DefineStorageBuffers() {
48 } 48 }
49 u32 binding{}; 49 u32 binding{};
50 for (const auto& desc : info.storage_buffers_descriptors) { 50 for (const auto& desc : info.storage_buffers_descriptors) {
51 Add("layout(std430,binding={}) buffer ssbo_{}_u32{{uint ssbo{}_u32[];}};", binding, binding, 51 if (True(info.used_storage_buffer_types & IR::Type::U32) ||
52 desc.cbuf_index, desc.count); 52 True(info.used_storage_buffer_types & IR::Type::F32)) {
53 // TODO: Track ssbo data type usage 53 Add("layout(std430,binding={}) buffer ssbo_{}_u32{{uint ssbo{}_u32[];}};", binding,
54 Add("layout(std430,binding={}) buffer ssbo_{}_u64{{uvec2 ssbo{}_u64[];}};", binding, 54 binding, desc.cbuf_index, desc.count);
55 binding, desc.cbuf_index, desc.count); 55 }
56 if (True(info.used_storage_buffer_types & IR::Type::U32x2) ||
57 True(info.used_storage_buffer_types & IR::Type::F32x2)) {
58 Add("layout(std430,binding={}) buffer ssbo_{}_u64{{uvec2 ssbo{}_u64[];}};", binding,
59 binding, desc.cbuf_index, desc.count);
60 }
56 ++binding; 61 ++binding;
57 } 62 }
58} 63}
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
index 2aa9f2cd3..19a3c236d 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
@@ -161,12 +161,12 @@ void EmitFPSaturate16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
161 161
162void EmitFPSaturate32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 162void EmitFPSaturate32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
163 [[maybe_unused]] std::string_view value) { 163 [[maybe_unused]] std::string_view value) {
164 ctx.AddF32("{}=clamp({},0.0,1.0);", inst, value); 164 ctx.AddF32("{}=min(max({},0.0),1.0);", inst, value);
165} 165}
166 166
167void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 167void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
168 [[maybe_unused]] std::string_view value) { 168 [[maybe_unused]] std::string_view value) {
169 ctx.AddF64("{}=clamp({},0.0,1.0);", inst, value); 169 ctx.AddF64("{}=min(max({},0.0),1.0);", inst, value);
170} 170}
171 171
172void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 172void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@@ -180,14 +180,16 @@ void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst&
180 [[maybe_unused]] std::string_view value, 180 [[maybe_unused]] std::string_view value,
181 [[maybe_unused]] std::string_view min_value, 181 [[maybe_unused]] std::string_view min_value,
182 [[maybe_unused]] std::string_view max_value) { 182 [[maybe_unused]] std::string_view max_value) {
183 ctx.AddF32("{}=clamp({},float({}),float({}));", inst, value, min_value, max_value); 183 // GLSL's clamp does not produce desirable results
184 ctx.AddF32("{}=min(max({},float({})),float({}));", inst, value, min_value, max_value);
184} 185}
185 186
186void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 187void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
187 [[maybe_unused]] std::string_view value, 188 [[maybe_unused]] std::string_view value,
188 [[maybe_unused]] std::string_view min_value, 189 [[maybe_unused]] std::string_view min_value,
189 [[maybe_unused]] std::string_view max_value) { 190 [[maybe_unused]] std::string_view max_value) {
190 ctx.AddF64("{}=clamp({},double({}),double({}));", inst, value, min_value, max_value); 191 // GLSL's clamp does not produce desirable results
192 ctx.AddF64("{}=min(max({},double({})),double({}));", inst, value, min_value, max_value);
191} 193}
192 194
193void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 195void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,