From dde5dce7366e58a35dce308ef81fa9debb038334 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 Aug 2018 02:54:06 -0400 Subject: gl_shader_manager: Amend sign differences in an assertion comparison in SetShaderUniformBlockBinding() Ensures both operands have the same sign in the comparison. While we're at it, we can get rid of the redundant casting of ub_size to an int. This type will always be trivial and alias a built-in type (not doing so would break backwards compatibility at a standard level). --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index e81fcbbc4..1d88f8cec 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -17,9 +17,8 @@ static void SetShaderUniformBlockBinding(GLuint shader, const char* name, if (ub_index != GL_INVALID_INDEX) { GLint ub_size = 0; glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); - ASSERT_MSG(ub_size == expected_size, - "Uniform block size did not match! Got {}, expected {}", - static_cast(ub_size), expected_size); + ASSERT_MSG(static_cast(ub_size) == expected_size, + "Uniform block size did not match! Got {}, expected {}", ub_size, expected_size); glUniformBlockBinding(shader, ub_index, static_cast(binding)); } } -- cgit v1.2.3 From 3b678b9e8e46d098571b22f1c25f7ff36caf3c2d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 Aug 2018 02:57:08 -0400 Subject: gl_shader_manager: Invert conditional in SetShaderUniformBlockBinding() This lets us indent the majority of the code and places the error case first. --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 1d88f8cec..415d42fda 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -13,14 +13,16 @@ namespace Impl { static void SetShaderUniformBlockBinding(GLuint shader, const char* name, Maxwell3D::Regs::ShaderStage binding, size_t expected_size) { - GLuint ub_index = glGetUniformBlockIndex(shader, name); - if (ub_index != GL_INVALID_INDEX) { - GLint ub_size = 0; - glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); - ASSERT_MSG(static_cast(ub_size) == expected_size, - "Uniform block size did not match! Got {}, expected {}", ub_size, expected_size); - glUniformBlockBinding(shader, ub_index, static_cast(binding)); + const GLuint ub_index = glGetUniformBlockIndex(shader, name); + if (ub_index == GL_INVALID_INDEX) { + return; } + + GLint ub_size = 0; + glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); + ASSERT_MSG(static_cast(ub_size) == expected_size, + "Uniform block size did not match! Got {}, expected {}", ub_size, expected_size); + glUniformBlockBinding(shader, ub_index, static_cast(binding)); } void SetShaderUniformBlockBindings(GLuint shader) { -- cgit v1.2.3