diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
4 files changed, 12 insertions, 11 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h index 8fa87c02c..ecdf6e5bc 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.h +++ b/src/shader_recompiler/backend/glsl/emit_context.h | |||
| @@ -153,6 +153,8 @@ public: | |||
| 153 | std::vector<TextureImageDefinition> images; | 153 | std::vector<TextureImageDefinition> images; |
| 154 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 154 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 155 | 155 | ||
| 156 | u32 num_safety_loop_vars{}; | ||
| 157 | |||
| 156 | bool uses_y_direction{}; | 158 | bool uses_y_direction{}; |
| 157 | bool uses_cc_carry{}; | 159 | bool uses_cc_carry{}; |
| 158 | 160 | ||
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index ff869923f..32c4f1da2 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <string> | 6 | #include <string> |
| 7 | 7 | ||
| 8 | #include "common/alignment.h" | 8 | #include "common/alignment.h" |
| 9 | #include "common/settings.h" | ||
| 9 | #include "shader_recompiler/backend/glsl/emit_context.h" | 10 | #include "shader_recompiler/backend/glsl/emit_context.h" |
| 10 | #include "shader_recompiler/backend/glsl/emit_glsl.h" | 11 | #include "shader_recompiler/backend/glsl/emit_glsl.h" |
| 11 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | 12 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" |
| @@ -156,7 +157,12 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) { | |||
| 156 | ctx.Add("for(;;){{"); | 157 | ctx.Add("for(;;){{"); |
| 157 | break; | 158 | break; |
| 158 | case IR::AbstractSyntaxNode::Type::Repeat: | 159 | case IR::AbstractSyntaxNode::Type::Repeat: |
| 159 | ctx.Add("if(!{}){{break;}}}}", ctx.var_alloc.Consume(node.data.repeat.cond)); | 160 | if (Settings::values.disable_shader_loop_safety_checks) { |
| 161 | ctx.Add("if(!{}){{break;}}}}", ctx.var_alloc.Consume(node.data.repeat.cond)); | ||
| 162 | } else { | ||
| 163 | ctx.Add("if(--loop{}<0 || !{}){{break;}}}}", ctx.num_safety_loop_vars++, | ||
| 164 | ctx.var_alloc.Consume(node.data.repeat.cond)); | ||
| 165 | } | ||
| 160 | break; | 166 | break; |
| 161 | default: | 167 | default: |
| 162 | throw NotImplementedException("AbstractSyntaxNode Type {}", node.type); | 168 | throw NotImplementedException("AbstractSyntaxNode Type {}", node.type); |
| @@ -198,6 +204,9 @@ void DefineVariables(const EmitContext& ctx, std::string& header) { | |||
| 198 | ctx.var_alloc.Representation(index, type), type_name); | 204 | ctx.var_alloc.Representation(index, type), type_name); |
| 199 | } | 205 | } |
| 200 | } | 206 | } |
| 207 | for (u32 i = 0; i < ctx.num_safety_loop_vars; ++i) { | ||
| 208 | header += fmt::format("int loop{}=0x2000;", i); | ||
| 209 | } | ||
| 201 | } | 210 | } |
| 202 | } // Anonymous namespace | 211 | } // Anonymous namespace |
| 203 | 212 | ||
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index df28036e4..6a30785bb 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -44,8 +44,6 @@ void EmitSetGotoVariable(EmitContext& ctx); | |||
| 44 | void EmitGetGotoVariable(EmitContext& ctx); | 44 | void EmitGetGotoVariable(EmitContext& ctx); |
| 45 | void EmitSetIndirectBranchVariable(EmitContext& ctx); | 45 | void EmitSetIndirectBranchVariable(EmitContext& ctx); |
| 46 | void EmitGetIndirectBranchVariable(EmitContext& ctx); | 46 | void EmitGetIndirectBranchVariable(EmitContext& ctx); |
| 47 | void EmitSetLoopSafetyVariable(EmitContext& ctx); | ||
| 48 | void EmitGetLoopSafetyVariable(EmitContext& ctx); | ||
| 49 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 47 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 50 | const IR::Value& offset); | 48 | const IR::Value& offset); |
| 51 | void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 49 | void EmitGetCbufS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
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 0a28a1ffc..f420fe388 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp | |||
| @@ -46,14 +46,6 @@ void EmitGetIndirectBranchVariable(EmitContext& ctx) { | |||
| 46 | NotImplemented(); | 46 | NotImplemented(); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void EmitSetLoopSafetyVariable(EmitContext& ctx) { | ||
| 50 | NotImplemented(); | ||
| 51 | } | ||
| 52 | |||
| 53 | void EmitGetLoopSafetyVariable(EmitContext& ctx) { | ||
| 54 | NotImplemented(); | ||
| 55 | } | ||
| 56 | |||
| 57 | void EmitGetZFlag(EmitContext& ctx) { | 49 | void EmitGetZFlag(EmitContext& ctx) { |
| 58 | NotImplemented(); | 50 | NotImplemented(); |
| 59 | } | 51 | } |