mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
gl_shader_util: Fix precision bug with alpha testing.
- Alpha testing is not done with float32 precision, this makes the HW renderer match the SW renderer.
This commit is contained in:
parent
e3f4233cef
commit
82f3e6dc69
2 changed files with 9 additions and 9 deletions
|
@ -195,7 +195,7 @@ void RasterizerOpenGL::RegenerateShaders() {
|
||||||
|
|
||||||
// Sync alpha reference
|
// Sync alpha reference
|
||||||
if (current_shader->uniform_alphatest_ref != -1)
|
if (current_shader->uniform_alphatest_ref != -1)
|
||||||
glUniform1f(current_shader->uniform_alphatest_ref, regs.output_merger.alpha_test.ref / 255.0f);
|
glUniform1i(current_shader->uniform_alphatest_ref, regs.output_merger.alpha_test.ref);
|
||||||
|
|
||||||
// Sync combiner buffer color
|
// Sync combiner buffer color
|
||||||
if (current_shader->uniform_tev_combiner_buffer_color != -1) {
|
if (current_shader->uniform_tev_combiner_buffer_color != -1) {
|
||||||
|
@ -655,7 +655,7 @@ void RasterizerOpenGL::SyncBlendColor() {
|
||||||
void RasterizerOpenGL::SyncAlphaTest() {
|
void RasterizerOpenGL::SyncAlphaTest() {
|
||||||
const auto& regs = Pica::g_state.regs;
|
const auto& regs = Pica::g_state.regs;
|
||||||
if (current_shader->uniform_alphatest_ref != -1)
|
if (current_shader->uniform_alphatest_ref != -1)
|
||||||
glUniform1f(current_shader->uniform_alphatest_ref, regs.output_merger.alpha_test.ref / 255.0f);
|
glUniform1i(current_shader->uniform_alphatest_ref, regs.output_merger.alpha_test.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncLogicOp() {
|
void RasterizerOpenGL::SyncLogicOp() {
|
||||||
|
|
|
@ -336,22 +336,22 @@ void AppendAlphaTestCondition(std::string& shader, Pica::Regs::CompareFunc func)
|
||||||
shader += "false";
|
shader += "false";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::Equal:
|
case CompareFunc::Equal:
|
||||||
shader += "g_last_tex_env_out.a != alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) != alphatest_ref";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::NotEqual:
|
case CompareFunc::NotEqual:
|
||||||
shader += "g_last_tex_env_out.a == alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) == alphatest_ref";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::LessThan:
|
case CompareFunc::LessThan:
|
||||||
shader += "g_last_tex_env_out.a >= alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) >= alphatest_ref";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::LessThanOrEqual:
|
case CompareFunc::LessThanOrEqual:
|
||||||
shader += "g_last_tex_env_out.a > alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) > alphatest_ref";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::GreaterThan:
|
case CompareFunc::GreaterThan:
|
||||||
shader += "g_last_tex_env_out.a <= alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) <= alphatest_ref";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::GreaterThanOrEqual:
|
case CompareFunc::GreaterThanOrEqual:
|
||||||
shader += "g_last_tex_env_out.a < alphatest_ref";
|
shader += "int(g_last_tex_env_out.a * 255.0f) < alphatest_ref";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shader += "false";
|
shader += "false";
|
||||||
|
@ -370,7 +370,7 @@ std::string GenerateFragmentShader(const ShaderCacheKey& config) {
|
||||||
in vec4 o[NUM_VTX_ATTR];
|
in vec4 o[NUM_VTX_ATTR];
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
uniform float alphatest_ref;
|
uniform int alphatest_ref;
|
||||||
uniform vec4 const_color[NUM_TEV_STAGES];
|
uniform vec4 const_color[NUM_TEV_STAGES];
|
||||||
uniform sampler2D tex[3];
|
uniform sampler2D tex[3];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue