diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-05-21 07:56:59 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:33 +0200 |
commit | b382f57b286f72f89cff4e710ba6e6b34d22035d (patch) | |
tree | 78fea5da1865ba99ac1bd4c0ce7afbb8a1faae05 /src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |
parent | gl_shader_cache: Pass shader runtime information (diff) | |
download | yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar.gz yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar.bz2 yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar.lz yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar.xz yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.tar.zst yuzu-b382f57b286f72f89cff4e710ba6e6b34d22035d.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
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 ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset); } +bool IsInputArray(Stage stage) { + return stage == Stage::Geometry || stage == Stage::TessellationControl || + stage == Stage::TessellationEval; +} + std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) { - switch (ctx.stage) { - case Stage::TessellationControl: - case Stage::TessellationEval: - case Stage::Geometry: - return fmt::format("[{}]", vertex); - default: - return ""; - } + return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; } } // Anonymous namespace @@ -77,7 +75,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal case IR::Attribute::PositionY: case IR::Attribute::PositionZ: case IR::Attribute::PositionW: - if (ctx.stage == Stage::Geometry) { + if (IsInputArray(ctx.stage)) { ctx.Add("MOV.F {}.x,vertex_position{}.{};", inst, VertexIndex(ctx, vertex), swizzle); } else { 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) { } const u32 index{IR::GenericPatchIndex(patch)}; const u32 element{IR::GenericPatchElement(patch)}; - ctx.Add("MOV.F {},result.patch.attrib[{}].{};", inst, index, "xyzw"[element]); + const char swizzle{"xyzw"[element]}; + if (ctx.stage == Stage::TessellationControl) { + ctx.Add("MOV.F {},primitive.out.patch.attrib[{}].{};", inst, index, swizzle); + } else { + ctx.Add("MOV.F {},primitive.patch.attrib[{}].{};", inst, index, swizzle); + } } void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value) { |