diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-05-31 19:28:53 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:37 +0200 |
commit | 19247ba4fad59b3d821b099dfbcd60e985041249 (patch) | |
tree | c30455f98fa5c2fe5b5febdc4baabb61db3fd293 /src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |
parent | glsl: Use NotImplemented macro with function name output (diff) | |
download | yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar.gz yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar.bz2 yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar.lz yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar.xz yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.tar.zst yuzu-19247ba4fad59b3d821b099dfbcd60e985041249.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index c66b4b282..28e89a0a6 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp @@ -19,6 +19,15 @@ u32 CbufIndex(u32 offset) { char OffsetSwizzle(u32 offset) { return SWIZZLE[CbufIndex(offset)]; } + +bool IsInputArray(Stage stage) { + return stage == Stage::Geometry || stage == Stage::TessellationControl || + stage == Stage::TessellationEval; +} + +std::string VertexIndex(EmitContext& ctx, std::string_view vertex) { + return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; +} } // namespace void EmitGetCbufU8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, @@ -128,7 +137,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, const char swizzle{"xyzw"[element]}; if (IR::IsGeneric(attr)) { const u32 index{IR::GenericAttributeIndex(attr)}; - ctx.AddF32("{}=in_attr{}.{};", inst, index, swizzle); + ctx.AddF32("{}=in_attr{}{}.{};", inst, index, VertexIndex(ctx, vertex), swizzle); return; } switch (attr) { @@ -139,9 +148,11 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, switch (ctx.stage) { case Stage::VertexA: case Stage::VertexB: - case Stage::Geometry: ctx.AddF32("{}=gl_Position.{};", inst, swizzle); break; + case Stage::Geometry: + ctx.AddF32("{}=gl_in[{}].gl_Position.{};", inst, vertex, swizzle); + break; case Stage::Fragment: ctx.AddF32("{}=gl_FragCoord.{};", inst, swizzle); break; |