diff options
4 files changed, 14 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index d1c58cefc..e48f152d0 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -146,7 +146,6 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) { | |||
| 146 | std::string EmitGLSL(const Profile& profile, const RuntimeInfo&, IR::Program& program, | 146 | std::string EmitGLSL(const Profile& profile, const RuntimeInfo&, IR::Program& program, |
| 147 | Bindings& bindings) { | 147 | Bindings& bindings) { |
| 148 | EmitContext ctx{program, bindings, profile}; | 148 | EmitContext ctx{program, bindings, profile}; |
| 149 | // ctx.SetupBuffers(); | ||
| 150 | EmitCode(ctx, program); | 149 | EmitCode(ctx, program); |
| 151 | ctx.code += "}"; | 150 | ctx.code += "}"; |
| 152 | return ctx.code; | 151 | return ctx.code; |
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 19a3c236d..e8c828e7c 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp | |||
| @@ -101,12 +101,12 @@ void EmitFPNeg16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& i | |||
| 101 | 101 | ||
| 102 | void EmitFPNeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 102 | void EmitFPNeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 103 | [[maybe_unused]] std::string_view value) { | 103 | [[maybe_unused]] std::string_view value) { |
| 104 | ctx.AddF32("{}=-{};", inst, value); | 104 | ctx.AddF32("{}=-({});", inst, value); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | void EmitFPNeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 107 | void EmitFPNeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 108 | [[maybe_unused]] std::string_view value) { | 108 | [[maybe_unused]] std::string_view value) { |
| 109 | ctx.AddF64("{}=-{};", inst, value); | 109 | ctx.AddF64("{}=-({});", inst, value); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | void EmitFPSin([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 112 | void EmitFPSin([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index 083d81ccb..681bc1bfa 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | |||
| @@ -31,11 +31,11 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | 33 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { |
| 34 | ctx.AddU32("{}=-{};", inst, value); | 34 | ctx.AddU32("{}=-({});", inst, value); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | 37 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { |
| 38 | ctx.AddU64("{}=-{};", inst, value); | 38 | ctx.AddU64("{}=-({});", inst, value); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | 41 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { |
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.cpp b/src/shader_recompiler/backend/glsl/reg_alloc.cpp index 73295a1e5..007f8c89d 100644 --- a/src/shader_recompiler/backend/glsl/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glsl/reg_alloc.cpp | |||
| @@ -10,10 +10,9 @@ | |||
| 10 | #include "shader_recompiler/backend/glsl/reg_alloc.h" | 10 | #include "shader_recompiler/backend/glsl/reg_alloc.h" |
| 11 | #include "shader_recompiler/exception.h" | 11 | #include "shader_recompiler/exception.h" |
| 12 | #include "shader_recompiler/frontend/ir/value.h" | 12 | #include "shader_recompiler/frontend/ir/value.h" |
| 13 | #pragma optimize("", off) | 13 | |
| 14 | namespace Shader::Backend::GLSL { | 14 | namespace Shader::Backend::GLSL { |
| 15 | namespace { | 15 | namespace { |
| 16 | |||
| 17 | std::string Representation(Id id) { | 16 | std::string Representation(Id id) { |
| 18 | if (id.is_condition_code != 0) { | 17 | if (id.is_condition_code != 0) { |
| 19 | throw NotImplementedException("Condition code"); | 18 | throw NotImplementedException("Condition code"); |
| @@ -25,6 +24,13 @@ std::string Representation(Id id) { | |||
| 25 | return fmt::format("R{}", index); | 24 | return fmt::format("R{}", index); |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 27 | std::string FormatFloat(std::string_view value, IR::Type type) { | ||
| 28 | const bool needs_dot = value.find_first_of('.') == std::string_view::npos; | ||
| 29 | const bool needs_suffix = !value.ends_with('f'); | ||
| 30 | const auto suffix = type == IR::Type::F32 ? "f" : "lf"; | ||
| 31 | return fmt::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : ""); | ||
| 32 | } | ||
| 33 | |||
| 28 | std::string MakeImm(const IR::Value& value) { | 34 | std::string MakeImm(const IR::Value& value) { |
| 29 | switch (value.Type()) { | 35 | switch (value.Type()) { |
| 30 | case IR::Type::U1: | 36 | case IR::Type::U1: |
| @@ -32,11 +38,11 @@ std::string MakeImm(const IR::Value& value) { | |||
| 32 | case IR::Type::U32: | 38 | case IR::Type::U32: |
| 33 | return fmt::format("{}u", value.U32()); | 39 | return fmt::format("{}u", value.U32()); |
| 34 | case IR::Type::F32: | 40 | case IR::Type::F32: |
| 35 | return fmt::format("{}f", value.F32()); | 41 | return FormatFloat(fmt::format("{}", value.F32()), IR::Type::F32); |
| 36 | case IR::Type::U64: | 42 | case IR::Type::U64: |
| 37 | return fmt::format("{}ul", value.U64()); | 43 | return fmt::format("{}ul", value.U64()); |
| 38 | case IR::Type::F64: | 44 | case IR::Type::F64: |
| 39 | return fmt::format("{}lf", value.F64()); | 45 | return FormatFloat(fmt::format("{}", value.F64()), IR::Type::F64); |
| 40 | default: | 46 | default: |
| 41 | throw NotImplementedException("Immediate type {}", value.Type()); | 47 | throw NotImplementedException("Immediate type {}", value.Type()); |
| 42 | } | 48 | } |