]> git.tdb.fi Git - libs/gl.git/commitdiff
Tweak some texture allocation checks
authorMikko Rasa <tdb@tdb.fi>
Mon, 13 Sep 2021 16:59:07 +0000 (19:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 13 Sep 2021 17:02:21 +0000 (20:02 +0300)
Sub_image calls allocate_ internally, so it should avoid doing
unnecessary work.

source/core/texture3d.cpp
source/core/texturecube.cpp

index 9db8b06150b110a525e8569a9ee0074badef7f51..bdb87882e878333c23e88373bc85b57d277c7e74 100644 (file)
@@ -57,8 +57,6 @@ void Texture3D::allocate(unsigned level)
                throw invalid_operation("Texture3D::allocate");
        if(level>=levels)
                throw invalid_argument("Texture3D::allocate");
-       if(allocated&(1<<level))
-               return;
 
        bool direct = ARB_texture_storage && ARB_direct_state_access;
        if(!direct)
@@ -75,6 +73,9 @@ void Texture3D::allocate(unsigned level)
 
 void Texture3D::allocate_(unsigned level)
 {
+       if(allocated&(1<<level))
+               return;
+
        if(ARB_texture_storage)
        {
                GLenum fmt = get_gl_pixelformat(storage_fmt);
index 277cba6df35b821d4119060dc83ed64be1dc886c..2db1b63b92162c358618c7c3d7a6a0831ce3cb5e 100644 (file)
@@ -77,8 +77,6 @@ void TextureCube::allocate(unsigned level)
                throw invalid_operation("TextureCube::allocate");
        if(level>=levels)
                throw invalid_argument("TextureCube::allocate");
-       if(allocated&(64<<level))
-               return;
 
        bool direct = ARB_texture_storage && ARB_direct_state_access;
        if(!direct)
@@ -95,6 +93,9 @@ void TextureCube::allocate(unsigned level)
 
 void TextureCube::allocate_(unsigned level)
 {
+       if(allocated&(64<<level))
+               return;
+
        if(ARB_texture_storage)
        {
                GLenum fmt = get_gl_pixelformat(storage_fmt);