Browse Source

Don't spread cubemap texture level parameter query workarounds elsewhere.

Pre-DSA code paths need to specify for which face we are querying the
level parameters, which meant that all other calls had to specify the
(implicit) target too. I'm also preparing to put a cubemap-specific
workaround in the level parameter query and that really shouldn't be
present in the generic implementation for all texture types.

The other place where a specific target is needed is in setImage()
implementations, but these are rather big chunks of code and I don't
feel like copying these verbatim to cubemap implementation just to
isolate the workaround in one place.
pull/132/head
Vladimír Vondruš 10 years ago
parent
commit
27aea0ccd5
  1. 44
      src/Magnum/AbstractTexture.cpp
  2. 12
      src/Magnum/AbstractTexture.h
  3. 57
      src/Magnum/CubeMapTexture.cpp
  4. 12
      src/Magnum/CubeMapTexture.h
  5. 2
      src/Magnum/CubeMapTextureArray.h
  6. 5
      src/Magnum/Implementation/TextureState.cpp
  7. 5
      src/Magnum/Implementation/TextureState.h
  8. 2
      src/Magnum/MultisampleTexture.h
  9. 2
      src/Magnum/RectangleTexture.h
  10. 2
      src/Magnum/Texture.h
  11. 2
      src/Magnum/TextureArray.h

44
src/Magnum/AbstractTexture.cpp

@ -1094,19 +1094,19 @@ void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
} }
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractTexture::getLevelParameterImplementationDefault(const GLenum target, const GLint level, const GLenum parameter, GLint* const values) { void AbstractTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) {
bindInternal(); bindInternal();
glGetTexLevelParameteriv(target, level, parameter, values); glGetTexLevelParameteriv(_target, level, parameter, values);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::getLevelParameterImplementationDSA(GLenum, const GLint level, const GLenum parameter, GLint* const values) { void AbstractTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) {
glGetTextureLevelParameteriv(_id, level, parameter, values); glGetTextureLevelParameteriv(_id, level, parameter, values);
} }
void AbstractTexture::getLevelParameterImplementationDSAEXT(const GLenum target, const GLint level, const GLenum parameter, GLint* const values) { void AbstractTexture::getLevelParameterImplementationDSAEXT(const GLint level, const GLenum parameter, GLint* const values) {
_flags |= ObjectFlag::Created; _flags |= ObjectFlag::Created;
glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); glGetTextureLevelParameterivEXT(_id, _target, level, parameter, values);
} }
#endif #endif
#endif #endif
@ -1493,7 +1493,7 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) { template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, _target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size);
/* Reallocate only if needed */ /* Reallocate only if needed */
@ -1512,7 +1512,7 @@ template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, Image<3>&); template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, BufferImage<dimensions>& image, BufferUsage usage) { template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, _target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size);
/* Reallocate only if needed */ /* Reallocate only if needed */
@ -1531,12 +1531,12 @@ template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, Bu
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage); template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage);
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image) { template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, _target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
GLint textureDataSize; GLint textureDataSize;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); (this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
Containers::Array<char> data{image.release()}; Containers::Array<char> data{image.release()};
@ -1554,12 +1554,12 @@ template void MAGNUM_EXPORT AbstractTexture::compressedImage<2>(GLint, Compresse
template void MAGNUM_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&); template void MAGNUM_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&);
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage<dimensions>& image, BufferUsage usage) { template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, _target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
GLint textureDataSize; GLint textureDataSize;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); (this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
if(image.dataSize() < dataSize) if(image.dataSize() < dataSize)
@ -1626,30 +1626,30 @@ template void MAGNUM_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&,
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, GLenum, const GLint level) { Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) {
Math::Vector<1, GLint> value; Math::Vector<1, GLint> value;
(texture.*Context::current()->state().texture->getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
return value; return value;
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) { Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector2i value; Vector2i value;
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
return value; return value;
} }
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, GLenum, const GLint level) { Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector3i value; Vector3i value;
(texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
(texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_DEPTH, &value[2]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]);
return value; return value;
} }
#endif #endif

12
src/Magnum/AbstractTexture.h

@ -463,10 +463,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy); void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy);
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values); void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLenum, GLint level, GLenum parameter, GLint* values); void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values);
void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLenum target, GLint level, GLenum parameter, GLint* values); void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLint level, GLenum parameter, GLint* values);
#endif #endif
#endif #endif
@ -584,7 +584,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> {
static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLenum, GLint level); static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level);
static void setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping);
@ -605,7 +605,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> {
#endif #endif
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level); static Vector2i imageSize(AbstractTexture& texture, GLint level);
#endif #endif
static void setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping);
@ -647,7 +647,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
static Vector3i imageSize(AbstractTexture& texture, GLenum, GLint level); static Vector3i imageSize(AbstractTexture& texture, GLint level);
#endif #endif
static void setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping);

57
src/Magnum/CubeMapTexture.cpp

@ -49,6 +49,17 @@ Vector2i CubeMapTexture::maxSize() {
return Vector2i{Implementation::maxCubeMapTextureSideSize()}; return Vector2i{Implementation::maxCubeMapTextureSideSize()};
} }
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Vector2i CubeMapTexture::imageSize(const Int level) {
const Implementation::TextureState& state = *Context::current()->state().texture;
Vector2i value;
(this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
return value;
}
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void CubeMapTexture::image(const Int level, Image3D& image) { void CubeMapTexture::image(const Int level, Image3D& image) {
createIfNotAlready(); createIfNotAlready();
@ -99,12 +110,10 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
const Vector3i size{imageSize(level), 6}; const Vector3i size{imageSize(level), 6};
GLint textureDataSize; GLint textureDataSize;
/* Similarly to imageSize(), use only parameters of +X in pre-DSA code path (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
and assume that all other slices are the same */
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
Containers::Array<char> data{image.release()}; Containers::Array<char> data{image.release()};
@ -127,12 +136,10 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
const Vector3i size{imageSize(level), 6}; const Vector3i size{imageSize(level), 6};
GLint textureDataSize; GLint textureDataSize;
/* Similarly to imageSize(), use only parameters of +X in pre-DSA code path (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
and assume that all other slices are the same */
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
if(image.dataSize() < dataSize) if(image.dataSize() < dataSize)
@ -193,12 +200,10 @@ BufferImage2D CubeMapTexture::image(const Coordinate coordinate, const Int level
void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedImage2D& image) { void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedImage2D& image) {
const Vector2i size = imageSize(level); const Vector2i size = imageSize(level);
GLint textureDataSize; GLint textureDataSize;
/* Similarly to imageSize(), use only parameters of +X in pre-DSA code path (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
and assume that all other slices are the same */
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
Containers::Array<char> data{image.release()}; Containers::Array<char> data{image.release()};
@ -219,12 +224,10 @@ CompressedImage2D CubeMapTexture::compressedImage(const Coordinate coordinate, c
void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) {
const Vector2i size = imageSize(level); const Vector2i size = imageSize(level);
GLint textureDataSize; GLint textureDataSize;
/* Similarly to imageSize(), use only parameters of +X in pre-DSA code path (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
and assume that all other slices are the same */
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize);
GLint format; GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current()->state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Reallocate only if needed */ /* Reallocate only if needed */
if(image.dataSize() < dataSize) if(image.dataSize() < dataSize)
@ -337,6 +340,28 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Coordinate coordinat
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void CubeMapTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) {
bindInternal();
/* Using only parameters of +X in pre-DSA code path and assuming that all
other faces are the same */
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, parameter, values);
}
#ifndef MAGNUM_TARGET_GLES
void CubeMapTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) {
glGetTextureLevelParameteriv(_id, level, parameter, values);
}
void CubeMapTexture::getLevelParameterImplementationDSAEXT(const GLint level, const GLenum parameter, GLint* const values) {
_flags |= ObjectFlag::Created;
/* Using only parameters of +X in pre-DSA code path and assuming that all
other faces are the same */
glGetTextureLevelParameterivEXT(_id, GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, parameter, values);
}
#endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void CubeMapTexture::getImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { void CubeMapTexture::getImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) {
bindInternal(); bindInternal();

12
src/Magnum/CubeMapTexture.h

@ -421,9 +421,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
* @requires_gles Texture image size queries are not available in * @requires_gles Texture image size queries are not available in
* WebGL. * WebGL.
*/ */
Vector2i imageSize(Int level) { Vector2i imageSize(Int level);
return DataHelper<2>::imageSize(*this, GL_TEXTURE_CUBE_MAP_POSITIVE_X, level);
}
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@ -946,6 +944,14 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
private: private:
explicit CubeMapTexture(GLuint id, ObjectFlags flags) noexcept: AbstractTexture{id, GL_TEXTURE_CUBE_MAP, flags} {} explicit CubeMapTexture(GLuint id, ObjectFlags flags) noexcept: AbstractTexture{id, GL_TEXTURE_CUBE_MAP, flags} {}
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values);
void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLint level, GLenum parameter, GLint* values);
#endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); void MAGNUM_LOCAL getImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);

2
src/Magnum/CubeMapTextureArray.h

@ -368,7 +368,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
*/ */
Vector3i imageSize(Int level) { Vector3i imageSize(Int level) {
return DataHelper<3>::imageSize(*this, _target, level); return DataHelper<3>::imageSize(*this, level);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

5
src/Magnum/Implementation/TextureState.cpp

@ -135,6 +135,7 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
setBufferImplementation = &BufferTexture::setBufferImplementationDSA; setBufferImplementation = &BufferTexture::setBufferImplementationDSA;
setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSA; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSA;
getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDSA;
cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSA; cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSA;
cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSA; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSA;
@ -159,6 +160,7 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
setBufferImplementation = &BufferTexture::setBufferImplementationDSAEXT; setBufferImplementation = &BufferTexture::setBufferImplementationDSAEXT;
setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSAEXT; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSAEXT;
getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDSAEXT;
cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSAEXT; cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSAEXT;
cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSAEXT; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSAEXT;
@ -195,6 +197,9 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault;
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDefault;
#endif
cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDefault; cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDefault;
cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDefault; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDefault;
} }

5
src/Magnum/Implementation/TextureState.h

@ -61,7 +61,7 @@ struct TextureState {
#endif #endif
void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat);
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*); void(AbstractTexture::*getLevelParameterivImplementation)(GLint, GLenum, GLint*);
#endif #endif
void(AbstractTexture::*mipmapImplementation)(); void(AbstractTexture::*mipmapImplementation)();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -97,6 +97,9 @@ struct TextureState {
void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr);
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void(CubeMapTexture::*getCubeLevelParameterivImplementation)(GLint, GLenum, GLint*);
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void(CubeMapTexture::*getCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); void(CubeMapTexture::*getCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*);
void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, std::size_t, GLvoid*); void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, std::size_t, GLvoid*);

2
src/Magnum/MultisampleTexture.h

@ -210,7 +210,7 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
* OpenGL ES 3.0 and older. * OpenGL ES 3.0 and older.
*/ */
VectorTypeFor<dimensions, Int> imageSize() { VectorTypeFor<dimensions, Int> imageSize() {
return DataHelper<dimensions>::imageSize(*this, _target, 0); return DataHelper<dimensions>::imageSize(*this, 0);
} }
/** /**

2
src/Magnum/RectangleTexture.h

@ -275,7 +275,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
* *
* See @ref Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
*/ */
Vector2i imageSize() { return DataHelper<2>::imageSize(*this, _target, 0); } Vector2i imageSize() { return DataHelper<2>::imageSize(*this, 0); }
/** /**
* @brief Read texture to image * @brief Read texture to image

2
src/Magnum/Texture.h

@ -625,7 +625,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* WebGL. * WebGL.
*/ */
VectorTypeFor<dimensions, Int> imageSize(Int level) { VectorTypeFor<dimensions, Int> imageSize(Int level) {
return DataHelper<dimensions>::imageSize(*this, _target, level); return DataHelper<dimensions>::imageSize(*this, level);
} }
#endif #endif

2
src/Magnum/TextureArray.h

@ -388,7 +388,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* WebGL. * WebGL.
*/ */
VectorTypeFor<dimensions+1, Int> imageSize(Int level) { VectorTypeFor<dimensions+1, Int> imageSize(Int level) {
return DataHelper<dimensions+1>::imageSize(*this, _target, level); return DataHelper<dimensions+1>::imageSize(*this, level);
} }
#endif #endif

Loading…
Cancel
Save