summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-23 05:31:30 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:36 +0200
commitcdde7302196d6642724d36e8ed5a523dce702b6b (patch)
tree2700fc87a4762486b84cc73d783542d97bb6a96a /src/shader_recompiler/backend
parentglsl: More FP fixes (diff)
downloadyuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar.gz
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar.bz2
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar.lz
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar.xz
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.tar.zst
yuzu-cdde7302196d6642724d36e8ed5a523dce702b6b.zip
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl.cpp1
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp4
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp4
-rw-r--r--src/shader_recompiler/backend/glsl/reg_alloc.cpp14
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) {
std::string EmitGLSL(const Profile& profile, const RuntimeInfo&, IR::Program& program,
Bindings& bindings) {
EmitContext ctx{program, bindings, profile};
- // ctx.SetupBuffers();
EmitCode(ctx, program);
ctx.code += "}";
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
void EmitFPNeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
- ctx.AddF32("{}=-{};", inst, value);
+ ctx.AddF32("{}=-({});", inst, value);
}
void EmitFPNeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
- ctx.AddF64("{}=-{};", inst, value);
+ ctx.AddF64("{}=-({});", inst, value);
}
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
}
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
- ctx.AddU32("{}=-{};", inst, value);
+ ctx.AddU32("{}=-({});", inst, value);
}
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
- ctx.AddU64("{}=-{};", inst, value);
+ ctx.AddU64("{}=-({});", inst, value);
}
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 @@
#include "shader_recompiler/backend/glsl/reg_alloc.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/ir/value.h"
-#pragma optimize("", off)
+
namespace Shader::Backend::GLSL {
namespace {
-
std::string Representation(Id id) {
if (id.is_condition_code != 0) {
throw NotImplementedException("Condition code");
@@ -25,6 +24,13 @@ std::string Representation(Id id) {
return fmt::format("R{}", index);
}
+std::string FormatFloat(std::string_view value, IR::Type type) {
+ const bool needs_dot = value.find_first_of('.') == std::string_view::npos;
+ const bool needs_suffix = !value.ends_with('f');
+ const auto suffix = type == IR::Type::F32 ? "f" : "lf";
+ return fmt::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : "");
+}
+
std::string MakeImm(const IR::Value& value) {
switch (value.Type()) {
case IR::Type::U1:
@@ -32,11 +38,11 @@ std::string MakeImm(const IR::Value& value) {
case IR::Type::U32:
return fmt::format("{}u", value.U32());
case IR::Type::F32:
- return fmt::format("{}f", value.F32());
+ return FormatFloat(fmt::format("{}", value.F32()), IR::Type::F32);
case IR::Type::U64:
return fmt::format("{}ul", value.U64());
case IR::Type::F64:
- return fmt::format("{}lf", value.F64());
+ return FormatFloat(fmt::format("{}", value.F64()), IR::Type::F64);
default:
throw NotImplementedException("Immediate type {}", value.Type());
}