summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp10
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_instructions.h8
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_logical.cpp29
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp16
-rw-r--r--src/shader_recompiler/backend/glsl/reg_alloc.cpp6
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
34void EmitFPAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 34void 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
39void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 39void 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
44void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 44void 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
186void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 186void 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
193void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 193void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@@ -259,7 +259,7 @@ void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
259void EmitFPOrdEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 259void 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
265void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 265void 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);
525void EmitGlobalAtomicMinF32x2(EmitContext& ctx); 525void EmitGlobalAtomicMinF32x2(EmitContext& ctx);
526void EmitGlobalAtomicMaxF16x2(EmitContext& ctx); 526void EmitGlobalAtomicMaxF16x2(EmitContext& ctx);
527void EmitGlobalAtomicMaxF32x2(EmitContext& ctx); 527void EmitGlobalAtomicMaxF32x2(EmitContext& ctx);
528void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b); 528void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
529void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b); 529void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
530void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b); 530void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
531void EmitLogicalNot(EmitContext& ctx, std::string_view value); 531void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, std::string_view value);
532void EmitConvertS16F16(EmitContext& ctx, IR::Inst& inst, std::string_view value); 532void EmitConvertS16F16(EmitContext& ctx, IR::Inst& inst, std::string_view value);
533void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value); 533void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
534void EmitConvertS16F64(EmitContext& ctx, IR::Inst& inst, std::string_view value); 534void 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
12namespace Shader::Backend::GLSL {
13
14void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
15 ctx.AddU1("{}={}||{};", inst, a, b);
16}
17
18void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
19 ctx.AddU1("{}={}&&{};", inst, a, b);
20}
21
22void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
23 ctx.AddU1("{}={}^^{};", inst, a, b);
24}
25
26void 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
693void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b) {
694 NotImplemented();
695}
696
697void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b) {
698 NotImplemented();
699}
700
701void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b) {
702 NotImplemented();
703}
704
705void EmitLogicalNot(EmitContext& ctx, std::string_view value) {
706 NotImplemented();
707}
708
709void EmitBindlessImageSampleImplicitLod(EmitContext&) { 693void 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: