Browse Source

Queries for max supported texture size.

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
2cbcdeaeb4
  1. 2
      doc/opengl-mapping.dox
  2. 4
      doc/opengl-support.dox
  3. 1
      src/Magnum/AbstractTexture.h
  4. 12
      src/Magnum/BufferTexture.cpp
  5. 20
      src/Magnum/BufferTexture.h
  6. 9
      src/Magnum/CMakeLists.txt
  7. 36
      src/Magnum/CubeMapTexture.cpp
  8. 13
      src/Magnum/CubeMapTexture.h
  9. 45
      src/Magnum/CubeMapTextureArray.cpp
  10. 13
      src/Magnum/CubeMapTextureArray.h
  11. 8
      src/Magnum/Implementation/TextureState.h
  12. 77
      src/Magnum/Implementation/maxTextureSize.cpp
  13. 39
      src/Magnum/Implementation/maxTextureSize.h
  14. 51
      src/Magnum/MultisampleTexture.cpp
  15. 19
      src/Magnum/MultisampleTexture.h
  16. 50
      src/Magnum/RectangleTexture.cpp
  17. 22
      src/Magnum/RectangleTexture.h
  18. 54
      src/Magnum/Texture.cpp
  19. 28
      src/Magnum/Texture.h
  20. 58
      src/Magnum/TextureArray.cpp
  21. 15
      src/Magnum/TextureArray.h

2
doc/opengl-mapping.dox

@ -299,7 +299,7 @@ OpenGL function | Matching API
`GL_MAX_*_UNIFORM_BLOCKS`, \n @def_gl{MAX_COMBINED_UNIFORM_BLOCKS} | @ref Shader::maxUniformBlocks(), \n @ref Shader::maxCombinedUniformBlocks()
`GL_MAX_*_UNIFORM_COMPONENTS`, \n @def_gl{MAX_VERTEX_UNIFORM_VECTORS}, \n @def_gl{MAX_FRAGMENT_UNIFORM_VECTORS} | @ref Shader::maxUniformComponents()
`GL_MAX_COMBINED_*_UNIFORM_COMPONENTS` | @ref Shader::maxCombinedUniformComponents()
@def_gl{MAX_3D_TEXTURE_SIZE}, \n @def_gl{MAX_ARRAY_TEXTURE_LAYERS}, \n @def_gl{MAX_CUBE_MAP_TEXTURE_SIZE}, \n @def_gl{MAX_RECTANGLE_TEXTURE_SIZE}, \n @def_gl{MAX_TEXTURE_SIZE} | |
@def_gl{MAX_3D_TEXTURE_SIZE}, \n @def_gl{MAX_ARRAY_TEXTURE_LAYERS}, \n @def_gl{MAX_CUBE_MAP_TEXTURE_SIZE}, \n @def_gl{MAX_RECTANGLE_TEXTURE_SIZE}, \n @def_gl{MAX_TEXTURE_SIZE} | @ref Texture::maxSize(), \n @ref TextureArray::maxSize(), \n @ref CubeMapTexture::maxSize(), \n @ref CubeMapTextureArray::maxSize(), \n @ref RectangleTexture::maxSize(), \n @ref BufferTexture::maxSize(), \n @ref MultisampleTexture::maxSize()
@def_gl{MAX_ATOMIC_COUNTER_BUFFER_SIZE} | @ref AbstractShaderProgram::maxAtomicCounterBufferSize()
@def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} | @ref Buffer::maxAtomicCounterBindings()
@def_gl{MAX_COLOR_ATTACHMENTS} | @ref Framebuffer::maxColorAttachments()

4
doc/opengl-support.dox

@ -81,9 +81,9 @@ following:
%Extension | Status
-------------------------------------------- | ------
@extension{ARB,texture_rectangle} | missing limit query
@extension{ARB,texture_rectangle} | done
@extension{ARB,draw_instanced} | |
@extension{ARB,texture_buffer_object} | missing limit query
@extension{ARB,texture_buffer_object} | done
@extension{ARB,uniform_buffer_object} | |
@extension{ARB,copy_buffer} | done
@extension{EXT,texture_snorm} | done

1
src/Magnum/AbstractTexture.h

@ -104,7 +104,6 @@ functions do nothing.
@todo Move constructor/assignment - how to avoid creation of empty texture and
then deleting it immediately?
@todo ES2 - proper support for pixel unpack buffer when extension is in headers
@todo `GL_MAX_3D_TEXTURE_SIZE`, `GL_MAX_ARRAY_TEXTURE_LAYERS`, `GL_MAX_CUBE_MAP_TEXTURE_SIZE`, `GL_MAX_RECTANGLE_TEXTURE_SIZE`, `GL_MAX_TEXTURE_SIZE`, `GL_MAX_TEXTURE_BUFFER_SIZE` enable them only where it makes sense?
@todo `GL_NUM_COMPRESSED_TEXTURE_FORMATS` when compressed textures are implemented
@todo `GL_MAX_SAMPLE_MASK_WORDS` when @extension{ARB,texture_multisample} is done
@todo Query for immutable levels (@extension{ARB,ES3_compatibility})

12
src/Magnum/BufferTexture.cpp

@ -35,6 +35,18 @@
namespace Magnum {
Int BufferTexture::maxSize() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_buffer_object>())
return 0;
GLint& value = Context::current()->state().texture->maxBufferSize;
if(value == 0)
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &value);
return value;
}
Int BufferTexture::offsetAlignment() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_buffer_range>())
return 0;

20
src/Magnum/BufferTexture.h

@ -202,6 +202,16 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
friend struct Implementation::TextureState;
public:
/**
* @brief Max supported buffer texture size
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If @extension{ARB,texture_buffer_object} (part of
* OpenGL 3.1) is not available, returns `0`.
* @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_BUFFER_SIZE}
*/
static Int maxSize();
/**
* @brief Minimum required alignment for texture buffer offsets
*
@ -229,8 +239,9 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
* Binds given buffer to this texture. The buffer itself can be then
* filled with data of proper format at any time using @ref Buffer "Buffer"'s
* own data setting functions.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBuffer,EXT,direct_state_access}
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexBuffer} or
* @fn_gl_extension{TextureBuffer,EXT,direct_state_access}
*/
BufferTexture& setBuffer(BufferTextureFormat internalFormat, Buffer& buffer);
@ -245,9 +256,10 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
* Binds range of given buffer to this texture. The buffer itself can
* be then filled with data of proper format at any time using @ref Buffer "Buffer"'s
* own data setting functions.
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexBufferRange} or
* @fn_gl_extension{TextureBufferRange,EXT,direct_state_access}
* @requires_gl43 %Extension @extension{ARB,texture_buffer_range}
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange}
* or @fn_gl_extension{TextureBufferRange,EXT,direct_state_access}
*/
BufferTexture& setBuffer(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size);

9
src/Magnum/CMakeLists.txt

@ -35,6 +35,7 @@ set(Magnum_SRCS
AbstractShaderProgram.cpp
Buffer.cpp
ColorFormat.cpp
CubeMapTexture.cpp
Context.cpp
DebugMessage.cpp
DefaultFramebuffer.cpp
@ -49,6 +50,7 @@ set(Magnum_SRCS
Resource.cpp
Sampler.cpp
Shader.cpp
Texture.cpp
Timeline.cpp
Version.cpp
@ -60,6 +62,7 @@ set(Magnum_SRCS
Implementation/ShaderProgramState.cpp
Implementation/State.cpp
Implementation/TextureState.cpp
Implementation/maxTextureSize.cpp
Implementation/setupDriverWorkarounds.cpp
Trade/AbstractImageConverter.cpp
@ -130,6 +133,9 @@ if(NOT TARGET_GLES)
RectangleTexture.h)
set(Magnum_SRCS ${Magnum_SRCS}
BufferTexture.cpp
CubeMapTextureArray.cpp
MultisampleTexture.cpp
RectangleTexture.cpp
$<TARGET_OBJECTS:MagnumGLLoadGenObjects>)
endif()
@ -139,7 +145,8 @@ if(NOT TARGET_GLES2)
BufferImage.h
TextureArray.h)
set(Magnum_SRCS ${Magnum_SRCS}
BufferImage.cpp)
BufferImage.cpp
TextureArray.cpp)
endif()
# Files shared between main library and math unit test library

36
src/Magnum/CubeMapTexture.cpp

@ -0,0 +1,36 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "CubeMapTexture.h"
#include "Implementation/maxTextureSize.h"
namespace Magnum {
Vector2i CubeMapTexture::maxSize() {
return Vector2i{Implementation::maxCubeMapTextureSideSize()};
}
}

13
src/Magnum/CubeMapTexture.h

@ -79,7 +79,7 @@ which intersects one of the six sides of the cube map. See
@ref Texture, @ref TextureArray, @ref RectangleTexture, @ref BufferTexture,
@ref MultisampleTexture
*/
class CubeMapTexture: public AbstractTexture {
class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
public:
/** @brief Cube map coordinate */
enum class Coordinate: GLenum {
@ -91,6 +91,15 @@ class CubeMapTexture: public AbstractTexture {
NegativeZ = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z /**< -Z cube side */
};
/**
* @brief Max supported size of one side of cube map texture
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls.
* @see @fn_gl{Get} with @def_gl{MAX_CUBE_MAP_TEXTURE_SIZE}
*/
static Vector2i maxSize();
/**
* @brief Constructor
*
@ -205,6 +214,7 @@ class CubeMapTexture: public AbstractTexture {
* @brief Set storage
*
* See @ref Texture::setStorage() for more information.
* @see @ref maxSize()
*/
CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) {
DataHelper<2>::setStorage(*this, _target, levels, internalFormat, size);
@ -251,6 +261,7 @@ class CubeMapTexture: public AbstractTexture {
* @return Reference to self (for method chaining)
*
* See @ref Texture::setImage() for more information.
* @see @ref maxSize()
*/
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) {
DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image);

45
src/Magnum/CubeMapTextureArray.cpp

@ -0,0 +1,45 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "CubeMapTextureArray.h"
#ifndef MAGNUM_TARGET_GLES
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Implementation/maxTextureSize.h"
namespace Magnum {
Vector3i CubeMapTextureArray::maxSize() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
return {};
return Vector3i{Vector2i{Implementation::maxCubeMapTextureSideSize()},
Implementation::maxTextureArrayLayers()};
}
}
#endif

13
src/Magnum/CubeMapTextureArray.h

@ -92,6 +92,17 @@ class CubeMapTextureArray: public AbstractTexture {
*/
explicit CubeMapTextureArray(): AbstractTexture(GL_TEXTURE_CUBE_MAP_ARRAY) {}
/**
* @brief Max supported size of one side of cube map texture array
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If @extension{ARB,texture_cube_map_array} (part of
* OpenGL 4.0) is not available, returns zero vector.
* @see @fn_gl{Get} with @def_gl{MAX_CUBE_MAP_TEXTURE_SIZE} and
* @def_gl{MAX_ARRAY_TEXTURE_LAYERS}
*/
static Vector3i maxSize();
/**
* @brief Set base mip level
* @return Reference to self (for method chaining)
@ -230,6 +241,7 @@ class CubeMapTextureArray: public AbstractTexture {
*
* Z coordinate of @p size must be multiple of 6. See
* @ref Texture::setStorage() for more information.
* @see @ref maxSize()
*/
CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) {
DataHelper<3>::setStorage(*this, _target, levels, internalFormat, size);
@ -274,6 +286,7 @@ class CubeMapTextureArray: public AbstractTexture {
* images are in order of (+X, -X, +Y, -Y, +Z, -Z).
*
* See @ref Texture::setImage() for more information.
* @see @ref maxSize()
*/
CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) {
DataHelper<3>::setImage(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);

8
src/Magnum/Implementation/TextureState.h

@ -74,6 +74,14 @@ struct TextureState {
void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr);
#endif
GLint maxSize,
max3DSize,
maxArrayLayers,
maxCubeMapSize;
#ifndef MAGNUM_TARGET_GLES
GLint maxRectangleSize,
maxBufferSize;
#endif
GLint maxTextureUnits;
GLfloat maxLodBias,
maxMaxAnisotropy;

77
src/Magnum/Implementation/maxTextureSize.cpp

@ -0,0 +1,77 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "maxTextureSize.h"
#include "Magnum/Context.h"
#include "State.h"
#include "TextureState.h"
namespace Magnum { namespace Implementation {
GLint maxTextureSideSize() {
GLint& value = Context::current()->state().texture->maxSize;
if(value == 0)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
return value;
}
GLint max3DTextureDepth() {
GLint& value = Context::current()->state().texture->max3DSize;
if(value == 0)
#ifndef MAGNUM_TARGET_GLES2
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &value);
#else
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_OES, &value);
#endif
return value;
}
#ifndef MAGNUM_TARGET_GLES2
GLint maxTextureArrayLayers() {
GLint& value = Context::current()->state().texture->maxArrayLayers;
if(value == 0)
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &value);
return value;
}
#endif
GLint maxCubeMapTextureSideSize() {
GLint& value = Context::current()->state().texture->maxCubeMapSize;
if(value == 0)
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value);
return value;
}
}}

39
src/Magnum/Implementation/maxTextureSize.h

@ -0,0 +1,39 @@
#ifndef Magnum_Implementation_maxTextureSize_h
#define Magnum_Implementation_maxTextureSize_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGL.h"
namespace Magnum { namespace Implementation {
GLint maxTextureSideSize();
GLint max3DTextureDepth();
GLint maxTextureArrayLayers();
GLint maxCubeMapTextureSideSize();
}}
#endif

51
src/Magnum/MultisampleTexture.cpp

@ -0,0 +1,51 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MultisampleTexture.h"
#ifndef MAGNUM_TARGET_GLES
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Implementation/maxTextureSize.h"
namespace Magnum { namespace Implementation {
template<> Vector2i MAGNUM_EXPORT maxMultisampleTextureSize<2>() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
return {};
return Vector2i{Implementation::maxTextureSideSize()};
}
template<> Vector3i MAGNUM_EXPORT maxMultisampleTextureSize<3>() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
return {};
return {Vector2i{Implementation::maxTextureSideSize()}, Implementation::max3DTextureDepth()};
}
}}
#endif

19
src/Magnum/MultisampleTexture.h

@ -42,6 +42,10 @@ namespace Implementation {
template<UnsignedInt> constexpr GLenum multisampleTextureTarget();
template<> inline constexpr GLenum multisampleTextureTarget<2>() { return GL_TEXTURE_2D_MULTISAMPLE; }
template<> inline constexpr GLenum multisampleTextureTarget<3>() { return GL_TEXTURE_2D_MULTISAMPLE_ARRAY; }
template<UnsignedInt dimensions> typename DimensionTraits<dimensions, Int>::VectorType maxMultisampleTextureSize();
template<> Vector2i maxMultisampleTextureSize<2>();
template<> Vector3i maxMultisampleTextureSize<3>();
}
/**
@ -85,6 +89,19 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
public:
static const UnsignedInt Dimensions = dimensions; /**< @brief %Texture dimension count */
/**
* @brief Max supported multisample texture size
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If extension @extension{ARB,texture_multisample} (part
* of OpenGL 3.2) is not available, returns zero vector.
* @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_SIZE} and
* @def_gl{MAX_3D_TEXTURE_SIZE}
*/
static typename DimensionTraits<dimensions, Int>::VectorType maxSize() {
return Implementation::maxMultisampleTextureSize<dimensions>();
}
/**
* @brief Constructor
*
@ -127,7 +144,7 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
* @extension{ARB,texture_storage} functionality (which unfortunately
* doesn't have any DSA alternative, so the texture must be bound
* to some texture unit before).
* @see @ref maxColorSamples(), @ref maxDepthSamples(),
* @see @ref maxSize(), @ref maxColorSamples(), @ref maxDepthSamples(),
* @ref maxIntegerSamples(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture}
* and @fn_gl{TexStorage2DMultisample}/@fn_gl{TexStorage3DMultisample}
* or @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}/

50
src/Magnum/RectangleTexture.cpp

@ -0,0 +1,50 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "RectangleTexture.h"
#ifndef MAGNUM_TARGET_GLES
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Implementation/State.h"
#include "Implementation/TextureState.h"
namespace Magnum {
Vector2i RectangleTexture::maxSize() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
return {};
GLint& value = Context::current()->state().texture->maxRectangleSize;
if(value == 0)
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &value);
return Vector2i{value};
}
}
#endif

22
src/Magnum/RectangleTexture.h

@ -68,8 +68,18 @@ documentation for more information about usage in shaders.
@requires_gl31 %Extension @extension{ARB,texture_rectangle}
@requires_gl Rectangle textures are not available in OpenGL ES.
*/
class RectangleTexture: public AbstractTexture {
class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
public:
/**
* @brief Max supported rectangle texture size
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If @extension{ARB,texture_rectangle} (part of
* OpenGL 3.1) is not available, returns zero vector.
* @see @fn_gl{Get} with @def_gl{MAX_RECTANGLE_TEXTURE_SIZE}
*/
static Vector2i maxSize();
/**
* @brief Constructor
*
@ -205,8 +215,9 @@ class RectangleTexture: public AbstractTexture {
* @extension{ARB,texture_storage} (part of OpenGL 4.2), OpenGL ES 3.0
* or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not
* available, the feature is emulated with @ref setImage() call.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexStorage2D}
* or @fn_gl_extension{TextureStorage2D,EXT,direct_state_access},
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexStorage2D} or
* @fn_gl_extension{TextureStorage2D,EXT,direct_state_access},
* eventually @fn_gl{TexImage2D} or
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}.
*/
@ -263,8 +274,9 @@ class RectangleTexture: public AbstractTexture {
*
* If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some texture unit before the operation.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexImage2D}
* or @fn_gl_extension{TextureImage2D,EXT,direct_state_access}
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexImage2D} or
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}
*/
RectangleTexture& setImage(TextureFormat internalFormat, const ImageReference2D& image) {
DataHelper<2>::setImage(*this, _target, 0, internalFormat, image);

54
src/Magnum/Texture.cpp

@ -0,0 +1,54 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "Texture.h"
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Implementation/maxTextureSize.h"
#include "Implementation/State.h"
#include "Implementation/TextureState.h"
namespace Magnum { namespace Implementation {
template<UnsignedInt dimensions> typename DimensionTraits<dimensions, Int>::VectorType maxTextureSize() {
return typename DimensionTraits<dimensions, Int>::VectorType{Implementation::maxTextureSideSize()};
}
#ifndef MAGNUM_TARGET_GLES
template MAGNUM_EXPORT Math::Vector<1, Int> maxTextureSize<1>();
#endif
template MAGNUM_EXPORT Vector2i maxTextureSize<2>();
template<> MAGNUM_EXPORT Vector3i maxTextureSize<3>() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>())
return {};
#endif
return {Vector2i(Implementation::maxTextureSideSize()), Implementation::max3DTextureDepth()};
}
}}

28
src/Magnum/Texture.h

@ -51,6 +51,9 @@ namespace Implementation {
return GL_TEXTURE_3D_OES;
#endif
}
template<UnsignedInt dimensions> typename DimensionTraits<dimensions, Int>::VectorType maxTextureSize();
template<> Vector3i maxTextureSize<3>();
}
/**
@ -139,6 +142,20 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
#endif
#endif
/**
* @brief Max supported texture size
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. For 3D textures in OpenGL ES 2.0, if
* @es_extension{OES,texture_3D} extension is not available, returns
* zero vector.
* @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_SIZE},
* @def_gl{MAX_3D_TEXTURE_SIZE}
*/
static typename DimensionTraits<dimensions, Int>::VectorType maxSize() {
return Implementation::maxTextureSize<dimensions>();
}
/**
* @brief Constructor
*
@ -466,13 +483,14 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* calls.
* @todo allow the user to specify ColorType explicitly to avoid
* issues in WebGL (see setSubImage())
* @see @ref setMaxLevel(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture}
* and @fn_gl{TexStorage1D}/@fn_gl{TexStorage2D}/@fn_gl{TexStorage3D}
* @see @ref maxSize(), @ref setMaxLevel(), @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and
* @fn_gl{TexStorage1D}/@fn_gl{TexStorage2D}/@fn_gl{TexStorage3D}
* or @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}/
* @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureStorage3D,EXT,direct_state_access},
* eventually @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D} or
* @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/
* eventually @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D}
* or @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureImage3D,EXT,direct_state_access}
*/
@ -537,7 +555,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some texture unit before the operation.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D} or
* @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/

58
src/Magnum/TextureArray.cpp

@ -0,0 +1,58 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "TextureArray.h"
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Implementation/maxTextureSize.h"
namespace Magnum {
namespace {
template<UnsignedInt> struct VectorOrScalar;
template<> struct VectorOrScalar<1> { typedef Int Type; };
template<> struct VectorOrScalar<2> { typedef Vector2i Type; };
}
template<UnsignedInt dimensions> typename DimensionTraits<dimensions+1, Int>::VectorType TextureArray<dimensions>::maxSize() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
return {};
#endif
return {typename VectorOrScalar<dimensions>::Type{Implementation::maxTextureSideSize()},
Implementation::maxTextureArrayLayers()};
}
#ifndef MAGNUM_TARGET_GLES
template class MAGNUM_EXPORT TextureArray<1>;
#endif
template class MAGNUM_EXPORT TextureArray<2>;
}
#endif

15
src/Magnum/TextureArray.h

@ -95,6 +95,17 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
public:
static const UnsignedInt Dimensions = dimensions; /**< @brief %Texture dimension count */
/**
* @brief Max supported texture array size
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If extension @extension{EXT,texture_array} (part of
* OpenGL 3.0) is not available, returns zero vector.
* @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_SIZE} and
* @def_gl{MAX_ARRAY_TEXTURE_LAYERS}
*/
static typename DimensionTraits<dimensions+1, Int>::VectorType maxSize();
/**
* @brief Constructor
*
@ -217,7 +228,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* @extension{ARB,texture_storage} (part of OpenGL 4.2) or OpenGL ES
* 3.0 is not available, the feature is emulated with sequence of
* @ref setImage() calls.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexStorage2D}/@fn_gl{TexStorage3D} or
* @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureStorage3D,EXT,direct_state_access},
@ -256,7 +267,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
*
* If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some texture unit before the operation.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @see @ref maxSize(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexImage2D}/@fn_gl{TexImage3D} or
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureImage3D,EXT,direct_state_access}

Loading…
Cancel
Save