diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 8b42a55ef..54c2e7f5e 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -57,17 +57,6 @@ namespace GL { namespace Implementation { struct ContextState; struct State; - - enum: std::size_t { - ExtensionCount = - #ifndef MAGNUM_TARGET_GLES - 192 - #elif !defined(MAGNUM_TARGET_WEBGL) - 160 - #else - 48 - #endif - }; } /** diff --git a/src/Magnum/GL/GL.h b/src/Magnum/GL/GL.h index 132f89e22..6371880c6 100644 --- a/src/Magnum/GL/GL.h +++ b/src/Magnum/GL/GL.h @@ -29,6 +29,8 @@ * @brief Forward declarations for the @ref Magnum::GL namespace */ +#include + #include "Magnum/Types.h" #ifndef DOXYGEN_GENERATING_OUTPUT @@ -40,6 +42,20 @@ typedef unsigned int GLuint; /* Needed by Implementation/State.h */ namespace Magnum { namespace GL { #ifndef DOXYGEN_GENERATING_OUTPUT +namespace Implementation { + /* Needed by Context as well as all Implementation::*State classes */ + enum: std::size_t { + ExtensionCount = + #ifndef MAGNUM_TARGET_GLES + 192 + #elif !defined(MAGNUM_TARGET_WEBGL) + 160 + #else + 48 + #endif + }; +} + /* FramebufferClear[Mask], FramebufferBlit[Mask], FramebufferBlitFilter, FramebufferTarget enums used only directly with framebuffer instance */ class AbstractFramebuffer; diff --git a/src/Magnum/GL/Implementation/BufferState.cpp b/src/Magnum/GL/Implementation/BufferState.cpp index 60a4f78df..54494b552 100644 --- a/src/Magnum/GL/Implementation/BufferState.cpp +++ b/src/Magnum/GL/Implementation/BufferState.cpp @@ -80,7 +80,7 @@ std::size_t BufferState::indexForTarget(Buffer::TargetHint target) { CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } -BufferState::BufferState(Context& context, std::vector& extensions): bindings() +BufferState::BufferState(Context& context, Containers::StaticArrayView extensions): bindings() #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES , minMapAlignment(0) @@ -99,7 +99,8 @@ BufferState::BufferState(Context& context, std::vector& extensions) context.isDriverWorkaroundDisabled("intel-windows-crazy-broken-buffer-dsa"_s)) #endif ) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); createImplementation = &Buffer::createImplementationDSA; copyImplementation = &Buffer::copyImplementationDSA; @@ -140,7 +141,8 @@ BufferState::BufferState(Context& context, std::vector& extensions) #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::invalidate_subdata::string()); + extensions[Extensions::ARB::invalidate_subdata::Index] = + Extensions::ARB::invalidate_subdata::string(); invalidateImplementation = &Buffer::invalidateImplementationARB; invalidateSubImplementation = &Buffer::invalidateSubImplementationARB; @@ -154,7 +156,8 @@ BufferState::BufferState(Context& context, std::vector& extensions) #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::multi_bind::string()); + extensions[Extensions::ARB::multi_bind::Index] = + Extensions::ARB::multi_bind::string(); bindBasesImplementation = &Buffer::bindImplementationMulti; bindRangesImplementation = &Buffer::bindImplementationMulti; diff --git a/src/Magnum/GL/Implementation/BufferState.h b/src/Magnum/GL/Implementation/BufferState.h index 1d7f55dd1..3c1dc5d0c 100644 --- a/src/Magnum/GL/Implementation/BufferState.h +++ b/src/Magnum/GL/Implementation/BufferState.h @@ -25,8 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include - #include "Magnum/GL/Buffer.h" namespace Magnum { namespace GL { namespace Implementation { @@ -46,7 +44,7 @@ struct BufferState { static std::size_t indexForTarget(Buffer::TargetHint target); static const Buffer::TargetHint targetForIndex[TargetCount-1]; - explicit BufferState(Context& context, std::vector& extensions); + explicit BufferState(Context& context, Containers::StaticArrayView extensions); void reset(); diff --git a/src/Magnum/GL/Implementation/ContextState.cpp b/src/Magnum/GL/Implementation/ContextState.cpp index e9fae46a5..78a834a17 100644 --- a/src/Magnum/GL/Implementation/ContextState.cpp +++ b/src/Magnum/GL/Implementation/ContextState.cpp @@ -33,7 +33,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -ContextState::ContextState(Context& context, std::vector&) { +ContextState::ContextState(Context& context, Containers::StaticArrayView) { #ifndef MAGNUM_TARGET_GLES if((context.detectedDriver() & Context::DetectedDriver::NVidia) && !context.isDriverWorkaroundDisabled("nv-zero-context-profile-mask"_s)) diff --git a/src/Magnum/GL/Implementation/ContextState.h b/src/Magnum/GL/Implementation/ContextState.h index 63d1e13e1..f159a3231 100644 --- a/src/Magnum/GL/Implementation/ContextState.h +++ b/src/Magnum/GL/Implementation/ContextState.h @@ -25,9 +25,7 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - +#include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #ifdef _MSC_VER @@ -40,7 +38,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct ContextState { - explicit ContextState(Context& context, std::vector& extensions); + explicit ContextState(Context& context, Containers::StaticArrayView extensions); #ifndef MAGNUM_TARGET_GLES enum class CoreProfile { diff --git a/src/Magnum/GL/Implementation/DebugState.cpp b/src/Magnum/GL/Implementation/DebugState.cpp index ed3f4301a..bf0aabb9a 100644 --- a/src/Magnum/GL/Implementation/DebugState.cpp +++ b/src/Magnum/GL/Implementation/DebugState.cpp @@ -31,7 +31,7 @@ namespace Magnum { namespace GL { namespace Implementation { -DebugState::DebugState(Context& context, std::vector& extensions): +DebugState::DebugState(Context& context, Containers::StaticArrayView extensions): maxLabelLength{0}, maxLoggedMessages{0}, maxMessageLength{0}, @@ -45,7 +45,8 @@ DebugState::DebugState(Context& context, std::vector& extensions): #endif { #ifndef MAGNUM_TARGET_GLES - extensions.emplace_back(Extensions::KHR::debug::string()); + extensions[Extensions::KHR::debug::Index] = + Extensions::KHR::debug::string(); #endif getLabelImplementation = &AbstractObject::getLabelImplementationKhrDesktopES32; @@ -60,7 +61,8 @@ DebugState::DebugState(Context& context, std::vector& extensions): #endif #ifdef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::KHR::debug::string()); + extensions[Extensions::KHR::debug::Index] = + Extensions::KHR::debug::string(); getLabelImplementation = &AbstractObject::getLabelImplementationKhrES; labelImplementation = &AbstractObject::labelImplementationKhrES; @@ -74,7 +76,8 @@ DebugState::DebugState(Context& context, std::vector& extensions): #endif { if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::EXT::debug_label::string()); + extensions[Extensions::EXT::debug_label::Index] = + Extensions::EXT::debug_label::string(); getLabelImplementation = &AbstractObject::getLabelImplementationExt; labelImplementation = &AbstractObject::labelImplementationExt; @@ -84,14 +87,16 @@ DebugState::DebugState(Context& context, std::vector& extensions): } if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::EXT::debug_marker::string()); + extensions[Extensions::EXT::debug_marker::Index] = + Extensions::EXT::debug_marker::string(); pushGroupImplementation = &DebugGroup::pushImplementationExt; popGroupImplementation = &DebugGroup::popImplementationExt; messageInsertImplementation = &DebugMessage::insertImplementationExt; #ifndef MAGNUM_TARGET_GLES } else if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::GREMEDY::string_marker::string()); + extensions[Extensions::GREMEDY::string_marker::Index] = + Extensions::GREMEDY::string_marker::string(); pushGroupImplementation = &DebugGroup::pushImplementationNoOp; popGroupImplementation = &DebugGroup::popImplementationNoOp; diff --git a/src/Magnum/GL/Implementation/DebugState.h b/src/Magnum/GL/Implementation/DebugState.h index 6205ff109..c537055fe 100644 --- a/src/Magnum/GL/Implementation/DebugState.h +++ b/src/Magnum/GL/Implementation/DebugState.h @@ -25,9 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include "Magnum/GL/DebugOutput.h" #include "Magnum/GL/GL.h" @@ -38,7 +35,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct DebugState { - explicit DebugState(Context& context, std::vector& extensions); + explicit DebugState(Context& context, Containers::StaticArrayView extensions); std::string(*getLabelImplementation)(GLenum, GLuint); void(*labelImplementation)(GLenum, GLuint, Containers::ArrayView); diff --git a/src/Magnum/GL/Implementation/FramebufferState.cpp b/src/Magnum/GL/Implementation/FramebufferState.cpp index bae28c63e..38f48883c 100644 --- a/src/Magnum/GL/Implementation/FramebufferState.cpp +++ b/src/Magnum/GL/Implementation/FramebufferState.cpp @@ -39,7 +39,7 @@ using namespace Containers::Literals; constexpr const Range2Di FramebufferState::DisengagedViewport; -FramebufferState::FramebufferState(Context& context, std::vector& extensions): readBinding{0}, drawBinding{0}, renderbufferBinding{0}, maxDrawBuffers{0}, maxColorAttachments{0}, maxRenderbufferSize{0}, +FramebufferState::FramebufferState(Context& context, Containers::StaticArrayView extensions): readBinding{0}, drawBinding{0}, renderbufferBinding{0}, maxDrawBuffers{0}, maxColorAttachments{0}, maxRenderbufferSize{0}, #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) maxSamples{0}, #endif @@ -51,7 +51,9 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Create implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); + createImplementation = &Framebuffer::createImplementationDSA; createRenderbufferImplementation = &Renderbuffer::createImplementationDSA; @@ -65,7 +67,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* DSA/non-DSA implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - /* Extension added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSA; @@ -143,7 +146,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e } else #endif { - /* Extension name added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); copySubCubeMapImplementation = &AbstractFramebuffer::copySubCubeMapImplementationDSA; textureCubeMapImplementation = &Framebuffer::textureCubeMapImplementationDSA; @@ -165,7 +169,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-layered-cubemap-array-framebuffer-attachment"_s)) #endif ) { - /* Extension name added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); layeredTextureCubeMapArrayImplementation = &Framebuffer::textureImplementationDSA; } else @@ -203,12 +208,16 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Framebuffer texture attachment on ES3 */ #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) - if(context.isVersionSupported(Version::GLES320)) + if(context.isVersionSupported(Version::GLES320)) { textureImplementation = &Framebuffer::textureImplementationDefault; - else if(context.isExtensionSupported()) + } else if(context.isExtensionSupported()) { + extensions[Extensions::EXT::geometry_shader::Index] = + Extensions::EXT::geometry_shader::string(); + textureImplementation = &Framebuffer::textureImplementationEXT; - else + } else { textureImplementation = nullptr; + } #endif #ifdef MAGNUM_TARGET_GLES2 @@ -221,20 +230,24 @@ FramebufferState::FramebufferState(Context& context, std::vector& e checkStatusImplementation = &Framebuffer::checkStatusImplementationDefault; if(context.isExtensionSupported()) { - extensions.push_back(Extensions::ANGLE::framebuffer_blit::string()); + extensions[Extensions::ANGLE::framebuffer_blit::Index] = + Extensions::ANGLE::framebuffer_blit::string(); } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::APPLE::framebuffer_multisample::string()); + extensions[Extensions::APPLE::framebuffer_multisample::Index] = + Extensions::APPLE::framebuffer_multisample::string(); } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::framebuffer_blit::string()); + extensions[Extensions::NV::framebuffer_blit::Index] = + Extensions::NV::framebuffer_blit::string(); /* NV_framebuffer_multisample requires NV_framebuffer_blit, which has these enums. However, on my system only NV_framebuffer_multisample is supported, but NV_framebuffer_blit isn't. I will hold my breath and assume these enums are available. */ } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::framebuffer_multisample::string()); + extensions[Extensions::NV::framebuffer_multisample::Index] = + Extensions::NV::framebuffer_multisample::string(); /* If no such extension is available, reset back to single target */ } else { @@ -249,17 +262,21 @@ FramebufferState::FramebufferState(Context& context, std::vector& e #ifndef MAGNUM_TARGET_WEBGL /* Framebuffer draw mapping on ES2 */ if(context.isExtensionSupported()) { - extensions.push_back(Extensions::EXT::draw_buffers::string()); + extensions[Extensions::EXT::draw_buffers::Index] = + Extensions::EXT::draw_buffers::string(); drawBuffersImplementation = &AbstractFramebuffer::drawBuffersImplementationEXT; } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::draw_buffers::string()); + extensions[Extensions::NV::draw_buffers::Index] = + Extensions::NV::draw_buffers::string(); drawBuffersImplementation = &AbstractFramebuffer::drawBuffersImplementationNV; } else drawBuffersImplementation = nullptr; #else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::WEBGL::draw_buffers::string()); + extensions[Extensions::WEBGL::draw_buffers::Index] = + Extensions::WEBGL::draw_buffers::string(); + /* The EXT implementation is exposed in Emscripten */ drawBuffersImplementation = &AbstractFramebuffer::drawBuffersImplementationEXT; } else drawBuffersImplementation = nullptr; @@ -296,7 +313,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e if(context.isExtensionSupported() && !((context.detectedDriver() & Context::DetectedDriver::NVidia) && !context.isDriverWorkaroundDisabled("nv-implementation-color-read-format-dsa-broken"_s)) ) { - /* DSA extension added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); if((context.detectedDriver() & Context::DetectedDriver::Mesa) && !context.isDriverWorkaroundDisabled("mesa-implementation-color-read-format-dsa-explicit-binding"_s)) implementationColorReadFormatTypeImplementation = &AbstractFramebuffer::implementationColorReadFormatTypeImplementationFramebufferDSAMesa; @@ -319,9 +337,11 @@ FramebufferState::FramebufferState(Context& context, std::vector& e #endif { #ifndef MAGNUM_TARGET_GLES - extensions.emplace_back(Extensions::ARB::robustness::string()); + extensions[Extensions::ARB::robustness::Index] = + Extensions::ARB::robustness::string(); #else - extensions.push_back(Extensions::EXT::robustness::string()); + extensions[Extensions::EXT::robustness::Index] = + Extensions::EXT::robustness::string(); #endif readImplementation = &AbstractFramebuffer::readImplementationRobustness; @@ -335,7 +355,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Multisample renderbuffer storage implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - /* Extension added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSA; @@ -344,11 +365,13 @@ FramebufferState::FramebufferState(Context& context, std::vector& e { #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(context.isExtensionSupported()) { - extensions.push_back(Extensions::ANGLE::framebuffer_multisample::string()); + extensions[Extensions::ANGLE::framebuffer_multisample::Index] = + Extensions::ANGLE::framebuffer_multisample::string(); renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationANGLE; } else if (context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::framebuffer_multisample::string()); + extensions[Extensions::NV::framebuffer_multisample::Index] = + Extensions::NV::framebuffer_multisample::string(); renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationNV; } else renderbufferStorageMultisampleImplementation = nullptr; @@ -360,7 +383,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Framebuffer invalidation implementation on desktop GL */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::invalidate_subdata::string()); + extensions[Extensions::ARB::invalidate_subdata::Index] = + Extensions::ARB::invalidate_subdata::string(); if(context.isExtensionSupported()) { /* Extension added above */ @@ -379,7 +403,8 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Framebuffer invalidation implementation on ES2 */ #elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(context.isExtensionSupported()) { - extensions.push_back(Extensions::EXT::discard_framebuffer::string()); + extensions[Extensions::EXT::discard_framebuffer::Index] = + Extensions::EXT::discard_framebuffer::string(); invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault; } else { @@ -395,7 +420,9 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Blit implementation on desktop GL */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - /* Extension added above */ + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); + blitImplementation = &AbstractFramebuffer::blitImplementationDSA; } else blitImplementation = &AbstractFramebuffer::blitImplementationDefault; @@ -403,11 +430,15 @@ FramebufferState::FramebufferState(Context& context, std::vector& e /* Blit implementation on ES2 */ #elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(context.isExtensionSupported()) { - extensions.push_back(Extensions::ANGLE::framebuffer_blit::string()); + extensions[Extensions::ANGLE::framebuffer_blit::Index] = + Extensions::ANGLE::framebuffer_blit::string(); + blitImplementation = &AbstractFramebuffer::blitImplementationANGLE; } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::framebuffer_blit::string()); + extensions[Extensions::NV::framebuffer_blit::Index] = + Extensions::NV::framebuffer_blit::string(); + blitImplementation = &AbstractFramebuffer::blitImplementationNV; } else blitImplementation = nullptr; diff --git a/src/Magnum/GL/Implementation/FramebufferState.h b/src/Magnum/GL/Implementation/FramebufferState.h index 8cd0574e2..7b6e9c8d5 100644 --- a/src/Magnum/GL/Implementation/FramebufferState.h +++ b/src/Magnum/GL/Implementation/FramebufferState.h @@ -25,9 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include "Magnum/GL/Framebuffer.h" #ifdef _MSC_VER @@ -42,7 +39,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct FramebufferState { constexpr static const Range2Di DisengagedViewport{{}, {-1, -1}}; - explicit FramebufferState(Context& context, std::vector& extensions); + explicit FramebufferState(Context& context, Containers::StaticArrayView extensions); void reset(); diff --git a/src/Magnum/GL/Implementation/MeshState.cpp b/src/Magnum/GL/Implementation/MeshState.cpp index cd44de651..155023482 100644 --- a/src/Magnum/GL/Implementation/MeshState.cpp +++ b/src/Magnum/GL/Implementation/MeshState.cpp @@ -37,7 +37,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -MeshState::MeshState(Context& context, ContextState& contextState, std::vector& extensions): currentVAO(0) +MeshState::MeshState(Context& context, ContextState& contextState, Containers::StaticArrayView extensions): currentVAO(0) #ifndef MAGNUM_TARGET_GLES2 , maxElementIndex{0}, maxElementsIndices{0}, maxElementsVertices{0} #endif @@ -52,9 +52,11 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::EXT::draw_elements_base_vertex::string()); + extensions[Extensions::EXT::draw_elements_base_vertex::Index] = + Extensions::EXT::draw_elements_base_vertex::string(); drawElementsBaseVertexImplementation = glDrawElementsBaseVertexEXT; #ifndef MAGNUM_TARGET_GLES2 @@ -130,7 +134,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::OES::draw_elements_base_vertex::string()); + extensions[Extensions::OES::draw_elements_base_vertex::Index] = + Extensions::OES::draw_elements_base_vertex::string(); drawElementsBaseVertexImplementation = glDrawElementsBaseVertexOES; #ifndef MAGNUM_TARGET_GLES2 @@ -140,7 +145,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::WEBGL::draw_instanced_base_vertex_base_instance::string()); + extensions[Extensions::WEBGL::draw_instanced_base_vertex_base_instance::Index] = + Extensions::WEBGL::draw_instanced_base_vertex_base_instance::string(); /* The WEBGL extension uses the same entrypoints as the ANGLE extension it was based on, however we wrap it to supply trivial instance count @@ -171,7 +177,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::ANGLE::base_vertex_base_instance::string()); + extensions[Extensions::ANGLE::base_vertex_base_instance::Index] = + Extensions::ANGLE::base_vertex_base_instance::string(); drawArraysInstancedBaseInstanceImplementation = glDrawArraysInstancedBaseInstanceANGLE; /* This variant isn't in the ext, emulated using @@ -182,7 +189,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::WEBGL::draw_instanced_base_vertex_base_instance::string()); + extensions[Extensions::WEBGL::draw_instanced_base_vertex_base_instance::Index] = + Extensions::WEBGL::draw_instanced_base_vertex_base_instance::string(); /* The WEBGL extension uses the same entrypoints as the ANGLE extension it was based on. Only available since 1.39.15: @@ -221,19 +229,22 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::EXT::multi_draw_arrays::string()); + extensions[Extensions::EXT::multi_draw_arrays::Index] = + Extensions::EXT::multi_draw_arrays::string(); multiDrawArraysImplementation = glMultiDrawArraysEXT; multiDrawElementsImplementation = glMultiDrawElementsEXT; } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::ANGLE::multi_draw::string()); + extensions[Extensions::ANGLE::multi_draw::Index] = + Extensions::ANGLE::multi_draw::string(); multiDrawArraysImplementation = glMultiDrawArraysANGLE; multiDrawElementsImplementation = glMultiDrawElementsANGLE; } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); #else { - extensions.push_back(Extensions::WEBGL::multi_draw::string()); + extensions[Extensions::WEBGL::multi_draw::Index] = + Extensions::WEBGL::multi_draw::string(); /* The WEBGL extension uses the same entrypoints as the ANGLE extension it was based on. Only available since 2.0.0: @@ -254,11 +265,13 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::EXT::draw_elements_base_vertex::string()); + extensions[Extensions::EXT::draw_elements_base_vertex::Index] = + Extensions::EXT::draw_elements_base_vertex::string(); multiDrawElementsBaseVertexImplementation = glMultiDrawElementsBaseVertexEXT; } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::OES::draw_elements_base_vertex::string()); + extensions[Extensions::OES::draw_elements_base_vertex::Index] = + Extensions::OES::draw_elements_base_vertex::string(); /* Yes, it's really EXT, the same as with EXT_draw_elements_base_vertex. I have no idea why the two @@ -267,7 +280,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::WEBGL::multi_draw_instanced_base_vertex_base_instance::string()); + extensions[Extensions::WEBGL::multi_draw_instanced_base_vertex_base_instance::Index] = + Extensions::WEBGL::multi_draw_instanced_base_vertex_base_instance::string(); /* The WEBGL extension uses the same entrypoints as the ANGLE extension it was based on, however we wrap it and supply trivial @@ -295,7 +309,8 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::ANGLE::instanced_arrays::string()); + extensions[Extensions::ANGLE::instanced_arrays::Index] = + Extensions::ANGLE::instanced_arrays::string(); drawArraysInstancedImplementation = glDrawArraysInstancedANGLE; drawElementsInstancedImplementation = glDrawElementsInstancedANGLE; @@ -303,18 +318,22 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector() || context.isExtensionSupported()) { - extensions.push_back(context.isExtensionSupported() ? - Extensions::EXT::instanced_arrays::string() : - Extensions::EXT::draw_instanced::string()); + if(context.isExtensionSupported()) + extensions[Extensions::EXT::instanced_arrays::Index] = + Extensions::EXT::instanced_arrays::string(); + else extensions[Extensions::EXT::draw_instanced::Index] = + Extensions::EXT::draw_instanced::string(); drawArraysInstancedImplementation = glDrawArraysInstancedEXT; drawElementsInstancedImplementation = glDrawElementsInstancedEXT; } else if(context.isExtensionSupported() || context.isExtensionSupported()) { - extensions.push_back(context.isExtensionSupported() ? - Extensions::NV::instanced_arrays::string() : - Extensions::NV::draw_instanced::string()); + if(context.isExtensionSupported()) + extensions[Extensions::NV::instanced_arrays::Index] = + Extensions::NV::instanced_arrays::string(); + else extensions[Extensions::NV::draw_instanced::Index] = + Extensions::NV::draw_instanced::string(); drawArraysInstancedImplementation = glDrawArraysInstancedNV; drawElementsInstancedImplementation = glDrawElementsInstancedNV; @@ -332,27 +351,37 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) + } else if(context.isExtensionSupported()) { + extensions[Extensions::ARB::vertex_array_object::Index] = + Extensions::ARB::vertex_array_object::string(); + vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationVAO; - else + } else { vertexAttribDivisorImplementation = nullptr; + } #elif defined(MAGNUM_TARGET_GLES2) /* Instanced arrays implementation on ES2 */ if(context.isExtensionSupported()) { - /* Extension added above */ + extensions[Extensions::ANGLE::instanced_arrays::Index] = + Extensions::ANGLE::instanced_arrays::string(); vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationANGLE; } #ifndef MAGNUM_TARGET_WEBGL else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::EXT::instanced_arrays::string()); + extensions[Extensions::EXT::instanced_arrays::Index] = + Extensions::EXT::instanced_arrays::string(); vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationEXT; } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::instanced_arrays::string()); + extensions[Extensions::NV::instanced_arrays::Index] = + Extensions::NV::instanced_arrays::string(); vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationNV; } diff --git a/src/Magnum/GL/Implementation/MeshState.h b/src/Magnum/GL/Implementation/MeshState.h index 30a6034f0..13a46478b 100644 --- a/src/Magnum/GL/Implementation/MeshState.h +++ b/src/Magnum/GL/Implementation/MeshState.h @@ -25,9 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include "Magnum/GL/Mesh.h" namespace Magnum { namespace GL { namespace Implementation { @@ -35,7 +32,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct ContextState; struct MeshState { - explicit MeshState(Context& context, ContextState& contextState, std::vector& extensions); + explicit MeshState(Context& context, ContextState& contextState, Containers::StaticArrayView extensions); ~MeshState(); void reset(); diff --git a/src/Magnum/GL/Implementation/QueryState.cpp b/src/Magnum/GL/Implementation/QueryState.cpp index 41fb3168d..debc507b9 100644 --- a/src/Magnum/GL/Implementation/QueryState.cpp +++ b/src/Magnum/GL/Implementation/QueryState.cpp @@ -35,7 +35,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -QueryState::QueryState(Context& context, std::vector& extensions) { +QueryState::QueryState(Context& context, Containers::StaticArrayView extensions) { /* Create implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { @@ -43,15 +43,21 @@ QueryState::QueryState(Context& context, std::vector& extensions) { if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) && !context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-indexed-queries"_s)) { createImplementation = &AbstractQuery::createImplementationDefault; } else if((context.detectedDriver() & Context::DetectedDriver::Amd) && !context.isDriverWorkaroundDisabled("amd-windows-dsa-createquery-except-xfb-overflow"_s)) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); + createImplementation = &AbstractQuery::createImplementationDSAExceptXfbOverflow; } else #endif if((context.detectedDriver() & Context::DetectedDriver::Mesa) && !context.isDriverWorkaroundDisabled("mesa-dsa-createquery-except-pipeline-stats"_s)) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); + createImplementation = &AbstractQuery::createImplementationDSAExceptPipelineStats; } else { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); + createImplementation = &AbstractQuery::createImplementationDSA; } } else diff --git a/src/Magnum/GL/Implementation/QueryState.h b/src/Magnum/GL/Implementation/QueryState.h index bf30c2870..caf9f3db6 100644 --- a/src/Magnum/GL/Implementation/QueryState.h +++ b/src/Magnum/GL/Implementation/QueryState.h @@ -25,9 +25,7 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - +#include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #ifdef _MSC_VER @@ -40,7 +38,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct QueryState { - explicit QueryState(Context& context, std::vector& extensions); + explicit QueryState(Context& context, Containers::StaticArrayView extensions); void reset(); diff --git a/src/Magnum/GL/Implementation/RendererState.cpp b/src/Magnum/GL/Implementation/RendererState.cpp index 6ebd3f909..706fd3503 100644 --- a/src/Magnum/GL/Implementation/RendererState.cpp +++ b/src/Magnum/GL/Implementation/RendererState.cpp @@ -35,7 +35,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -RendererState::RendererState(Context& context, ContextState& contextState, std::vector& extensions) +RendererState::RendererState(Context& context, ContextState& contextState, Containers::StaticArrayView extensions) #ifndef MAGNUM_TARGET_WEBGL : resetNotificationStrategy() #endif @@ -46,7 +46,8 @@ RendererState::RendererState(Context& context, ContextState& contextState, std:: #endif { #ifndef MAGNUM_TARGET_GLES - extensions.emplace_back(Extensions::ARB::ES2_compatibility::string()); + extensions[Extensions::ARB::ES2_compatibility::Index] = + Extensions::ARB::ES2_compatibility::string(); #endif clearDepthfImplementation = &Renderer::clearDepthfImplementationES; @@ -64,9 +65,11 @@ RendererState::RendererState(Context& context, ContextState& contextState, std:: #endif { #ifndef MAGNUM_TARGET_GLES - extensions.emplace_back(Extensions::ARB::robustness::string()); + extensions[Extensions::ARB::robustness::Index] = + Extensions::ARB::robustness::string(); #else - extensions.push_back(Extensions::EXT::robustness::string()); + extensions[Extensions::EXT::robustness::Index] = + Extensions::EXT::robustness::string(); #endif graphicsResetStatusImplementation = &Renderer::graphicsResetStatusImplementationRobustness; @@ -103,12 +106,16 @@ RendererState::RendererState(Context& context, ContextState& contextState, std:: #ifndef MAGNUM_TARGET_GLES minSampleShadingImplementation = &Renderer::minSampleShadingImplementationDefault; #elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - if(context.isVersionSupported(Version::GLES320)) + if(context.isVersionSupported(Version::GLES320)) { minSampleShadingImplementation = &Renderer::minSampleShadingImplementationDefault; - else if(context.isExtensionSupported()) + } else if(context.isExtensionSupported()) { + extensions[Extensions::OES::sample_shading::Index] = + Extensions::OES::sample_shading::string(); + minSampleShadingImplementation = &Renderer::minSampleShadingImplementationOES; - else + } else { minSampleShadingImplementation = nullptr; + } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) diff --git a/src/Magnum/GL/Implementation/RendererState.h b/src/Magnum/GL/Implementation/RendererState.h index 0ff9abde7..f8f91034d 100644 --- a/src/Magnum/GL/Implementation/RendererState.h +++ b/src/Magnum/GL/Implementation/RendererState.h @@ -25,9 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include "Magnum/GL/Renderer.h" #include "Magnum/Math/Range.h" @@ -36,7 +33,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct ContextState; struct RendererState { - explicit RendererState(Context& context, ContextState& contextState, std::vector& extensions); + explicit RendererState(Context& context, ContextState& contextState, Containers::StaticArrayView extensions); Range1D(*lineWidthRangeImplementation)(); void(*clearDepthfImplementation)(GLfloat); diff --git a/src/Magnum/GL/Implementation/ShaderProgramState.cpp b/src/Magnum/GL/Implementation/ShaderProgramState.cpp index e22fc5190..141197fce 100644 --- a/src/Magnum/GL/Implementation/ShaderProgramState.cpp +++ b/src/Magnum/GL/Implementation/ShaderProgramState.cpp @@ -37,7 +37,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -ShaderProgramState::ShaderProgramState(Context& context, std::vector& extensions): current(0), maxVertexAttributes(0) +ShaderProgramState::ShaderProgramState(Context& context, Containers::StaticArrayView extensions): current(0), maxVertexAttributes(0) #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL , maxGeometryOutputVertices{0}, maxAtomicCounterBufferSize(0), maxComputeSharedMemorySize(0), maxComputeWorkGroupInvocations(0), maxImageUnits(0), maxCombinedShaderOutputResources(0), maxUniformLocations(0) @@ -86,7 +86,8 @@ ShaderProgramState::ShaderProgramState(Context& context, std::vector()) { - extensions.push_back(Extensions::EXT::separate_shader_objects::string()); + extensions[Extensions::EXT::separate_shader_objects::Index] = + Extensions::EXT::separate_shader_objects::string(); uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationSSOEXT; uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationSSOEXT; diff --git a/src/Magnum/GL/Implementation/ShaderProgramState.h b/src/Magnum/GL/Implementation/ShaderProgramState.h index 42e925ef6..92f68c5c7 100644 --- a/src/Magnum/GL/Implementation/ShaderProgramState.h +++ b/src/Magnum/GL/Implementation/ShaderProgramState.h @@ -25,9 +25,9 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include +#include +#include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" #include "Magnum/Math/Vector3.h" @@ -39,7 +39,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct ShaderProgramState { - explicit ShaderProgramState(Context& context, std::vector& extensions); + explicit ShaderProgramState(Context& context, Containers::StaticArrayView extensions); void reset(); diff --git a/src/Magnum/GL/Implementation/ShaderState.cpp b/src/Magnum/GL/Implementation/ShaderState.cpp index 391d03b05..da221fafa 100644 --- a/src/Magnum/GL/Implementation/ShaderState.cpp +++ b/src/Magnum/GL/Implementation/ShaderState.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -ShaderState::ShaderState(Context& context, std::vector&): +ShaderState::ShaderState(Context& context, Containers::StaticArrayView): maxVertexOutputComponents{}, maxFragmentInputComponents{}, #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) maxTessellationControlInputComponents{}, maxTessellationControlOutputComponents{}, maxTessellationControlTotalOutputComponents{}, maxTessellationEvaluationInputComponents{}, maxTessellationEvaluationOutputComponents{}, maxGeometryInputComponents{}, maxGeometryOutputComponents{}, maxGeometryTotalOutputComponents{}, maxAtomicCounterBuffers{}, maxCombinedAtomicCounterBuffers{}, maxAtomicCounters{}, maxCombinedAtomicCounters{}, maxImageUniforms{}, maxCombinedImageUniforms{}, maxShaderStorageBlocks{}, maxCombinedShaderStorageBlocks{}, diff --git a/src/Magnum/GL/Implementation/ShaderState.h b/src/Magnum/GL/Implementation/ShaderState.h index 7dd6fc52a..1cd83ef77 100644 --- a/src/Magnum/GL/Implementation/ShaderState.h +++ b/src/Magnum/GL/Implementation/ShaderState.h @@ -25,9 +25,9 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include +#include +#include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" @@ -41,7 +41,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct ShaderState { - explicit ShaderState(Context& context, std::vector& extensions); + explicit ShaderState(Context& context, Containers::StaticArrayView extensions); enum: std::size_t { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) diff --git a/src/Magnum/GL/Implementation/State.cpp b/src/Magnum/GL/Implementation/State.cpp index 909baff9f..558f87776 100644 --- a/src/Magnum/GL/Implementation/State.cpp +++ b/src/Magnum/GL/Implementation/State.cpp @@ -25,9 +25,6 @@ #include "State.h" -#include -#include - #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" #include "Magnum/GL/Implementation/BufferState.h" @@ -49,14 +46,12 @@ namespace Magnum { namespace GL { namespace Implementation { State::State(Context& context, std::ostream* const out) { - /* List of extensions used in current context. Guesstimate count to avoid - unnecessary reallocations. */ - std::vector extensions; - #ifndef MAGNUM_TARGET_GLES - extensions.reserve(32); - #else - extensions.reserve(8); - #endif + /* Extensions that might get used by current context. The State classes + will set strings based on Extension::index() and then we'll go through + the list and print ones that aren't null. It's 1.5 kB of temporary data + but I think in terms of code size and overhead it's better than + populating a heap array and then std::sort() it to remove duplicates. */ + const char* extensions[Implementation::ExtensionCount]{}; buffer.reset(new BufferState{context, extensions}); this->context.reset(new ContextState{context, extensions}); @@ -74,12 +69,9 @@ State::State(Context& context, std::ostream* const out) { transformFeedback.reset(new TransformFeedbackState{context, extensions}); #endif - /* Sort the features and remove duplicates */ - std::sort(extensions.begin(), extensions.end()); - extensions.erase(std::unique(extensions.begin(), extensions.end()), extensions.end()); - Debug{out} << "Using optional features:"; - for(const auto& ext: extensions) Debug(out) << " " << ext; + for(const char* extension: extensions) + if(extension) Debug(out) << " " << extension; } State::~State() = default; diff --git a/src/Magnum/GL/Implementation/TextureState.cpp b/src/Magnum/GL/Implementation/TextureState.cpp index f96b2987a..aca81d760 100644 --- a/src/Magnum/GL/Implementation/TextureState.cpp +++ b/src/Magnum/GL/Implementation/TextureState.cpp @@ -43,7 +43,7 @@ namespace Magnum { namespace GL { namespace Implementation { using namespace Containers::Literals; -TextureState::TextureState(Context& context, std::vector& extensions): maxSize{}, +TextureState::TextureState(Context& context, Containers::StaticArrayView extensions): maxSize{}, #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) max3DSize{}, #endif @@ -69,7 +69,8 @@ TextureState::TextureState(Context& context, std::vector& extension /* Create implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); createImplementation = &AbstractTexture::createImplementationDSA; } else @@ -114,7 +115,8 @@ TextureState::TextureState(Context& context, std::vector& extension /* Multi bind implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::multi_bind::string()); + extensions[Extensions::ARB::multi_bind::Index] = + Extensions::ARB::multi_bind::string(); bindMultiImplementation = &AbstractTexture::bindImplementationMulti; @@ -127,7 +129,8 @@ TextureState::TextureState(Context& context, std::vector& extension /* DSA/non-DSA implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); parameteriImplementation = &AbstractTexture::parameterImplementationDSA; parameterfImplementation = &AbstractTexture::parameterImplementationDSA; @@ -244,7 +247,8 @@ TextureState::TextureState(Context& context, std::vector& extension /* Data invalidation implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::invalidate_subdata::string()); + extensions[Extensions::ARB::invalidate_subdata::Index] = + Extensions::ARB::invalidate_subdata::string(); invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationARB; invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationARB; @@ -281,7 +285,9 @@ TextureState::TextureState(Context& context, std::vector& extension getCompressedImageImplementation = &AbstractTexture::getCompressedImageImplementationDSA; } else if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::robustness::string()); + extensions[Extensions::ARB::robustness::Index] = + Extensions::ARB::robustness::string(); + getImageImplementation = &AbstractTexture::getImageImplementationRobustness; getCompressedImageImplementation = &AbstractTexture::getCompressedImageImplementationRobustness; @@ -292,7 +298,9 @@ TextureState::TextureState(Context& context, std::vector& extension /* Image retrieval implementation for cube map */ if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::get_texture_sub_image::string()); + extensions[Extensions::ARB::get_texture_sub_image::Index] = + Extensions::ARB::get_texture_sub_image::string(); + getCubeImageImplementation = &CubeMapTexture::getImageImplementationDSA; getCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDSA; @@ -342,9 +350,11 @@ TextureState::TextureState(Context& context, std::vector& extension #endif { #ifndef MAGNUM_TARGET_GLES - extensions.emplace_back(Extensions::ARB::texture_storage::string()); + extensions[Extensions::ARB::texture_storage::Index] = + Extensions::ARB::texture_storage::string(); #elif defined(MAGNUM_TARGET_GLES2) - extensions.push_back(Extensions::EXT::texture_storage::string()); + extensions[Extensions::EXT::texture_storage::Index] = + Extensions::EXT::texture_storage::string(); #endif #ifndef MAGNUM_TARGET_GLES @@ -387,7 +397,8 @@ TextureState::TextureState(Context& context, std::vector& extension /* Storage implementation for multisample textures. The fallback doesn't have DSA alternative, so it must be handled specially. */ if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::texture_storage_multisample::string()); + extensions[Extensions::ARB::texture_storage_multisample::Index] = + Extensions::ARB::texture_storage_multisample::string(); if(context.isExtensionSupported()) { storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDSA; @@ -403,24 +414,30 @@ TextureState::TextureState(Context& context, std::vector& extension #elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; - if(context.isVersionSupported(Version::GLES320)) + if(context.isVersionSupported(Version::GLES320)) { storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; - else if(context.isExtensionSupported()) + } else if(context.isExtensionSupported()) { + extensions[Extensions::OES::texture_storage_multisample_2d_array::Index] = + Extensions::OES::texture_storage_multisample_2d_array::string(); + storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationOES; - else + } else { storage3DMultisampleImplementation = nullptr; + } #endif /* Anisotropic filter implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::ARB::texture_filter_anisotropic::string()); + extensions[Extensions::ARB::texture_filter_anisotropic::Index] = + Extensions::ARB::texture_filter_anisotropic::string(); setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationArb; } else #endif if(context.isExtensionSupported()) { - extensions.emplace_back(Extensions::EXT::texture_filter_anisotropic::string()); + extensions[Extensions::EXT::texture_filter_anisotropic::Index] = + Extensions::EXT::texture_filter_anisotropic::string(); setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt; } else setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationNoOp; diff --git a/src/Magnum/GL/Implementation/TextureState.h b/src/Magnum/GL/Implementation/TextureState.h index 2a33eff88..f36f76811 100644 --- a/src/Magnum/GL/Implementation/TextureState.h +++ b/src/Magnum/GL/Implementation/TextureState.h @@ -25,8 +25,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include #include #include @@ -53,7 +51,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct TextureState { - explicit TextureState(Context& context, std::vector& extensions); + explicit TextureState(Context& context, Containers::StaticArrayView extensions); ~TextureState(); void reset(); diff --git a/src/Magnum/GL/Implementation/TransformFeedbackState.cpp b/src/Magnum/GL/Implementation/TransformFeedbackState.cpp index 7ce2fbb4a..5a0b6855d 100644 --- a/src/Magnum/GL/Implementation/TransformFeedbackState.cpp +++ b/src/Magnum/GL/Implementation/TransformFeedbackState.cpp @@ -7,7 +7,7 @@ namespace Magnum { namespace GL { namespace Implementation { -TransformFeedbackState::TransformFeedbackState(Context& context, std::vector& extensions): maxInterleavedComponents{0}, maxSeparateAttributes{0}, maxSeparateComponents{0}, +TransformFeedbackState::TransformFeedbackState(Context& context, Containers::StaticArrayView extensions): maxInterleavedComponents{0}, maxSeparateAttributes{0}, maxSeparateComponents{0}, #ifndef MAGNUM_TARGET_GLES maxBuffers{0}, maxVertexStreams{0}, #endif @@ -15,7 +15,8 @@ TransformFeedbackState::TransformFeedbackState(Context& context, std::vector()) { - extensions.emplace_back(Extensions::ARB::direct_state_access::string()); + extensions[Extensions::ARB::direct_state_access::Index] = + Extensions::ARB::direct_state_access::string(); createImplementation = &TransformFeedback::createImplementationDSA; attachRangeImplementation = &TransformFeedback::attachImplementationDSA; diff --git a/src/Magnum/GL/Implementation/TransformFeedbackState.h b/src/Magnum/GL/Implementation/TransformFeedbackState.h index add8477d4..d146fa638 100644 --- a/src/Magnum/GL/Implementation/TransformFeedbackState.h +++ b/src/Magnum/GL/Implementation/TransformFeedbackState.h @@ -25,9 +25,10 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include +#include +#include +#include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #include "Magnum/GL/OpenGL.h" @@ -45,7 +46,7 @@ namespace Magnum { namespace GL { namespace Implementation { struct TransformFeedbackState { - explicit TransformFeedbackState(Context& context, std::vector& extensions); + explicit TransformFeedbackState(Context& context, Containers::StaticArrayView extensions); void reset();