Skip to content

Commit

Permalink
Merge pull request #10 from sudachi-emu/hotfix-geometry-stage
Browse files Browse the repository at this point in the history
Added support for Princess Peach: Showtime!
  • Loading branch information
jarrodnorwell committed Mar 23, 2024
2 parents 8db48f8 + 6a35aa6 commit 7715077
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/shader_recompiler/backend/glasm/glasm_emit_context.h
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 7715077

Please sign in to comment.