diff options
| author | 2021-06-03 20:57:52 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | 34fdb6471d6050b438fd53a0406aedbf6b690600 (patch) | |
| tree | 0f483ab7f1e38bff1b03db30b9a000730df95913 /src/shader_recompiler/backend/glsl/emit_glsl.cpp | |
| parent | glsl: Refactor Global memory functions (diff) | |
| download | yuzu-34fdb6471d6050b438fd53a0406aedbf6b690600.tar.gz yuzu-34fdb6471d6050b438fd53a0406aedbf6b690600.tar.xz yuzu-34fdb6471d6050b438fd53a0406aedbf6b690600.zip | |
glsl: Cleanup and address feedback
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl.cpp | 15 |
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 | ||
| 85 | void EmitInst(EmitContext& ctx, IR::Inst* inst) { | 85 | void 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 | ||