Skip to content

Commit 8475b13

Browse files
author
coldhex
committed
nv2a/gl: Try to work around a possible GeForce shader compiler bug
This geometry shader modification is done based on the assumption that GeForce compiler has a bug where it may incorrectly detect a geometry shader as a passthrough shader.
1 parent 7cec10d commit 8475b13

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

hw/xbox/nv2a/pgraph/gl/gpuprops.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ static const char *geometry_shader_source =
6868
"out vec3 fragColor;\n"
6969
"in vec3 v_fragColor[];\n"
7070
"\n"
71-
"void emit_vertex(int index) {\n"
72-
" gl_Position = gl_in[index].gl_Position;\n"
73-
" fragColor = v_fragColor[0];\n"
74-
" EmitVertex();\n"
75-
"}\n"
76-
"\n"
7771
"void main() {\n"
78-
" emit_vertex(0);\n"
79-
" emit_vertex(1);\n"
80-
" emit_vertex(2);\n"
72+
" for (int i = 0; i < 3; i++) {\n"
73+
// This should be just:
74+
// gl_Position = gl_in[i].gl_Position;
75+
// fragColor = v_fragColor[0];
76+
// but we try to work around a possible GeForce compiler bug.
77+
" gl_Position = gl_in[i].gl_Position + vec4(1.0/16384.0, 1.0/16384.0, 0.0, 0.0);\n"
78+
" precise vec3 color = v_fragColor[0]*(0.999 + gl_in[i].gl_Position.x/16384.0) + v_fragColor[1]*0.00005 + v_fragColor[2]*0.00005;\n"
79+
" fragColor = color;\n"
80+
" EmitVertex();\n"
81+
" }\n"
8182
" EndPrimitive();\n"
8283
"}\n";
8384

0 commit comments

Comments
 (0)