From 0863d9e811fb56e421ecaf796264e08f5b68d975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 20 May 2021 16:59:18 +0200 Subject: [PATCH] Shaders: reassign MeshVisualizer uniforms to be contiguous for UBOs too. --- src/Magnum/Shaders/MeshVisualizer.frag | 4 ++-- src/Magnum/Shaders/MeshVisualizer.geom | 4 ++-- src/Magnum/Shaders/MeshVisualizer.vert | 8 ++++---- src/Magnum/Shaders/MeshVisualizerGL.h | 18 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Magnum/Shaders/MeshVisualizer.frag b/src/Magnum/Shaders/MeshVisualizer.frag index e75b64eea..c88460c0f 100644 --- a/src/Magnum/Shaders/MeshVisualizer.frag +++ b/src/Magnum/Shaders/MeshVisualizer.frag @@ -100,7 +100,7 @@ uniform lowp float smoothness #if defined(INSTANCED_OBJECT_ID) || defined(PRIMITIVE_ID) || defined(PRIMITIVE_ID_FROM_VERTEX_ID) #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 6) +layout(location = 5) #endif uniform lowp vec2 colorMapOffsetScale #ifndef GL_ES @@ -115,7 +115,7 @@ uniform lowp vec2 colorMapOffsetScale #else #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 0) +layout(location = 1) #endif uniform highp uint drawOffset #ifndef GL_ES diff --git a/src/Magnum/Shaders/MeshVisualizer.geom b/src/Magnum/Shaders/MeshVisualizer.geom index 928e1f2b2..89709595f 100644 --- a/src/Magnum/Shaders/MeshVisualizer.geom +++ b/src/Magnum/Shaders/MeshVisualizer.geom @@ -39,7 +39,7 @@ /* This one is for both classic and UBOs, as it's usually set globally instead of changing per-draw */ #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 5) +layout(location = 0) #endif uniform lowp vec2 viewportSize; /* defaults to zero */ @@ -88,7 +88,7 @@ uniform lowp float smoothness #else #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 0) +layout(location = 1) #endif uniform highp uint drawOffset #ifndef GL_ES diff --git a/src/Magnum/Shaders/MeshVisualizer.vert b/src/Magnum/Shaders/MeshVisualizer.vert index 44b270b50..38ce85ffb 100644 --- a/src/Magnum/Shaders/MeshVisualizer.vert +++ b/src/Magnum/Shaders/MeshVisualizer.vert @@ -41,7 +41,7 @@ #ifndef UNIFORM_BUFFERS #ifdef TWO_DIMENSIONS #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 0) +layout(location = 6) #endif uniform highp mat3 transformationProjectionMatrix #ifndef GL_ES @@ -50,7 +50,7 @@ uniform highp mat3 transformationProjectionMatrix ; #elif defined(THREE_DIMENSIONS) #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 0) +layout(location = 6) #endif uniform highp mat4 transformationMatrix #ifndef GL_ES @@ -71,7 +71,7 @@ uniform highp mat4 projectionMatrix #ifdef VERTEX_ID #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 6) +layout(location = 5) #endif uniform lowp vec2 colorMapOffsetScale #ifndef GL_ES @@ -106,7 +106,7 @@ uniform highp float lineLength #else #ifdef EXPLICIT_UNIFORM_LOCATION -layout(location = 0) +layout(location = 1) #endif uniform highp uint drawOffset #ifndef GL_ES diff --git a/src/Magnum/Shaders/MeshVisualizerGL.h b/src/Magnum/Shaders/MeshVisualizerGL.h index ca21d8de9..fa750c895 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.h +++ b/src/Magnum/Shaders/MeshVisualizerGL.h @@ -97,16 +97,16 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGLBase: public GL::AbstractShaderProgr #ifndef MAGNUM_TARGET_GLES2 UnsignedInt _materialCount{}, _drawCount{}; #endif - Int _colorUniform{1}, + Int _viewportSizeUniform{0}, + _colorUniform{1}, _wireframeColorUniform{2}, _wireframeWidthUniform{3}, - _smoothnessUniform{4}, - _viewportSizeUniform{5}; + _smoothnessUniform{4}; #ifndef MAGNUM_TARGET_GLES2 - Int _colorMapOffsetScaleUniform{6}; - /* Used instead of all other uniforms when Flag::UniformBuffers is set, - so it can alias them */ - Int _drawOffsetUniform{0}; + Int _colorMapOffsetScaleUniform{5}; + /* Used instead of all other uniforms except viewportSize when + Flag::UniformBuffers is set, so it can alias them */ + Int _drawOffsetUniform{1}; #endif }; @@ -565,7 +565,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua */ private: - Int _transformationProjectionMatrixUniform{0}; + Int _transformationProjectionMatrixUniform{6}; }; /** @@ -1514,7 +1514,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua */ private: - Int _transformationMatrixUniform{0}, + Int _transformationMatrixUniform{6}, _projectionMatrixUniform{7}; #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Int _normalMatrixUniform{8},