From 6a35aa6b94dbb32283003f679167de9eadf37c1b Mon Sep 17 00:00:00 2001 From: Jarrod Norwell Date: Sat, 23 Mar 2024 11:53:26 +0800 Subject: [PATCH] Added support for Princess Peach: Showtime! --- .../glasm/emit_glasm_context_get_set.cpp | 24 +++++++++++++++++++ .../backend/glasm/glasm_emit_context.h | 1 + .../glsl/emit_glsl_context_get_set.cpp | 24 +++++++++++++++++++ .../spirv/emit_spirv_context_get_set.cpp | 23 ++++++++++++++++++ 4 files changed, 72 insertions(+) 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 1ae6136..6645699 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 @@ -406,6 +406,30 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) { case Stage::TessellationEval: ctx.Add("SHL.U {}.x,primitive.vertexcount,16;", inst); break; + case Stage::Geometry: { + u32 vertices_count = 0; + switch (ctx.runtime_info.input_topology) { + case InputTopology::Lines: + vertices_count = 2; + break; + case InputTopology::LinesAdjacency: + vertices_count = 4; + break; + case InputTopology::Triangles: + vertices_count = 3; + break; + case InputTopology::TrianglesAdjacency: + vertices_count = 6; + break; + case InputTopology::Points: + default: + vertices_count = 1; + break; + }; + + ctx.Add("SHL.U {}.x,{},16;", inst, vertices_count); + break; + } default: LOG_WARNING(Shader, "(STUBBED) called"); ctx.Add("MOV.S {}.x,0x00ff0000;", inst); diff --git a/src/shader_recompiler/backend/glasm/glasm_emit_context.h b/src/shader_recompiler/backend/glasm/glasm_emit_context.h index 3026766..9c01e07 100644 --- a/src/shader_recompiler/backend/glasm/glasm_emit_context.h +++ b/src/shader_recompiler/backend/glasm/glasm_emit_context.h @@ -11,6 +11,7 @@ #include "shader_recompiler/backend/glasm/reg_alloc.h" #include "shader_recompiler/stage.h" +#include "shader_recompiler/runtime_info.h" namespace Shader { struct Info; 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 0769c1b..bacb068 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 @@ -426,6 +426,30 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) { case Stage::TessellationEval: ctx.AddU32("{}=uint(gl_PatchVerticesIn)<<16;", inst); break; + case Stage::Geometry: { + u32 vertices_count = 0; + switch (ctx.runtime_info.input_topology) { + case InputTopology::Lines: + vertices_count = 2; + break; + case InputTopology::LinesAdjacency: + vertices_count = 4; + break; + case InputTopology::Triangles: + vertices_count = 3; + break; + case InputTopology::TrianglesAdjacency: + vertices_count = 6; + break; + case InputTopology::Points: + default: + vertices_count = 1; + break; + }; + + ctx.AddU32("{}=uint({});", inst, vertices_count << 16); + break; + } default: LOG_WARNING(Shader, "(STUBBED) called"); ctx.AddU32("{}=uint(0x00ff0000);", inst); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 307b39f..5af3a3d 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -549,6 +549,29 @@ Id EmitInvocationInfo(EmitContext& ctx) { case Stage::TessellationEval: return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.patch_vertices_in), ctx.Const(16u)); + case Stage::Geometry: { + u32 vertices_count = 0; + switch (ctx.runtime_info.input_topology) { + case InputTopology::Lines: + vertices_count = 2; + break; + case InputTopology::LinesAdjacency: + vertices_count = 4; + break; + case InputTopology::Triangles: + vertices_count = 3; + break; + case InputTopology::TrianglesAdjacency: + vertices_count = 6; + break; + case InputTopology::Points: + default: + vertices_count = 1; + break; + }; + + return ctx.Const(vertices_count << 16); + } default: LOG_WARNING(Shader, "(STUBBED) called"); return ctx.Const(0x00ff0000u);