diff options
| author | 2021-05-22 02:32:57 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | 65c6f73e436ba3116030277a7a8bcb563f9554e2 (patch) | |
| tree | 379f8ed7647aa543e54ef953cc39d761b85c192e /src/shader_recompiler | |
| parent | glsl: Add many FP32/64 instructions (diff) | |
| download | yuzu-65c6f73e436ba3116030277a7a8bcb563f9554e2.tar.gz yuzu-65c6f73e436ba3116030277a7a8bcb563f9554e2.tar.xz yuzu-65c6f73e436ba3116030277a7a8bcb563f9554e2.zip | |
glsl: More FP instructions/fixes
Diffstat (limited to 'src/shader_recompiler')
5 files changed, 41 insertions, 28 deletions
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 bea7600af..3f3a83b20 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp | |||
| @@ -33,12 +33,12 @@ void EmitFPAdd16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& i | |||
| 33 | 33 | ||
| 34 | void EmitFPAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 34 | void EmitFPAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 35 | [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { | 35 | [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { |
| 36 | ctx.AddF32("{}={}+{};", inst, a, b); | 36 | ctx.AddF32("{}=float({})+float({});", inst, a, b); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 39 | void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 40 | [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { | 40 | [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { |
| 41 | ctx.AddF64("{}={}+{};", inst, a, b); | 41 | ctx.AddF64("{}=double({})+double({});", inst, a, b); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 44 | void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| @@ -180,14 +180,14 @@ 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({},{},{});", inst, value, min_value, max_value); | 183 | ctx.AddF32("{}=clamp({},float({}),float({}));", inst, value, min_value, max_value); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 186 | void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 187 | [[maybe_unused]] std::string_view value, | 187 | [[maybe_unused]] std::string_view value, |
| 188 | [[maybe_unused]] std::string_view min_value, | 188 | [[maybe_unused]] std::string_view min_value, |
| 189 | [[maybe_unused]] std::string_view max_value) { | 189 | [[maybe_unused]] std::string_view max_value) { |
| 190 | ctx.AddF64("{}=clamp({},{},{});", inst, value, min_value, max_value); | 190 | ctx.AddF64("{}=clamp({},double({}),double({}));", inst, value, min_value, max_value); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 193 | void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| @@ -259,7 +259,7 @@ void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In | |||
| 259 | void EmitFPOrdEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 259 | void EmitFPOrdEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 260 | [[maybe_unused]] std::string_view lhs, | 260 | [[maybe_unused]] std::string_view lhs, |
| 261 | [[maybe_unused]] std::string_view rhs) { | 261 | [[maybe_unused]] std::string_view rhs) { |
| 262 | throw NotImplementedException("GLSL"); | 262 | ctx.AddU1("{}={}=={};", inst, lhs, rhs); |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 265 | void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 49993dc5c..efa515a3c 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -525,10 +525,10 @@ void EmitGlobalAtomicMinF16x2(EmitContext& ctx); | |||
| 525 | void EmitGlobalAtomicMinF32x2(EmitContext& ctx); | 525 | void EmitGlobalAtomicMinF32x2(EmitContext& ctx); |
| 526 | void EmitGlobalAtomicMaxF16x2(EmitContext& ctx); | 526 | void EmitGlobalAtomicMaxF16x2(EmitContext& ctx); |
| 527 | void EmitGlobalAtomicMaxF32x2(EmitContext& ctx); | 527 | void EmitGlobalAtomicMaxF32x2(EmitContext& ctx); |
| 528 | void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b); | 528 | void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 529 | void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b); | 529 | void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 530 | void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b); | 530 | void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 531 | void EmitLogicalNot(EmitContext& ctx, std::string_view value); | 531 | void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 532 | void EmitConvertS16F16(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 532 | void EmitConvertS16F16(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 533 | void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 533 | void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 534 | void EmitConvertS16F64(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 534 | void EmitConvertS16F64(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_logical.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_logical.cpp index e69de29bb..e4781c03c 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_logical.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_logical.cpp | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <string_view> | ||
| 6 | |||
| 7 | #include "shader_recompiler/backend/glsl/emit_context.h" | ||
| 8 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | ||
| 9 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 10 | #include "shader_recompiler/profile.h" | ||
| 11 | |||
| 12 | namespace Shader::Backend::GLSL { | ||
| 13 | |||
| 14 | void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 15 | ctx.AddU1("{}={}||{};", inst, a, b); | ||
| 16 | } | ||
| 17 | |||
| 18 | void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 19 | ctx.AddU1("{}={}&&{};", inst, a, b); | ||
| 20 | } | ||
| 21 | |||
| 22 | void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 23 | ctx.AddU1("{}={}^^{};", inst, a, b); | ||
| 24 | } | ||
| 25 | |||
| 26 | void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 27 | ctx.AddU1("{}=!{};", inst, value); | ||
| 28 | } | ||
| 29 | } // namespace Shader::Backend::GLSL | ||
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp index 23f8730ca..cb6562ebf 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp | |||
| @@ -690,22 +690,6 @@ void EmitGlobalAtomicMaxF32x2(EmitContext& ctx) { | |||
| 690 | NotImplemented(); | 690 | NotImplemented(); |
| 691 | } | 691 | } |
| 692 | 692 | ||
| 693 | void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b) { | ||
| 694 | NotImplemented(); | ||
| 695 | } | ||
| 696 | |||
| 697 | void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b) { | ||
| 698 | NotImplemented(); | ||
| 699 | } | ||
| 700 | |||
| 701 | void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b) { | ||
| 702 | NotImplemented(); | ||
| 703 | } | ||
| 704 | |||
| 705 | void EmitLogicalNot(EmitContext& ctx, std::string_view value) { | ||
| 706 | NotImplemented(); | ||
| 707 | } | ||
| 708 | |||
| 709 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | 693 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| 710 | NotImplemented(); | 694 | NotImplemented(); |
| 711 | } | 695 | } |
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.cpp b/src/shader_recompiler/backend/glsl/reg_alloc.cpp index 039236689..c370aabb5 100644 --- a/src/shader_recompiler/backend/glsl/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glsl/reg_alloc.cpp | |||
| @@ -30,11 +30,11 @@ std::string MakeImm(const IR::Value& value) { | |||
| 30 | case IR::Type::U1: | 30 | case IR::Type::U1: |
| 31 | return fmt::format("{}", value.U1() ? "true" : "false"); | 31 | return fmt::format("{}", value.U1() ? "true" : "false"); |
| 32 | case IR::Type::U32: | 32 | case IR::Type::U32: |
| 33 | return fmt::format("{}", value.U32()); | 33 | return fmt::format("{}u", value.U32()); |
| 34 | case IR::Type::F32: | 34 | case IR::Type::F32: |
| 35 | return fmt::format("{}", value.F32()); | 35 | return fmt::format("{}f", value.F32()); |
| 36 | case IR::Type::U64: | 36 | case IR::Type::U64: |
| 37 | return fmt::format("{}", value.U64()); | 37 | return fmt::format("{}ul", value.U64()); |
| 38 | case IR::Type::F64: | 38 | case IR::Type::F64: |
| 39 | return fmt::format("{}", value.F64()); | 39 | return fmt::format("{}", value.F64()); |
| 40 | default: | 40 | default: |