]> git.tdb.fi Git - libs/gl.git/commitdiff
Rearrange texture bind calls to keep them closer to where they're needed
authorMikko Rasa <tdb@tdb.fi>
Fri, 28 Oct 2016 12:21:03 +0000 (15:21 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 28 Oct 2016 12:21:03 +0000 (15:21 +0300)
source/texture1d.cpp
source/texture2d.cpp
source/texture3d.cpp
source/texturecube.cpp

index e5a496a455095093c89502d15c3727dd7306ecec..ed7d8f6e2b877fd4f660d71dbdc72874ef3de34b 100644 (file)
@@ -59,10 +59,10 @@ void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void
 
        unsigned w = get_level_size(level);
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(level, 0, w, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage1D(target, level, ifmt, w, 0, fmt, type, data);
 
        allocated |= 1<<level;
@@ -78,9 +78,9 @@ void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelFormat fmt, D
        if(width==0)
                throw invalid_operation("Texture3D::image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage1D(target, level, x, wd, fmt, type, data);
 
        if(gen_mipmap && level==0)
index 4d6e32f5550cd6f48ee68c71d957278b7ffe355e..23cb9477e122c69ddabdbf614dfafca05ed71801 100644 (file)
@@ -89,10 +89,10 @@ void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void
        unsigned h = height;
        get_level_size(level, w, h);
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(level, 0, 0, w, h, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage2D(target, level, ifmt, w, h, 0, fmt, type, data);
 
        allocated |= 1<<level;
@@ -108,9 +108,9 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        if(width==0 || height==0)
                throw invalid_operation("Texture2D::sub_image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
 
        if(gen_mipmap && level==0)
index 7ea17b137e545d0fcc757173799f3598998788cb..36afa9bcdfe9b3fc2dc1e72c5ef8d19bce06f8aa 100644 (file)
@@ -78,10 +78,10 @@ void Texture3D::image(unsigned level, PixelFormat fmt, DataType type, const void
        unsigned d = depth;
        get_level_size(level, w, h, d);
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(level, 0, 0, 0, w, h, d, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage3D(target, level, ifmt, width, height, depth, 0, fmt, type, data);
 
        allocated |= 1<<level;
@@ -97,9 +97,9 @@ void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsi
        if(width==0 || height==0 || depth==0)
                throw invalid_operation("Texture3D::image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
 
        if(gen_mipmap && level==0)
index a9961af90a3900660f2e2c71a5a46be8820f6441..e767423fe539f9ee92fd10dd5af8f1beaa6eebb4 100644 (file)
@@ -77,10 +77,10 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
        if(s==0)
                throw out_of_range("TextureCube::image");
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(face, level, 0, 0, s, s, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
@@ -98,9 +98,9 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
        if(size==0)
                throw invalid_operation("TextureCube::sub_image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
 
        if(gen_mipmap && level==0)