diff --git a/hw/xbox/nv2a/pgraph/gl/shaders.c b/hw/xbox/nv2a/pgraph/gl/shaders.c index f47105980c0..3095ca3c3aa 100644 --- a/hw/xbox/nv2a/pgraph/gl/shaders.c +++ b/hw/xbox/nv2a/pgraph/gl/shaders.c @@ -712,9 +712,9 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding, } } if (binding->alpha_ref_loc != -1) { - float alpha_ref = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CONTROL_0), - NV_PGRAPH_CONTROL_0_ALPHAREF) / 255.0; - glUniform1f(binding->alpha_ref_loc, alpha_ref); + int alpha_ref = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CONTROL_0), + NV_PGRAPH_CONTROL_0_ALPHAREF); + glUniform1i(binding->alpha_ref_loc, alpha_ref); } diff --git a/hw/xbox/nv2a/pgraph/glsl/psh.c b/hw/xbox/nv2a/pgraph/glsl/psh.c index 9775db2a8ab..44c56a9c9ba 100644 --- a/hw/xbox/nv2a/pgraph/glsl/psh.c +++ b/hw/xbox/nv2a/pgraph/glsl/psh.c @@ -743,7 +743,7 @@ static MString* psh_convert(struct PixelShader *ps) "layout(location = 0) out vec4 fragColor;\n"); } - mstring_append_fmt(preflight, "%sfloat alphaRef;\n" + mstring_append_fmt(preflight, "%sint alphaRef;\n" "%svec4 fogColor;\n" "%sivec4 clipRegion[8];\n", u, u, u); @@ -1190,7 +1190,9 @@ static MString* psh_convert(struct PixelShader *ps) assert(false); break; } - mstring_append_fmt(ps->code, "if (!(fragColor.a %s alphaRef)) discard;\n", + mstring_append_fmt(ps->code, + "int fragAlpha = int(round(fragColor.a * 255.0));\n" + "if (!(fragAlpha %s alphaRef)) discard;\n", alpha_op); } } diff --git a/hw/xbox/nv2a/pgraph/vk/shaders.c b/hw/xbox/nv2a/pgraph/vk/shaders.c index 1f4ad765de2..5fce943d490 100644 --- a/hw/xbox/nv2a/pgraph/vk/shaders.c +++ b/hw/xbox/nv2a/pgraph/vk/shaders.c @@ -477,10 +477,9 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding, } } if (binding->alpha_ref_loc != -1) { - float alpha_ref = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CONTROL_0), - NV_PGRAPH_CONTROL_0_ALPHAREF) / - 255.0; - uniform1f(&binding->fragment->uniforms, binding->alpha_ref_loc, + int alpha_ref = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CONTROL_0), + NV_PGRAPH_CONTROL_0_ALPHAREF); + uniform1i(&binding->fragment->uniforms, binding->alpha_ref_loc, alpha_ref); }