Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

Add InputTopologyVertices from torzu adapted to eden

MrPurple66644dc152a2beb
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 ed6d96f70b..47babcdc07 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
@@ -6,6 +6,7 @@
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
#include "shader_recompiler/backend/glasm/glasm_emit_context.h"
#include "shader_recompiler/frontend/ir/value.h"
+#include "shader_recompiler/runtime_info.h"
#include "shader_recompiler/profile.h"
#include "shader_recompiler/shader_info.h"
@@ -406,6 +407,10 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) {
case Stage::TessellationEval:
ctx.Add("SHL.U {}.x,primitive.vertexcount,16;", inst);
break;
+ case Stage::Geometry:
+ ctx.Add("SHL.U {}.x,{},16;", inst,
+ InputTopologyVertices::vertices(ctx.runtime_info.input_topology));
+ break;
default:
LOG_WARNING(Shader, "(STUBBED) called");
ctx.Add("MOV.S {}.x,0x00ff0000;", inst);
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 d575f6e335..ffe5cd116c 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,10 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) {
case Stage::TessellationEval:
ctx.AddU32("{}=uint(gl_PatchVerticesIn)<<16;", inst);
break;
+ case Stage::Geometry:
+ ctx.AddU32("{}=uint({}<<16);", inst,
+ InputTopologyVertices::vertices(ctx.runtime_info.input_topology));
+ break;
default:
LOG_WARNING(Shader, "(STUBBED) called");
ctx.AddU32("{}=uint(0x00ff0000);", inst);
diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h
index 619c0b1387..dc54d932a6 100644
--- a/src/shader_recompiler/runtime_info.h
+++ b/src/shader_recompiler/runtime_info.h
@@ -30,6 +30,24 @@ enum class InputTopology {
TrianglesAdjacency,
};
+struct InputTopologyVertices {
+ static u32 vertices(InputTopology input_topology) {
+ switch (input_topology) {
+ case InputTopology::Lines:
+ return 2;
+ case InputTopology::LinesAdjacency:
+ return 4;
+ case InputTopology::Triangles:
+ return 3;
+ case InputTopology::TrianglesAdjacency:
+ return 6;
+ case InputTopology::Points:
+ default:
+ return 1;
+ }
+ }
+};
+
enum class CompareFunction {
Never,
Less,