diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index ff6d31e44..e6c704ba5 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -48,9 +48,15 @@ Int Buffer::minMapAlignment() { return value; } +#endif +#ifndef MAGNUM_TARGET_GLES2 Int Buffer::maxAtomicCounterBindings() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + #endif return 0; GLint& value = Context::current()->state().buffer->maxAtomicCounterBindings; @@ -62,7 +68,11 @@ Int Buffer::maxAtomicCounterBindings() { } Int Buffer::maxShaderStorageBindings() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + #endif return 0; GLint& value = Context::current()->state().buffer->maxShaderStorageBindings; @@ -74,7 +84,11 @@ Int Buffer::maxShaderStorageBindings() { } Int Buffer::shaderStorageOffsetAlignment() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + #endif return 0; GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment; @@ -396,14 +410,10 @@ Debug operator<<(Debug debug, Buffer::Target value) { switch(value) { #define _c(value) case Buffer::Target::value: return debug << "Buffer::Target::" #value; _c(Array) - #ifndef MAGNUM_TARGET_GLES - _c(AtomicCounter) - #endif #ifndef MAGNUM_TARGET_GLES2 + _c(AtomicCounter) _c(CopyRead) _c(CopyWrite) - #endif - #ifndef MAGNUM_TARGET_GLES _c(DispatchIndirect) _c(DrawIndirect) #endif @@ -411,9 +421,9 @@ Debug operator<<(Debug debug, Buffer::Target value) { #ifndef MAGNUM_TARGET_GLES2 _c(PixelPack) _c(PixelUnpack) + _c(ShaderStorage) #endif #ifndef MAGNUM_TARGET_GLES - _c(ShaderStorage) _c(Texture) #endif #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index e53d24fd5..8f867aae8 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -219,11 +219,12 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { /** Used for storing vertex attributes. */ Array = GL_ARRAY_BUFFER, - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * Used for storing atomic counters. * @requires_gl42 %Extension @extension{ARB,shader_atomic_counters} - * @requires_gl Atomic counters are not available in OpenGL ES. + * @requires_gles31 Atomic counters are not available in OpenGL ES + * 3.0 and older. */ AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, #endif @@ -246,18 +247,20 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { CopyWrite = GL_COPY_WRITE_BUFFER, #endif - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * Indirect compute dispatch commands. * @requires_gl43 %Extension @extension{ARB,compute_shader} - * @requires_gl Compute shaders are not available in OpenGL ES. + * @requires_gles31 Compute shaders are not available in OpenGL ES + * 3.0 and older. */ DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, /** * Used for supplying arguments for indirect drawing. * @requires_gl40 %Extension @extension{ARB,draw_indirect} - * @requires_gl Indirect drawing not available in OpenGL ES. + * @requires_gles31 Indirect drawing not available in OpenGL ES 3.0 + * and older. */ DrawIndirect = GL_DRAW_INDIRECT_BUFFER, #endif @@ -283,14 +286,17 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { PixelUnpack = GL_PIXEL_UNPACK_BUFFER, #endif - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * Used for shader storage. * @requires_gl43 %Extension @extension{ARB,shader_storage_buffer_object} - * @requires_gl Shader storage is not available in OpenGL ES. + * @requires_gles31 Shader storage is not available in OpenGL ES + * 3.0 and older. */ ShaderStorage = GL_SHADER_STORAGE_BUFFER, + #endif + #ifndef MAGNUM_TARGET_GLES /** * Source for texel fetches. See @ref BufferTexture. * @requires_gl31 %Extension @extension{ARB,texture_buffer_object} @@ -442,21 +448,23 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @brief Minimal supported mapping alignment * * The result is cached, repeated queries don't result in repeated - * OpenGL calls. If extension @extension{ARB,map_buffer_alignment} is - * not available, returns `0`. + * OpenGL calls. If extension @extension{ARB,map_buffer_alignment} + * (part of OpenGL 4.2) is not available, returns `0`. * @see @ref map(), @fn_gl{Get} with @def_gl{MIN_MAP_BUFFER_ALIGNMENT} * @requires_gl No minimal value is specified for OpenGL ES. */ static Int minMapAlignment(); + #endif + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Max supported atomic counter buffer binding count * * The result is cached, repeated queries don't result in repeated - * OpenGL calls. If extension @extension{ARB,shader_atomic_counters} is - * not available, returns `0`. + * OpenGL calls. If neither extension @extension{ARB,shader_atomic_counters} + * (part of OpenGL 4.2) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} - * @requires_gl Atomic counters are not available in OpenGL ES. + * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int maxAtomicCounterBindings(); @@ -464,10 +472,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @brief Max supported shader storage buffer binding count * * The result is cached, repeated queries don't result in repeated - * OpenGL calls. If extension @extension{ARB,shader_storage_buffer_object} - * is not available, returns `0`. + * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} + * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} - * @requires_gl Atomic counters are not available in OpenGL ES. + * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int maxShaderStorageBindings(); @@ -475,10 +483,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @brief Alignment of shader storage buffer binding offset * * The result is cached, repeated queries don't result in repeated - * OpenGL calls. If extension @extension{ARB,shader_storage_buffer_object} - * is not available, returns `0`. + * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} + * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} - * @requires_gl Atomic counters are not available in OpenGL ES. + * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int shaderStorageOffsetAlignment(); #endif @@ -489,7 +497,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * * The result is cached, repeated queries don't result in repeated * OpenGL calls. If extension @extension{ARB,uniform_buffer_object} - * is not available, returns `0`. + * (part of OpenGL 3.1) is not available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} * @requires_gles30 Uniform blocks are not available in OpenGL ES 2.0. */ diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index d9e0b1d3d..618dff7f0 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -36,24 +36,22 @@ namespace Magnum { namespace Implementation { const Buffer::Target BufferState::targetForIndex[] = { Buffer::Target::Array, - Buffer::Target::ElementArray + Buffer::Target::ElementArray, #ifndef MAGNUM_TARGET_GLES2 - , Buffer::Target::CopyRead, Buffer::Target::CopyWrite, Buffer::Target::PixelPack, Buffer::Target::PixelUnpack, Buffer::Target::TransformFeedback, - Buffer::Target::Uniform - #endif - #ifndef MAGNUM_TARGET_GLES - , + Buffer::Target::Uniform, Buffer::Target::AtomicCounter, Buffer::Target::DispatchIndirect, Buffer::Target::DrawIndirect, Buffer::Target::ShaderStorage, + #ifndef MAGNUM_TARGET_GLES Buffer::Target::Texture #endif + #endif }; std::size_t BufferState::indexForTarget(Buffer::Target target) { @@ -67,14 +65,14 @@ std::size_t BufferState::indexForTarget(Buffer::Target target) { case Buffer::Target::PixelUnpack: return 6; case Buffer::Target::TransformFeedback: return 7; case Buffer::Target::Uniform: return 8; - #endif - #ifndef MAGNUM_TARGET_GLES case Buffer::Target::AtomicCounter: return 9; case Buffer::Target::DispatchIndirect: return 10; case Buffer::Target::DrawIndirect: return 11; case Buffer::Target::ShaderStorage: return 12; + #ifndef MAGNUM_TARGET_GLES case Buffer::Target::Texture: return 13; #endif + #endif } CORRADE_ASSERT_UNREACHABLE(); @@ -83,9 +81,9 @@ std::size_t BufferState::indexForTarget(Buffer::Target target) { BufferState::BufferState(Context& context, std::vector& extensions): bindings() #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - , minMapAlignment(0), maxAtomicCounterBindings(0), maxShaderStorageBindings(0), shaderStorageOffsetAlignment(0) + , minMapAlignment(0) #endif - , maxUniformBindings(0) + , maxAtomicCounterBindings(0), maxShaderStorageBindings(0), shaderStorageOffsetAlignment(0), maxUniformBindings(0) #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Implementation/BufferState.h b/src/Magnum/Implementation/BufferState.h index 9c255c37a..48ccba415 100644 --- a/src/Magnum/Implementation/BufferState.h +++ b/src/Magnum/Implementation/BufferState.h @@ -32,13 +32,11 @@ namespace Magnum { namespace Implementation { struct BufferState { #ifndef MAGNUM_TARGET_GLES static const std::size_t TargetCount = 13+1; - #else - #ifndef MAGNUM_TARGET_GLES2 - static const std::size_t TargetCount = 8+1; + #elif !defined(MAGNUM_TARGET_GLES2) + static const std::size_t TargetCount = 12+1; #else static const std::size_t TargetCount = 2+1; #endif - #endif /* Target <-> index mapping */ static std::size_t indexForTarget(Buffer::Target target); @@ -72,10 +70,10 @@ struct BufferState { GLint #ifndef MAGNUM_TARGET_GLES minMapAlignment, + #endif maxAtomicCounterBindings, maxShaderStorageBindings, shaderStorageOffsetAlignment, - #endif maxUniformBindings; #endif };