]> git.tdb.fi Git - libs/gl.git/commitdiff
Use DSA for TextureCube if available
authorMikko Rasa <tdb@tdb.fi>
Thu, 12 Aug 2021 13:03:25 +0000 (16:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 12 Aug 2021 19:32:18 +0000 (22:32 +0300)
source/core/texturecube.cpp

index 01820fa8766be6afa5235419c5da9d63062a6388..93faa3703ab993ee29e05710347c56be82c3bca2 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/datafile/collection.h>
+#include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/arb_seamless_cube_map.h>
 #include <msp/gl/extensions/arb_texture_cube_map.h>
 #include <msp/gl/extensions/arb_texture_storage.h>
@@ -83,8 +84,11 @@ void TextureCube::allocate(unsigned level)
 
        if(ARB_texture_storage)
        {
-               BindRestore _bind(this);
-               glTexStorage2D(target, levels, storage_fmt, size, size);
+               Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
+               if(ARB_direct_state_access)
+                       glTextureStorage2D(id, levels, storage_fmt, size, size);
+               else
+                       glTexStorage2D(target, levels, storage_fmt, size, size);
                apply_swizzle();
                allocated |= (64<<levels)-1;
        }
@@ -154,12 +158,15 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
        if(size==0)
                throw invalid_operation("TextureCube::sub_image");
 
-       BindRestore _bind(this);
+       Conditional<BindRestore> _bind(!ARB_direct_state_acess, this);
        allocate(level);
 
        PixelComponents comp = get_components(storage_fmt);
        GLenum type = get_gl_type(get_component_type(storage_fmt));
-       glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data);
+       if(ARB_direct_state_access)
+               glTextureSubImage3D(id, level, x, y, get_face_index(face), wd, ht, 1, comp, type, data);
+       else
+               glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data);
 
        if(auto_gen_mipmap && level==0)
                generate_mipmap();