Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nv2a: Use rounded values for alpha testing #1955

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hw/xbox/nv2a/pgraph/gl/shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
6 changes: 4 additions & 2 deletions hw/xbox/nv2a/pgraph/glsl/psh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
7 changes: 3 additions & 4 deletions hw/xbox/nv2a/pgraph/vk/shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down