diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_context.cpp | 12 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | 23 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp index 659ff6d17..0f7d79843 100644 --- a/src/shader_recompiler/backend/glasm/emit_context.cpp +++ b/src/shader_recompiler/backend/glasm/emit_context.cpp | |||
| @@ -21,6 +21,11 @@ std::string_view InterpDecorator(Interpolation interp) { | |||
| 21 | } | 21 | } |
| 22 | throw InvalidArgument("Invalid interpolation {}", interp); | 22 | throw InvalidArgument("Invalid interpolation {}", interp); |
| 23 | } | 23 | } |
| 24 | |||
| 25 | bool IsInputArray(Stage stage) { | ||
| 26 | return stage == Stage::Geometry || stage == Stage::TessellationControl || | ||
| 27 | stage == Stage::TessellationEval; | ||
| 28 | } | ||
| 24 | } // Anonymous namespace | 29 | } // Anonymous namespace |
| 25 | 30 | ||
| 26 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 31 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| @@ -76,7 +81,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 76 | InterpDecorator(generic.interpolation), index, attr_stage, index, index); | 81 | InterpDecorator(generic.interpolation), index, attr_stage, index, index); |
| 77 | } | 82 | } |
| 78 | } | 83 | } |
| 79 | if (stage == Stage::Geometry && info.loads_position) { | 84 | if (IsInputArray(stage) && info.loads_position) { |
| 80 | Add("ATTRIB vertex_position=vertex.position;"); | 85 | Add("ATTRIB vertex_position=vertex.position;"); |
| 81 | } | 86 | } |
| 82 | if (info.uses_invocation_id) { | 87 | if (info.uses_invocation_id) { |
| @@ -96,8 +101,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 96 | continue; | 101 | continue; |
| 97 | } | 102 | } |
| 98 | if (stage == Stage::TessellationControl) { | 103 | if (stage == Stage::TessellationControl) { |
| 99 | Add("OUTPUT result_patch_attrib{}[]={{result.patch.attrib[{}..{}]}};", index, index, | 104 | Add("OUTPUT result_patch_attrib{}[]={{result.patch.attrib[{}..{}]}};" |
| 100 | index); | 105 | "ATTRIB primitive_out_patch_attrib{}[]={{primitive.out.patch.attrib[{}..{}]}};", |
| 106 | index, index, index, index, index, index); | ||
| 101 | } else { | 107 | } else { |
| 102 | Add("ATTRIB primitive_patch_attrib{}[]={{primitive.patch.attrib[{}..{}]}};", index, | 108 | Add("ATTRIB primitive_patch_attrib{}[]={{primitive.patch.attrib[{}..{}]}};", index, |
| 103 | index, index); | 109 | index, index); |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 34669160a..97b0e7409 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |||
| @@ -20,15 +20,13 @@ void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU | |||
| 20 | ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset); | 20 | ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | bool IsInputArray(Stage stage) { | ||
| 24 | return stage == Stage::Geometry || stage == Stage::TessellationControl || | ||
| 25 | stage == Stage::TessellationEval; | ||
| 26 | } | ||
| 27 | |||
| 23 | std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) { | 28 | std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) { |
| 24 | switch (ctx.stage) { | 29 | return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; |
| 25 | case Stage::TessellationControl: | ||
| 26 | case Stage::TessellationEval: | ||
| 27 | case Stage::Geometry: | ||
| 28 | return fmt::format("[{}]", vertex); | ||
| 29 | default: | ||
| 30 | return ""; | ||
| 31 | } | ||
| 32 | } | 30 | } |
| 33 | } // Anonymous namespace | 31 | } // Anonymous namespace |
| 34 | 32 | ||
| @@ -77,7 +75,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 77 | case IR::Attribute::PositionY: | 75 | case IR::Attribute::PositionY: |
| 78 | case IR::Attribute::PositionZ: | 76 | case IR::Attribute::PositionZ: |
| 79 | case IR::Attribute::PositionW: | 77 | case IR::Attribute::PositionW: |
| 80 | if (ctx.stage == Stage::Geometry) { | 78 | if (IsInputArray(ctx.stage)) { |
| 81 | ctx.Add("MOV.F {}.x,vertex_position{}.{};", inst, VertexIndex(ctx, vertex), swizzle); | 79 | ctx.Add("MOV.F {}.x,vertex_position{}.{};", inst, VertexIndex(ctx, vertex), swizzle); |
| 82 | } else { | 80 | } else { |
| 83 | ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle); | 81 | ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle); |
| @@ -164,7 +162,12 @@ void EmitGetPatch(EmitContext& ctx, IR::Inst& inst, IR::Patch patch) { | |||
| 164 | } | 162 | } |
| 165 | const u32 index{IR::GenericPatchIndex(patch)}; | 163 | const u32 index{IR::GenericPatchIndex(patch)}; |
| 166 | const u32 element{IR::GenericPatchElement(patch)}; | 164 | const u32 element{IR::GenericPatchElement(patch)}; |
| 167 | ctx.Add("MOV.F {},result.patch.attrib[{}].{};", inst, index, "xyzw"[element]); | 165 | const char swizzle{"xyzw"[element]}; |
| 166 | if (ctx.stage == Stage::TessellationControl) { | ||
| 167 | ctx.Add("MOV.F {},primitive.out.patch.attrib[{}].{};", inst, index, swizzle); | ||
| 168 | } else { | ||
| 169 | ctx.Add("MOV.F {},primitive.patch.attrib[{}].{};", inst, index, swizzle); | ||
| 170 | } | ||
| 168 | } | 171 | } |
| 169 | 172 | ||
| 170 | void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value) { | 173 | void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value) { |