summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
index bfc42e1b4..7b57c1e91 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
@@ -83,7 +83,6 @@ void Invoke(EmitContext& ctx, IR::Inst* inst) {
83} 83}
84 84
85void EmitInst(EmitContext& ctx, IR::Inst* inst) { 85void EmitInst(EmitContext& ctx, IR::Inst* inst) {
86 // ctx.Add("/* $ {} $ */", inst->GetOpcode());
87 switch (inst->GetOpcode()) { 86 switch (inst->GetOpcode()) {
88#define OPCODE(name, result_type, ...) \ 87#define OPCODE(name, result_type, ...) \
89 case IR::Opcode::name: \ 88 case IR::Opcode::name: \
@@ -134,7 +133,7 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
134 } 133 }
135 break; 134 break;
136 case IR::AbstractSyntaxNode::Type::If: 135 case IR::AbstractSyntaxNode::Type::If:
137 ctx.Add("if ({}){{", ctx.var_alloc.Consume(node.data.if_node.cond)); 136 ctx.Add("if({}){{", ctx.var_alloc.Consume(node.data.if_node.cond));
138 break; 137 break;
139 case IR::AbstractSyntaxNode::Type::EndIf: 138 case IR::AbstractSyntaxNode::Type::EndIf:
140 ctx.Add("}}"); 139 ctx.Add("}}");
@@ -156,12 +155,10 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
156 ctx.Add("for(;;){{"); 155 ctx.Add("for(;;){{");
157 break; 156 break;
158 case IR::AbstractSyntaxNode::Type::Repeat: 157 case IR::AbstractSyntaxNode::Type::Repeat:
159 ctx.Add("if({}){{", ctx.var_alloc.Consume(node.data.repeat.cond)); 158 ctx.Add("if({}){{continue;}}else{{break;}}}}",
160 ctx.Add("continue;\n}}else{{"); 159 ctx.var_alloc.Consume(node.data.repeat.cond));
161 ctx.Add("break;\n}}\n}}");
162 break; 160 break;
163 default: 161 default:
164 fmt::print("{}", node.type);
165 throw NotImplementedException("AbstractSyntaxNode::Type {}", node.type); 162 throw NotImplementedException("AbstractSyntaxNode::Type {}", node.type);
166 break; 163 break;
167 } 164 }
@@ -200,7 +197,7 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR
200 EmitContext ctx{program, bindings, profile, runtime_info}; 197 EmitContext ctx{program, bindings, profile, runtime_info};
201 Precolor(program); 198 Precolor(program);
202 EmitCode(ctx, program); 199 EmitCode(ctx, program);
203 const std::string version{fmt::format("#version 460{}\n", GlslVersionSpecifier(ctx))}; 200 const std::string version{fmt::format("#version 450{}\n", GlslVersionSpecifier(ctx))};
204 ctx.header.insert(0, version); 201 ctx.header.insert(0, version);
205 if (program.local_memory_size > 0) { 202 if (program.local_memory_size > 0) {
206 ctx.header += fmt::format("uint lmem[{}];", program.local_memory_size / 4); 203 ctx.header += fmt::format("uint lmem[{}];", program.local_memory_size / 4);
@@ -225,10 +222,8 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR
225 if (program.info.uses_subgroup_shuffles) { 222 if (program.info.uses_subgroup_shuffles) {
226 ctx.header += "bool shfl_in_bounds;"; 223 ctx.header += "bool shfl_in_bounds;";
227 } 224 }
228 ctx.header += "\n";
229 ctx.code.insert(0, ctx.header); 225 ctx.code.insert(0, ctx.header);
230 ctx.code += "}"; 226 ctx.code += '}';
231 // fmt::print("\n{}\n", ctx.code);
232 return ctx.code; 227 return ctx.code;
233} 228}
234 229