gl_shader_gen: Optimize code for AppendAlphaTestCondition.
- Also add a comment to AppendColorCombiner.
This commit is contained in:
parent
e7b1f2ae0a
commit
e663f5c914
|
@ -205,7 +205,7 @@ static void AppendColorCombiner(std::string& out, TevStageConfig::Operation oper
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: %u", operation);
|
LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: %u", operation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out += ", vec3(0.0), vec3(1.0))";
|
out += ", vec3(0.0), vec3(1.0))"; // Clamp result to 0.0, 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes the combiner function for the alpha component for the specified TEV stage operation
|
/// Writes the combiner function for the alpha component for the specified TEV stage operation
|
||||||
|
@ -257,23 +257,18 @@ static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) {
|
||||||
out += "false";
|
out += "false";
|
||||||
break;
|
break;
|
||||||
case CompareFunc::Equal:
|
case CompareFunc::Equal:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) != alphatest_ref";
|
|
||||||
break;
|
|
||||||
case CompareFunc::NotEqual:
|
case CompareFunc::NotEqual:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) == alphatest_ref";
|
|
||||||
break;
|
|
||||||
case CompareFunc::LessThan:
|
case CompareFunc::LessThan:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) >= alphatest_ref";
|
|
||||||
break;
|
|
||||||
case CompareFunc::LessThanOrEqual:
|
case CompareFunc::LessThanOrEqual:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) > alphatest_ref";
|
|
||||||
break;
|
|
||||||
case CompareFunc::GreaterThan:
|
case CompareFunc::GreaterThan:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) <= alphatest_ref";
|
|
||||||
break;
|
|
||||||
case CompareFunc::GreaterThanOrEqual:
|
case CompareFunc::GreaterThanOrEqual:
|
||||||
out += "int(last_tex_env_out.a * 255.0f) < alphatest_ref";
|
{
|
||||||
|
static const char* op[] = { "!=", "==", ">=", ">", "<=", "<", };
|
||||||
|
unsigned index = (unsigned)func - (unsigned)CompareFunc::Equal;
|
||||||
|
out += "int(last_tex_env_out.a * 255.0f) " + std::string(op[index]) + " alphatest_ref";
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
out += "false";
|
out += "false";
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition %u", func);
|
LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition %u", func);
|
||||||
|
@ -337,10 +332,10 @@ out vec4 color;
|
||||||
)";
|
)";
|
||||||
|
|
||||||
using Uniform = RasterizerOpenGL::PicaShader::Uniform;
|
using Uniform = RasterizerOpenGL::PicaShader::Uniform;
|
||||||
out += "layout(location = " + std::to_string(Uniform::AlphaTestRef) + ") uniform int alphatest_ref;\n";
|
out += "layout(location = " + std::to_string((int)Uniform::AlphaTestRef) + ") uniform int alphatest_ref;\n";
|
||||||
out += "layout(location = " + std::to_string(Uniform::TevConstColors) + ") uniform vec4 const_color[NUM_TEV_STAGES];\n";
|
out += "layout(location = " + std::to_string((int)Uniform::TevConstColors) + ") uniform vec4 const_color[NUM_TEV_STAGES];\n";
|
||||||
out += "layout(location = " + std::to_string(Uniform::Texture0) + ") uniform sampler2D tex[3];\n";
|
out += "layout(location = " + std::to_string((int)Uniform::Texture0) + ") uniform sampler2D tex[3];\n";
|
||||||
out += "layout(location = " + std::to_string(Uniform::TevCombinerBufferColor) + ") uniform vec4 tev_combiner_buffer_color;\n";
|
out += "layout(location = " + std::to_string((int)Uniform::TevCombinerBufferColor) + ") uniform vec4 tev_combiner_buffer_color;\n";
|
||||||
|
|
||||||
out += "void main() {\n";
|
out += "void main() {\n";
|
||||||
out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n";
|
out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n";
|
||||||
|
|
Loading…
Reference in New Issue