From de62bbf5233c18b6147bddfcc23ca4b760667e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 23 Jan 2022 21:54:37 +0100 Subject: [PATCH] Shaders: clean up base array layer setting in Flat and Phong tests. Do it always when Flag::TextureArrays is set, not inside handling of some particular texture. Because that way it won't work when other textures are added/tested. --- src/Magnum/Shaders/Test/FlatGLTest.cpp | 14 ++++++++++---- src/Magnum/Shaders/Test/PhongGLTest.cpp | 4 +--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 37a45ca46..c5b3438dc 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -2615,8 +2615,6 @@ template void FlatGLTest::renderInstanced2D() { .setSubImage(0, {image->size().x()/2, 0, 3}, second) .setSubImage(0, {0, 0, 4}, third); shader.bindTexture(textureArray); - if(flag != FlatGL2D::Flag::UniformBuffers) - shader.setTextureLayer(2); /* base offset */ } else #endif @@ -2647,6 +2645,11 @@ template void FlatGLTest::renderInstanced2D() { Vector2{0.5f} )); + #ifndef MAGNUM_TARGET_GLES2 + if(data.flags & FlatGL2D::Flag::TextureArrays) + shader.setTextureLayer(2); /* base offset */ + #endif + #ifndef MAGNUM_TARGET_GLES2 if(data.flags & FlatGL2D::Flag::ObjectId) { /* Gets added to the per-instance ID, if that's enabled as well */ @@ -2879,8 +2882,6 @@ template void FlatGLTest::renderInstanced3D() { .setSubImage(0, {image->size().x()/2, 0, 3}, second) .setSubImage(0, {0, 0, 4}, third); shader.bindTexture(textureArray); - if(flag != FlatGL2D::Flag::UniformBuffers) - shader.setTextureLayer(2); /* base offset */ } else #endif @@ -2912,6 +2913,11 @@ template void FlatGLTest::renderInstanced3D() { Vector2{0.5f} )); + #ifndef MAGNUM_TARGET_GLES2 + if(data.flags & FlatGL3D::Flag::TextureArrays) + shader.setTextureLayer(2); /* base offset */ + #endif + #ifndef MAGNUM_TARGET_GLES2 if(data.flags & FlatGL3D::Flag::ObjectId) { /* Gets added to the per-instance ID, if that's enabled as well */ diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index 849272de9..1fc7e5fc5 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -3518,8 +3518,6 @@ template void PhongGLTest::renderInstanced() { .setSubImage(0, {image->size().x()/2, 0, 3}, second) .setSubImage(0, {0, 0, 4}, third); shader.bindDiffuseTexture(diffuseArray); - if(flag != PhongGL::Flag::UniformBuffers) - shader.setTextureLayer(2); /* base offset */ } else #endif @@ -3616,7 +3614,7 @@ template void PhongGLTest::renderInstanced() { Vector2{0.5f} )); #ifndef MAGNUM_TARGET_GLES2 - if((data.flags & PhongGL::Flag::TextureArrays) && flag != PhongGL::Flag::UniformBuffers) + if(data.flags & PhongGL::Flag::TextureArrays) shader.setTextureLayer(2); /* base offset */ #endif