diff options
| author | 2015-10-21 00:04:02 -0400 | |
|---|---|---|
| committer | 2015-10-21 22:29:56 -0400 | |
| commit | e663f5c91450ac5b36358195718edddbde25cd75 (patch) | |
| tree | 479fbe5a9e1d54857baf102aa3032672df87dac6 | |
| parent | gl_rasterizer: Define enum types for each vertex texcoord attribute. (diff) | |
| download | yuzu-e663f5c91450ac5b36358195718edddbde25cd75.tar.gz yuzu-e663f5c91450ac5b36358195718edddbde25cd75.tar.xz yuzu-e663f5c91450ac5b36358195718edddbde25cd75.zip | |
gl_shader_gen: Optimize code for AppendAlphaTestCondition.
- Also add a comment to AppendColorCombiner.
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 7506cdc08..e456f5847 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -205,7 +205,7 @@ static void AppendColorCombiner(std::string& out, TevStageConfig::Operation oper | |||
| 205 | LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: %u", operation); | 205 | LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: %u", operation); |
| 206 | break; | 206 | break; |
| 207 | } | 207 | } |
| 208 | out += ", vec3(0.0), vec3(1.0))"; | 208 | out += ", vec3(0.0), vec3(1.0))"; // Clamp result to 0.0, 1.0 |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | /// Writes the combiner function for the alpha component for the specified TEV stage operation | 211 | /// 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) { | |||
| 257 | out += "false"; | 257 | out += "false"; |
| 258 | break; | 258 | break; |
| 259 | case CompareFunc::Equal: | 259 | case CompareFunc::Equal: |
| 260 | out += "int(last_tex_env_out.a * 255.0f) != alphatest_ref"; | ||
| 261 | break; | ||
| 262 | case CompareFunc::NotEqual: | 260 | case CompareFunc::NotEqual: |
| 263 | out += "int(last_tex_env_out.a * 255.0f) == alphatest_ref"; | ||
| 264 | break; | ||
| 265 | case CompareFunc::LessThan: | 261 | case CompareFunc::LessThan: |
| 266 | out += "int(last_tex_env_out.a * 255.0f) >= alphatest_ref"; | ||
| 267 | break; | ||
| 268 | case CompareFunc::LessThanOrEqual: | 262 | case CompareFunc::LessThanOrEqual: |
| 269 | out += "int(last_tex_env_out.a * 255.0f) > alphatest_ref"; | ||
| 270 | break; | ||
| 271 | case CompareFunc::GreaterThan: | 263 | case CompareFunc::GreaterThan: |
| 272 | out += "int(last_tex_env_out.a * 255.0f) <= alphatest_ref"; | ||
| 273 | break; | ||
| 274 | case CompareFunc::GreaterThanOrEqual: | 264 | case CompareFunc::GreaterThanOrEqual: |
| 275 | out += "int(last_tex_env_out.a * 255.0f) < alphatest_ref"; | 265 | { |
| 266 | static const char* op[] = { "!=", "==", ">=", ">", "<=", "<", }; | ||
| 267 | unsigned index = (unsigned)func - (unsigned)CompareFunc::Equal; | ||
| 268 | out += "int(last_tex_env_out.a * 255.0f) " + std::string(op[index]) + " alphatest_ref"; | ||
| 276 | break; | 269 | break; |
| 270 | } | ||
| 271 | |||
| 277 | default: | 272 | default: |
| 278 | out += "false"; | 273 | out += "false"; |
| 279 | LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition %u", func); | 274 | LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition %u", func); |
| @@ -337,10 +332,10 @@ out vec4 color; | |||
| 337 | )"; | 332 | )"; |
| 338 | 333 | ||
| 339 | using Uniform = RasterizerOpenGL::PicaShader::Uniform; | 334 | using Uniform = RasterizerOpenGL::PicaShader::Uniform; |
| 340 | out += "layout(location = " + std::to_string(Uniform::AlphaTestRef) + ") uniform int alphatest_ref;\n"; | 335 | out += "layout(location = " + std::to_string((int)Uniform::AlphaTestRef) + ") uniform int alphatest_ref;\n"; |
| 341 | out += "layout(location = " + std::to_string(Uniform::TevConstColors) + ") uniform vec4 const_color[NUM_TEV_STAGES];\n"; | 336 | out += "layout(location = " + std::to_string((int)Uniform::TevConstColors) + ") uniform vec4 const_color[NUM_TEV_STAGES];\n"; |
| 342 | out += "layout(location = " + std::to_string(Uniform::Texture0) + ") uniform sampler2D tex[3];\n"; | 337 | out += "layout(location = " + std::to_string((int)Uniform::Texture0) + ") uniform sampler2D tex[3];\n"; |
| 343 | out += "layout(location = " + std::to_string(Uniform::TevCombinerBufferColor) + ") uniform vec4 tev_combiner_buffer_color;\n"; | 338 | out += "layout(location = " + std::to_string((int)Uniform::TevCombinerBufferColor) + ") uniform vec4 tev_combiner_buffer_color;\n"; |
| 344 | 339 | ||
| 345 | out += "void main() {\n"; | 340 | out += "void main() {\n"; |
| 346 | out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n"; | 341 | out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n"; |