Browse Source

GL: put all internal Context State substructures in a single allocation.

This means that instead of 12 separate allocations we have just one,
allocating everything together in a contiguous piece of memory. That
should be also a bit more cache friendly when accessing the state as
it's not scattered around the memory like crazy.

Because there are no Pointer indirections needed anymore, the State
members are just references now. That resulted in a lot of sweeping
changes around the whole GL library, but they're all trivial, changing
`->` to `.`, mostly.

There's two more nested allocations in the TextureState struct, will
take care of them in a separate commit.
euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
532d72e1aa
  1. 58
      src/Magnum/GL/AbstractFramebuffer.cpp
  2. 2
      src/Magnum/GL/AbstractObject.cpp
  3. 10
      src/Magnum/GL/AbstractQuery.cpp
  4. 116
      src/Magnum/GL/AbstractShaderProgram.cpp
  5. 250
      src/Magnum/GL/AbstractTexture.cpp
  6. 68
      src/Magnum/GL/Buffer.cpp
  7. 12
      src/Magnum/GL/BufferTexture.cpp
  8. 30
      src/Magnum/GL/Context.cpp
  9. 5
      src/Magnum/GL/Context.h
  10. 114
      src/Magnum/GL/CubeMapTexture.cpp
  11. 32
      src/Magnum/GL/DebugOutput.cpp
  12. 22
      src/Magnum/GL/DefaultFramebuffer.cpp
  13. 66
      src/Magnum/GL/Framebuffer.cpp
  14. 84
      src/Magnum/GL/Implementation/State.cpp
  15. 33
      src/Magnum/GL/Implementation/State.h
  16. 8
      src/Magnum/GL/Implementation/maxTextureSize.cpp
  17. 50
      src/Magnum/GL/Mesh.cpp
  18. 2
      src/Magnum/GL/MeshView.cpp
  19. 2
      src/Magnum/GL/RectangleTexture.cpp
  20. 18
      src/Magnum/GL/Renderbuffer.cpp
  21. 34
      src/Magnum/GL/Renderer.cpp
  22. 2
      src/Magnum/GL/Sampler.cpp
  23. 60
      src/Magnum/GL/Shader.cpp
  24. 28
      src/Magnum/GL/TransformFeedback.cpp

58
src/Magnum/GL/AbstractFramebuffer.cpp

@ -51,7 +51,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
Vector2i AbstractFramebuffer::maxViewportSize() { Vector2i AbstractFramebuffer::maxViewportSize() {
Vector2i& value = Context::current().state().framebuffer->maxViewportSize; Vector2i& value = Context::current().state().framebuffer.maxViewportSize;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == Vector2i()) if(value == Vector2i())
@ -72,7 +72,7 @@ Int AbstractFramebuffer::maxDrawBuffers() {
#endif #endif
#endif #endif
GLint& value = Context::current().state().framebuffer->maxDrawBuffers; GLint& value = Context::current().state().framebuffer.maxDrawBuffers;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) { if(value == 0) {
@ -91,7 +91,7 @@ Int AbstractFramebuffer::maxDualSourceDrawBuffers() {
if(!Context::current().isExtensionSupported<Extensions::ARB::blend_func_extended>()) if(!Context::current().isExtensionSupported<Extensions::ARB::blend_func_extended>())
return 0; return 0;
GLint& value = Context::current().state().framebuffer->maxDualSourceDrawBuffers; GLint& value = Context::current().state().framebuffer.maxDualSourceDrawBuffers;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -124,13 +124,13 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
static_cast<void>(target); static_cast<void>(target);
bindImplementationSingle(); bindImplementationSingle();
#else #else
(this->*Context::current().state().framebuffer->bindImplementation)(target); (this->*Context::current().state().framebuffer.bindImplementation)(target);
#endif #endif
} }
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) { void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) {
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding);
if(state.readBinding == _id) return; if(state.readBinding == _id) return;
@ -146,7 +146,7 @@ void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) {
inline inline
#endif #endif
void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) { void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) {
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
if(target == FramebufferTarget::Read) { if(target == FramebufferTarget::Read) {
if(state.readBinding == _id) return; if(state.readBinding == _id) return;
@ -167,13 +167,13 @@ FramebufferTarget AbstractFramebuffer::bindInternal() {
#elif defined(MAGNUM_TARGET_WEBGL) #elif defined(MAGNUM_TARGET_WEBGL)
return bindImplementationSingle(); return bindImplementationSingle();
#else #else
return (this->*Context::current().state().framebuffer->bindInternalImplementation)(); return (this->*Context::current().state().framebuffer.bindInternalImplementation)();
#endif #endif
} }
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { FramebufferTarget AbstractFramebuffer::bindImplementationSingle() {
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding);
/* Bind the framebuffer, if not already */ /* Bind the framebuffer, if not already */
@ -197,7 +197,7 @@ FramebufferTarget AbstractFramebuffer::bindImplementationSingle() {
inline inline
#endif #endif
FramebufferTarget AbstractFramebuffer::bindImplementationDefault() { FramebufferTarget AbstractFramebuffer::bindImplementationDefault() {
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
/* Return target to which the framebuffer is already bound */ /* Return target to which the framebuffer is already bound */
if(state.readBinding == _id) if(state.readBinding == _id)
@ -215,11 +215,11 @@ FramebufferTarget AbstractFramebuffer::bindImplementationDefault() {
} }
PixelFormat AbstractFramebuffer::implementationColorReadFormat() { PixelFormat AbstractFramebuffer::implementationColorReadFormat() {
return PixelFormat((this->*Context::current().state().framebuffer->implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_FORMAT)); return PixelFormat((this->*Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_FORMAT));
} }
PixelType AbstractFramebuffer::implementationColorReadType() { PixelType AbstractFramebuffer::implementationColorReadType() {
return PixelType((this->*Context::current().state().framebuffer->implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_TYPE)); return PixelType((this->*Context::current().state().framebuffer.implementationColorReadFormatTypeImplementation)(GL_IMPLEMENTATION_COLOR_READ_TYPE));
} }
GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationGlobal(const GLenum what) { GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationGlobal(const GLenum what) {
@ -254,7 +254,7 @@ GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFrame
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) { void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
Context::current().state().framebuffer->blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter); Context::current().state().framebuffer.blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter);
} }
#endif #endif
@ -290,14 +290,14 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle)
_viewport = rectangle; _viewport = rectangle;
/* Update the viewport if the framebuffer is currently bound */ /* Update the viewport if the framebuffer is currently bound */
if(Context::current().state().framebuffer->drawBinding == _id) if(Context::current().state().framebuffer.drawBinding == _id)
setViewportInternal(); setViewportInternal();
return *this; return *this;
} }
void AbstractFramebuffer::setViewportInternal() { void AbstractFramebuffer::setViewportInternal() {
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
CORRADE_INTERNAL_ASSERT(_viewport != Implementation::FramebufferState::DisengagedViewport); CORRADE_INTERNAL_ASSERT(_viewport != Implementation::FramebufferState::DisengagedViewport);
CORRADE_INTERNAL_ASSERT(state.drawBinding == _id); CORRADE_INTERNAL_ASSERT(state.drawBinding == _id);
@ -320,17 +320,17 @@ AbstractFramebuffer& AbstractFramebuffer::clear(const FramebufferClearMask mask)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
AbstractFramebuffer& AbstractFramebuffer::clearDepth(const Float depth) { AbstractFramebuffer& AbstractFramebuffer::clearDepth(const Float depth) {
(this->*Context::current().state().framebuffer->clearFImplementation)(GL_DEPTH, 0, &depth); (this->*Context::current().state().framebuffer.clearFImplementation)(GL_DEPTH, 0, &depth);
return *this; return *this;
} }
AbstractFramebuffer& AbstractFramebuffer::clearStencil(const Int stencil) { AbstractFramebuffer& AbstractFramebuffer::clearStencil(const Int stencil) {
(this->*Context::current().state().framebuffer->clearIImplementation)(GL_STENCIL, 0, &stencil); (this->*Context::current().state().framebuffer.clearIImplementation)(GL_STENCIL, 0, &stencil);
return *this; return *this;
} }
AbstractFramebuffer& AbstractFramebuffer::clearDepthStencil(const Float depth, const Int stencil) { AbstractFramebuffer& AbstractFramebuffer::clearDepthStencil(const Float depth, const Int stencil) {
(this->*Context::current().state().framebuffer->clearFIImplementation)(GL_DEPTH_STENCIL, depth, stencil); (this->*Context::current().state().framebuffer.clearFIImplementation)(GL_DEPTH_STENCIL, depth, stencil);
return *this; return *this;
} }
#endif #endif
@ -345,8 +345,8 @@ void AbstractFramebuffer::read(const Range2Di& rectangle, const MutableImageView
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
#endif #endif
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(Context::current().state().framebuffer->readImplementation)(rectangle, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data() (Context::current().state().framebuffer.readImplementation)(rectangle, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffsetFor(image, rectangle.size()) + Magnum::Implementation::pixelStorageSkipOffsetFor(image, rectangle.size())
#endif #endif
@ -382,8 +382,8 @@ void AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D& image,
image.setData(image.storage(), image.format(), image.type(), rectangle.size(), nullptr, usage); image.setData(image.storage(), image.format(), image.type(), rectangle.size(), nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(Context::current().state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr); (Context::current().state().framebuffer.readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr);
} }
BufferImage2D AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage) { BufferImage2D AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage) {
@ -433,52 +433,52 @@ void AbstractFramebuffer::copyImage(const Range2Di& rectangle, Texture1DArray& t
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture1D& texture, const Int level, const Int offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture1D& texture, const Int level, const Int offset) {
CORRADE_ASSERT(rectangle.sizeY() == 1, "GL::AbstractFramebuffer::copyImage(): height must be 1 for 1D textures", ); CORRADE_ASSERT(rectangle.sizeY() == 1, "GL::AbstractFramebuffer::copyImage(): height must be 1 for 1D textures", );
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub1DImplementation(rectangle, texture, level, offset); Context::current().state().framebuffer.copySub1DImplementation(rectangle, texture, level, offset);
} }
#endif #endif
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2D& texture, const Int level, const Vector2i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2D& texture, const Int level, const Vector2i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub2DImplementation(rectangle, texture, GL_TEXTURE_2D, level, offset); Context::current().state().framebuffer.copySub2DImplementation(rectangle, texture, GL_TEXTURE_2D, level, offset);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, RectangleTexture& texture, const Vector2i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, RectangleTexture& texture, const Vector2i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub2DImplementation(rectangle, texture, GL_TEXTURE_RECTANGLE, 0, offset); Context::current().state().framebuffer.copySub2DImplementation(rectangle, texture, GL_TEXTURE_RECTANGLE, 0, offset);
} }
#endif #endif
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTexture& texture, const Int level, const Vector3i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTexture& texture, const Int level, const Vector3i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySubCubeMapImplementation(rectangle, texture, GL_TEXTURE_CUBE_MAP_POSITIVE_X + offset.z(), level, offset.xy()); Context::current().state().framebuffer.copySubCubeMapImplementation(rectangle, texture, GL_TEXTURE_CUBE_MAP_POSITIVE_X + offset.z(), level, offset.xy());
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture3D& texture, const Int level, const Vector3i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture3D& texture, const Int level, const Vector3i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture1DArray& texture, const Int level, const Vector2i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture1DArray& texture, const Int level, const Vector2i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub2DImplementation(rectangle, texture, GL_TEXTURE_1D_ARRAY, level, offset); Context::current().state().framebuffer.copySub2DImplementation(rectangle, texture, GL_TEXTURE_1D_ARRAY, level, offset);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2DArray& texture, const Int level, const Vector3i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2DArray& texture, const Int level, const Vector3i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset);
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTextureArray& texture, const Int level, const Vector3i& offset) { void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTextureArray& texture, const Int level, const Vector3i& offset) {
bindInternal(FramebufferTarget::Read); bindInternal(FramebufferTarget::Read);
Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset);
} }
#endif #endif

2
src/Magnum/GL/AbstractObject.cpp

@ -110,7 +110,7 @@ Int AbstractObject::maxLabelLength() {
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>()) if(!Context::current().isExtensionSupported<Extensions::KHR::debug>())
return 0; return 0;
GLint& value = Context::current().state().debug->maxLabelLength; GLint& value = Context::current().state().debug.maxLabelLength;
if(value == 0) { if(value == 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2

10
src/Magnum/GL/AbstractQuery.cpp

@ -37,7 +37,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().query->createImplementation)(); (this->*Context::current().state().query.createImplementation)();
} }
AbstractQuery::~AbstractQuery() { AbstractQuery::~AbstractQuery() {
@ -93,17 +93,17 @@ void AbstractQuery::createImplementationDSAExceptPipelineStats() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string AbstractQuery::label() const { std::string AbstractQuery::label() const {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug->getLabelImplementation(GL_QUERY, _id); return Context::current().state().debug.getLabelImplementation(GL_QUERY, _id);
#else #else
return Context::current().state().debug->getLabelImplementation(GL_QUERY_KHR, _id); return Context::current().state().debug.getLabelImplementation(GL_QUERY_KHR, _id);
#endif #endif
} }
AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayView<const char> label) { AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayView<const char> label) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug->labelImplementation(GL_QUERY, _id, label); Context::current().state().debug.labelImplementation(GL_QUERY, _id, label);
#else #else
Context::current().state().debug->labelImplementation(GL_QUERY_KHR, _id, label); Context::current().state().debug.labelImplementation(GL_QUERY_KHR, _id, label);
#endif #endif
return *this; return *this;
} }

116
src/Magnum/GL/AbstractShaderProgram.cpp

@ -47,7 +47,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
Int AbstractShaderProgram::maxVertexAttributes() { Int AbstractShaderProgram::maxVertexAttributes() {
GLint& value = Context::current().state().shaderProgram->maxVertexAttributes; GLint& value = Context::current().state().shaderProgram.maxVertexAttributes;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -66,7 +66,7 @@ Int AbstractShaderProgram::maxGeometryOutputVertices() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shaderProgram->maxGeometryOutputVertices; GLint& value = Context::current().state().shaderProgram.maxGeometryOutputVertices;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &value); glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &value);
@ -82,7 +82,7 @@ Int AbstractShaderProgram::maxAtomicCounterBufferSize() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxAtomicCounterBufferSize; GLint& value = Context::current().state().shaderProgram.maxAtomicCounterBufferSize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &value); glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &value);
@ -98,7 +98,7 @@ Int AbstractShaderProgram::maxComputeSharedMemorySize() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxComputeSharedMemorySize; GLint& value = Context::current().state().shaderProgram.maxComputeSharedMemorySize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &value); glGetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &value);
@ -114,7 +114,7 @@ Int AbstractShaderProgram::maxComputeWorkGroupInvocations() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxComputeWorkGroupInvocations; GLint& value = Context::current().state().shaderProgram.maxComputeWorkGroupInvocations;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &value); glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &value);
@ -130,7 +130,7 @@ Vector3i AbstractShaderProgram::maxComputeWorkGroupCount() {
#endif #endif
return {}; return {};
Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupCount; Vector3i& value = Context::current().state().shaderProgram.maxComputeWorkGroupCount;
if(value.isZero()) { if(value.isZero()) {
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &value.x()); glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &value.x());
@ -149,7 +149,7 @@ Vector3i AbstractShaderProgram::maxComputeWorkGroupSize() {
#endif #endif
return {}; return {};
Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupSize; Vector3i& value = Context::current().state().shaderProgram.maxComputeWorkGroupSize;
if(value.isZero()) { if(value.isZero()) {
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &value.x()); glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &value.x());
@ -168,7 +168,7 @@ Int AbstractShaderProgram::maxImageUnits() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxImageUnits; GLint& value = Context::current().state().shaderProgram.maxImageUnits;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_IMAGE_UNITS, &value); glGetIntegerv(GL_MAX_IMAGE_UNITS, &value);
@ -182,7 +182,7 @@ Int AbstractShaderProgram::maxImageSamples() {
if(!Context::current().isExtensionSupported<Extensions::ARB::shader_image_load_store>()) if(!Context::current().isExtensionSupported<Extensions::ARB::shader_image_load_store>())
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxImageSamples; GLint& value = Context::current().state().shaderProgram.maxImageSamples;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_IMAGE_SAMPLES, &value); glGetIntegerv(GL_MAX_IMAGE_SAMPLES, &value);
@ -201,7 +201,7 @@ Int AbstractShaderProgram::maxCombinedShaderOutputResources() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxCombinedShaderOutputResources; GLint& value = Context::current().state().shaderProgram.maxCombinedShaderOutputResources;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES, &value); glGetIntegerv(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES, &value);
@ -217,7 +217,7 @@ Long AbstractShaderProgram::maxShaderStorageBlockSize() {
#endif #endif
return 0; return 0;
GLint64& value = Context::current().state().shaderProgram->maxShaderStorageBlockSize; GLint64& value = Context::current().state().shaderProgram.maxShaderStorageBlockSize;
if(value == 0) if(value == 0)
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &value); glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &value);
@ -232,7 +232,7 @@ Int AbstractShaderProgram::maxUniformBlockSize() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shaderProgram->maxUniformBlockSize; GLint& value = Context::current().state().shaderProgram.maxUniformBlockSize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &value); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &value);
@ -249,7 +249,7 @@ Int AbstractShaderProgram::maxUniformLocations() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shaderProgram->maxUniformLocations; GLint& value = Context::current().state().shaderProgram.maxUniformLocations;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &value); glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &value);
@ -264,7 +264,7 @@ Int AbstractShaderProgram::minTexelOffset() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shaderProgram->minTexelOffset; GLint& value = Context::current().state().shaderProgram.minTexelOffset;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &value); glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &value);
@ -278,7 +278,7 @@ Int AbstractShaderProgram::maxTexelOffset() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shaderProgram->maxTexelOffset; GLint& value = Context::current().state().shaderProgram.maxTexelOffset;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &value); glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &value);
@ -301,7 +301,7 @@ AbstractShaderProgram::~AbstractShaderProgram() {
if(!_id) return; if(!_id) return;
/* Remove current usage from the state */ /* Remove current usage from the state */
GLuint& current = Context::current().state().shaderProgram->current; GLuint& current = Context::current().state().shaderProgram.current;
if(current == _id) current = 0; if(current == _id) current = 0;
glDeleteProgram(_id); glDeleteProgram(_id);
@ -316,17 +316,17 @@ AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&&
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string AbstractShaderProgram::label() const { std::string AbstractShaderProgram::label() const {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug->getLabelImplementation(GL_PROGRAM, _id); return Context::current().state().debug.getLabelImplementation(GL_PROGRAM, _id);
#else #else
return Context::current().state().debug->getLabelImplementation(GL_PROGRAM_KHR, _id); return Context::current().state().debug.getLabelImplementation(GL_PROGRAM_KHR, _id);
#endif #endif
} }
AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayView<const char> label) { AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayView<const char> label) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug->labelImplementation(GL_PROGRAM, _id, label); Context::current().state().debug.labelImplementation(GL_PROGRAM, _id, label);
#else #else
Context::current().state().debug->labelImplementation(GL_PROGRAM_KHR, _id, label); Context::current().state().debug.labelImplementation(GL_PROGRAM_KHR, _id, label);
#endif #endif
return *this; return *this;
} }
@ -394,7 +394,7 @@ void AbstractShaderProgram::draw(Containers::ArrayView<const Containers::Referen
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
MeshView::multiDrawImplementationDefault(meshes); MeshView::multiDrawImplementationDefault(meshes);
#else #else
Context::current().state().mesh->multiDrawImplementation(meshes); Context::current().state().mesh.multiDrawImplementation(meshes);
#endif #endif
} }
@ -429,7 +429,7 @@ void AbstractShaderProgram::dispatchCompute(const Vector3ui& workgroupCount) {
void AbstractShaderProgram::use() { void AbstractShaderProgram::use() {
/* Use only if the program isn't already in use */ /* Use only if the program isn't already in use */
GLuint& current = Context::current().state().shaderProgram->current; GLuint& current = Context::current().state().shaderProgram.current;
if(current != _id) glUseProgram(current = _id); if(current != _id) glUseProgram(current = _id);
} }
@ -456,7 +456,7 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const Unsign
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list<std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list<std::string> outputs, const TransformFeedbackBufferMode bufferMode) {
(this->*Context::current().state().shaderProgram->transformFeedbackVaryingsImplementation)({outputs.begin(), outputs.size()}, bufferMode); (this->*Context::current().state().shaderProgram.transformFeedbackVaryingsImplementation)({outputs.begin(), outputs.size()}, bufferMode);
} }
void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const Containers::ArrayView<const std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const Containers::ArrayView<const std::string> outputs, const TransformFeedbackBufferMode bufferMode) {
@ -507,7 +507,7 @@ bool AbstractShaderProgram::link(std::initializer_list<Containers::Reference<Abs
/* Some drivers are chatty and can't keep shut when there's nothing to /* Some drivers are chatty and can't keep shut when there's nothing to
be said, handle that as well. */ be said, handle that as well. */
Context::current().state().shaderProgram->cleanLogImplementation(message); Context::current().state().shaderProgram.cleanLogImplementation(message);
/* Show error log */ /* Show error log */
if(!success) { if(!success) {
@ -563,7 +563,7 @@ UnsignedInt AbstractShaderProgram::uniformBlockIndexInternal(const Containers::A
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Float> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Float> values) {
(this->*Context::current().state().shaderProgram->uniform1fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform1fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLfloat* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLfloat* const values) {
@ -584,7 +584,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Float>> values) {
(this->*Context::current().state().shaderProgram->uniform2fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform2fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) {
@ -605,7 +605,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Float>> values) {
(this->*Context::current().state().shaderProgram->uniform3fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform3fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) {
@ -626,7 +626,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Float>> values) {
(this->*Context::current().state().shaderProgram->uniform4fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform4fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) {
@ -647,7 +647,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Int> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Int> values) {
(this->*Context::current().state().shaderProgram->uniform1ivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform1ivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLint* values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLint* values) {
@ -668,7 +668,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Int>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Int>> values) {
(this->*Context::current().state().shaderProgram->uniform2ivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform2ivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) {
@ -689,7 +689,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Int>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Int>> values) {
(this->*Context::current().state().shaderProgram->uniform3ivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform3ivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) {
@ -710,7 +710,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Int>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Int>> values) {
(this->*Context::current().state().shaderProgram->uniform4ivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform4ivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) {
@ -732,7 +732,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const UnsignedInt> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const UnsignedInt> values) {
(this->*Context::current().state().shaderProgram->uniform1uivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform1uivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLuint* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLuint* const values) {
@ -753,7 +753,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, UnsignedInt>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, UnsignedInt>> values) {
(this->*Context::current().state().shaderProgram->uniform2uivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform2uivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) {
@ -774,7 +774,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, UnsignedInt>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, UnsignedInt>> values) {
(this->*Context::current().state().shaderProgram->uniform3uivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform3uivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) {
@ -795,7 +795,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, UnsignedInt>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, UnsignedInt>> values) {
(this->*Context::current().state().shaderProgram->uniform4uivImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform4uivImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) {
@ -818,7 +818,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Double> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Double> values) {
(this->*Context::current().state().shaderProgram->uniform1dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform1dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLdouble* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLdouble* const values) {
@ -831,7 +831,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Double>> values) {
(this->*Context::current().state().shaderProgram->uniform2dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform2dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) {
@ -844,7 +844,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Double>> values) {
(this->*Context::current().state().shaderProgram->uniform3dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform3dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) {
@ -857,7 +857,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Double>> values) {
(this->*Context::current().state().shaderProgram->uniform4dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniform4dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) {
@ -871,7 +871,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) {
@ -892,7 +892,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) {
@ -913,7 +913,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) {
@ -935,7 +935,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2x3fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2x3fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) {
@ -956,7 +956,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3x2fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3x2fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) {
@ -977,7 +977,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2x4fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2x4fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) {
@ -998,7 +998,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4x2fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4x2fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) {
@ -1019,7 +1019,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3x4fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3x4fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) {
@ -1040,7 +1040,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#endif #endif
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Float>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Float>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4x3fvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4x3fvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) {
@ -1063,7 +1063,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) {
@ -1076,7 +1076,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) {
@ -1089,7 +1089,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) {
@ -1102,7 +1102,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2x3dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2x3dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) {
@ -1115,7 +1115,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3x2dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3x2dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) {
@ -1128,7 +1128,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix2x4dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix2x4dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) {
@ -1141,7 +1141,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4x2dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4x2dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) {
@ -1154,7 +1154,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix3x4dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix3x4dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) {
@ -1167,7 +1167,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
} }
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Double>> values) { void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Double>> values) {
(this->*Context::current().state().shaderProgram->uniformMatrix4x3dvImplementation)(location, values.size(), values); (this->*Context::current().state().shaderProgram.uniformMatrix4x3dvImplementation)(location, values.size(), values);
} }
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) { void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) {

250
src/Magnum/GL/AbstractTexture.cpp

@ -51,7 +51,7 @@ namespace Magnum { namespace GL {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Float AbstractTexture::maxLodBias() { Float AbstractTexture::maxLodBias() {
GLfloat& value = Context::current().state().texture->maxLodBias; GLfloat& value = Context::current().state().texture.maxLodBias;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0.0f) if(value == 0.0f)
@ -70,7 +70,7 @@ Int AbstractTexture::maxColorSamples() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().texture->maxColorSamples; GLint& value = Context::current().state().texture.maxColorSamples;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -87,7 +87,7 @@ Int AbstractTexture::maxDepthSamples() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().texture->maxDepthSamples; GLint& value = Context::current().state().texture.maxDepthSamples;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -104,7 +104,7 @@ Int AbstractTexture::maxIntegerSamples() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().texture->maxIntegerSamples; GLint& value = Context::current().state().texture.maxIntegerSamples;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -115,20 +115,20 @@ Int AbstractTexture::maxIntegerSamples() {
#endif #endif
void AbstractTexture::unbind(const Int textureUnit) { void AbstractTexture::unbind(const Int textureUnit) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If given texture unit is already unbound, nothing to do */ /* If given texture unit is already unbound, nothing to do */
if(textureState.bindings[textureUnit].second == 0) return; if(textureState.bindings[textureUnit].second == 0) return;
/* Unbind the texture, reset state tracker */ /* Unbind the texture, reset state tracker */
Context::current().state().texture->unbindImplementation(textureUnit); Context::current().state().texture.unbindImplementation(textureUnit);
/* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload of /* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload of
operator=) */ operator=) */
textureState.bindings[textureUnit] = std::pair<GLenum, GLuint>{}; textureState.bindings[textureUnit] = std::pair<GLenum, GLuint>{};
} }
void AbstractTexture::unbindImplementationDefault(const GLint textureUnit) { void AbstractTexture::unbindImplementationDefault(const GLint textureUnit) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* Activate given texture unit if not already active, update state tracker */ /* Activate given texture unit if not already active, update state tracker */
if(textureState.currentTextureUnit != textureUnit) if(textureState.currentTextureUnit != textureUnit)
@ -145,20 +145,20 @@ void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) {
} }
void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) { void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) {
CORRADE_INTERNAL_ASSERT(Context::current().state().texture->bindings[textureUnit].first != 0); CORRADE_INTERNAL_ASSERT(Context::current().state().texture.bindings[textureUnit].first != 0);
glBindTextureUnit(textureUnit, 0); glBindTextureUnit(textureUnit, 0);
} }
#endif #endif
void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) { void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) {
/* State tracker is updated in the implementations */ /* State tracker is updated in the implementations */
Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {nullptr, count}); Context::current().state().texture.bindMultiImplementation(firstTextureUnit, {nullptr, count});
} }
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
void AbstractTexture::bind(const Int firstTextureUnit, Containers::ArrayView<AbstractTexture* const> textures) { void AbstractTexture::bind(const Int firstTextureUnit, Containers::ArrayView<AbstractTexture* const> textures) {
/* State tracker is updated in the implementations */ /* State tracker is updated in the implementations */
Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()}); Context::current().state().texture.bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()});
} }
void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, const Containers::ArrayView<AbstractTexture* const> textures) { void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, const Containers::ArrayView<AbstractTexture* const> textures) {
@ -169,7 +169,7 @@ void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, c
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** @todoc const Containers::ArrayView makes Doxygen grumpy */ /** @todoc const Containers::ArrayView makes Doxygen grumpy */
void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayView<AbstractTexture* const> textures) { void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayView<AbstractTexture* const> textures) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* Create array of IDs and also update bindings in state tracker */ /* Create array of IDs and also update bindings in state tracker */
/** @todo VLAs */ /** @todo VLAs */
@ -196,7 +196,7 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Cont
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Int AbstractTexture::compressedBlockDataSize(const GLenum target, const TextureFormat format) { Int AbstractTexture::compressedBlockDataSize(const GLenum target, const TextureFormat format) {
return (Context::current().state().texture->compressedBlockDataSizeImplementation)(target, format); return (Context::current().state().texture.compressedBlockDataSizeImplementation)(target, format);
} }
Int AbstractTexture::compressedBlockDataSizeImplementationDefault(const GLenum target, const TextureFormat format) { Int AbstractTexture::compressedBlockDataSizeImplementationDefault(const GLenum target, const TextureFormat format) {
@ -212,7 +212,7 @@ Int AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround(const G
#endif #endif
AbstractTexture::AbstractTexture(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { AbstractTexture::AbstractTexture(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().texture->createImplementation)(); (this->*Context::current().state().texture.createImplementation)();
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
@ -232,7 +232,7 @@ AbstractTexture::~AbstractTexture() {
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
/* Remove all bindings */ /* Remove all bindings */
for(auto& binding: Context::current().state().texture->bindings) { for(auto& binding: Context::current().state().texture.bindings) {
/* MSVC 2015 needs the parentheses around */ /* MSVC 2015 needs the parentheses around */
/* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload /* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload
of operator=) */ of operator=) */
@ -241,7 +241,7 @@ AbstractTexture::~AbstractTexture() {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
/* Remove all image bindings */ /* Remove all image bindings */
for(auto& binding: Context::current().state().texture->imageBindings) { for(auto& binding: Context::current().state().texture.imageBindings) {
/* MSVC 2015 needs the parentheses around */ /* MSVC 2015 needs the parentheses around */
if(std::get<0>(binding) == _id) binding = {}; if(std::get<0>(binding) == _id) binding = {};
} }
@ -264,19 +264,19 @@ void AbstractTexture::createIfNotAlready() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string AbstractTexture::label() { std::string AbstractTexture::label() {
createIfNotAlready(); createIfNotAlready();
return Context::current().state().debug->getLabelImplementation(GL_TEXTURE, _id); return Context::current().state().debug.getLabelImplementation(GL_TEXTURE, _id);
} }
AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayView<const char> label) { AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
Context::current().state().debug->labelImplementation(GL_TEXTURE, _id, label); Context::current().state().debug.labelImplementation(GL_TEXTURE, _id, label);
return *this; return *this;
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractTexture::unbindImage(const Int imageUnit) { void AbstractTexture::unbindImage(const Int imageUnit) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If already unbound in given image unit, nothing to do */ /* If already unbound in given image unit, nothing to do */
if(std::get<0>(textureState.imageBindings[imageUnit]) == 0) return; if(std::get<0>(textureState.imageBindings[imageUnit]) == 0) return;
@ -289,7 +289,7 @@ void AbstractTexture::unbindImage(const Int imageUnit) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** @todoc const Containers::ArrayView makes Doxygen grumpy */ /** @todoc const Containers::ArrayView makes Doxygen grumpy */
void AbstractTexture::bindImages(const Int firstImageUnit, Containers::ArrayView<AbstractTexture* const> textures) { void AbstractTexture::bindImages(const Int firstImageUnit, Containers::ArrayView<AbstractTexture* const> textures) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* Create array of IDs and also update bindings in state tracker */ /* Create array of IDs and also update bindings in state tracker */
Containers::Array<GLuint> ids{textures ? textures.size() : 0}; Containers::Array<GLuint> ids{textures ? textures.size() : 0};
@ -318,7 +318,7 @@ void AbstractTexture::bindImages(const Int firstImageUnit, Containers::ArrayView
#endif #endif
void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, const bool layered, const Int layer, const ImageAccess access, const ImageFormat format) { void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, const bool layered, const Int layer, const ImageAccess access, const ImageFormat format) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
const std::tuple<GLuint, GLint, GLboolean, GLint, GLenum> state{_id, level, layered, layer, GLenum(access)}; const std::tuple<GLuint, GLint, GLboolean, GLint, GLenum> state{_id, level, layered, layer, GLenum(access)};
/* If already bound in given texture unit, nothing to do */ /* If already bound in given texture unit, nothing to do */
@ -331,7 +331,7 @@ void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, co
#endif #endif
void AbstractTexture::bind(Int textureUnit) { void AbstractTexture::bind(Int textureUnit) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If already bound in given texture unit, nothing to do */ /* If already bound in given texture unit, nothing to do */
if(textureState.bindings[textureUnit].second == _id) return; if(textureState.bindings[textureUnit].second == _id) return;
@ -342,7 +342,7 @@ void AbstractTexture::bind(Int textureUnit) {
} }
void AbstractTexture::bindImplementationDefault(GLint textureUnit) { void AbstractTexture::bindImplementationDefault(GLint textureUnit) {
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* Activate given texture unit if not already active, update state tracker */ /* Activate given texture unit if not already active, update state tracker */
if(textureState.currentTextureUnit != textureUnit) if(textureState.currentTextureUnit != textureUnit)
@ -375,20 +375,20 @@ void AbstractTexture::bindImplementationDSAIntelWindows(const GLint textureUnit)
void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(const GLint textureUnit) { void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(const GLint textureUnit) {
bindImplementationDefault(textureUnit); bindImplementationDefault(textureUnit);
if(_target == GL_TEXTURE_BUFFER) if(_target == GL_TEXTURE_BUFFER)
Context::current().state().texture->bufferTextureBound.set(textureUnit, true); Context::current().state().texture.bufferTextureBound.set(textureUnit, true);
} }
#endif #endif
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::setBaseLevel(Int level) { void AbstractTexture::setBaseLevel(Int level) {
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level);
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::setMaxLevel(Int level) { void AbstractTexture::setMaxLevel(Int level) {
(this->*Context::current().state().texture->parameteriImplementation)( (this->*Context::current().state().texture.parameteriImplementation)(
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL
#else #else
@ -399,32 +399,32 @@ void AbstractTexture::setMaxLevel(Int level) {
#endif #endif
void AbstractTexture::setMinificationFilter(SamplerFilter filter, SamplerMipmap mipmap) { void AbstractTexture::setMinificationFilter(SamplerFilter filter, SamplerMipmap mipmap) {
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap));
} }
void AbstractTexture::setMagnificationFilter(const SamplerFilter filter) { void AbstractTexture::setMagnificationFilter(const SamplerFilter filter) {
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter)); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter));
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::setMinLod(const Float lod) { void AbstractTexture::setMinLod(const Float lod) {
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod); (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod);
} }
void AbstractTexture::setMaxLod(const Float lod) { void AbstractTexture::setMaxLod(const Float lod) {
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::setLodBias(const Float bias) { void AbstractTexture::setLodBias(const Float bias) {
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias); (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias);
} }
#endif #endif
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractTexture::setBorderColor(const Color4& color) { void AbstractTexture::setBorderColor(const Color4& color) {
(this->*Context::current().state().texture->parameterfvImplementation)( (this->*Context::current().state().texture.parameterfvImplementation)(
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GL_TEXTURE_BORDER_COLOR, GL_TEXTURE_BORDER_COLOR,
#else #else
@ -435,22 +435,22 @@ void AbstractTexture::setBorderColor(const Color4& color) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::setBorderColor(const Vector4ui& color) { void AbstractTexture::setBorderColor(const Vector4ui& color) {
(this->*Context::current().state().texture->parameterIuivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); (this->*Context::current().state().texture.parameterIuivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data());
} }
void AbstractTexture::setBorderColor(const Vector4i& color) { void AbstractTexture::setBorderColor(const Vector4i& color) {
(this->*Context::current().state().texture->parameterIivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); (this->*Context::current().state().texture.parameterIivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data());
} }
#endif #endif
#endif #endif
void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { void AbstractTexture::setMaxAnisotropy(const Float anisotropy) {
(this->*Context::current().state().texture->setMaxAnisotropyImplementation)(anisotropy); (this->*Context::current().state().texture.setMaxAnisotropyImplementation)(anisotropy);
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractTexture::setSrgbDecode(bool decode) { void AbstractTexture::setSrgbDecode(bool decode) {
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT,
decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT); decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
} }
#endif #endif
@ -459,19 +459,19 @@ void AbstractTexture::setSrgbDecode(bool decode) {
void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) { void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GLint rgba[] = {r, g, b, a}; const GLint rgba[] = {r, g, b, a};
(this->*Context::current().state().texture->parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba); (this->*Context::current().state().texture.parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba);
#else #else
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r);
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g);
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b);
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a);
#endif #endif
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::setCompareMode(const SamplerCompareMode mode) { void AbstractTexture::setCompareMode(const SamplerCompareMode mode) {
(this->*Context::current().state().texture->parameteriImplementation)( (this->*Context::current().state().texture.parameteriImplementation)(
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GL_TEXTURE_COMPARE_MODE GL_TEXTURE_COMPARE_MODE
#else #else
@ -481,7 +481,7 @@ void AbstractTexture::setCompareMode(const SamplerCompareMode mode) {
} }
void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) { void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) {
(this->*Context::current().state().texture->parameteriImplementation)( (this->*Context::current().state().texture.parameteriImplementation)(
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC
#else #else
@ -493,16 +493,16 @@ void AbstractTexture::setCompareFunction(const SamplerCompareFunction function)
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractTexture::setDepthStencilMode(const SamplerDepthStencilMode mode) { void AbstractTexture::setDepthStencilMode(const SamplerDepthStencilMode mode) {
(this->*Context::current().state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); (this->*Context::current().state().texture.parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode));
} }
#endif #endif
void AbstractTexture::invalidateImage(const Int level) { void AbstractTexture::invalidateImage(const Int level) {
(this->*Context::current().state().texture->invalidateImageImplementation)(level); (this->*Context::current().state().texture.invalidateImageImplementation)(level);
} }
void AbstractTexture::generateMipmap() { void AbstractTexture::generateMipmap() {
(this->*Context::current().state().texture->mipmapImplementation)(); (this->*Context::current().state().texture.mipmapImplementation)();
} }
void AbstractTexture::mipmapImplementationDefault() { void AbstractTexture::mipmapImplementationDefault() {
@ -521,7 +521,7 @@ void AbstractTexture::bindInternal() {
functions need to have the texture bound in *currently active* unit, functions need to have the texture bound in *currently active* unit,
so we would need to call glActiveTexture() afterwards anyway. */ so we would need to call glActiveTexture() afterwards anyway. */
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If the texture is already bound in current unit, nothing to do */ /* If the texture is already bound in current unit, nothing to do */
if(textureState.bindings[textureState.currentTextureUnit].second == _id) if(textureState.bindings[textureState.currentTextureUnit].second == _id)
@ -1281,7 +1281,7 @@ void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const
void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {} void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {}
void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy) { void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy) {
(this->*Context::current().state().texture->parameterfImplementation)( (this->*Context::current().state().texture.parameterfImplementation)(
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
GL_TEXTURE_MAX_ANISOTROPY GL_TEXTURE_MAX_ANISOTROPY
#else #else
@ -1729,8 +1729,8 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); (this->*Context::current().state().texture.getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data);
image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)}; image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
} }
@ -1748,8 +1748,8 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, const
#endif #endif
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); (this->*Context::current().state().texture.getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data());
} }
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, const BasicMutableImageView<1>&); template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, const BasicMutableImageView<1>&);
@ -1767,8 +1767,8 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Buffer
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr); (this->*Context::current().state().texture.getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr);
} }
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&, BufferUsage); template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&, BufferUsage);
@ -1783,13 +1783,13 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) {
GLint textureDataSize; GLint textureDataSize;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
dataSize = textureDataSize; dataSize = textureDataSize;
} else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(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()};
@ -1797,8 +1797,8 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedImageImplementation)(level, data.size(), data); (this->*Context::current().state().texture.getCompressedImageImplementation)(level, data.size(), data);
image = CompressedImage<dimensions>{image.storage(), CompressedPixelFormat(format), size, std::move(data)}; image = CompressedImage<dimensions>{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
} }
@ -1820,7 +1820,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) {
GLint textureDataSize; GLint textureDataSize;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
dataSize = textureDataSize; dataSize = textureDataSize;
} else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
@ -1829,15 +1829,15 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format),
"GL::AbstractTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); "GL::AbstractTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), );
#endif #endif
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedImageImplementation)(level, image.data().size(), image.data()); (this->*Context::current().state().texture.getCompressedImageImplementation)(level, image.data().size(), image.data());
} }
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, const BasicMutableCompressedImageView<1>&); template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, const BasicMutableCompressedImageView<1>&);
@ -1852,13 +1852,13 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) {
GLint textureDataSize; GLint textureDataSize;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
dataSize = textureDataSize; dataSize = textureDataSize;
} else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(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)
@ -1867,8 +1867,8 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedImageImplementation)(level, dataSize, nullptr); (this->*Context::current().state().texture.getCompressedImageImplementation)(level, dataSize, nullptr);
} }
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage); template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage);
@ -1904,7 +1904,7 @@ template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint leve
const Vector3i paddedSize = Vector3i::pad(size, 1); const Vector3i paddedSize = Vector3i::pad(size, 1);
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(pixelFormat(image.format())), GLenum(pixelType(image.format(), image.formatExtra())), image.data().size(), image.data()); glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(pixelFormat(image.format())), GLenum(pixelType(image.format(), image.formatExtra())), image.data().size(), image.data());
} }
@ -1927,7 +1927,7 @@ template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint leve
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), dataSize, nullptr); glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), dataSize, nullptr);
} }
@ -1956,7 +1956,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Calculate compressed subimage size. If the user-provided pixel storage /* Calculate compressed subimage size. If the user-provided pixel storage
doesn't tell us all properties about the compression, we need to ask GL doesn't tell us all properties about the compression, we need to ask GL
@ -1972,7 +1972,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), data.size(), data); glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), data.size(), data);
image = CompressedImage<dimensions>{CompressedPixelFormat(format), size, std::move(data)}; image = CompressedImage<dimensions>{CompressedPixelFormat(format), size, std::move(data)};
} }
@ -1994,7 +1994,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format),
"GL::AbstractTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); "GL::AbstractTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), );
@ -2015,7 +2015,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
const Vector3i paddedSize = Vector3i::pad(size, 1); const Vector3i paddedSize = Vector3i::pad(size, 1);
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), image.data().size(), image.data()); glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), image.data().size(), image.data());
} }
@ -2032,7 +2032,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Calculate compressed subimage size. If the user-provided pixel storage /* Calculate compressed subimage size. If the user-provided pixel storage
doesn't tell us all properties about the compression, we need to ask GL doesn't tell us all properties about the compression, we need to ask GL
@ -2049,7 +2049,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), dataSize, nullptr); glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), dataSize, nullptr);
} }
@ -2083,14 +2083,14 @@ Vector3i AbstractTexture::DataHelper<3>::compressedBlockSize(const GLenum target
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, 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)(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 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)(level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
@ -2099,7 +2099,7 @@ Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, con
} }
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, 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)(level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
@ -2111,81 +2111,81 @@ Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, con
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) {
(texture.*Context::current().state().texture->storage1DImplementation)(levels, internalFormat, size); (texture.*Context::current().state().texture.storage1DImplementation)(levels, internalFormat, size);
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
(texture.*Context::current().state().texture->storage2DImplementation)(levels, internalFormat, size); (texture.*Context::current().state().texture.storage2DImplementation)(levels, internalFormat, size);
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
(texture.*Context::current().state().texture->storage3DImplementation)(levels, internalFormat, size); (texture.*Context::current().state().texture.storage3DImplementation)(levels, internalFormat, size);
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current().state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); (texture.*Context::current().state().texture.storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
} }
void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current().state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); (texture.*Context::current().state().texture.storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView1D& image) { void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(pixelFormat(image.format())), GLenum(pixelType(image.format(), image.formatExtra())), image.data()); glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(pixelFormat(image.format())), GLenum(pixelType(image.format(), image.formatExtra())), image.data());
} }
void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, const CompressedImageView1D& image) { void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, const CompressedImageView1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
} }
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) { void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), nullptr); glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), nullptr);
} }
void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage1D& image) { void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr); glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
} }
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) { void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()); (texture.*Context::current().state().texture.subImage1DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data());
} }
void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) { void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); (texture.*Context::current().state().texture.compressedSubImage1DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
} }
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current().state().texture.subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr);
} }
void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, CompressedBufferImage1D& image) { void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, CompressedBufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); (texture.*Context::current().state().texture.compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
} }
#endif #endif
@ -2193,8 +2193,8 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->image2DImplementation)(target, level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() (texture.*Context::current().state().texture.image2DImplementation)(target, level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffset(image) + Magnum::Implementation::pixelStorageSkipOffset(image)
#endif #endif
@ -2205,7 +2205,7 @@ void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glCompressedTexImage2D(target, level, GLenum(compressedPixelFormat(image.format())), image.size().x(), image.size().y(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); glCompressedTexImage2D(target, level, GLenum(compressedPixelFormat(image.format())), image.size().x(), image.size().y(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
} }
@ -2213,14 +2213,14 @@ void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glTexImage2D(target, level, GLint(internalFormat), image.size().x(), image.size().y(), 0, GLenum(image.format()), GLenum(image.type()), nullptr); glTexImage2D(target, level, GLint(internalFormat), image.size().x(), image.size().y(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
} }
void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture, const GLenum target, const GLint level, CompressedBufferImage2D& image) { void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture, const GLenum target, const GLint level, CompressedBufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glCompressedTexImage2D(target, level, GLenum(image.format()), image.size().x(), image.size().y(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr); glCompressedTexImage2D(target, level, GLenum(image.format()), image.size().x(), image.size().y(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
} }
@ -2230,8 +2230,8 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() (texture.*Context::current().state().texture.subImage2DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffset(image) + Magnum::Implementation::pixelStorageSkipOffset(image)
#endif #endif
@ -2242,21 +2242,21 @@ void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& text
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); (texture.*Context::current().state().texture.compressedSubImage2DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) { void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); (texture.*Context::current().state().texture.subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage());
} }
void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) { void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); (texture.*Context::current().state().texture.compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
} }
#endif #endif
@ -2265,8 +2265,8 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->image3DImplementation)(level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() (texture.*Context::current().state().texture.image3DImplementation)(level, internalFormat, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffset(image) + Magnum::Implementation::pixelStorageSkipOffset(image)
#endif #endif
@ -2277,7 +2277,7 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glCompressedTexImage3D(texture._target, level, GLenum(compressedPixelFormat(image.format())), image.size().x(), image.size().y(), image.size().z(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); glCompressedTexImage3D(texture._target, level, GLenum(compressedPixelFormat(image.format())), image.size().x(), image.size().y(), image.size().z(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
@ -2290,14 +2290,14 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), nullptr); glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
} }
void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage3D& image) { void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
texture.bindInternal(); texture.bindInternal();
glCompressedTexImage3D(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr); glCompressedTexImage3D(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
} }
@ -2308,8 +2308,8 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() (texture.*Context::current().state().texture.subImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffset(image) + Magnum::Implementation::pixelStorageSkipOffset(image)
#endif #endif
@ -2320,47 +2320,47 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); (texture.*Context::current().state().texture.compressedSubImage3DImplementation)(level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) { void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); (texture.*Context::current().state().texture.subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage());
} }
void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) { void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); (texture.*Context::current().state().texture.compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) {
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1});
} }
#endif #endif
void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) { void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) {
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, {offset, 0}, {size, 1});
} }
void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) { void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) {
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, offset, size); (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, offset, size);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D<SamplerWrapping>& wrapping) { void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D<SamplerWrapping>& wrapping) {
(texture.*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D<SamplerWrapping>& wrapping) { void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D<SamplerWrapping>& wrapping) {
const Implementation::TextureState& state = *Context::current().state().texture; const Implementation::TextureState& state = Context::current().state().texture;
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
@ -2368,7 +2368,7 @@ void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D<SamplerWrapping>& wrapping) { void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D<SamplerWrapping>& wrapping) {
const Implementation::TextureState& state = *Context::current().state().texture; const Implementation::TextureState& state = Context::current().state().texture;
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));

68
src/Magnum/GL/Buffer.cpp

@ -49,7 +49,7 @@ Int Buffer::minMapAlignment() {
if(!Context::current().isExtensionSupported<Extensions::ARB::map_buffer_alignment>()) if(!Context::current().isExtensionSupported<Extensions::ARB::map_buffer_alignment>())
return 1; return 1;
GLint& value = Context::current().state().buffer->minMapAlignment; GLint& value = Context::current().state().buffer.minMapAlignment;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &value); glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &value);
@ -68,7 +68,7 @@ Int Buffer::maxAtomicCounterBindings() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().buffer->maxAtomicCounterBindings; GLint& value = Context::current().state().buffer.maxAtomicCounterBindings;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &value); glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &value);
@ -84,7 +84,7 @@ Int Buffer::maxShaderStorageBindings() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().buffer->maxShaderStorageBindings; GLint& value = Context::current().state().buffer.maxShaderStorageBindings;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &value); glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &value);
@ -99,7 +99,7 @@ Int Buffer::uniformOffsetAlignment() {
return 1; return 1;
#endif #endif
GLint& value = Context::current().state().buffer->uniformOffsetAlignment; GLint& value = Context::current().state().buffer.uniformOffsetAlignment;
if(value == 0) if(value == 0)
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value); glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value);
@ -116,7 +116,7 @@ Int Buffer::shaderStorageOffsetAlignment() {
#endif #endif
return 1; return 1;
GLint& value = Context::current().state().buffer->shaderStorageOffsetAlignment; GLint& value = Context::current().state().buffer.shaderStorageOffsetAlignment;
if(value == 0) if(value == 0)
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value); glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value);
@ -131,7 +131,7 @@ Int Buffer::maxUniformBindings() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().buffer->maxUniformBindings; GLint& value = Context::current().state().buffer.maxUniformBindings;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &value); glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &value);
@ -144,33 +144,33 @@ void Buffer::unbind(const Target target, const UnsignedInt index) {
} }
void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) { void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) {
Context::current().state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count}); Context::current().state().buffer.bindBasesImplementation(target, firstIndex, {nullptr, count});
} }
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) { void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
Context::current().state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); Context::current().state().buffer.bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
} }
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) { void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
Context::current().state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); Context::current().state().buffer.bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
} }
void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) { void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) {
Context::current().state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); Context::current().state().buffer.copyImplementation(read, write, readOffset, writeOffset, size);
} }
#endif #endif
Buffer::Buffer(const TargetHint targetHint): _flags{ObjectFlag::DeleteOnDestruction} { Buffer::Buffer(const TargetHint targetHint): _flags{ObjectFlag::DeleteOnDestruction} {
Implementation::BufferState& state = *Context::current().state().buffer; const Implementation::BufferState& state = Context::current().state().buffer;
(this->*state.createImplementation)(); (this->*state.createImplementation)();
(this->*state.setTargetHintImplementation)(targetHint); (this->*state.setTargetHintImplementation)(targetHint);
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
Buffer::Buffer(GLuint id, TargetHint targetHint, ObjectFlags flags) noexcept: _id{id}, _flags{flags} { Buffer::Buffer(GLuint id, TargetHint targetHint, ObjectFlags flags) noexcept: _id{id}, _flags{flags} {
(this->*Context::current().state().buffer->setTargetHintImplementation)(targetHint); (this->*Context::current().state().buffer.setTargetHintImplementation)(targetHint);
} }
void Buffer::createImplementationDefault() { void Buffer::createImplementationDefault() {
@ -188,7 +188,7 @@ Buffer::~Buffer() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
GLuint* bindings = Context::current().state().buffer->bindings; GLuint* bindings = Context::current().state().buffer.bindings;
/* Remove all current bindings from the state */ /* Remove all current bindings from the state */
for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i)
@ -198,7 +198,7 @@ Buffer::~Buffer() {
} }
Buffer& Buffer::setTargetHint(TargetHint hint) { Buffer& Buffer::setTargetHint(TargetHint hint) {
(this->*Context::current().state().buffer->setTargetHintImplementation)(hint); (this->*Context::current().state().buffer.setTargetHintImplementation)(hint);
return *this; return *this;
} }
@ -230,18 +230,18 @@ void Buffer::createIfNotAlready() {
std::string Buffer::label() { std::string Buffer::label() {
createIfNotAlready(); createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug->getLabelImplementation(GL_BUFFER, _id); return Context::current().state().debug.getLabelImplementation(GL_BUFFER, _id);
#else #else
return Context::current().state().debug->getLabelImplementation(GL_BUFFER_KHR, _id); return Context::current().state().debug.getLabelImplementation(GL_BUFFER_KHR, _id);
#endif #endif
} }
Buffer& Buffer::setLabelInternal(const Containers::ArrayView<const char> label) { Buffer& Buffer::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug->labelImplementation(GL_BUFFER, _id, label); Context::current().state().debug.labelImplementation(GL_BUFFER, _id, label);
#else #else
Context::current().state().debug->labelImplementation(GL_BUFFER_KHR, _id, label); Context::current().state().debug.labelImplementation(GL_BUFFER_KHR, _id, label);
#endif #endif
return *this; return *this;
} }
@ -249,7 +249,7 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayView<const char> label)
void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) {
const GLuint id = buffer ? buffer->_id : 0; const GLuint id = buffer ? buffer->_id : 0;
GLuint& bound = Context::current().state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; GLuint& bound = Context::current().state().buffer.bindings[Implementation::BufferState::indexForTarget(target)];
/* Already bound, nothing to do */ /* Already bound, nothing to do */
if(bound == id) return; if(bound == id) return;
@ -261,7 +261,7 @@ void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) {
} }
auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint { auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint {
GLuint* bindings = Context::current().state().buffer->bindings; GLuint* bindings = Context::current().state().buffer.bindings;
GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)];
/* Shortcut - if already bound to hint, return */ /* Shortcut - if already bound to hint, return */
@ -279,11 +279,11 @@ auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint {
prevent accidental modification of that VAO. See prevent accidental modification of that VAO. See
Test::MeshGLTest::unbindVAOwhenSettingIndexBufferData() for details. */ Test::MeshGLTest::unbindVAOwhenSettingIndexBufferData() for details. */
if(hint == TargetHint::ElementArray) { if(hint == TargetHint::ElementArray) {
auto& currentVAO = Context::current().state().mesh->currentVAO; auto& currentVAO = Context::current().state().mesh.currentVAO;
/* It can be also State::DisengagedBinding, in which case we unbind as /* It can be also State::DisengagedBinding, in which case we unbind as
well to be sure */ well to be sure */
if(currentVAO != 0) if(currentVAO != 0)
Context::current().state().mesh->bindVAOImplementation(0); Context::current().state().mesh.bindVAOImplementation(0);
} }
/* Bind the buffer to hint target otherwise */ /* Bind the buffer to hint target otherwise */
@ -307,7 +307,7 @@ Buffer& Buffer::bind(const Target target, const UnsignedInt index) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Buffer& Buffer::setStorage(const Containers::ArrayView<const void> data, const StorageFlags flags) { Buffer& Buffer::setStorage(const Containers::ArrayView<const void> data, const StorageFlags flags) {
(this->*Context::current().state().buffer->storageImplementation)(data, flags); (this->*Context::current().state().buffer.storageImplementation)(data, flags);
return *this; return *this;
} }
#endif #endif
@ -318,7 +318,7 @@ Int Buffer::size() {
* couldn't find any matching extension, though) * couldn't find any matching extension, though)
*/ */
GLint size; GLint size;
(this->*Context::current().state().buffer->getParameterImplementation)(GL_BUFFER_SIZE, &size); (this->*Context::current().state().buffer.getParameterImplementation)(GL_BUFFER_SIZE, &size);
return size; return size;
} }
@ -329,46 +329,46 @@ Containers::Array<char> Buffer::data() {
#endif #endif
Buffer& Buffer::setData(const Containers::ArrayView<const void> data, const BufferUsage usage) { Buffer& Buffer::setData(const Containers::ArrayView<const void> data, const BufferUsage usage) {
(this->*Context::current().state().buffer->dataImplementation)(data.size(), data, usage); (this->*Context::current().state().buffer.dataImplementation)(data.size(), data, usage);
return *this; return *this;
} }
Buffer& Buffer::setSubData(const GLintptr offset, const Containers::ArrayView<const void> data) { Buffer& Buffer::setSubData(const GLintptr offset, const Containers::ArrayView<const void> data) {
(this->*Context::current().state().buffer->subDataImplementation)(offset, data.size(), data); (this->*Context::current().state().buffer.subDataImplementation)(offset, data.size(), data);
return *this; return *this;
} }
Buffer& Buffer::invalidateData() { Buffer& Buffer::invalidateData() {
(this->*Context::current().state().buffer->invalidateImplementation)(); (this->*Context::current().state().buffer.invalidateImplementation)();
return *this; return *this;
} }
Buffer& Buffer::invalidateSubData(const GLintptr offset, const GLsizeiptr length) { Buffer& Buffer::invalidateSubData(const GLintptr offset, const GLsizeiptr length) {
(this->*Context::current().state().buffer->invalidateSubImplementation)(offset, length); (this->*Context::current().state().buffer.invalidateSubImplementation)(offset, length);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
char* Buffer::map(const MapAccess access) { char* Buffer::map(const MapAccess access) {
return static_cast<char*>((this->*Context::current().state().buffer->mapImplementation)(access)); return static_cast<char*>((this->*Context::current().state().buffer.mapImplementation)(access));
} }
Containers::ArrayView<char> Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { Containers::ArrayView<char> Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) {
return {static_cast<char*>((this->*Context::current().state().buffer->mapRangeImplementation)(offset, length, flags)), std::size_t(length)}; return {static_cast<char*>((this->*Context::current().state().buffer.mapRangeImplementation)(offset, length, flags)), std::size_t(length)};
} }
Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) { Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) {
(this->*Context::current().state().buffer->flushMappedRangeImplementation)(offset, length); (this->*Context::current().state().buffer.flushMappedRangeImplementation)(offset, length);
return *this; return *this;
} }
bool Buffer::unmap() { return (this->*Context::current().state().buffer->unmapImplementation)(); } bool Buffer::unmap() { return (this->*Context::current().state().buffer.unmapImplementation)(); }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Containers::Array<char> Buffer::subData(const GLintptr offset, const GLsizeiptr size) { Containers::Array<char> Buffer::subData(const GLintptr offset, const GLsizeiptr size) {
Containers::Array<char> data(size); Containers::Array<char> data(size);
if(size) (this->*Context::current().state().buffer->getSubDataImplementation)(offset, size, data); if(size) (this->*Context::current().state().buffer.getSubDataImplementation)(offset, size, data);
return data; return data;
} }
#endif #endif
@ -573,7 +573,7 @@ void Buffer::textureWorkaroundAppleBefore() {
/* My Mac Mini reports 80 texture units, which means this thing can have a /* My Mac Mini reports 80 texture units, which means this thing can have a
pretty significant overhead. Skipping the whole thing if no buffer pretty significant overhead. Skipping the whole thing if no buffer
texture is known to be bound. */ texture is known to be bound. */
Implementation::TextureState& textureState = *Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
if(textureState.bufferTextureBound.none()) return; if(textureState.bufferTextureBound.none()) return;
for(GLint textureUnit = 0; textureUnit != GLint(textureState.bindings.size()); ++textureUnit) { for(GLint textureUnit = 0; textureUnit != GLint(textureState.bindings.size()); ++textureUnit) {
/* Checking just /* Checking just

12
src/Magnum/GL/BufferTexture.cpp

@ -44,7 +44,7 @@ Int BufferTexture::maxSize() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().texture->maxBufferSize; GLint& value = Context::current().state().texture.maxBufferSize;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -62,7 +62,7 @@ Int BufferTexture::offsetAlignment() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().texture->bufferOffsetAlignment; GLint& value = Context::current().state().texture.bufferOffsetAlignment;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -75,19 +75,19 @@ Int BufferTexture::size() {
/* Can't use DataHelper<1>::imageSize(*this, 0)[0] because for 1D textures /* Can't use DataHelper<1>::imageSize(*this, 0)[0] because for 1D textures
it's not defined on ES */ it's not defined on ES */
Int size; Int size;
(this->*Context::current().state().texture->getLevelParameterivImplementation)(0, GL_TEXTURE_WIDTH, &size); (this->*Context::current().state().texture.getLevelParameterivImplementation)(0, GL_TEXTURE_WIDTH, &size);
return size; return size;
} }
BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) { BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) {
buffer.createIfNotAlready(); buffer.createIfNotAlready();
(this->*Context::current().state().texture->setBufferImplementation)(internalFormat, &buffer); (this->*Context::current().state().texture.setBufferImplementation)(internalFormat, &buffer);
return *this; return *this;
} }
BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) {
buffer.createIfNotAlready(); buffer.createIfNotAlready();
(this->*Context::current().state().texture->setBufferRangeImplementation)(internalFormat, buffer, offset, size); (this->*Context::current().state().texture.setBufferRangeImplementation)(internalFormat, buffer, offset, size);
return *this; return *this;
} }
@ -130,7 +130,7 @@ void BufferTexture::setBufferRangeImplementationDSA(const BufferTextureFormat in
BufferTexture& BufferTexture::resetBuffer() { BufferTexture& BufferTexture::resetBuffer() {
/* R8 is the default state according to ARB_texture_buffer_object, so use /* R8 is the default state according to ARB_texture_buffer_object, so use
that */ that */
(this->*Context::current().state().texture->setBufferImplementation)(BufferTextureFormat::R8, nullptr); (this->*Context::current().state().texture.setBufferImplementation)(BufferTextureFormat::R8, nullptr);
return *this; return *this;
} }

30
src/Magnum/GL/Context.cpp

@ -963,7 +963,9 @@ bool Context::tryCreate(const Configuration& configuration) {
} }
} }
_state.emplace(*this, output); std::pair<Containers::ArrayTuple, Implementation::State&> state = Implementation::State::allocate(*this, output);
_stateData = std::move(state.first);
_state = &state.second;
/* Print a list of used workarounds */ /* Print a list of used workarounds */
if(!_driverWorkarounds.empty()) { if(!_driverWorkarounds.empty()) {
@ -1066,7 +1068,7 @@ Containers::Array<Containers::StringView> Context::extensionStrings() const {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
bool Context::isCoreProfile() { bool Context::isCoreProfile() {
return isCoreProfileInternal(*_state->context); return isCoreProfileInternal(_state->context);
} }
bool Context::isCoreProfileInternal(Implementation::ContextState& state) { bool Context::isCoreProfileInternal(Implementation::ContextState& state) {
@ -1137,45 +1139,45 @@ void Context::resetState(const States states) {
#endif #endif
if(states & State::Buffers) if(states & State::Buffers)
_state->buffer->reset(); _state->buffer.reset();
if(states & State::Framebuffers) if(states & State::Framebuffers)
_state->framebuffer->reset(); _state->framebuffer.reset();
if(states & State::Meshes) if(states & State::Meshes)
_state->mesh->reset(); _state->mesh.reset();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/* Bind a scratch VAO for external GL code that is not VAO-aware and just /* Bind a scratch VAO for external GL code that is not VAO-aware and just
enables vertex attributes on the default VAO. Generate it on-demand as enables vertex attributes on the default VAO. Generate it on-demand as
we don't expect this case to be used very often. */ we don't expect this case to be used very often. */
if(states & State::BindScratchVao) { if(states & State::BindScratchVao) {
if(!_state->mesh->scratchVAO) if(!_state->mesh.scratchVAO)
glGenVertexArrays(1, &_state->mesh->scratchVAO); glGenVertexArrays(1, &_state->mesh.scratchVAO);
_state->mesh->bindVAOImplementation(_state->mesh->scratchVAO); _state->mesh.bindVAOImplementation(_state->mesh.scratchVAO);
/* Otherwise just unbind the current VAO and leave the the default */ /* Otherwise just unbind the current VAO and leave the the default */
} else } else
#endif #endif
if(states & State::MeshVao) if(states & State::MeshVao)
_state->mesh->bindVAOImplementation(0); _state->mesh.bindVAOImplementation(0);
if(states & State::PixelStorage) { if(states & State::PixelStorage) {
_state->renderer->unpackPixelStorage.reset(); _state->renderer.unpackPixelStorage.reset();
_state->renderer->packPixelStorage.reset(); _state->renderer.packPixelStorage.reset();
} }
/* Nothing to reset for renderer yet */ /* Nothing to reset for renderer yet */
if(states & State::Shaders) { if(states & State::Shaders) {
/* Nothing to reset for shaders */ /* Nothing to reset for shaders */
_state->shaderProgram->reset(); _state->shaderProgram.reset();
} }
if(states & State::Textures) if(states & State::Textures)
_state->texture->reset(); _state->texture.reset();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(states & State::TransformFeedback) if(states & State::TransformFeedback)
_state->transformFeedback->reset(); _state->transformFeedback.reset();
#endif #endif
} }

5
src/Magnum/GL/Context.h

@ -31,9 +31,9 @@
#include <cstdlib> #include <cstdlib>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/Containers/EnumSet.h> #include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
@ -853,7 +853,8 @@ class MAGNUM_GL_EXPORT Context {
Containers::Array<Extension> _supportedExtensions; Containers::Array<Extension> _supportedExtensions;
#endif #endif
Containers::Pointer<Implementation::State> _state; Containers::ArrayTuple _stateData;
Implementation::State* _state;
Containers::Optional<DetectedDrivers> _detectedDrivers; Containers::Optional<DetectedDrivers> _detectedDrivers;

114
src/Magnum/GL/CubeMapTexture.cpp

@ -53,7 +53,7 @@ Vector2i CubeMapTexture::maxSize() {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Vector2i CubeMapTexture::imageSize(const Int level) { Vector2i CubeMapTexture::imageSize(const Int level) {
const Implementation::TextureState& state = *Context::current().state().texture; const Implementation::TextureState& state = Context::current().state().texture;
Vector2i value; Vector2i value;
(this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
@ -75,8 +75,8 @@ void CubeMapTexture::image(const Int level, Image3D& image) {
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage()); (this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage());
image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)}; image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
} }
@ -93,8 +93,8 @@ void CubeMapTexture::image(const Int level, const MutableImageView3D& image) {
"GL::CubeMapTexture::image(): expected image view size" << size << "but got" << image.size(), ); "GL::CubeMapTexture::image(): expected image view size" << size << "but got" << image.size(), );
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage()); (this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage());
} }
void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUsage usage) { void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUsage usage) {
@ -110,8 +110,8 @@ void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUs
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCubeImageImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, image.storage()); (this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, image.storage());
} }
BufferImage3D CubeMapTexture::image(const Int level, BufferImage3D&& image, const BufferUsage usage) { BufferImage3D CubeMapTexture::image(const Int level, BufferImage3D&& image, const BufferUsage usage) {
@ -133,12 +133,12 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
nv-cubemap-broken-full-compressed-image-query workaround, where it nv-cubemap-broken-full-compressed-image-query workaround, where it
needs to go slice-by-slice, advancing the offset each time */ needs to go slice-by-slice, advancing the offset each time */
dataOffsetSize.first = 0; dataOffsetSize.first = 0;
dataOffsetSize.second = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6;
} else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size);
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(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()};
@ -146,8 +146,8 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
data = Containers::Array<char>{dataOffsetSize.first + dataOffsetSize.second}; data = Containers::Array<char>{dataOffsetSize.first + dataOffsetSize.second};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data); (this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data);
image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data)}; image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
} }
@ -173,7 +173,7 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma
nv-cubemap-broken-full-compressed-image-query workaround, where it nv-cubemap-broken-full-compressed-image-query workaround, where it
needs to go slice-by-slice, advancing the offset each time */ needs to go slice-by-slice, advancing the offset each time */
dataOffsetSize.first = 0; dataOffsetSize.first = 0;
dataOffsetSize.second = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6;
} else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size);
CORRADE_ASSERT(image.data().size() == dataOffsetSize.first + dataOffsetSize.second, CORRADE_ASSERT(image.data().size() == dataOffsetSize.first + dataOffsetSize.second,
@ -182,15 +182,15 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format),
"GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), );
#endif #endif
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data()); (this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data());
} }
void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& image, const BufferUsage usage) { void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& image, const BufferUsage usage) {
@ -207,12 +207,12 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
nv-cubemap-broken-full-compressed-image-query workaround, where it nv-cubemap-broken-full-compressed-image-query workaround, where it
needs to go slice-by-slice, advancing the offset each time */ needs to go slice-by-slice, advancing the offset each time */
dataOffsetSize.first = 0; dataOffsetSize.first = 0;
dataOffsetSize.second = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; dataOffsetSize.second = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level)*6;
} else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size); } else dataOffsetSize = Magnum::Implementation::compressedImageDataOffsetSizeFor(image, size);
/* Internal texture format */ /* Internal texture format */
GLint format; GLint format;
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(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() < dataOffsetSize.first + dataOffsetSize.second) if(image.dataSize() < dataOffsetSize.first + dataOffsetSize.second)
@ -221,8 +221,8 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr); (this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr);
} }
CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) { CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) {
@ -240,8 +240,8 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level,
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data); (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data);
image = Image2D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)}; image = Image2D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
} }
@ -258,8 +258,8 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level,
"GL::CubeMapTexture::image(): expected image view size" << size << "but got" << image.size(), ); "GL::CubeMapTexture::image(): expected image view size" << size << "but got" << image.size(), );
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data()); (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data());
} }
void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) { void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) {
@ -273,8 +273,8 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level,
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); (this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr);
} }
BufferImage2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D&& image, const BufferUsage usage) { BufferImage2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D&& image, const BufferUsage usage) {
@ -289,7 +289,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
the compression, we need to ask GL for it */ the compression, we need to ask GL for it */
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level);
else else
dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
@ -297,7 +297,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(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()};
@ -305,8 +305,8 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data);
image = CompressedImage2D{image.storage(), CompressedPixelFormat(format), size, std::move(data)}; image = CompressedImage2D{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
} }
@ -328,7 +328,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
the compression, we need to ask GL for it */ the compression, we need to ask GL for it */
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level);
else else
dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
@ -339,15 +339,15 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format),
"GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), );
#endif #endif
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, image.data().size(), image.data()); (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, image.data().size(), image.data());
} }
void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) {
@ -357,7 +357,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
the compression, we need to ask GL for it */ the compression, we need to ask GL for it */
std::size_t dataSize; std::size_t dataSize;
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); dataSize = (this->*Context::current().state().texture.getCubeLevelCompressedImageSizeImplementation)(level);
else else
dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size);
@ -365,7 +365,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(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)
@ -374,8 +374,8 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr);
} }
CompressedBufferImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D&& image, const BufferUsage usage) { CompressedBufferImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D&& image, const BufferUsage usage) {
@ -400,7 +400,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Calculate compressed subimage size. If the user-provided pixel storage /* Calculate compressed subimage size. If the user-provided pixel storage
doesn't tell us all properties about the compression, we need to ask GL doesn't tell us all properties about the compression, we need to ask GL
@ -416,7 +416,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
data = Containers::Array<char>{dataSize}; data = Containers::Array<char>{dataSize};
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), data.size(), data); glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), data.size(), data);
image = CompressedImage3D{CompressedPixelFormat(format), range.size(), std::move(data)}; image = CompressedImage3D{CompressedPixelFormat(format), range.size(), std::move(data)};
} }
@ -439,7 +439,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format), CORRADE_ASSERT(compressedPixelFormat(image.format()) == CompressedPixelFormat(format),
"GL::CubeMapTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); "GL::CubeMapTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), );
@ -457,7 +457,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
#endif #endif
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), image.data().size(), image.data()); glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), image.data().size(), image.data());
} }
@ -468,7 +468,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
already wrapped in compressedPixelFormatWrap() later if the drivers are already wrapped in compressedPixelFormatWrap() later if the drivers are
extra shitty (Intel Windows drivers, I'm talking about you). */ extra shitty (Intel Windows drivers, I'm talking about you). */
GLint format{}; GLint format{};
(this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); (this->*Context::current().state().texture.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
/* Calculate compressed subimage size. If the user-provided pixel storage /* Calculate compressed subimage size. If the user-provided pixel storage
doesn't tell us all properties about the compression, we need to ask GL doesn't tell us all properties about the compression, we need to ask GL
@ -485,7 +485,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
image.setData(image.storage(), CompressedPixelFormat(format), range.size(), nullptr, usage); image.setData(image.storage(), CompressedPixelFormat(format), range.size(), nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer->applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), dataSize, nullptr); glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), dataSize, nullptr);
} }
@ -498,8 +498,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off
createIfNotAlready(); createIfNotAlready();
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeSubImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data(), image.storage()); (this->*Context::current().state().texture.cubeSubImage3DImplementation)(level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data(), image.storage());
return *this; return *this;
} }
@ -507,8 +507,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off
createIfNotAlready(); createIfNotAlready();
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeSubImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage()); (this->*Context::current().state().texture.cubeSubImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage());
return *this; return *this;
} }
@ -516,7 +516,7 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Int level, const Vec
createIfNotAlready(); createIfNotAlready();
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), image.size().x(), image.size().y(), image.size().z(), GLenum(compressedPixelFormat(image.format())), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), image.size().x(), image.size().y(), image.size().z(), GLenum(compressedPixelFormat(image.format())), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
return *this; return *this;
} }
@ -525,7 +525,7 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Int level, const Vec
createIfNotAlready(); createIfNotAlready();
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), image.size().x(), image.size().y(), image.size().z(), GLenum(image.format()), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr); glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), image.size().x(), image.size().y(), image.size().z(), GLenum(image.format()), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
return *this; return *this;
} }
@ -535,8 +535,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data() (this->*Context::current().state().texture.cubeSubImageImplementation)(coordinate, level, offset, image.size(), pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data()
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
+ Magnum::Implementation::pixelStorageSkipOffset(image) + Magnum::Implementation::pixelStorageSkipOffset(image)
#endif #endif
@ -547,8 +547,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) { CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); (this->*Context::current().state().texture.cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr);
return *this; return *this;
} }
#endif #endif
@ -557,16 +557,16 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate co
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #endif
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size())); (this->*Context::current().state().texture.cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), compressedPixelFormat(image.format()), image.data(), Magnum::Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) { CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); Context::current().state().renderer.applyPixelStorageUnpack(image.storage());
(this->*Context::current().state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); (this->*Context::current().state().texture.cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), nullptr, Magnum::Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
return *this; return *this;
} }
#endif #endif

32
src/Magnum/GL/DebugOutput.cpp

@ -114,7 +114,7 @@ Int DebugOutput::maxLoggedMessages() {
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>()) if(!Context::current().isExtensionSupported<Extensions::KHR::debug>())
return 0; return 0;
GLint& value = Context::current().state().debug->maxLoggedMessages; GLint& value = Context::current().state().debug.maxLoggedMessages;
if(value == 0) { if(value == 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -131,7 +131,7 @@ Int DebugOutput::maxMessageLength() {
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>()) if(!Context::current().isExtensionSupported<Extensions::KHR::debug>())
return 0; return 0;
GLint& value = Context::current().state().debug->maxMessageLength; GLint& value = Context::current().state().debug.maxMessageLength;
if(value == 0) { if(value == 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -145,7 +145,7 @@ Int DebugOutput::maxMessageLength() {
} }
void DebugOutput::setCallback(const Callback callback, const void* userParam) { void DebugOutput::setCallback(const Callback callback, const void* userParam) {
Context::current().state().debug->callbackImplementation(callback, userParam); Context::current().state().debug.callbackImplementation(callback, userParam);
} }
void DebugOutput::setDefaultCallback() { void DebugOutput::setDefaultCallback() {
@ -155,7 +155,7 @@ void DebugOutput::setDefaultCallback() {
} }
void DebugOutput::setEnabledInternal(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list<UnsignedInt> ids, const bool enabled) { void DebugOutput::setEnabledInternal(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list<UnsignedInt> ids, const bool enabled) {
Context::current().state().debug->controlImplementation(source, type, severity, ids, enabled); Context::current().state().debug.controlImplementation(source, type, severity, ids, enabled);
} }
void DebugOutput::controlImplementationNoOp(GLenum, GLenum, GLenum, std::initializer_list<UnsignedInt>, bool) {} void DebugOutput::controlImplementationNoOp(GLenum, GLenum, GLenum, std::initializer_list<UnsignedInt>, bool) {}
@ -177,13 +177,13 @@ void DebugOutput::callbackImplementationNoOp(Callback, const void*) {}
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback, const void* userParam) { void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback, const void* userParam) {
/* Replace the callback */ /* Replace the callback */
const Callback original = Context::current().state().debug->messageCallback.callback; const Callback original = Context::current().state().debug.messageCallback.callback;
Context::current().state().debug->messageCallback.callback = callback; Context::current().state().debug.messageCallback.callback = callback;
Context::current().state().debug->messageCallback.userParam = userParam; Context::current().state().debug.messageCallback.userParam = userParam;
/* Adding callback */ /* Adding callback */
if(!original && callback) if(!original && callback)
glDebugMessageCallback(callbackWrapper, &Context::current().state().debug->messageCallback); glDebugMessageCallback(callbackWrapper, &Context::current().state().debug.messageCallback);
/* Deleting callback */ /* Deleting callback */
else if(original && !callback) else if(original && !callback)
@ -194,13 +194,13 @@ void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback,
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
void DebugOutput::callbackImplementationKhrES(const Callback callback, const void* userParam) { void DebugOutput::callbackImplementationKhrES(const Callback callback, const void* userParam) {
/* Replace the callback */ /* Replace the callback */
const Callback original = Context::current().state().debug->messageCallback.callback; const Callback original = Context::current().state().debug.messageCallback.callback;
Context::current().state().debug->messageCallback.callback = callback; Context::current().state().debug.messageCallback.callback = callback;
Context::current().state().debug->messageCallback.userParam = userParam; Context::current().state().debug.messageCallback.userParam = userParam;
/* Adding callback */ /* Adding callback */
if(!original && callback) if(!original && callback)
glDebugMessageCallbackKHR(callbackWrapper, &Context::current().state().debug->messageCallback); glDebugMessageCallbackKHR(callbackWrapper, &Context::current().state().debug.messageCallback);
/* Deleting callback */ /* Deleting callback */
else if(original && !callback) else if(original && !callback)
@ -267,7 +267,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Severity value) {
#endif #endif
void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView<const char> string) { void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView<const char> string) {
Context::current().state().debug->messageInsertImplementation(source, type, id, severity, string); Context::current().state().debug.messageInsertImplementation(source, type, id, severity, string);
} }
void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView<const char>) {} void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView<const char>) {}
@ -333,7 +333,7 @@ Int DebugGroup::maxStackDepth() {
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>()) if(!Context::current().isExtensionSupported<Extensions::KHR::debug>())
return 0; return 0;
GLint& value = Context::current().state().debug->maxStackDepth; GLint& value = Context::current().state().debug.maxStackDepth;
if(value == 0) { if(value == 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -348,13 +348,13 @@ Int DebugGroup::maxStackDepth() {
void DebugGroup::pushInternal(const Source source, const UnsignedInt id, const Containers::ArrayView<const char> message) { void DebugGroup::pushInternal(const Source source, const UnsignedInt id, const Containers::ArrayView<const char> message) {
CORRADE_ASSERT(!_active, "GL::DebugGroup::push(): group is already active", ); CORRADE_ASSERT(!_active, "GL::DebugGroup::push(): group is already active", );
Context::current().state().debug->pushGroupImplementation(source, id, message); Context::current().state().debug.pushGroupImplementation(source, id, message);
_active = true; _active = true;
} }
void DebugGroup::pop() { void DebugGroup::pop() {
CORRADE_ASSERT(_active, "GL::DebugGroup::pop(): group is not active", ); CORRADE_ASSERT(_active, "GL::DebugGroup::pop(): group is not active", );
Context::current().state().debug->popGroupImplementation(); Context::current().state().debug.popGroupImplementation();
_active = false; _active = false;
} }

22
src/Magnum/GL/DefaultFramebuffer.cpp

@ -40,22 +40,22 @@ namespace Magnum { namespace GL {
DefaultFramebuffer defaultFramebuffer; DefaultFramebuffer defaultFramebuffer;
DefaultFramebuffer::Status DefaultFramebuffer::checkStatus(const FramebufferTarget target) { DefaultFramebuffer::Status DefaultFramebuffer::checkStatus(const FramebufferTarget target) {
return Status((this->*Context::current().state().framebuffer->checkStatusImplementation)(target)); return Status((this->*Context::current().state().framebuffer.checkStatusImplementation)(target));
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
DefaultFramebuffer& DefaultFramebuffer::clearColor(const Color4& color) { DefaultFramebuffer& DefaultFramebuffer::clearColor(const Color4& color) {
(this->*Context::current().state().framebuffer->clearFImplementation)(GL_COLOR, 0, color.data()); (this->*Context::current().state().framebuffer.clearFImplementation)(GL_COLOR, 0, color.data());
return *this; return *this;
} }
DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4i& color) { DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4i& color) {
(this->*Context::current().state().framebuffer->clearIImplementation)(GL_COLOR, 0, color.data()); (this->*Context::current().state().framebuffer.clearIImplementation)(GL_COLOR, 0, color.data());
return *this; return *this;
} }
DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4ui& color) { DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4ui& color) {
(this->*Context::current().state().framebuffer->clearUIImplementation)(GL_COLOR, 0, color.data()); (this->*Context::current().state().framebuffer.clearUIImplementation)(GL_COLOR, 0, color.data());
return *this; return *this;
} }
#endif #endif
@ -73,22 +73,22 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list<std::pa
for(const auto& attachment: attachments) for(const auto& attachment: attachments)
_attachments[attachment.first] = GLenum(attachment.second); _attachments[attachment.first] = GLenum(attachment.second);
(this->*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); (this->*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments);
return *this; return *this;
} }
DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const DrawAttachment attachment) { DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const DrawAttachment attachment) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
(this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); (this->*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment));
#else #else
(this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast<const GLenum*>(&attachment)); (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast<const GLenum*>(&attachment));
#endif #endif
return *this; return *this;
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
DefaultFramebuffer& DefaultFramebuffer::mapForRead(const ReadAttachment attachment) { DefaultFramebuffer& DefaultFramebuffer::mapForRead(const ReadAttachment attachment) {
(this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment));
return *this; return *this;
} }
@ -98,7 +98,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
for(std::size_t i = 0; i != attachments.size(); ++i) for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i)); _attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); (this->*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments);
} }
#endif #endif
@ -109,12 +109,12 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
for(std::size_t i = 0; i != attachments.size(); ++i) for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i)); _attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); (this->*Context::current().state().framebuffer.invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
} }
#endif #endif
void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) { void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {
Implementation::FramebufferState& state = *context.state().framebuffer; Implementation::FramebufferState& state = context.state().framebuffer;
/* Initial framebuffer size */ /* Initial framebuffer size */
GLint viewport[4]; GLint viewport[4];

66
src/Magnum/GL/Framebuffer.cpp

@ -84,7 +84,7 @@ Int Framebuffer::maxColorAttachments() {
#endif #endif
#endif #endif
GLint& value = Context::current().state().framebuffer->maxColorAttachments; GLint& value = Context::current().state().framebuffer.maxColorAttachments;
if(value == 0) { if(value == 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -100,7 +100,7 @@ Int Framebuffer::maxColorAttachments() {
Framebuffer::Framebuffer(const Range2Di& viewport): AbstractFramebuffer{0, viewport, ObjectFlag::DeleteOnDestruction} { Framebuffer::Framebuffer(const Range2Di& viewport): AbstractFramebuffer{0, viewport, ObjectFlag::DeleteOnDestruction} {
CORRADE_INTERNAL_ASSERT(viewport != Implementation::FramebufferState::DisengagedViewport); CORRADE_INTERNAL_ASSERT(viewport != Implementation::FramebufferState::DisengagedViewport);
_viewport = viewport; _viewport = viewport;
(this->*Context::current().state().framebuffer->createImplementation)(); (this->*Context::current().state().framebuffer.createImplementation)();
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
@ -120,7 +120,7 @@ Framebuffer::~Framebuffer() {
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
Implementation::FramebufferState& state = *Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
if(state.readBinding == _id) state.readBinding = 0; if(state.readBinding == _id) state.readBinding = 0;
/* For draw binding reset also viewport */ /* For draw binding reset also viewport */
@ -140,33 +140,33 @@ Framebuffer::~Framebuffer() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string Framebuffer::label() { std::string Framebuffer::label() {
createIfNotAlready(); createIfNotAlready();
return Context::current().state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); return Context::current().state().debug.getLabelImplementation(GL_FRAMEBUFFER, _id);
} }
Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayView<const char> label) { Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
Context::current().state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); Context::current().state().debug.labelImplementation(GL_FRAMEBUFFER, _id, label);
return *this; return *this;
} }
#endif #endif
Framebuffer::Status Framebuffer::checkStatus(const FramebufferTarget target) { Framebuffer::Status Framebuffer::checkStatus(const FramebufferTarget target) {
return Status((this->*Context::current().state().framebuffer->checkStatusImplementation)(target)); return Status((this->*Context::current().state().framebuffer.checkStatusImplementation)(target));
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Framebuffer& Framebuffer::clearColor(const Int attachment, const Color4& color) { Framebuffer& Framebuffer::clearColor(const Int attachment, const Color4& color) {
(this->*Context::current().state().framebuffer->clearFImplementation)(GL_COLOR, attachment, color.data()); (this->*Context::current().state().framebuffer.clearFImplementation)(GL_COLOR, attachment, color.data());
return *this; return *this;
} }
Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4i& color) { Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4i& color) {
(this->*Context::current().state().framebuffer->clearIImplementation)(GL_COLOR, attachment, color.data()); (this->*Context::current().state().framebuffer.clearIImplementation)(GL_COLOR, attachment, color.data());
return *this; return *this;
} }
Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4ui& color) { Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4ui& color) {
(this->*Context::current().state().framebuffer->clearUIImplementation)(GL_COLOR, attachment, color.data()); (this->*Context::current().state().framebuffer.clearUIImplementation)(GL_COLOR, attachment, color.data());
return *this; return *this;
} }
#endif #endif
@ -184,22 +184,22 @@ Framebuffer& Framebuffer::mapForDraw(std::initializer_list<std::pair<UnsignedInt
for(const auto& attachment: attachments) for(const auto& attachment: attachments)
_attachments[attachment.first] = GLenum(attachment.second); _attachments[attachment.first] = GLenum(attachment.second);
(this->*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); (this->*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments);
return *this; return *this;
} }
Framebuffer& Framebuffer::mapForDraw(const DrawAttachment attachment) { Framebuffer& Framebuffer::mapForDraw(const DrawAttachment attachment) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
(this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); (this->*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment));
#else #else
(this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast<const GLenum*>(&attachment)); (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast<const GLenum*>(&attachment));
#endif #endif
return *this; return *this;
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
Framebuffer& Framebuffer::mapForRead(const ColorAttachment attachment) { Framebuffer& Framebuffer::mapForRead(const ColorAttachment attachment) {
(this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment));
return *this; return *this;
} }
@ -209,7 +209,7 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
for(std::size_t i = 0; i != attachments.size(); ++i) for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i)); _attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); (this->*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments);
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -219,116 +219,116 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
for(std::size_t i = 0; i != attachments.size(); ++i) for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i)); _attachments[i] = GLenum(*(attachments.begin()+i));
(this->*Context::current().state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); (this->*Context::current().state().framebuffer.invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
} }
#endif #endif
#endif #endif
Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) { Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) {
(this->*Context::current().state().framebuffer->renderbufferImplementation)(attachment, renderbuffer.id()); (this->*Context::current().state().framebuffer.renderbufferImplementation)(attachment, renderbuffer.id());
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture1D& texture, const Int level) { Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture1D& texture, const Int level) {
(this->*Context::current().state().framebuffer->texture1DImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.texture1DImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
#endif #endif
Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture2D& texture, const Int level) { Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture2D& texture, const Int level) {
(this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level); (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, RectangleTexture& texture) { Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, RectangleTexture& texture) {
(this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0); (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0);
return *this; return *this;
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, MultisampleTexture2D& texture) { Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, MultisampleTexture2D& texture) {
(this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0); (this->*Context::current().state().framebuffer.texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0);
return *this; return *this;
} }
#endif #endif
Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapCoordinate coordinate, const Int level) { Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapCoordinate coordinate, const Int level) {
(this->*Context::current().state().framebuffer->textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level); (this->*Context::current().state().framebuffer.textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level);
return *this; return *this;
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture3D& texture, Int level, Int layer) {
(this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer);
return *this; return *this;
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer) { Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer) {
(this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer);
return *this; return *this;
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer) { Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer) {
(this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer);
return *this; return *this;
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer) { Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer) {
(this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), level, layer);
return *this; return *this;
} }
Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, MultisampleTexture2DArray& texture, Int layer) { Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, MultisampleTexture2DArray& texture, Int layer) {
(this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), 0, layer); (this->*Context::current().state().framebuffer.textureLayerImplementation)(attachment, texture.id(), 0, layer);
return *this; return *this;
} }
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture3D& texture, const Int level) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture3D& texture, const Int level) {
(this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture1DArray& texture, const Int level) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture1DArray& texture, const Int level) {
(this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
#endif #endif
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture2DArray& texture, const Int level) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture2DArray& texture, const Int level) {
(this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTexture& texture, const Int level) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTexture& texture, const Int level) {
(this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTextureArray& texture, const Int level) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTextureArray& texture, const Int level) {
(this->*Context::current().state().framebuffer->layeredTextureCubeMapArrayImplementation)(attachment, texture.id(), level); (this->*Context::current().state().framebuffer.layeredTextureCubeMapArrayImplementation)(attachment, texture.id(), level);
return *this; return *this;
} }
Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, MultisampleTexture2DArray& texture) { Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, MultisampleTexture2DArray& texture) {
(this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), 0); (this->*Context::current().state().framebuffer.textureImplementation)(attachment, texture.id(), 0);
return *this; return *this;
} }
#endif #endif
Framebuffer& Framebuffer::detach(const BufferAttachment attachment) { Framebuffer& Framebuffer::detach(const BufferAttachment attachment) {
(this->*Context::current().state().framebuffer->renderbufferImplementation)(attachment, 0); (this->*Context::current().state().framebuffer.renderbufferImplementation)(attachment, 0);
return *this; return *this;
} }

84
src/Magnum/GL/Implementation/State.cpp

@ -25,6 +25,8 @@
#include "State.h" #include "State.h"
#include <Corrade/Containers/ArrayTuple.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Implementation/BufferState.h" #include "Magnum/GL/Implementation/BufferState.h"
@ -45,7 +47,43 @@
namespace Magnum { namespace GL { namespace Implementation { namespace Magnum { namespace GL { namespace Implementation {
State::State(Context& context, std::ostream* const out) { std::pair<Containers::ArrayTuple, State&> State::allocate(Context& context, std::ostream* const out) {
/* I have to say, the ArrayTuple is quite a crazy thing */
Containers::ArrayView<State> stateView;
Containers::ArrayView<BufferState> bufferStateView;
Containers::ArrayView<ContextState> contextStateView;
#ifndef MAGNUM_TARGET_WEBGL
Containers::ArrayView<DebugState> debugStateView;
#endif
Containers::ArrayView<FramebufferState> framebufferStateView;
Containers::ArrayView<MeshState> meshStateView;
Containers::ArrayView<QueryState> queryStateView;
Containers::ArrayView<RendererState> rendererStateView;
Containers::ArrayView<ShaderState> shaderStateView;
Containers::ArrayView<ShaderProgramState> shaderProgramStateView;
Containers::ArrayView<TextureState> textureStateView;
#ifndef MAGNUM_TARGET_GLES2
Containers::ArrayView<TransformFeedbackState> transformFeedbackStateView;
#endif
Containers::ArrayTuple data{
{Containers::NoInit, 1, stateView},
{Containers::NoInit, 1, bufferStateView},
{Containers::NoInit, 1, contextStateView},
#ifndef MAGNUM_TARGET_WEBGL
{Containers::NoInit, 1, debugStateView},
#endif
{Containers::NoInit, 1, framebufferStateView},
{Containers::NoInit, 1, meshStateView},
{Containers::NoInit, 1, queryStateView},
{Containers::NoInit, 1, rendererStateView},
{Containers::NoInit, 1, shaderStateView},
{Containers::NoInit, 1, shaderProgramStateView},
{Containers::NoInit, 1, textureStateView},
#ifndef MAGNUM_TARGET_GLES2
{Containers::NoInit, 1, transformFeedbackStateView}
#endif
};
/* Extensions that might get used by current context. The State classes /* Extensions that might get used by current context. The State classes
will set strings based on Extension::index() and then we'll go through will set strings based on Extension::index() and then we'll go through
the list and print ones that aren't null. It's 1.5 kB of temporary data the list and print ones that aren't null. It's 1.5 kB of temporary data
@ -53,27 +91,45 @@ State::State(Context& context, std::ostream* const out) {
populating a heap array and then std::sort() it to remove duplicates. */ populating a heap array and then std::sort() it to remove duplicates. */
const char* extensions[Implementation::ExtensionCount]{}; const char* extensions[Implementation::ExtensionCount]{};
buffer.reset(new BufferState{context, extensions}); State& state = *(new(&stateView.front()) State{
this->context.reset(new ContextState{context, extensions}); bufferStateView.front(),
contextStateView.front(),
#ifndef MAGNUM_TARGET_WEBGL
debugStateView.front(),
#endif
framebufferStateView.front(),
meshStateView.front(),
queryStateView.front(),
rendererStateView.front(),
shaderStateView.front(),
shaderProgramStateView.front(),
textureStateView.front(),
#ifndef MAGNUM_TARGET_GLES2
transformFeedbackStateView.front()
#endif
});
new(&state.buffer) BufferState{context, extensions};
new(&state.context) ContextState{context, extensions};
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
debug.reset(new DebugState{context, extensions}); new(&state.debug) DebugState{context, extensions};
#endif #endif
framebuffer.reset(new FramebufferState{context, extensions}); new(&state.framebuffer) FramebufferState{context, extensions};
mesh.reset(new MeshState{context, *this->context, extensions}); new(&state.mesh) MeshState{context, stateView.front().context, extensions};
query.reset(new QueryState{context, extensions}); new(&state.query) QueryState{context, extensions};
renderer.reset(new RendererState{context, *this->context, extensions}); new(&state.renderer) RendererState{context, stateView.front().context, extensions};
shader.reset(new ShaderState(context, extensions)); new(&state.shader) ShaderState(context, extensions);
shaderProgram.reset(new ShaderProgramState{context, extensions}); new(&state.shaderProgram) ShaderProgramState{context, extensions};
texture.reset(new TextureState{context, extensions}); new(&state.texture) TextureState{context, extensions};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
transformFeedback.reset(new TransformFeedbackState{context, extensions}); new(&state.transformFeedback) TransformFeedbackState{context, extensions};
#endif #endif
Debug{out} << "Using optional features:"; Debug{out} << "Using optional features:";
for(const char* extension: extensions) for(const char* extension: extensions)
if(extension) Debug(out) << " " << extension; if(extension) Debug(out) << " " << extension;
}
State::~State() = default; return {std::move(data), state};
}
}}} }}}

33
src/Magnum/GL/Implementation/State.h

@ -25,7 +25,9 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/Pointer.h> #include <iosfwd>
#include <utility>
#include <Corrade/Containers/Containers.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/GL/GL.h" #include "Magnum/GL/GL.h"
@ -49,27 +51,26 @@ struct TransformFeedbackState;
#endif #endif
struct State { struct State {
/* Initializes context-based functionality */ /* Initializes context-based functionality together with all nested classes
explicit State(Context& context, std::ostream* out); in a single allocation */
static std::pair<Containers::ArrayTuple, State&> allocate(Context& context, std::ostream* out);
~State();
enum: GLuint { DisengagedBinding = ~0u }; enum: GLuint { DisengagedBinding = ~0u };
Containers::Pointer<BufferState> buffer; BufferState& buffer;
Containers::Pointer<ContextState> context; ContextState& context;
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
Containers::Pointer<DebugState> debug; DebugState& debug;
#endif #endif
Containers::Pointer<FramebufferState> framebuffer; FramebufferState& framebuffer;
Containers::Pointer<MeshState> mesh; MeshState& mesh;
Containers::Pointer<QueryState> query; QueryState& query;
Containers::Pointer<RendererState> renderer; RendererState& renderer;
Containers::Pointer<ShaderState> shader; ShaderState& shader;
Containers::Pointer<ShaderProgramState> shaderProgram; ShaderProgramState& shaderProgram;
Containers::Pointer<TextureState> texture; TextureState& texture;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Containers::Pointer<TransformFeedbackState> transformFeedback; TransformFeedbackState& transformFeedback;
#endif #endif
}; };

8
src/Magnum/GL/Implementation/maxTextureSize.cpp

@ -32,7 +32,7 @@
namespace Magnum { namespace GL { namespace Implementation { namespace Magnum { namespace GL { namespace Implementation {
GLint maxTextureSideSize() { GLint maxTextureSideSize() {
GLint& value = Context::current().state().texture->maxSize; GLint& value = Context::current().state().texture.maxSize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
@ -42,7 +42,7 @@ GLint maxTextureSideSize() {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
GLint max3DTextureDepth() { GLint max3DTextureDepth() {
GLint& value = Context::current().state().texture->max3DSize; GLint& value = Context::current().state().texture.max3DSize;
if(value == 0) if(value == 0)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -57,7 +57,7 @@ GLint max3DTextureDepth() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GLint maxTextureArrayLayers() { GLint maxTextureArrayLayers() {
GLint& value = Context::current().state().texture->maxArrayLayers; GLint& value = Context::current().state().texture.maxArrayLayers;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &value); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &value);
@ -67,7 +67,7 @@ GLint maxTextureArrayLayers() {
#endif #endif
GLint maxCubeMapTextureSideSize() { GLint maxCubeMapTextureSideSize() {
GLint& value = Context::current().state().texture->maxCubeMapSize; GLint& value = Context::current().state().texture.maxCubeMapSize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value); glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value);

50
src/Magnum/GL/Mesh.cpp

@ -181,7 +181,7 @@ UnsignedInt Mesh::maxVertexAttributeStride() {
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
GLint& value = Context::current().state().mesh->maxVertexAttributeStride; GLint& value = Context::current().state().mesh.maxVertexAttributeStride;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -209,7 +209,7 @@ Int Mesh::maxElementIndex()
#else #else
GLint& value = GLint& value =
#endif #endif
Context::current().state().mesh->maxElementIndex; Context::current().state().mesh.maxElementIndex;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) { if(value == 0) {
@ -224,7 +224,7 @@ Int Mesh::maxElementIndex()
} }
Int Mesh::maxElementsIndices() { Int Mesh::maxElementsIndices() {
GLint& value = Context::current().state().mesh->maxElementsIndices; GLint& value = Context::current().state().mesh.maxElementsIndices;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -234,7 +234,7 @@ Int Mesh::maxElementsIndices() {
} }
Int Mesh::maxElementsVertices() { Int Mesh::maxElementsVertices() {
GLint& value = Context::current().state().mesh->maxElementsVertices; GLint& value = Context::current().state().mesh.maxElementsVertices;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -245,7 +245,7 @@ Int Mesh::maxElementsVertices() {
#endif #endif
Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction} { Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().mesh->createImplementation)(true); (this->*Context::current().state().mesh.createImplementation)(true);
} }
Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction} {} Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction} {}
@ -256,11 +256,11 @@ Mesh::~Mesh() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(deleteObject) { if(deleteObject) {
/* Remove current vao from the state */ /* Remove current vao from the state */
GLuint& current = Context::current().state().mesh->currentVAO; GLuint& current = Context::current().state().mesh.currentVAO;
if(current == _id) current = 0; if(current == _id) current = 0;
} }
if(_constructed) (this->*Context::current().state().mesh->destroyImplementation)(deleteObject); if(_constructed) (this->*Context::current().state().mesh.destroyImplementation)(deleteObject);
} }
Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _flags{other._flags}, _countSet{other._countSet}, _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount}, Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _flags{other._flags}, _countSet{other._countSet}, _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount},
@ -273,7 +273,7 @@ Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive),
_indexOffset(other._indexOffset), _indexType(other._indexType), _indexBuffer{std::move(other._indexBuffer)} _indexOffset(other._indexOffset), _indexType(other._indexType), _indexBuffer{std::move(other._indexBuffer)}
{ {
if(_constructed || other._constructed) if(_constructed || other._constructed)
(this->*Context::current().state().mesh->moveConstructImplementation)(std::move(other)); (this->*Context::current().state().mesh.moveConstructImplementation)(std::move(other));
other._id = 0; other._id = 0;
} }
@ -298,13 +298,13 @@ Mesh& Mesh::operator=(Mesh&& other) noexcept {
swap(_indexBuffer, other._indexBuffer); swap(_indexBuffer, other._indexBuffer);
if(_constructed || other._constructed) if(_constructed || other._constructed)
(this->*Context::current().state().mesh->moveAssignImplementation)(std::move(other)); (this->*Context::current().state().mesh.moveAssignImplementation)(std::move(other));
return *this; return *this;
} }
Mesh::Mesh(const GLuint id, const MeshPrimitive primitive, const ObjectFlags flags): _id{id}, _primitive{primitive}, _flags{flags} { Mesh::Mesh(const GLuint id, const MeshPrimitive primitive, const ObjectFlags flags): _id{id}, _primitive{primitive}, _flags{flags} {
(this->*Context::current().state().mesh->createImplementation)(false); (this->*Context::current().state().mesh.createImplementation)(false);
} }
inline void Mesh::createIfNotAlready() { inline void Mesh::createIfNotAlready() {
@ -323,18 +323,18 @@ inline void Mesh::createIfNotAlready() {
std::string Mesh::label() { std::string Mesh::label() {
createIfNotAlready(); createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug->getLabelImplementation(GL_VERTEX_ARRAY, _id); return Context::current().state().debug.getLabelImplementation(GL_VERTEX_ARRAY, _id);
#else #else
return Context::current().state().debug->getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id); return Context::current().state().debug.getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id);
#endif #endif
} }
Mesh& Mesh::setLabelInternal(const Containers::ArrayView<const char> label) { Mesh& Mesh::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); Context::current().state().debug.labelImplementation(GL_VERTEX_ARRAY, _id, label);
#else #else
Context::current().state().debug->labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label); Context::current().state().debug.labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label);
#endif #endif
return *this; return *this;
} }
@ -381,7 +381,7 @@ Mesh& Mesh::setIndexBuffer(Buffer&& buffer, GLintptr offset, MeshIndexType type,
/* It's IMPORTANT to do this *before* the _indexBuffer is set, since the /* It's IMPORTANT to do this *before* the _indexBuffer is set, since the
bindVAO() function called from here is resetting element buffer state bindVAO() function called from here is resetting element buffer state
tracker to _indexBuffer.id(). */ tracker to _indexBuffer.id(). */
(this->*Context::current().state().mesh->bindIndexBufferImplementation)(buffer); (this->*Context::current().state().mesh.bindIndexBufferImplementation)(buffer);
_indexBuffer = std::move(buffer); _indexBuffer = std::move(buffer);
_indexOffset = offset; _indexOffset = offset;
@ -407,7 +407,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, UnsignedIn
void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr indexOffset) void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr indexOffset)
#endif #endif
{ {
const Implementation::MeshState& state = *Context::current().state().mesh; const Implementation::MeshState& state = Context::current().state().mesh;
(this->*state.bindImplementation)(); (this->*state.bindImplementation)();
@ -548,7 +548,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const Int instanceCount) { void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const Int instanceCount) {
const Implementation::MeshState& state = *Context::current().state().mesh; const Implementation::MeshState& state = Context::current().state().mesh;
(this->*state.bindImplementation)(); (this->*state.bindImplementation)();
@ -605,11 +605,11 @@ void Mesh::bindVAOImplementationVAO(const GLuint id) {
#else #else
glBindVertexArrayOES glBindVertexArrayOES
#endif #endif
(Context::current().state().mesh->currentVAO = id); (Context::current().state().mesh.currentVAO = id);
} }
void Mesh::bindVAO() { void Mesh::bindVAO() {
GLuint& current = Context::current().state().mesh->currentVAO; GLuint& current = Context::current().state().mesh.currentVAO;
if(current != _id) { if(current != _id) {
/* Binding the VAO finally creates it */ /* Binding the VAO finally creates it */
_flags |= ObjectFlag::Created; _flags |= ObjectFlag::Created;
@ -622,7 +622,7 @@ void Mesh::bindVAO() {
particular, the setIndexBuffer() buffers call this function *and particular, the setIndexBuffer() buffers call this function *and
then* sets the _indexBuffer, which means at this point the ID will then* sets the _indexBuffer, which means at this point the ID will
be still 0. */ be still 0. */
Context::current().state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::TargetHint::ElementArray)] = _indexBuffer.id(); Context::current().state().buffer.bindings[Implementation::BufferState::indexForTarget(Buffer::TargetHint::ElementArray)] = _indexBuffer.id();
} }
} }
@ -731,7 +731,7 @@ void Mesh::attributePointerInternal(const Buffer& buffer, const GLuint location,
void Mesh::attributePointerInternal(AttributeLayout&& attribute) { void Mesh::attributePointerInternal(AttributeLayout&& attribute) {
CORRADE_ASSERT(attribute.buffer.id(), CORRADE_ASSERT(attribute.buffer.id(),
"GL::Mesh::addVertexBuffer(): empty or moved-out Buffer instance was passed", ); "GL::Mesh::addVertexBuffer(): empty or moved-out Buffer instance was passed", );
(this->*Context::current().state().mesh->attributePointerImplementation)(std::move(attribute)); (this->*Context::current().state().mesh.attributePointerImplementation)(std::move(attribute));
} }
void Mesh::attributePointerImplementationDefault(AttributeLayout&& attribute) { void Mesh::attributePointerImplementationDefault(AttributeLayout&& attribute) {
@ -775,7 +775,7 @@ void Mesh::attributePointerImplementationVAODSA(AttributeLayout&& attribute) {
glVertexArrayVertexBuffer(_id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride); glVertexArrayVertexBuffer(_id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride);
if(attribute.divisor) if(attribute.divisor)
(this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, attribute.divisor);
} }
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
@ -811,7 +811,7 @@ void Mesh::vertexAttribPointer(AttributeLayout& attribute) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glVertexAttribDivisor(attribute.location, attribute.divisor); glVertexAttribDivisor(attribute.location, attribute.divisor);
#else #else
(this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, attribute.divisor);
#endif #endif
} }
} }
@ -839,7 +839,7 @@ void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint
#endif #endif
void Mesh::acquireVertexBuffer(Buffer&& buffer) { void Mesh::acquireVertexBuffer(Buffer&& buffer) {
(this->*Context::current().state().mesh->acquireVertexBufferImplementation)(std::move(buffer)); (this->*Context::current().state().mesh.acquireVertexBufferImplementation)(std::move(buffer));
} }
void Mesh::acquireVertexBufferImplementationDefault(Buffer&& buffer) { void Mesh::acquireVertexBufferImplementationDefault(Buffer&& buffer) {
@ -895,7 +895,7 @@ void Mesh::unbindImplementationDefault() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glVertexAttribDivisor(attribute.location, 0); glVertexAttribDivisor(attribute.location, 0);
#else #else
(this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, 0); (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, 0);
#endif #endif
} }
} }

2
src/Magnum/GL/MeshView.cpp

@ -88,7 +88,7 @@ MeshView& MeshView::draw(AbstractShaderProgram&& shader, TransformFeedback& xfb,
void MeshView::multiDrawImplementationDefault(Containers::ArrayView<const Containers::Reference<MeshView>> meshes) { void MeshView::multiDrawImplementationDefault(Containers::ArrayView<const Containers::Reference<MeshView>> meshes) {
CORRADE_INTERNAL_ASSERT(meshes.size()); CORRADE_INTERNAL_ASSERT(meshes.size());
const Implementation::MeshState& state = *Context::current().state().mesh; const Implementation::MeshState& state = Context::current().state().mesh;
Mesh& original = meshes.begin()->get()._original; Mesh& original = meshes.begin()->get()._original;
Containers::Array<GLsizei> count{meshes.size()}; Containers::Array<GLsizei> count{meshes.size()};

2
src/Magnum/GL/RectangleTexture.cpp

@ -40,7 +40,7 @@ Vector2i RectangleTexture::maxSize() {
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_rectangle>()) if(!Context::current().isExtensionSupported<Extensions::ARB::texture_rectangle>())
return {}; return {};
GLint& value = Context::current().state().texture->maxRectangleSize; GLint& value = Context::current().state().texture.maxRectangleSize;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &value); glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &value);

18
src/Magnum/GL/Renderbuffer.cpp

@ -37,7 +37,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
Int Renderbuffer::maxSize() { Int Renderbuffer::maxSize() {
GLint& value = Context::current().state().framebuffer->maxRenderbufferSize; GLint& value = Context::current().state().framebuffer.maxRenderbufferSize;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -53,7 +53,7 @@ Int Renderbuffer::maxSamples() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().framebuffer->maxSamples; GLint& value = Context::current().state().framebuffer.maxSamples;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) { if(value == 0) {
@ -69,7 +69,7 @@ Int Renderbuffer::maxSamples() {
#endif #endif
Renderbuffer::Renderbuffer(): _flags{ObjectFlag::DeleteOnDestruction} { Renderbuffer::Renderbuffer(): _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().framebuffer->createRenderbufferImplementation)(); (this->*Context::current().state().framebuffer.createRenderbufferImplementation)();
} }
void Renderbuffer::createImplementationDefault() { void Renderbuffer::createImplementationDefault() {
@ -88,7 +88,7 @@ Renderbuffer::~Renderbuffer() {
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
GLuint& binding = Context::current().state().framebuffer->renderbufferBinding; GLuint& binding = Context::current().state().framebuffer.renderbufferBinding;
if(binding == _id) binding = 0; if(binding == _id) binding = 0;
glDeleteRenderbuffers(1, &_id); glDeleteRenderbuffers(1, &_id);
@ -108,28 +108,28 @@ inline void Renderbuffer::createIfNotAlready() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string Renderbuffer::label() { std::string Renderbuffer::label() {
createIfNotAlready(); createIfNotAlready();
return Context::current().state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); return Context::current().state().debug.getLabelImplementation(GL_RENDERBUFFER, _id);
} }
Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayView<const char> label) { Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
Context::current().state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); Context::current().state().debug.labelImplementation(GL_RENDERBUFFER, _id, label);
return *this; return *this;
} }
#endif #endif
void Renderbuffer::setStorage(const RenderbufferFormat internalFormat, const Vector2i& size) { void Renderbuffer::setStorage(const RenderbufferFormat internalFormat, const Vector2i& size) {
(this->*Context::current().state().framebuffer->renderbufferStorageImplementation)(internalFormat, size); (this->*Context::current().state().framebuffer.renderbufferStorageImplementation)(internalFormat, size);
} }
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void Renderbuffer::setStorageMultisample(const Int samples, const RenderbufferFormat internalFormat, const Vector2i& size) { void Renderbuffer::setStorageMultisample(const Int samples, const RenderbufferFormat internalFormat, const Vector2i& size) {
(this->*Context::current().state().framebuffer->renderbufferStorageMultisampleImplementation)(samples, internalFormat, size); (this->*Context::current().state().framebuffer.renderbufferStorageMultisampleImplementation)(samples, internalFormat, size);
} }
#endif #endif
void Renderbuffer::bind() { void Renderbuffer::bind() {
GLuint& binding = Context::current().state().framebuffer->renderbufferBinding; GLuint& binding = Context::current().state().framebuffer.renderbufferBinding;
if(binding == _id) return; if(binding == _id) return;

34
src/Magnum/GL/Renderer.cpp

@ -36,7 +36,7 @@
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
Range1D Renderer::lineWidthRange() { Range1D Renderer::lineWidthRange() {
auto& state = *Context::current().state().renderer; Implementation::RendererState& state = Context::current().state().renderer;
Range1D& value = state.lineWidthRange; Range1D& value = state.lineWidthRange;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
@ -74,11 +74,11 @@ void Renderer::setFeature(const Feature feature, const bool enabled) {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void Renderer::enable(const Feature feature, const UnsignedInt drawBuffer) { void Renderer::enable(const Feature feature, const UnsignedInt drawBuffer) {
Context::current().state().renderer->enableiImplementation(GLenum(feature), drawBuffer); Context::current().state().renderer.enableiImplementation(GLenum(feature), drawBuffer);
} }
void Renderer::disable(const Feature feature, const UnsignedInt drawBuffer) { void Renderer::disable(const Feature feature, const UnsignedInt drawBuffer) {
Context::current().state().renderer->disableiImplementation(GLenum(feature), drawBuffer); Context::current().state().renderer.disableiImplementation(GLenum(feature), drawBuffer);
} }
void Renderer::setFeature(const Feature feature, const UnsignedInt drawBuffer, const bool enabled) { void Renderer::setFeature(const Feature feature, const UnsignedInt drawBuffer, const bool enabled) {
@ -101,7 +101,7 @@ void Renderer::setClearDepth(const Double depth) {
#endif #endif
void Renderer::setClearDepth(Float depth) { void Renderer::setClearDepth(Float depth) {
Context::current().state().renderer->clearDepthfImplementation(depth); Context::current().state().renderer.clearDepthfImplementation(depth);
} }
void Renderer::setClearStencil(const Int stencil) { void Renderer::setClearStencil(const Int stencil) {
@ -149,7 +149,7 @@ void Renderer::setPointSize(const Float size) {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void Renderer::setMinSampleShading(const Float value) { void Renderer::setMinSampleShading(const Float value) {
(Context::current().state().renderer->minSampleShadingImplementation)(value); (Context::current().state().renderer.minSampleShadingImplementation)(value);
} }
void Renderer::minSampleShadingImplementationDefault(const GLfloat value) { void Renderer::minSampleShadingImplementationDefault(const GLfloat value) {
@ -173,7 +173,7 @@ UnsignedInt Renderer::maxPatchVertexCount() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().renderer->maxPatchVertexCount; GLint& value = Context::current().state().renderer.maxPatchVertexCount;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -183,7 +183,7 @@ UnsignedInt Renderer::maxPatchVertexCount() {
} }
void Renderer::setPatchVertexCount(UnsignedInt count) { void Renderer::setPatchVertexCount(UnsignedInt count) {
Context::current().state().renderer->patchParameteriImplementation(GL_PATCH_VERTICES, count); Context::current().state().renderer.patchParameteriImplementation(GL_PATCH_VERTICES, count);
} }
#endif #endif
@ -210,7 +210,7 @@ UnsignedInt Renderer::maxClipDistances() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().renderer->maxClipDistances; GLint& value = Context::current().state().renderer.maxClipDistances;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -238,7 +238,7 @@ UnsignedInt Renderer::maxCullDistances() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().renderer->maxCullDistances; GLint& value = Context::current().state().renderer.maxCullDistances;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -262,7 +262,7 @@ UnsignedInt Renderer::maxCombinedClipAndCullDistances() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().renderer->maxCombinedClipAndCullDistances; GLint& value = Context::current().state().renderer.maxCombinedClipAndCullDistances;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -308,7 +308,7 @@ void Renderer::setColorMask(const GLboolean allowRed, const GLboolean allowGreen
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void Renderer::setColorMask(const UnsignedInt drawBuffer, const GLboolean allowRed, const GLboolean allowGreen, const GLboolean allowBlue, const GLboolean allowAlpha) { void Renderer::setColorMask(const UnsignedInt drawBuffer, const GLboolean allowRed, const GLboolean allowGreen, const GLboolean allowBlue, const GLboolean allowAlpha) {
Context::current().state().renderer->colorMaskiImplementation(drawBuffer, allowRed, allowGreen, allowBlue, allowAlpha); Context::current().state().renderer.colorMaskiImplementation(drawBuffer, allowRed, allowGreen, allowBlue, allowAlpha);
} }
#endif #endif
@ -342,19 +342,19 @@ void Renderer::setBlendFunction(const BlendFunction sourceRgb, const BlendFuncti
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void Renderer::setBlendEquation(const UnsignedInt drawBuffer, const BlendEquation equation) { void Renderer::setBlendEquation(const UnsignedInt drawBuffer, const BlendEquation equation) {
Context::current().state().renderer->blendEquationiImplementation(drawBuffer, GLenum(equation)); Context::current().state().renderer.blendEquationiImplementation(drawBuffer, GLenum(equation));
} }
void Renderer::setBlendEquation(const UnsignedInt drawBuffer, const BlendEquation rgb, const BlendEquation alpha) { void Renderer::setBlendEquation(const UnsignedInt drawBuffer, const BlendEquation rgb, const BlendEquation alpha) {
Context::current().state().renderer->blendEquationSeparateiImplementation(drawBuffer, GLenum(rgb), GLenum(alpha)); Context::current().state().renderer.blendEquationSeparateiImplementation(drawBuffer, GLenum(rgb), GLenum(alpha));
} }
void Renderer::setBlendFunction(const UnsignedInt drawBuffer, const BlendFunction source, const BlendFunction destination) { void Renderer::setBlendFunction(const UnsignedInt drawBuffer, const BlendFunction source, const BlendFunction destination) {
Context::current().state().renderer->blendFunciImplementation(drawBuffer, GLenum(source), GLenum(destination)); Context::current().state().renderer.blendFunciImplementation(drawBuffer, GLenum(source), GLenum(destination));
} }
void Renderer::setBlendFunction(const UnsignedInt drawBuffer, const BlendFunction sourceRgb, const BlendFunction destinationRgb, const BlendFunction sourceAlpha, const BlendFunction destinationAlpha) { void Renderer::setBlendFunction(const UnsignedInt drawBuffer, const BlendFunction sourceRgb, const BlendFunction destinationRgb, const BlendFunction sourceAlpha, const BlendFunction destinationAlpha) {
Context::current().state().renderer->blendFuncSeparateiImplementation(drawBuffer, GLenum(sourceRgb), GLenum(destinationRgb), GLenum(sourceAlpha), GLenum(destinationAlpha)); Context::current().state().renderer.blendFuncSeparateiImplementation(drawBuffer, GLenum(sourceRgb), GLenum(destinationRgb), GLenum(sourceAlpha), GLenum(destinationAlpha));
} }
#endif #endif
@ -388,7 +388,7 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() {
#endif #endif
return ResetNotificationStrategy::NoResetNotification; return ResetNotificationStrategy::NoResetNotification;
ResetNotificationStrategy& strategy = Context::current().state().renderer->resetNotificationStrategy; ResetNotificationStrategy& strategy = Context::current().state().renderer.resetNotificationStrategy;
if(strategy == ResetNotificationStrategy()) { if(strategy == ResetNotificationStrategy()) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -402,7 +402,7 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() {
} }
Renderer::GraphicsResetStatus Renderer::graphicsResetStatus() { Renderer::GraphicsResetStatus Renderer::graphicsResetStatus() {
return Context::current().state().renderer->graphicsResetStatusImplementation(); return Context::current().state().renderer.graphicsResetStatusImplementation();
} }
#endif #endif

2
src/Magnum/GL/Sampler.cpp

@ -107,7 +107,7 @@ SamplerWrapping samplerWrapping(const Magnum::SamplerWrapping wrapping) {
} }
Float Sampler::maxMaxAnisotropy() { Float Sampler::maxMaxAnisotropy() {
GLfloat& value = Context::current().state().texture->maxMaxAnisotropy; GLfloat& value = Context::current().state().texture.maxMaxAnisotropy;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0.0f) { if(value == 0.0f) {

60
src/Magnum/GL/Shader.cpp

@ -113,7 +113,7 @@ constexpr bool isTypeSupported(Shader::Type) { return true; }
} }
Int Shader::maxVertexOutputComponents() { Int Shader::maxVertexOutputComponents() {
GLint& value = Context::current().state().shader->maxVertexOutputComponents; GLint& value = Context::current().state().shader.maxVertexOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) { if(value == 0) {
@ -143,7 +143,7 @@ Int Shader::maxTessellationControlInputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxTessellationControlInputComponents; GLint& value = Context::current().state().shader.maxTessellationControlInputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -161,7 +161,7 @@ Int Shader::maxTessellationControlOutputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxTessellationControlOutputComponents; GLint& value = Context::current().state().shader.maxTessellationControlOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -179,7 +179,7 @@ Int Shader::maxTessellationControlTotalOutputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxTessellationControlTotalOutputComponents; GLint& value = Context::current().state().shader.maxTessellationControlTotalOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -197,7 +197,7 @@ Int Shader::maxTessellationEvaluationInputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxTessellationEvaluationInputComponents; GLint& value = Context::current().state().shader.maxTessellationEvaluationInputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -215,7 +215,7 @@ Int Shader::maxTessellationEvaluationOutputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxTessellationEvaluationOutputComponents; GLint& value = Context::current().state().shader.maxTessellationEvaluationOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -233,7 +233,7 @@ Int Shader::maxGeometryInputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxGeometryInputComponents; GLint& value = Context::current().state().shader.maxGeometryInputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
/** @todo The extension has only `GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB`, this is supported since GL 3.2 (wtf?) */ /** @todo The extension has only `GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB`, this is supported since GL 3.2 (wtf?) */
@ -252,7 +252,7 @@ Int Shader::maxGeometryOutputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxGeometryOutputComponents; GLint& value = Context::current().state().shader.maxGeometryOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
/** @todo The extension has only `GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB`, this is supported since GL 3.2 (wtf?) */ /** @todo The extension has only `GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB`, this is supported since GL 3.2 (wtf?) */
@ -271,7 +271,7 @@ Int Shader::maxGeometryTotalOutputComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxGeometryTotalOutputComponents; GLint& value = Context::current().state().shader.maxGeometryTotalOutputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -282,7 +282,7 @@ Int Shader::maxGeometryTotalOutputComponents() {
#endif #endif
Int Shader::maxFragmentInputComponents() { Int Shader::maxFragmentInputComponents() {
GLint& value = Context::current().state().shader->maxFragmentInputComponents; GLint& value = Context::current().state().shader.maxFragmentInputComponents;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) { if(value == 0) {
@ -316,7 +316,7 @@ Int Shader::maxAtomicCounterBuffers(const Type type) {
} }
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxAtomicCounterBuffers[index]; GLint& value = Context::current().state().shader.maxAtomicCounterBuffers[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -341,7 +341,7 @@ Int Shader::maxCombinedAtomicCounterBuffers() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shader->maxCombinedAtomicCounterBuffers; GLint& value = Context::current().state().shader.maxCombinedAtomicCounterBuffers;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -363,7 +363,7 @@ Int Shader::maxAtomicCounters(const Type type) {
} }
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxAtomicCounters[index]; GLint& value = Context::current().state().shader.maxAtomicCounters[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -388,7 +388,7 @@ Int Shader::maxCombinedAtomicCounters() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shader->maxCombinedAtomicCounters; GLint& value = Context::current().state().shader.maxCombinedAtomicCounters;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -410,7 +410,7 @@ Int Shader::maxImageUniforms(const Type type) {
} }
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxImageUniforms[index]; GLint& value = Context::current().state().shader.maxImageUniforms[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -435,7 +435,7 @@ Int Shader::maxCombinedImageUniforms() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shader->maxCombinedImageUniforms; GLint& value = Context::current().state().shader.maxCombinedImageUniforms;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -457,7 +457,7 @@ Int Shader::maxShaderStorageBlocks(const Type type) {
} }
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxShaderStorageBlocks[index]; GLint& value = Context::current().state().shader.maxShaderStorageBlocks[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -482,7 +482,7 @@ Int Shader::maxCombinedShaderStorageBlocks() {
#endif #endif
return 0; return 0;
GLint& value = Context::current().state().shader->maxCombinedShaderStorageBlocks; GLint& value = Context::current().state().shader.maxCombinedShaderStorageBlocks;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -497,7 +497,7 @@ Int Shader::maxTextureImageUnits(const Type type) {
return 0; return 0;
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxTextureImageUnits[index]; GLint& value = Context::current().state().shader.maxTextureImageUnits[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -517,7 +517,7 @@ Int Shader::maxTextureImageUnits(const Type type) {
} }
Int Shader::maxCombinedTextureImageUnits() { Int Shader::maxCombinedTextureImageUnits() {
GLint& value = Context::current().state().shader->maxTextureImageUnitsCombined; GLint& value = Context::current().state().shader.maxTextureImageUnitsCombined;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -536,7 +536,7 @@ Int Shader::maxUniformBlocks(const Type type) {
return 0; return 0;
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxUniformBlocks[index]; GLint& value = Context::current().state().shader.maxUniformBlocks[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -561,7 +561,7 @@ Int Shader::maxCombinedUniformBlocks() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().shader->maxCombinedUniformBlocks; GLint& value = Context::current().state().shader.maxCombinedUniformBlocks;
/* Get the value, if not already cached */ /* Get the value, if not already cached */
if(value == 0) if(value == 0)
@ -576,7 +576,7 @@ Int Shader::maxUniformComponents(const Type type) {
return 0; return 0;
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxUniformComponents[index]; GLint& value = Context::current().state().shader.maxUniformComponents[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -618,7 +618,7 @@ Int Shader::maxCombinedUniformComponents(const Type type) {
return 0; return 0;
const UnsignedInt index = typeToIndex(type); const UnsignedInt index = typeToIndex(type);
GLint& value = Context::current().state().shader->maxCombinedUniformComponents[index]; GLint& value = Context::current().state().shader.maxCombinedUniformComponents[index];
/* Get the value, if not already cached */ /* Get the value, if not already cached */
constexpr static GLenum what[] = { constexpr static GLenum what[] = {
@ -681,17 +681,17 @@ Shader::~Shader() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string Shader::label() const { std::string Shader::label() const {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug->getLabelImplementation(GL_SHADER, _id); return Context::current().state().debug.getLabelImplementation(GL_SHADER, _id);
#else #else
return Context::current().state().debug->getLabelImplementation(GL_SHADER_KHR, _id); return Context::current().state().debug.getLabelImplementation(GL_SHADER_KHR, _id);
#endif #endif
} }
Shader& Shader::setLabelInternal(const Containers::ArrayView<const char> label) { Shader& Shader::setLabelInternal(const Containers::ArrayView<const char> label) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug->labelImplementation(GL_SHADER, _id, label); Context::current().state().debug.labelImplementation(GL_SHADER, _id, label);
#else #else
Context::current().state().debug->labelImplementation(GL_SHADER_KHR, _id, label); Context::current().state().debug.labelImplementation(GL_SHADER_KHR, _id, label);
#endif #endif
return *this; return *this;
} }
@ -701,7 +701,7 @@ std::vector<std::string> Shader::sources() const { return _sources; }
Shader& Shader::addSource(std::string source) { Shader& Shader::addSource(std::string source) {
if(!source.empty()) { if(!source.empty()) {
auto addSource = Context::current().state().shader->addSourceImplementation; auto addSource = Context::current().state().shader.addSourceImplementation;
/* Fix line numbers, so line 41 of third added file is marked as 3(41) /* Fix line numbers, so line 41 of third added file is marked as 3(41)
in case shader version was not Version::None, because then source 0 in case shader version was not Version::None, because then source 0
@ -789,7 +789,7 @@ bool Shader::compile(std::initializer_list<Containers::Reference<Shader>> shader
/* Some drivers are chatty and can't keep shut when there's nothing to /* Some drivers are chatty and can't keep shut when there's nothing to
be said, handle that as well. */ be said, handle that as well. */
Context::current().state().shader->cleanLogImplementation(message); Context::current().state().shader.cleanLogImplementation(message);
/* Show error log */ /* Show error log */
if(!success) { if(!success) {

28
src/Magnum/GL/TransformFeedback.cpp

@ -47,7 +47,7 @@ Int TransformFeedback::maxInterleavedComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().transformFeedback->maxInterleavedComponents; GLint& value = Context::current().state().transformFeedback.maxInterleavedComponents;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &value); glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &value);
@ -61,7 +61,7 @@ Int TransformFeedback::maxSeparateAttributes() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().transformFeedback->maxSeparateAttributes; GLint& value = Context::current().state().transformFeedback.maxSeparateAttributes;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &value); glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &value);
@ -75,7 +75,7 @@ Int TransformFeedback::maxSeparateComponents() {
return 0; return 0;
#endif #endif
GLint& value = Context::current().state().transformFeedback->maxSeparateComponents; GLint& value = Context::current().state().transformFeedback.maxSeparateComponents;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, &value); glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, &value);
@ -88,7 +88,7 @@ Int TransformFeedback::maxBuffers() {
if(!Context::current().isExtensionSupported<Extensions::ARB::transform_feedback3>()) if(!Context::current().isExtensionSupported<Extensions::ARB::transform_feedback3>())
return maxSeparateAttributes(); return maxSeparateAttributes();
GLint& value = Context::current().state().transformFeedback->maxBuffers; GLint& value = Context::current().state().transformFeedback.maxBuffers;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &value); glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &value);
@ -100,7 +100,7 @@ Int TransformFeedback::maxVertexStreams() {
if(!Context::current().isExtensionSupported<Extensions::ARB::transform_feedback3>()) if(!Context::current().isExtensionSupported<Extensions::ARB::transform_feedback3>())
return 1; return 1;
GLint& value = Context::current().state().transformFeedback->maxVertexStreams; GLint& value = Context::current().state().transformFeedback.maxVertexStreams;
if(value == 0) if(value == 0)
glGetIntegerv(GL_MAX_VERTEX_STREAMS, &value); glGetIntegerv(GL_MAX_VERTEX_STREAMS, &value);
@ -110,7 +110,7 @@ Int TransformFeedback::maxVertexStreams() {
#endif #endif
TransformFeedback::TransformFeedback(): _flags{ObjectFlag::DeleteOnDestruction} { TransformFeedback::TransformFeedback(): _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().transformFeedback->createImplementation)(); (this->*Context::current().state().transformFeedback.createImplementation)();
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
@ -130,14 +130,14 @@ TransformFeedback::~TransformFeedback() {
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
GLuint& binding = Context::current().state().transformFeedback->binding; GLuint& binding = Context::current().state().transformFeedback.binding;
if(binding == _id) binding = 0; if(binding == _id) binding = 0;
glDeleteTransformFeedbacks(1, &_id); glDeleteTransformFeedbacks(1, &_id);
} }
void TransformFeedback::bindInternal() { void TransformFeedback::bindInternal() {
GLuint& bound = Context::current().state().transformFeedback->binding; GLuint& bound = Context::current().state().transformFeedback.binding;
/* Already bound, nothing to do */ /* Already bound, nothing to do */
if(bound == _id) return; if(bound == _id) return;
@ -162,23 +162,23 @@ inline void TransformFeedback::createIfNotAlready() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
std::string TransformFeedback::label() { std::string TransformFeedback::label() {
createIfNotAlready(); createIfNotAlready();
return Context::current().state().debug->getLabelImplementation(GL_TRANSFORM_FEEDBACK, _id); return Context::current().state().debug.getLabelImplementation(GL_TRANSFORM_FEEDBACK, _id);
} }
TransformFeedback& TransformFeedback::setLabelInternal(const Containers::ArrayView<const char> label) { TransformFeedback& TransformFeedback::setLabelInternal(const Containers::ArrayView<const char> label) {
createIfNotAlready(); createIfNotAlready();
Context::current().state().debug->labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); Context::current().state().debug.labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label);
return *this; return *this;
} }
#endif #endif
TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) {
(this->*Context::current().state().transformFeedback->attachRangeImplementation)(index, buffer, offset, size); (this->*Context::current().state().transformFeedback.attachRangeImplementation)(index, buffer, offset, size);
return *this; return *this;
} }
TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer) { TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer) {
(this->*Context::current().state().transformFeedback->attachBaseImplementation)(index, buffer); (this->*Context::current().state().transformFeedback.attachBaseImplementation)(index, buffer);
return *this; return *this;
} }
@ -206,13 +206,13 @@ void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buff
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) { TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
(this->*Context::current().state().transformFeedback->attachRangesImplementation)(firstIndex, buffers); (this->*Context::current().state().transformFeedback.attachRangesImplementation)(firstIndex, buffers);
return *this; return *this;
} }
/** @todoc const std::initializer_list makes Doxygen grumpy */ /** @todoc const std::initializer_list makes Doxygen grumpy */
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) { TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
(this->*Context::current().state().transformFeedback->attachBasesImplementation)(firstIndex, buffers); (this->*Context::current().state().transformFeedback.attachBasesImplementation)(firstIndex, buffers);
return *this; return *this;
} }

Loading…
Cancel
Save