summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.h1
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_image.cpp3
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp19
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp16
4 files changed, 19 insertions, 20 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h
index c9d629c40..7ae7c8766 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.h
+++ b/src/shader_recompiler/backend/glsl/emit_context.h
@@ -135,6 +135,7 @@ public:
135 std::vector<u32> image_bindings; 135 std::vector<u32> image_bindings;
136 136
137 bool uses_y_direction{}; 137 bool uses_y_direction{};
138 bool uses_cc_carry{};
138 139
139private: 140private:
140 void SetupExtensions(std::string& header); 141 void SetupExtensions(std::string& header);
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
index 9213375b4..d1f7c5d91 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
@@ -234,9 +234,6 @@ void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Ins
234 const auto texture{Texture(ctx, info, index)}; 234 const auto texture{Texture(ctx, info, index)};
235 const auto texel{ctx.reg_alloc.Define(inst, Type::F32x4)}; 235 const auto texel{ctx.reg_alloc.Define(inst, Type::F32x4)};
236 const auto sparse_inst{PrepareSparse(inst)}; 236 const auto sparse_inst{PrepareSparse(inst)};
237 if (!offset2.IsEmpty()) {
238 ctx.Add("/*OFFSET 2 IS {}*/", ctx.reg_alloc.Consume(offset2));
239 }
240 if (!sparse_inst) { 237 if (!sparse_inst) {
241 if (offset.IsEmpty()) { 238 if (offset.IsEmpty()) {
242 ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords, 239 ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords,
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
index 73ceb06d9..4a3d66c90 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
@@ -31,6 +31,7 @@ void SetSignFlag(EmitContext& ctx, IR::Inst& inst, std::string_view result) {
31void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 31void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
32 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 32 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
33 if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) { 33 if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) {
34 ctx.uses_cc_carry = true;
34 ctx.Add("{}=uaddCarry({},{},carry);", result, a, b); 35 ctx.Add("{}=uaddCarry({},{},carry);", result, a, b);
35 ctx.AddU1("{}=carry!=0;", *carry, result); 36 ctx.AddU1("{}=carry!=0;", *carry, result);
36 carry->Invalidate(); 37 carry->Invalidate();
@@ -61,11 +62,11 @@ void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin
61} 62}
62 63
63void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 64void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
64 ctx.AddU32("{}={}*{};", inst, a, b); 65 ctx.AddU32("{}=uint({}*{});", inst, a, b);
65} 66}
66 67
67void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 68void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
68 ctx.AddU32("{}=-({});", inst, value); 69 ctx.AddU32("{}=uint(-({}));", inst, value);
69} 70}
70 71
71void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 72void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
@@ -124,7 +125,7 @@ void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std:
124 125
125void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base, 126void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
126 std::string_view insert, std::string_view offset, std::string_view count) { 127 std::string_view insert, std::string_view offset, std::string_view count) {
127 ctx.AddU32("{}=bitfieldInsert({}, {}, int({}), int({}));", inst, base, insert, offset, count); 128 ctx.AddU32("{}=bitfieldInsert({},{},int({}),int({}));", inst, base, insert, offset, count);
128} 129}
129 130
130void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 131void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
@@ -166,25 +167,25 @@ void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst
166} 167}
167 168
168void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 169void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
169 ctx.AddU32("{}=min(int({}), int({}));", inst, a, b); 170 ctx.AddU32("{}=min(int({}),int({}));", inst, a, b);
170} 171}
171 172
172void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 173void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
173 ctx.AddU32("{}=min(uint({}), uint({}));", inst, a, b); 174 ctx.AddU32("{}=min(uint({}),uint({}));", inst, a, b);
174} 175}
175 176
176void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 177void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
177 ctx.AddU32("{}=max(int({}), int({}));", inst, a, b); 178 ctx.AddU32("{}=max(int({}),int({}));", inst, a, b);
178} 179}
179 180
180void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 181void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
181 ctx.AddU32("{}=max(uint({}), uint({}));", inst, a, b); 182 ctx.AddU32("{}=max(uint({}),uint({}));", inst, a, b);
182} 183}
183 184
184void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 185void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
185 std::string_view max) { 186 std::string_view max) {
186 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 187 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
187 ctx.Add("{}=clamp(int({}), int({}), int({}));", result, value, min, max); 188 ctx.Add("{}=clamp(int({}),int({}),int({}));", result, value, min, max);
188 SetZeroFlag(ctx, inst, result); 189 SetZeroFlag(ctx, inst, result);
189 SetSignFlag(ctx, inst, result); 190 SetSignFlag(ctx, inst, result);
190} 191}
@@ -192,7 +193,7 @@ void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std:
192void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 193void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
193 std::string_view max) { 194 std::string_view max) {
194 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 195 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
195 ctx.Add("{}=clamp(uint({}), uint({}), uint({}));", result, value, min, max); 196 ctx.Add("{}=clamp(uint({}),uint({}),uint({}));", result, value, min, max);
196 SetZeroFlag(ctx, inst, result); 197 SetZeroFlag(ctx, inst, result);
197 SetSignFlag(ctx, inst, result); 198 SetSignFlag(ctx, inst, result);
198} 199}
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
index 0450a7c21..c66b7b788 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
@@ -50,16 +50,16 @@ void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindin
50void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 50void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
51 const IR::Value& offset) { 51 const IR::Value& offset) {
52 const auto offset_var{ctx.reg_alloc.Consume(offset)}; 52 const auto offset_var{ctx.reg_alloc.Consume(offset)};
53 ctx.AddU32x2("{}=uvec2(ssbo{}[{}/4],ssbo{}[{}/4+1]);", inst, binding.U32(), offset_var, 53 ctx.AddU32x2("{}=uvec2(ssbo{}[{}/4],ssbo{}[({}+4)/4]);", inst, binding.U32(), offset_var,
54 binding.U32(), offset_var); 54 binding.U32(), offset_var);
55} 55}
56 56
57void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 57void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
58 const IR::Value& offset) { 58 const IR::Value& offset) {
59 const auto offset_var{ctx.reg_alloc.Consume(offset)}; 59 const auto offset_var{ctx.reg_alloc.Consume(offset)};
60 ctx.AddU32x4("{}=uvec4(ssbo{}[{}/4],ssbo{}[{}/4+1],ssbo{}[{}/4+2],ssbo{}[{}/4+3]);", inst, 60 ctx.AddU32x4("{}=uvec4(ssbo{}[{}/4],ssbo{}[({}+4)/4],ssbo{}[({}+8)/4],ssbo{}[({}+12)/4]);",
61 binding.U32(), offset_var, binding.U32(), offset_var, binding.U32(), offset_var, 61 inst, binding.U32(), offset_var, binding.U32(), offset_var, binding.U32(),
62 binding.U32(), offset_var); 62 offset_var, binding.U32(), offset_var);
63} 63}
64 64
65void EmitWriteStorageU8([[maybe_unused]] EmitContext& ctx, 65void EmitWriteStorageU8([[maybe_unused]] EmitContext& ctx,
@@ -108,7 +108,7 @@ void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, const IR::Va
108 std::string_view value) { 108 std::string_view value) {
109 const auto offset_var{ctx.reg_alloc.Consume(offset)}; 109 const auto offset_var{ctx.reg_alloc.Consume(offset)};
110 ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value); 110 ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
111 ctx.Add("ssbo{}[({}/4)+1]={}.y;", binding.U32(), offset_var, value); 111 ctx.Add("ssbo{}[({}+4)/4]={}.y;", binding.U32(), offset_var, value);
112} 112}
113 113
114void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx, 114void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx,
@@ -117,8 +117,8 @@ void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx,
117 [[maybe_unused]] std::string_view value) { 117 [[maybe_unused]] std::string_view value) {
118 const auto offset_var{ctx.reg_alloc.Consume(offset)}; 118 const auto offset_var{ctx.reg_alloc.Consume(offset)};
119 ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value); 119 ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
120 ctx.Add("ssbo{}[({}/4)+1]={}.y;", binding.U32(), offset_var, value); 120 ctx.Add("ssbo{}[({}+4)/4]={}.y;", binding.U32(), offset_var, value);
121 ctx.Add("ssbo{}[({}/4)+2]={}.z;", binding.U32(), offset_var, value); 121 ctx.Add("ssbo{}[({}+8)/4]={}.z;", binding.U32(), offset_var, value);
122 ctx.Add("ssbo{}[({}/4)+3]={}.w;", binding.U32(), offset_var, value); 122 ctx.Add("ssbo{}[({}+12)/4]={}.w;", binding.U32(), offset_var, value);
123} 123}
124} // namespace Shader::Backend::GLSL 124} // namespace Shader::Backend::GLSL