Browse Source

DebugTools: deprecate buffer overloads for textureSubImage().

I just don't see a point in those. PBOs are for when a roundtrip through
a CPU memory would be wasteful, but these utils are mainly for use in
tests. Definitely not for being called several times per frame, because
the temporary framebuffer creation just doesn't make sense. Not sure
what was I thinking in 2016 when I added those, apart from "feature
parity for no practical reason".
pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
a115b943b3
  1. 8
      doc/snippets/DebugTools-gl.cpp
  2. 20
      src/Magnum/DebugTools/Test/TextureImageGLTest.cpp
  3. 10
      src/Magnum/DebugTools/TextureImage.cpp
  4. 38
      src/Magnum/DebugTools/TextureImage.h

8
doc/snippets/DebugTools-gl.cpp

@ -171,14 +171,16 @@ Image2D image = DebugTools::textureSubImage(texture, 0, rect,
/* [textureSubImage-2D-rvalue] */ /* [textureSubImage-2D-rvalue] */
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
{ {
GL::Texture2D texture; GL::Texture2D texture;
Range2Di rect; Range2Di rect;
CORRADE_IGNORE_DEPRECATED_PUSH
/* [textureSubImage-2D-rvalue-buffer] */ /* [textureSubImage-2D-rvalue-buffer] */
GL::BufferImage2D image = DebugTools::textureSubImage(texture, 0, rect, GL::BufferImage2D image = DebugTools::textureSubImage(texture, 0, rect,
{PixelFormat::RGBA8Unorm}, GL::BufferUsage::StaticRead); {PixelFormat::RGBA8Unorm}, GL::BufferUsage::StaticRead);
/* [textureSubImage-2D-rvalue-buffer] */ /* [textureSubImage-2D-rvalue-buffer] */
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif #endif
@ -191,15 +193,17 @@ Image2D image = DebugTools::textureSubImage(texture,
/* [textureSubImage-cubemap-rvalue] */ /* [textureSubImage-cubemap-rvalue] */
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
{ {
GL::CubeMapTexture texture; GL::CubeMapTexture texture;
Range2Di rect; Range2Di rect;
CORRADE_IGNORE_DEPRECATED_PUSH
/* [textureSubImage-cubemap-rvalue-buffer] */ /* [textureSubImage-cubemap-rvalue-buffer] */
GL::BufferImage2D image = DebugTools::textureSubImage(texture, GL::BufferImage2D image = DebugTools::textureSubImage(texture,
GL::CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA8Unorm}, GL::CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA8Unorm},
GL::BufferUsage::StaticRead); GL::BufferUsage::StaticRead);
/* [textureSubImage-cubemap-rvalue-buffer] */ /* [textureSubImage-cubemap-rvalue-buffer] */
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif #endif
} }

20
src/Magnum/DebugTools/Test/TextureImageGLTest.cpp

@ -56,7 +56,7 @@ struct TextureImageGLTest: GL::OpenGLTester {
void subImage2D(); void subImage2D();
void subImage2DNotReadable(); void subImage2DNotReadable();
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void subImage2DBuffer(); void subImage2DBuffer();
void subImage2DBufferNotReadable(); void subImage2DBufferNotReadable();
#endif #endif
@ -64,7 +64,7 @@ struct TextureImageGLTest: GL::OpenGLTester {
void subImageCube(); void subImageCube();
void subImageCubeNotReadable(); void subImageCubeNotReadable();
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void subImageCubeBuffer(); void subImageCubeBuffer();
void subImageCubeBufferNotReadable(); void subImageCubeBufferNotReadable();
#endif #endif
@ -79,7 +79,7 @@ struct TextureImageGLTest: GL::OpenGLTester {
TextureImageGLTest::TextureImageGLTest() { TextureImageGLTest::TextureImageGLTest() {
addTests({&TextureImageGLTest::subImage2D, addTests({&TextureImageGLTest::subImage2D,
&TextureImageGLTest::subImage2DNotReadable, &TextureImageGLTest::subImage2DNotReadable,
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
&TextureImageGLTest::subImage2DBuffer, &TextureImageGLTest::subImage2DBuffer,
&TextureImageGLTest::subImage2DBufferNotReadable, &TextureImageGLTest::subImage2DBufferNotReadable,
#endif #endif
@ -87,7 +87,7 @@ TextureImageGLTest::TextureImageGLTest() {
&TextureImageGLTest::subImageCube, &TextureImageGLTest::subImageCube,
&TextureImageGLTest::subImageCubeNotReadable, &TextureImageGLTest::subImageCubeNotReadable,
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
&TextureImageGLTest::subImageCubeBuffer, &TextureImageGLTest::subImageCubeBuffer,
&TextureImageGLTest::subImageCubeBufferNotReadable, &TextureImageGLTest::subImageCubeBufferNotReadable,
#endif #endif
@ -154,12 +154,14 @@ void TextureImageGLTest::subImage2DNotReadable() {
#endif #endif
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void TextureImageGLTest::subImage2DBuffer() { void TextureImageGLTest::subImage2DBuffer() {
GL::Texture2D texture; GL::Texture2D texture;
texture.setImage(0, GL::TextureFormat::RGBA8, ImageView2D{GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte, Vector2i{2}, Data2D}); texture.setImage(0, GL::TextureFormat::RGBA8, ImageView2D{GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte, Vector2i{2}, Data2D});
CORRADE_IGNORE_DEPRECATED_PUSH
GL::BufferImage2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead); GL::BufferImage2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
CORRADE_IGNORE_DEPRECATED_POP
Containers::Array<char> data = bufferData(image.buffer()); Containers::Array<char> data = bufferData(image.buffer());
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{2}); CORRADE_COMPARE(image.size(), Vector2i{2});
@ -188,7 +190,9 @@ void TextureImageGLTest::subImage2DBufferNotReadable() {
Containers::String out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* The read type doesn't have to match, it doesn't get that far */
CORRADE_IGNORE_DEPRECATED_PUSH
textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead); textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
CORRADE_IGNORE_DEPRECATED_POP
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n"); CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
@ -283,7 +287,7 @@ void TextureImageGLTest::subImageCubeNotReadable() {
#endif #endif
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void TextureImageGLTest::subImageCubeBuffer() { void TextureImageGLTest::subImageCubeBuffer() {
ImageView2D view{GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte, Vector2i{2}, Data2D}; ImageView2D view{GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte, Vector2i{2}, Data2D};
@ -295,7 +299,9 @@ void TextureImageGLTest::subImageCubeBuffer() {
.setImage(GL::CubeMapCoordinate::PositiveZ, 0, GL::TextureFormat::RGBA8, view) .setImage(GL::CubeMapCoordinate::PositiveZ, 0, GL::TextureFormat::RGBA8, view)
.setImage(GL::CubeMapCoordinate::NegativeZ, 0, GL::TextureFormat::RGBA8, view); .setImage(GL::CubeMapCoordinate::NegativeZ, 0, GL::TextureFormat::RGBA8, view);
CORRADE_IGNORE_DEPRECATED_PUSH
GL::BufferImage2D image = textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead); GL::BufferImage2D image = textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
CORRADE_IGNORE_DEPRECATED_POP
Containers::Array<char> data = bufferData(image.buffer()); Containers::Array<char> data = bufferData(image.buffer());
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{2}); CORRADE_COMPARE(image.size(), Vector2i{2});
@ -332,7 +338,9 @@ void TextureImageGLTest::subImageCubeBufferNotReadable() {
Containers::String out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* The read type doesn't have to match, it doesn't get that far */
CORRADE_IGNORE_DEPRECATED_PUSH
textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead); textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
CORRADE_IGNORE_DEPRECATED_POP
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n"); CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");

10
src/Magnum/DebugTools/TextureImage.cpp

@ -27,7 +27,7 @@
#include "TextureImage.h" #include "TextureImage.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"
#endif #endif
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
@ -194,7 +194,7 @@ Image2D textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di&
return Utility::move(image); return Utility::move(image);
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& range, GL::BufferImage2D& image, const GL::BufferUsage usage) { void textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& range, GL::BufferImage2D& image, const GL::BufferUsage usage) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(GL::Context::current().isExtensionSupported<GL::Extensions::ARB::get_texture_sub_image>()) { if(GL::Context::current().isExtensionSupported<GL::Extensions::ARB::get_texture_sub_image>()) {
@ -213,7 +213,9 @@ void textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& ra
} }
GL::BufferImage2D textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& range, GL::BufferImage2D&& image, const GL::BufferUsage usage) { GL::BufferImage2D textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& range, GL::BufferImage2D&& image, const GL::BufferUsage usage) {
CORRADE_IGNORE_DEPRECATED_PUSH
textureSubImage(texture, level, range, image, usage); textureSubImage(texture, level, range, image, usage);
CORRADE_IGNORE_DEPRECATED_POP
return Utility::move(image); return Utility::move(image);
} }
#endif #endif
@ -233,7 +235,7 @@ Image2D textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate
return Utility::move(image); return Utility::move(image);
} }
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
void textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate coordinate, const Int level, const Range2Di& range, GL::BufferImage2D& image, const GL::BufferUsage usage) { void textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate coordinate, const Int level, const Range2Di& range, GL::BufferImage2D& image, const GL::BufferUsage usage) {
GL::Framebuffer fb{range}; GL::Framebuffer fb{range};
fb.attachCubeMapTexture(GL::Framebuffer::ColorAttachment{0}, texture, coordinate, level); fb.attachCubeMapTexture(GL::Framebuffer::ColorAttachment{0}, texture, coordinate, level);
@ -245,7 +247,9 @@ void textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate co
} }
GL::BufferImage2D textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate coordinate, const Int level, const Range2Di& range, GL::BufferImage2D&& image, const GL::BufferUsage usage) { GL::BufferImage2D textureSubImage(GL::CubeMapTexture& texture, const GL::CubeMapCoordinate coordinate, const Int level, const Range2Di& range, GL::BufferImage2D&& image, const GL::BufferUsage usage) {
CORRADE_IGNORE_DEPRECATED_PUSH
textureSubImage(texture, coordinate, level, range, image, usage); textureSubImage(texture, coordinate, level, range, image, usage);
CORRADE_IGNORE_DEPRECATED_POP
return Utility::move(image); return Utility::move(image);
} }
#endif #endif

38
src/Magnum/DebugTools/TextureImage.h

@ -106,9 +106,16 @@ Convenience alternative to the above, example usage:
*/ */
MAGNUM_DEBUGTOOLS_EXPORT Image2D textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, Image2D&& image); MAGNUM_DEBUGTOOLS_EXPORT Image2D textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, Image2D&& image);
#ifndef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2)
/** /**
@brief Read range of given texture mip level to buffer image @brief Read range of given texture mip level to buffer image
@m_deprecated_since_latest As these APIs are mainly meant to be used for
testing and verification, there's little point in having a variant that
puts the data into a pixel buffer by creating a temporary framebuffer. Use
@ref textureSubImage(GL::Texture2D&, Int, const Range2Di&, Image2D&)
instead or populate the buffer using
@ref GL::Framebuffer::read(const Range2Di&, GL::BufferImage2D&, GL::BufferUsage)
on a non-temporary framebuffer.
Emulates @ref GL::Texture2D::subImage() call on platforms that don't support it Emulates @ref GL::Texture2D::subImage() call on platforms that don't support it
(such as OpenGL ES) by creating a framebuffer object and using (such as OpenGL ES) by creating a framebuffer object and using
@ -127,10 +134,17 @@ it
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information. @ref building-features for more information.
*/ */
MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(GL::Texture2D& texture, Int level, const Range2Di& range, GL::BufferImage2D& image, GL::BufferUsage usage); MAGNUM_DEBUGTOOLS_EXPORT CORRADE_DEPRECATED("use textureSubImage(GL::Texture2D&, Int, const Range2Di&, Image2D&) instead") void textureSubImage(GL::Texture2D& texture, Int level, const Range2Di& range, GL::BufferImage2D& image, GL::BufferUsage usage);
/** /**
@brief Read range of given texture mip level to buffer image @brief Read range of given texture mip level to buffer image
@m_deprecated_since_latest As these APIs are mainly meant to be used for
testing and verification, there's little point in having a variant that
puts the data into a buffer image by creating a temporary framebuffer. Use
@ref textureSubImage(GL::Texture2D&, Int, const Range2Di&, Image2D&&)
instead or populate the buffer image directly using
@ref GL::Framebuffer::read(const Range2Di&, GL::BufferImage2D&&, GL::BufferUsage)
on a non-temporary framebuffer.
Convenience alternative to the above, example usage: Convenience alternative to the above, example usage:
@ -140,10 +154,17 @@ Convenience alternative to the above, example usage:
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information. @ref building-features for more information.
*/ */
MAGNUM_DEBUGTOOLS_EXPORT GL::BufferImage2D textureSubImage(GL::Texture2D& texture, Int level, const Range2Di& range, GL::BufferImage2D&& image, GL::BufferUsage usage); MAGNUM_DEBUGTOOLS_EXPORT CORRADE_DEPRECATED("use textureSubImage(GL::Texture2D&, Int, const Range2Di&, Image2D&&) instead") GL::BufferImage2D textureSubImage(GL::Texture2D& texture, Int level, const Range2Di& range, GL::BufferImage2D&& image, GL::BufferUsage usage);
/** /**
@brief Read range of given cube map texture coordinate mip level to buffer image @brief Read range of given cube map texture coordinate mip level to buffer image
@m_deprecated_since_latest As these APIs are mainly meant to be used for
testing and verification, there's little point in having a variant that
puts the data into a buffer image by creating a temporary framebuffer. Use
@ref textureSubImage(GL::CubeMapTexture&, GL::CubeMapCoordinate, Int, const Range2Di&, Image2D&)
instead or populate the buffer image directly using
@ref GL::Framebuffer::read(const Range2Di&, GL::BufferImage2D&, GL::BufferUsage)
on a non-temporary framebuffer.
Emulates @ref GL::CubeMapTexture::subImage() call on platforms that don't Emulates @ref GL::CubeMapTexture::subImage() call on platforms that don't
support it (such as OpenGL ES) by creating a framebuffer object and using support it (such as OpenGL ES) by creating a framebuffer object and using
@ -160,10 +181,17 @@ it
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information. @ref building-features for more information.
*/ */
MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, GL::BufferImage2D& image, GL::BufferUsage usage); MAGNUM_DEBUGTOOLS_EXPORT CORRADE_DEPRECATED("use textureSubImage(GL::CubeMapTexture2D&, GL::CubeMapCoordinate, Int, const Range2Di&, Image2D&) instead") void textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, GL::BufferImage2D& image, GL::BufferUsage usage);
/** /**
@brief Read range of given cube map texture coordinate mip level to buffer image @brief Read range of given cube map texture coordinate mip level to buffer image
@m_deprecated_since_latest As these APIs are mainly meant to be used for
testing and verification, there's little point in having a variant that
puts the data into a buffer image by creating a temporary framebuffer. Use
@ref textureSubImage(GL::CubeMapTexture&, GL::CubeMapCoordinate, Int, const Range2Di&, Image2D&)
instead or populate the buffer image directly using
@ref GL::Framebuffer::read(const Range2Di&, GL::BufferImage2D&, GL::BufferUsage)
on a non-temporary framebuffer.
Convenience alternative to the above, example usage: Convenience alternative to the above, example usage:
@ -173,7 +201,7 @@ Convenience alternative to the above, example usage:
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information. @ref building-features for more information.
*/ */
MAGNUM_DEBUGTOOLS_EXPORT GL::BufferImage2D textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, GL::BufferImage2D&& image, GL::BufferUsage usage); MAGNUM_DEBUGTOOLS_EXPORT CORRADE_DEPRECATED("use textureSubImage(GL::CubeMapTexture2D&, GL::CubeMapCoordinate, Int, const Range2Di&, Image2D&&) instead") GL::BufferImage2D textureSubImage(GL::CubeMapTexture& texture, GL::CubeMapCoordinate coordinate, Int level, const Range2Di& range, GL::BufferImage2D&& image, GL::BufferUsage usage);
#endif #endif
#else #else
#error this header is available only in the OpenGL build #error this header is available only in the OpenGL build

Loading…
Cancel
Save