Merge pull request #10 from sudachi-emu/hotfix-geometry-stage

Added support for Princess Peach: Showtime!
This commit is contained in:
Jarrod Norwell 2024-03-23 11:57:45 +08:00 committed by GitHub
commit 771507753d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 72 additions and 0 deletions

View File

@ -406,6 +406,30 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) {
case Stage::TessellationEval: case Stage::TessellationEval:
ctx.Add("SHL.U {}.x,primitive.vertexcount,16;", inst); ctx.Add("SHL.U {}.x,primitive.vertexcount,16;", inst);
break; 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: default:
LOG_WARNING(Shader, "(STUBBED) called"); LOG_WARNING(Shader, "(STUBBED) called");
ctx.Add("MOV.S {}.x,0x00ff0000;", inst); ctx.Add("MOV.S {}.x,0x00ff0000;", inst);

View File

@ -11,6 +11,7 @@
#include "shader_recompiler/backend/glasm/reg_alloc.h" #include "shader_recompiler/backend/glasm/reg_alloc.h"
#include "shader_recompiler/stage.h" #include "shader_recompiler/stage.h"
#include "shader_recompiler/runtime_info.h"
namespace Shader { namespace Shader {
struct Info; struct Info;

View File

@ -426,6 +426,30 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) {
case Stage::TessellationEval: case Stage::TessellationEval:
ctx.AddU32("{}=uint(gl_PatchVerticesIn)<<16;", inst); ctx.AddU32("{}=uint(gl_PatchVerticesIn)<<16;", inst);
break; 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: default:
LOG_WARNING(Shader, "(STUBBED) called"); LOG_WARNING(Shader, "(STUBBED) called");
ctx.AddU32("{}=uint(0x00ff0000);", inst); ctx.AddU32("{}=uint(0x00ff0000);", inst);

View File

@ -549,6 +549,29 @@ Id EmitInvocationInfo(EmitContext& ctx) {
case Stage::TessellationEval: case Stage::TessellationEval:
return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.patch_vertices_in), return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.patch_vertices_in),
ctx.Const(16u)); 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: default:
LOG_WARNING(Shader, "(STUBBED) called"); LOG_WARNING(Shader, "(STUBBED) called");
return ctx.Const(0x00ff0000u); return ctx.Const(0x00ff0000u);