From f54b207812a5a06aa6ec1d90132bcd55528a51f9 Mon Sep 17 00:00:00 2001 From: Erik Abair Date: Thu, 19 May 2022 11:22:20 -0700 Subject: [PATCH] nv2a: Handle invalid w in fixed function pipeline --- hw/xbox/nv2a/shaders.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/xbox/nv2a/shaders.c b/hw/xbox/nv2a/shaders.c index 1caaf46bc9..451eed728c 100644 --- a/hw/xbox/nv2a/shaders.c +++ b/hw/xbox/nv2a/shaders.c @@ -693,8 +693,13 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz state->surface_scale_factor); } - mstring_append(body, " vtx.inv_w = 1.0 / oPos.w;\n"); + mstring_append(body, + " if (oPos.w == 0.0 || isinf(oPos.w)) {\n" + " vtx.inv_w = 1.0;\n" + " } else {\n" + " vtx.inv_w = 1.0 / oPos.w;\n" + " }\n"); } static MString *generate_vertex_shader(const ShaderState *state,