From 532d72e1aaa4b8b86f62d97c2be4aa91c6e1a015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 26 Feb 2021 17:23:52 +0100 Subject: [PATCH] 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. --- src/Magnum/GL/AbstractFramebuffer.cpp | 58 ++-- src/Magnum/GL/AbstractObject.cpp | 2 +- src/Magnum/GL/AbstractQuery.cpp | 10 +- src/Magnum/GL/AbstractShaderProgram.cpp | 116 ++++---- src/Magnum/GL/AbstractTexture.cpp | 250 +++++++++--------- src/Magnum/GL/Buffer.cpp | 68 ++--- src/Magnum/GL/BufferTexture.cpp | 12 +- src/Magnum/GL/Context.cpp | 30 ++- src/Magnum/GL/Context.h | 5 +- src/Magnum/GL/CubeMapTexture.cpp | 114 ++++---- src/Magnum/GL/DebugOutput.cpp | 32 +-- src/Magnum/GL/DefaultFramebuffer.cpp | 22 +- src/Magnum/GL/Framebuffer.cpp | 66 ++--- src/Magnum/GL/Implementation/State.cpp | 84 +++++- src/Magnum/GL/Implementation/State.h | 33 +-- .../GL/Implementation/maxTextureSize.cpp | 8 +- src/Magnum/GL/Mesh.cpp | 50 ++-- src/Magnum/GL/MeshView.cpp | 2 +- src/Magnum/GL/RectangleTexture.cpp | 2 +- src/Magnum/GL/Renderbuffer.cpp | 18 +- src/Magnum/GL/Renderer.cpp | 34 +-- src/Magnum/GL/Sampler.cpp | 2 +- src/Magnum/GL/Shader.cpp | 60 ++--- src/Magnum/GL/TransformFeedback.cpp | 28 +- 24 files changed, 583 insertions(+), 523 deletions(-) diff --git a/src/Magnum/GL/AbstractFramebuffer.cpp b/src/Magnum/GL/AbstractFramebuffer.cpp index 659a75881..868f10dc7 100644 --- a/src/Magnum/GL/AbstractFramebuffer.cpp +++ b/src/Magnum/GL/AbstractFramebuffer.cpp @@ -51,7 +51,7 @@ namespace Magnum { namespace GL { Vector2i AbstractFramebuffer::maxViewportSize() { - Vector2i& value = Context::current().state().framebuffer->maxViewportSize; + Vector2i& value = Context::current().state().framebuffer.maxViewportSize; /* Get the value, if not already cached */ if(value == Vector2i()) @@ -72,7 +72,7 @@ Int AbstractFramebuffer::maxDrawBuffers() { #endif #endif - GLint& value = Context::current().state().framebuffer->maxDrawBuffers; + GLint& value = Context::current().state().framebuffer.maxDrawBuffers; /* Get the value, if not already cached */ if(value == 0) { @@ -91,7 +91,7 @@ Int AbstractFramebuffer::maxDualSourceDrawBuffers() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().framebuffer->maxDualSourceDrawBuffers; + GLint& value = Context::current().state().framebuffer.maxDualSourceDrawBuffers; /* Get the value, if not already cached */ if(value == 0) @@ -124,13 +124,13 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) { static_cast(target); bindImplementationSingle(); #else - (this->*Context::current().state().framebuffer->bindImplementation)(target); + (this->*Context::current().state().framebuffer.bindImplementation)(target); #endif } #ifdef MAGNUM_TARGET_GLES2 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); if(state.readBinding == _id) return; @@ -146,7 +146,7 @@ void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) { inline #endif void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) { - Implementation::FramebufferState& state = *Context::current().state().framebuffer; + Implementation::FramebufferState& state = Context::current().state().framebuffer; if(target == FramebufferTarget::Read) { if(state.readBinding == _id) return; @@ -167,13 +167,13 @@ FramebufferTarget AbstractFramebuffer::bindInternal() { #elif defined(MAGNUM_TARGET_WEBGL) return bindImplementationSingle(); #else - return (this->*Context::current().state().framebuffer->bindInternalImplementation)(); + return (this->*Context::current().state().framebuffer.bindInternalImplementation)(); #endif } #ifdef MAGNUM_TARGET_GLES2 FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { - Implementation::FramebufferState& state = *Context::current().state().framebuffer; + Implementation::FramebufferState& state = Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); /* Bind the framebuffer, if not already */ @@ -197,7 +197,7 @@ FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { inline #endif 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 */ if(state.readBinding == _id) @@ -215,11 +215,11 @@ FramebufferTarget AbstractFramebuffer::bindImplementationDefault() { } 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() { - 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) { @@ -254,7 +254,7 @@ GLenum AbstractFramebuffer::implementationColorReadFormatTypeImplementationFrame #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) { - Context::current().state().framebuffer->blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter); + Context::current().state().framebuffer.blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter); } #endif @@ -290,14 +290,14 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle) _viewport = rectangle; /* Update the viewport if the framebuffer is currently bound */ - if(Context::current().state().framebuffer->drawBinding == _id) + if(Context::current().state().framebuffer.drawBinding == _id) setViewportInternal(); return *this; } 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(state.drawBinding == _id); @@ -320,17 +320,17 @@ AbstractFramebuffer& AbstractFramebuffer::clear(const FramebufferClearMask mask) #ifndef MAGNUM_TARGET_GLES2 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; } 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; } 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; } #endif @@ -345,8 +345,8 @@ void AbstractFramebuffer::read(const Range2Di& rectangle, const MutableImageView #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelPack); #endif - 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().renderer.applyPixelStoragePack(image.storage()); + (Context::current().state().framebuffer.readImplementation)(rectangle, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffsetFor(image, rectangle.size()) #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.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (Context::current().state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (Context::current().state().framebuffer.readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr); } 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) { CORRADE_ASSERT(rectangle.sizeY() == 1, "GL::AbstractFramebuffer::copyImage(): height must be 1 for 1D textures", ); bindInternal(FramebufferTarget::Read); - Context::current().state().framebuffer->copySub1DImplementation(rectangle, texture, level, offset); + Context::current().state().framebuffer.copySub1DImplementation(rectangle, texture, level, offset); } #endif void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2D& texture, const Int level, const Vector2i& offset) { 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 void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, RectangleTexture& texture, const Vector2i& offset) { 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 void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTexture& texture, const Int level, const Vector3i& offset) { 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)) void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture3D& texture, const Int level, const Vector3i& offset) { bindInternal(FramebufferTarget::Read); - Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); + Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture1DArray& texture, const Int level, const Vector2i& offset) { 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 #ifndef MAGNUM_TARGET_GLES2 void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, Texture2DArray& texture, const Int level, const Vector3i& offset) { bindInternal(FramebufferTarget::Read); - Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); + Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractFramebuffer::copySubImage(const Range2Di& rectangle, CubeMapTextureArray& texture, const Int level, const Vector3i& offset) { bindInternal(FramebufferTarget::Read); - Context::current().state().framebuffer->copySub3DImplementation(rectangle, texture, level, offset); + Context::current().state().framebuffer.copySub3DImplementation(rectangle, texture, level, offset); } #endif diff --git a/src/Magnum/GL/AbstractObject.cpp b/src/Magnum/GL/AbstractObject.cpp index 616e5eade..965246eee 100644 --- a/src/Magnum/GL/AbstractObject.cpp +++ b/src/Magnum/GL/AbstractObject.cpp @@ -110,7 +110,7 @@ Int AbstractObject::maxLabelLength() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().debug->maxLabelLength; + GLint& value = Context::current().state().debug.maxLabelLength; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/GL/AbstractQuery.cpp b/src/Magnum/GL/AbstractQuery.cpp index c0e596223..095ce0a7f 100644 --- a/src/Magnum/GL/AbstractQuery.cpp +++ b/src/Magnum/GL/AbstractQuery.cpp @@ -37,7 +37,7 @@ namespace Magnum { namespace GL { AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().query->createImplementation)(); + (this->*Context::current().state().query.createImplementation)(); } AbstractQuery::~AbstractQuery() { @@ -93,17 +93,17 @@ void AbstractQuery::createImplementationDSAExceptPipelineStats() { #ifndef MAGNUM_TARGET_WEBGL std::string AbstractQuery::label() const { #ifndef MAGNUM_TARGET_GLES2 - return Context::current().state().debug->getLabelImplementation(GL_QUERY, _id); + return Context::current().state().debug.getLabelImplementation(GL_QUERY, _id); #else - return Context::current().state().debug->getLabelImplementation(GL_QUERY_KHR, _id); + return Context::current().state().debug.getLabelImplementation(GL_QUERY_KHR, _id); #endif } AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES2 - Context::current().state().debug->labelImplementation(GL_QUERY, _id, label); + Context::current().state().debug.labelImplementation(GL_QUERY, _id, label); #else - Context::current().state().debug->labelImplementation(GL_QUERY_KHR, _id, label); + Context::current().state().debug.labelImplementation(GL_QUERY_KHR, _id, label); #endif return *this; } diff --git a/src/Magnum/GL/AbstractShaderProgram.cpp b/src/Magnum/GL/AbstractShaderProgram.cpp index 065fc7dad..44ab50947 100644 --- a/src/Magnum/GL/AbstractShaderProgram.cpp +++ b/src/Magnum/GL/AbstractShaderProgram.cpp @@ -47,7 +47,7 @@ namespace Magnum { namespace GL { Int AbstractShaderProgram::maxVertexAttributes() { - GLint& value = Context::current().state().shaderProgram->maxVertexAttributes; + GLint& value = Context::current().state().shaderProgram.maxVertexAttributes; /* Get the value, if not already cached */ if(value == 0) @@ -66,7 +66,7 @@ Int AbstractShaderProgram::maxGeometryOutputVertices() { return 0; #endif - GLint& value = Context::current().state().shaderProgram->maxGeometryOutputVertices; + GLint& value = Context::current().state().shaderProgram.maxGeometryOutputVertices; if(value == 0) glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &value); @@ -82,7 +82,7 @@ Int AbstractShaderProgram::maxAtomicCounterBufferSize() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxAtomicCounterBufferSize; + GLint& value = Context::current().state().shaderProgram.maxAtomicCounterBufferSize; if(value == 0) glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &value); @@ -98,7 +98,7 @@ Int AbstractShaderProgram::maxComputeSharedMemorySize() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxComputeSharedMemorySize; + GLint& value = Context::current().state().shaderProgram.maxComputeSharedMemorySize; if(value == 0) glGetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &value); @@ -114,7 +114,7 @@ Int AbstractShaderProgram::maxComputeWorkGroupInvocations() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxComputeWorkGroupInvocations; + GLint& value = Context::current().state().shaderProgram.maxComputeWorkGroupInvocations; if(value == 0) glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &value); @@ -130,7 +130,7 @@ Vector3i AbstractShaderProgram::maxComputeWorkGroupCount() { #endif return {}; - Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupCount; + Vector3i& value = Context::current().state().shaderProgram.maxComputeWorkGroupCount; if(value.isZero()) { glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &value.x()); @@ -149,7 +149,7 @@ Vector3i AbstractShaderProgram::maxComputeWorkGroupSize() { #endif return {}; - Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupSize; + Vector3i& value = Context::current().state().shaderProgram.maxComputeWorkGroupSize; if(value.isZero()) { glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &value.x()); @@ -168,7 +168,7 @@ Int AbstractShaderProgram::maxImageUnits() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxImageUnits; + GLint& value = Context::current().state().shaderProgram.maxImageUnits; if(value == 0) glGetIntegerv(GL_MAX_IMAGE_UNITS, &value); @@ -182,7 +182,7 @@ Int AbstractShaderProgram::maxImageSamples() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().shaderProgram->maxImageSamples; + GLint& value = Context::current().state().shaderProgram.maxImageSamples; if(value == 0) glGetIntegerv(GL_MAX_IMAGE_SAMPLES, &value); @@ -201,7 +201,7 @@ Int AbstractShaderProgram::maxCombinedShaderOutputResources() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxCombinedShaderOutputResources; + GLint& value = Context::current().state().shaderProgram.maxCombinedShaderOutputResources; if(value == 0) glGetIntegerv(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES, &value); @@ -217,7 +217,7 @@ Long AbstractShaderProgram::maxShaderStorageBlockSize() { #endif return 0; - GLint64& value = Context::current().state().shaderProgram->maxShaderStorageBlockSize; + GLint64& value = Context::current().state().shaderProgram.maxShaderStorageBlockSize; if(value == 0) glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &value); @@ -232,7 +232,7 @@ Int AbstractShaderProgram::maxUniformBlockSize() { return 0; #endif - GLint& value = Context::current().state().shaderProgram->maxUniformBlockSize; + GLint& value = Context::current().state().shaderProgram.maxUniformBlockSize; if(value == 0) glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &value); @@ -249,7 +249,7 @@ Int AbstractShaderProgram::maxUniformLocations() { #endif return 0; - GLint& value = Context::current().state().shaderProgram->maxUniformLocations; + GLint& value = Context::current().state().shaderProgram.maxUniformLocations; if(value == 0) glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &value); @@ -264,7 +264,7 @@ Int AbstractShaderProgram::minTexelOffset() { return 0; #endif - GLint& value = Context::current().state().shaderProgram->minTexelOffset; + GLint& value = Context::current().state().shaderProgram.minTexelOffset; if(value == 0) glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &value); @@ -278,7 +278,7 @@ Int AbstractShaderProgram::maxTexelOffset() { return 0; #endif - GLint& value = Context::current().state().shaderProgram->maxTexelOffset; + GLint& value = Context::current().state().shaderProgram.maxTexelOffset; if(value == 0) glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &value); @@ -301,7 +301,7 @@ AbstractShaderProgram::~AbstractShaderProgram() { if(!_id) return; /* 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; glDeleteProgram(_id); @@ -316,17 +316,17 @@ AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& #ifndef MAGNUM_TARGET_WEBGL std::string AbstractShaderProgram::label() const { #ifndef MAGNUM_TARGET_GLES2 - return Context::current().state().debug->getLabelImplementation(GL_PROGRAM, _id); + return Context::current().state().debug.getLabelImplementation(GL_PROGRAM, _id); #else - return Context::current().state().debug->getLabelImplementation(GL_PROGRAM_KHR, _id); + return Context::current().state().debug.getLabelImplementation(GL_PROGRAM_KHR, _id); #endif } AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES2 - Context::current().state().debug->labelImplementation(GL_PROGRAM, _id, label); + Context::current().state().debug.labelImplementation(GL_PROGRAM, _id, label); #else - Context::current().state().debug->labelImplementation(GL_PROGRAM_KHR, _id, label); + Context::current().state().debug.labelImplementation(GL_PROGRAM_KHR, _id, label); #endif return *this; } @@ -394,7 +394,7 @@ void AbstractShaderProgram::draw(Containers::ArrayViewmultiDrawImplementation(meshes); + Context::current().state().mesh.multiDrawImplementation(meshes); #endif } @@ -429,7 +429,7 @@ void AbstractShaderProgram::dispatchCompute(const Vector3ui& workgroupCount) { void AbstractShaderProgram::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); } @@ -456,7 +456,7 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const Unsign #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list 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 outputs, const TransformFeedbackBufferMode bufferMode) { @@ -507,7 +507,7 @@ bool AbstractShaderProgram::link(std::initializer_listcleanLogImplementation(message); + Context::current().state().shaderProgram.cleanLogImplementation(message); /* Show error log */ if(!success) { @@ -563,7 +563,7 @@ UnsignedInt AbstractShaderProgram::uniformBlockIndexInternal(const Containers::A #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView 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) { @@ -584,7 +584,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -605,7 +605,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -626,7 +626,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -647,7 +647,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView 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) { @@ -668,7 +668,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -689,7 +689,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -710,7 +710,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -732,7 +732,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView 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) { @@ -753,7 +753,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -774,7 +774,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -795,7 +795,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -818,7 +818,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView 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) { @@ -831,7 +831,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -844,7 +844,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -857,7 +857,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -871,7 +871,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -892,7 +892,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -913,7 +913,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -935,7 +935,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -956,7 +956,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -977,7 +977,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -998,7 +998,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1019,7 +1019,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1040,7 +1040,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1063,7 +1063,7 @@ void AbstractShaderProgram::uniformImplementationSSOEXT(const GLint location, co #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1076,7 +1076,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1089,7 +1089,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1102,7 +1102,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1115,7 +1115,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1128,7 +1128,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1141,7 +1141,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1154,7 +1154,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { @@ -1167,7 +1167,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> 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) { diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 29cdd3dd9..4efa513ae 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -51,7 +51,7 @@ namespace Magnum { namespace GL { #ifndef MAGNUM_TARGET_GLES2 Float AbstractTexture::maxLodBias() { - GLfloat& value = Context::current().state().texture->maxLodBias; + GLfloat& value = Context::current().state().texture.maxLodBias; /* Get the value, if not already cached */ if(value == 0.0f) @@ -70,7 +70,7 @@ Int AbstractTexture::maxColorSamples() { #endif return 0; - GLint& value = Context::current().state().texture->maxColorSamples; + GLint& value = Context::current().state().texture.maxColorSamples; /* Get the value, if not already cached */ if(value == 0) @@ -87,7 +87,7 @@ Int AbstractTexture::maxDepthSamples() { #endif return 0; - GLint& value = Context::current().state().texture->maxDepthSamples; + GLint& value = Context::current().state().texture.maxDepthSamples; /* Get the value, if not already cached */ if(value == 0) @@ -104,7 +104,7 @@ Int AbstractTexture::maxIntegerSamples() { #endif return 0; - GLint& value = Context::current().state().texture->maxIntegerSamples; + GLint& value = Context::current().state().texture.maxIntegerSamples; /* Get the value, if not already cached */ if(value == 0) @@ -115,20 +115,20 @@ Int AbstractTexture::maxIntegerSamples() { #endif 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(textureState.bindings[textureUnit].second == 0) return; /* 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 operator=) */ textureState.bindings[textureUnit] = std::pair{}; } 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 */ if(textureState.currentTextureUnit != textureUnit) @@ -145,20 +145,20 @@ void AbstractTexture::unbindImplementationMulti(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); } #endif void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) { /* 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 */ void AbstractTexture::bind(const Int firstTextureUnit, Containers::ArrayView textures) { /* 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 textures) { @@ -169,7 +169,7 @@ void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, c #ifndef MAGNUM_TARGET_GLES /** @todoc const Containers::ArrayView makes Doxygen grumpy */ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayView 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 */ /** @todo VLAs */ @@ -196,7 +196,7 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Cont #ifndef MAGNUM_TARGET_GLES 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) { @@ -212,7 +212,7 @@ Int AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround(const G #endif 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); } @@ -232,7 +232,7 @@ AbstractTexture::~AbstractTexture() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* 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 */ /* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload of operator=) */ @@ -241,7 +241,7 @@ AbstractTexture::~AbstractTexture() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /* 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 */ if(std::get<0>(binding) == _id) binding = {}; } @@ -264,19 +264,19 @@ void AbstractTexture::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string AbstractTexture::label() { 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 label) { createIfNotAlready(); - Context::current().state().debug->labelImplementation(GL_TEXTURE, _id, label); + Context::current().state().debug.labelImplementation(GL_TEXTURE, _id, label); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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(std::get<0>(textureState.imageBindings[imageUnit]) == 0) return; @@ -289,7 +289,7 @@ void AbstractTexture::unbindImage(const Int imageUnit) { #ifndef MAGNUM_TARGET_GLES /** @todoc const Containers::ArrayView makes Doxygen grumpy */ void AbstractTexture::bindImages(const Int firstImageUnit, Containers::ArrayView 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 */ Containers::Array ids{textures ? textures.size() : 0}; @@ -318,7 +318,7 @@ void AbstractTexture::bindImages(const Int firstImageUnit, Containers::ArrayView #endif 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 state{_id, level, layered, layer, GLenum(access)}; /* 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 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(textureState.bindings[textureUnit].second == _id) return; @@ -342,7 +342,7 @@ void AbstractTexture::bind(Int 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 */ if(textureState.currentTextureUnit != textureUnit) @@ -375,20 +375,20 @@ void AbstractTexture::bindImplementationDSAIntelWindows(const GLint textureUnit) void AbstractTexture::bindImplementationAppleBufferTextureWorkaround(const GLint textureUnit) { bindImplementationDefault(textureUnit); if(_target == GL_TEXTURE_BUFFER) - Context::current().state().texture->bufferTextureBound.set(textureUnit, true); + Context::current().state().texture.bufferTextureBound.set(textureUnit, true); } #endif #endif #ifndef MAGNUM_TARGET_GLES2 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 #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setMaxLevel(Int level) { - (this->*Context::current().state().texture->parameteriImplementation)( + (this->*Context::current().state().texture.parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_MAX_LEVEL #else @@ -399,32 +399,32 @@ void AbstractTexture::setMaxLevel(Int level) { #endif 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) { - (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 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) { - (this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); + (this->*Context::current().state().texture.parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); } #endif #ifndef MAGNUM_TARGET_GLES 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 #ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setBorderColor(const Color4& color) { - (this->*Context::current().state().texture->parameterfvImplementation)( + (this->*Context::current().state().texture.parameterfvImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_BORDER_COLOR, #else @@ -435,22 +435,22 @@ void AbstractTexture::setBorderColor(const Color4& color) { #ifndef MAGNUM_TARGET_GLES2 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) { - (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 void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { - (this->*Context::current().state().texture->setMaxAnisotropyImplementation)(anisotropy); + (this->*Context::current().state().texture.setMaxAnisotropyImplementation)(anisotropy); } #ifndef MAGNUM_TARGET_WEBGL 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); } #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) { #ifndef MAGNUM_TARGET_GLES 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 - (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_B, b); - (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); + (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_B, b); + (this->*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); #endif } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setCompareMode(const SamplerCompareMode mode) { - (this->*Context::current().state().texture->parameteriImplementation)( + (this->*Context::current().state().texture.parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_MODE #else @@ -481,7 +481,7 @@ void AbstractTexture::setCompareMode(const SamplerCompareMode mode) { } void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) { - (this->*Context::current().state().texture->parameteriImplementation)( + (this->*Context::current().state().texture.parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_FUNC #else @@ -493,16 +493,16 @@ void AbstractTexture::setCompareFunction(const SamplerCompareFunction function) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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 void AbstractTexture::invalidateImage(const Int level) { - (this->*Context::current().state().texture->invalidateImageImplementation)(level); + (this->*Context::current().state().texture.invalidateImageImplementation)(level); } void AbstractTexture::generateMipmap() { - (this->*Context::current().state().texture->mipmapImplementation)(); + (this->*Context::current().state().texture.mipmapImplementation)(); } void AbstractTexture::mipmapImplementationDefault() { @@ -521,7 +521,7 @@ void AbstractTexture::bindInternal() { functions need to have the texture bound in *currently active* unit, 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(textureState.bindings[textureState.currentTextureUnit].second == _id) @@ -1281,7 +1281,7 @@ void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {} void AbstractTexture::setMaxAnisotropyImplementationArbOrExt(GLfloat anisotropy) { - (this->*Context::current().state().texture->parameterfImplementation)( + (this->*Context::current().state().texture.parameterfImplementation)( #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_MAX_ANISOTROPY #else @@ -1729,8 +1729,8 @@ template void AbstractTexture::image(GLint level, Image< data = Containers::Array{dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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); + 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); image = Image{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)}; } @@ -1748,8 +1748,8 @@ template void AbstractTexture::image(GLint level, const #endif Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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()); + 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()); } template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, const BasicMutableImageView<1>&); @@ -1767,8 +1767,8 @@ template void AbstractTexture::image(GLint level, Buffer image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); image.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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); @@ -1783,13 +1783,13 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { 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; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); /* Internal texture 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 */ Containers::Array data{image.release()}; @@ -1797,8 +1797,8 @@ template void AbstractTexture::compressedImage(const GLi data = Containers::Array{dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedImageImplementation)(level, data.size(), data); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (this->*Context::current().state().texture.getCompressedImageImplementation)(level, data.size(), data); image = CompressedImage{image.storage(), CompressedPixelFormat(format), size, std::move(data)}; } @@ -1820,7 +1820,7 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { 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; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); @@ -1829,15 +1829,15 @@ template void AbstractTexture::compressedImage(const GLi /* Internal texture 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), "GL::AbstractTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); #endif Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedImageImplementation)(level, image.data().size(), image.data()); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (this->*Context::current().state().texture.getCompressedImageImplementation)(level, image.data().size(), image.data()); } template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, const BasicMutableCompressedImageView<1>&); @@ -1852,13 +1852,13 @@ template void AbstractTexture::compressedImage(const GLi std::size_t dataSize; if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { 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; } else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); /* Internal texture 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 */ if(image.dataSize() < dataSize) @@ -1867,8 +1867,8 @@ template void AbstractTexture::compressedImage(const GLi image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedImageImplementation)(level, dataSize, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (this->*Context::current().state().texture.getCompressedImageImplementation)(level, dataSize, nullptr); } template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage); @@ -1904,7 +1904,7 @@ template void AbstractTexture::subImage(const GLint leve const Vector3i paddedSize = Vector3i::pad(size, 1); 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()); } @@ -1927,7 +1927,7 @@ template void AbstractTexture::subImage(const GLint leve image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); 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); } @@ -1956,7 +1956,7 @@ template void AbstractTexture::compressedSubImage(const /* Internal texture 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 doesn't tell us all properties about the compression, we need to ask GL @@ -1972,7 +1972,7 @@ template void AbstractTexture::compressedSubImage(const data = Containers::Array{dataSize}; 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); image = CompressedImage{CompressedPixelFormat(format), size, std::move(data)}; } @@ -1994,7 +1994,7 @@ template void AbstractTexture::compressedSubImage(const #ifndef CORRADE_NO_ASSERT /* Internal texture 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), "GL::AbstractTexture::compressedSubImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); @@ -2015,7 +2015,7 @@ template void AbstractTexture::compressedSubImage(const const Vector3i paddedSize = Vector3i::pad(size, 1); 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()); } @@ -2032,7 +2032,7 @@ template void AbstractTexture::compressedSubImage(const /* Internal texture 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 doesn't tell us all properties about the compression, we need to ask GL @@ -2049,7 +2049,7 @@ template void AbstractTexture::compressedSubImage(const image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); 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); } @@ -2083,14 +2083,14 @@ Vector3i AbstractTexture::DataHelper<3>::compressedBlockSize(const GLenum target #ifndef MAGNUM_TARGET_GLES Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) { 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; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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; (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) { - const Implementation::TextureState& state = *Context::current().state().texture; + const Implementation::TextureState& state = Context::current().state().texture; Vector3i value; (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 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 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)) 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 #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) { - (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) { - (texture.*Context::current().state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); + (texture.*Context::current().state().texture.storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); - 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()); + 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()); } void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); - 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())); + 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())); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); + (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) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - 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())); + 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())); } #endif @@ -2193,8 +2193,8 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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() + 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() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2205,7 +2205,7 @@ void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); 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()); } @@ -2213,14 +2213,14 @@ void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); 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 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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() + 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() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2242,21 +2242,21 @@ void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& text #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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())); + 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())); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, 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()); } void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - 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())); + 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())); } #endif @@ -2265,8 +2265,8 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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() + 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() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2277,7 +2277,7 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); texture.bindInternal(); #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()); @@ -2290,14 +2290,14 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); 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); } void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); 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); } @@ -2308,8 +2308,8 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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() + 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() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -2320,47 +2320,47 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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())); + 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())); } #endif #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); - (texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, 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()); } void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - 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())); + 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())); } #endif #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) { - (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 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) { - (texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, offset, size); + (texture.*Context::current().state().texture.invalidateSubImageImplementation)(level, offset, size); } #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D& 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 void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D& 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_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)) void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D& 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_T, GLint(wrapping.y())); diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index 9c315940d..00f4d8449 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -49,7 +49,7 @@ Int Buffer::minMapAlignment() { if(!Context::current().isExtensionSupported()) return 1; - GLint& value = Context::current().state().buffer->minMapAlignment; + GLint& value = Context::current().state().buffer.minMapAlignment; if(value == 0) glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &value); @@ -68,7 +68,7 @@ Int Buffer::maxAtomicCounterBindings() { #endif return 0; - GLint& value = Context::current().state().buffer->maxAtomicCounterBindings; + GLint& value = Context::current().state().buffer.maxAtomicCounterBindings; if(value == 0) glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &value); @@ -84,7 +84,7 @@ Int Buffer::maxShaderStorageBindings() { #endif return 0; - GLint& value = Context::current().state().buffer->maxShaderStorageBindings; + GLint& value = Context::current().state().buffer.maxShaderStorageBindings; if(value == 0) glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &value); @@ -99,7 +99,7 @@ Int Buffer::uniformOffsetAlignment() { return 1; #endif - GLint& value = Context::current().state().buffer->uniformOffsetAlignment; + GLint& value = Context::current().state().buffer.uniformOffsetAlignment; if(value == 0) glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value); @@ -116,7 +116,7 @@ Int Buffer::shaderStorageOffsetAlignment() { #endif return 1; - GLint& value = Context::current().state().buffer->shaderStorageOffsetAlignment; + GLint& value = Context::current().state().buffer.shaderStorageOffsetAlignment; if(value == 0) glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value); @@ -131,7 +131,7 @@ Int Buffer::maxUniformBindings() { return 0; #endif - GLint& value = Context::current().state().buffer->maxUniformBindings; + GLint& value = Context::current().state().buffer.maxUniformBindings; if(value == 0) 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) { - 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 */ void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list> 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 */ void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list 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) { - Context::current().state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); + Context::current().state().buffer.copyImplementation(read, write, readOffset, writeOffset, size); } #endif 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.setTargetHintImplementation)(targetHint); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } 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() { @@ -188,7 +188,7 @@ Buffer::~Buffer() { /* Moved out or not deleting on destruction, nothing to do */ 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 */ for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) @@ -198,7 +198,7 @@ Buffer::~Buffer() { } Buffer& Buffer::setTargetHint(TargetHint hint) { - (this->*Context::current().state().buffer->setTargetHintImplementation)(hint); + (this->*Context::current().state().buffer.setTargetHintImplementation)(hint); return *this; } @@ -230,18 +230,18 @@ void Buffer::createIfNotAlready() { std::string Buffer::label() { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES2 - return Context::current().state().debug->getLabelImplementation(GL_BUFFER, _id); + return Context::current().state().debug.getLabelImplementation(GL_BUFFER, _id); #else - return Context::current().state().debug->getLabelImplementation(GL_BUFFER_KHR, _id); + return Context::current().state().debug.getLabelImplementation(GL_BUFFER_KHR, _id); #endif } Buffer& Buffer::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES2 - Context::current().state().debug->labelImplementation(GL_BUFFER, _id, label); + Context::current().state().debug.labelImplementation(GL_BUFFER, _id, label); #else - Context::current().state().debug->labelImplementation(GL_BUFFER_KHR, _id, label); + Context::current().state().debug.labelImplementation(GL_BUFFER_KHR, _id, label); #endif return *this; } @@ -249,7 +249,7 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayView label) void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { 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 */ if(bound == id) return; @@ -261,7 +261,7 @@ void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { } 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)]; /* 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 Test::MeshGLTest::unbindVAOwhenSettingIndexBufferData() for details. */ 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 well to be sure */ if(currentVAO != 0) - Context::current().state().mesh->bindVAOImplementation(0); + Context::current().state().mesh.bindVAOImplementation(0); } /* Bind the buffer to hint target otherwise */ @@ -307,7 +307,7 @@ Buffer& Buffer::bind(const Target target, const UnsignedInt index) { #ifndef MAGNUM_TARGET_GLES Buffer& Buffer::setStorage(const Containers::ArrayView data, const StorageFlags flags) { - (this->*Context::current().state().buffer->storageImplementation)(data, flags); + (this->*Context::current().state().buffer.storageImplementation)(data, flags); return *this; } #endif @@ -318,7 +318,7 @@ Int Buffer::size() { * couldn't find any matching extension, though) */ GLint size; - (this->*Context::current().state().buffer->getParameterImplementation)(GL_BUFFER_SIZE, &size); + (this->*Context::current().state().buffer.getParameterImplementation)(GL_BUFFER_SIZE, &size); return size; } @@ -329,46 +329,46 @@ Containers::Array Buffer::data() { #endif Buffer& Buffer::setData(const Containers::ArrayView 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; } Buffer& Buffer::setSubData(const GLintptr offset, const Containers::ArrayView data) { - (this->*Context::current().state().buffer->subDataImplementation)(offset, data.size(), data); + (this->*Context::current().state().buffer.subDataImplementation)(offset, data.size(), data); return *this; } Buffer& Buffer::invalidateData() { - (this->*Context::current().state().buffer->invalidateImplementation)(); + (this->*Context::current().state().buffer.invalidateImplementation)(); return *this; } 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; } #ifndef MAGNUM_TARGET_WEBGL char* Buffer::map(const MapAccess access) { - return static_cast((this->*Context::current().state().buffer->mapImplementation)(access)); + return static_cast((this->*Context::current().state().buffer.mapImplementation)(access)); } Containers::ArrayView Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { - return {static_cast((this->*Context::current().state().buffer->mapRangeImplementation)(offset, length, flags)), std::size_t(length)}; + return {static_cast((this->*Context::current().state().buffer.mapRangeImplementation)(offset, length, flags)), std::size_t(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; } -bool Buffer::unmap() { return (this->*Context::current().state().buffer->unmapImplementation)(); } +bool Buffer::unmap() { return (this->*Context::current().state().buffer.unmapImplementation)(); } #endif #ifndef MAGNUM_TARGET_GLES Containers::Array Buffer::subData(const GLintptr offset, const GLsizeiptr size) { Containers::Array 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; } #endif @@ -573,7 +573,7 @@ void Buffer::textureWorkaroundAppleBefore() { /* My Mac Mini reports 80 texture units, which means this thing can have a pretty significant overhead. Skipping the whole thing if no buffer 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; for(GLint textureUnit = 0; textureUnit != GLint(textureState.bindings.size()); ++textureUnit) { /* Checking just diff --git a/src/Magnum/GL/BufferTexture.cpp b/src/Magnum/GL/BufferTexture.cpp index 014856f4c..39f36cf1e 100644 --- a/src/Magnum/GL/BufferTexture.cpp +++ b/src/Magnum/GL/BufferTexture.cpp @@ -44,7 +44,7 @@ Int BufferTexture::maxSize() { return 0; #endif - GLint& value = Context::current().state().texture->maxBufferSize; + GLint& value = Context::current().state().texture.maxBufferSize; /* Get the value, if not already cached */ if(value == 0) @@ -62,7 +62,7 @@ Int BufferTexture::offsetAlignment() { return 0; #endif - GLint& value = Context::current().state().texture->bufferOffsetAlignment; + GLint& value = Context::current().state().texture.bufferOffsetAlignment; /* Get the value, if not already cached */ if(value == 0) @@ -75,19 +75,19 @@ Int BufferTexture::size() { /* Can't use DataHelper<1>::imageSize(*this, 0)[0] because for 1D textures it's not defined on ES */ 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; } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) { buffer.createIfNotAlready(); - (this->*Context::current().state().texture->setBufferImplementation)(internalFormat, &buffer); + (this->*Context::current().state().texture.setBufferImplementation)(internalFormat, &buffer); return *this; } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { buffer.createIfNotAlready(); - (this->*Context::current().state().texture->setBufferRangeImplementation)(internalFormat, buffer, offset, size); + (this->*Context::current().state().texture.setBufferRangeImplementation)(internalFormat, buffer, offset, size); return *this; } @@ -130,7 +130,7 @@ void BufferTexture::setBufferRangeImplementationDSA(const BufferTextureFormat in BufferTexture& BufferTexture::resetBuffer() { /* R8 is the default state according to ARB_texture_buffer_object, so use that */ - (this->*Context::current().state().texture->setBufferImplementation)(BufferTextureFormat::R8, nullptr); + (this->*Context::current().state().texture.setBufferImplementation)(BufferTextureFormat::R8, nullptr); return *this; } diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index e1b2cb0ca..288a837b9 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -963,7 +963,9 @@ bool Context::tryCreate(const Configuration& configuration) { } } - _state.emplace(*this, output); + std::pair state = Implementation::State::allocate(*this, output); + _stateData = std::move(state.first); + _state = &state.second; /* Print a list of used workarounds */ if(!_driverWorkarounds.empty()) { @@ -1066,7 +1068,7 @@ Containers::Array Context::extensionStrings() const { #ifndef MAGNUM_TARGET_GLES bool Context::isCoreProfile() { - return isCoreProfileInternal(*_state->context); + return isCoreProfileInternal(_state->context); } bool Context::isCoreProfileInternal(Implementation::ContextState& state) { @@ -1137,45 +1139,45 @@ void Context::resetState(const States states) { #endif if(states & State::Buffers) - _state->buffer->reset(); + _state->buffer.reset(); if(states & State::Framebuffers) - _state->framebuffer->reset(); + _state->framebuffer.reset(); if(states & State::Meshes) - _state->mesh->reset(); + _state->mesh.reset(); #ifndef MAGNUM_TARGET_GLES /* 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 we don't expect this case to be used very often. */ if(states & State::BindScratchVao) { - if(!_state->mesh->scratchVAO) - glGenVertexArrays(1, &_state->mesh->scratchVAO); + if(!_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 */ } else #endif if(states & State::MeshVao) - _state->mesh->bindVAOImplementation(0); + _state->mesh.bindVAOImplementation(0); if(states & State::PixelStorage) { - _state->renderer->unpackPixelStorage.reset(); - _state->renderer->packPixelStorage.reset(); + _state->renderer.unpackPixelStorage.reset(); + _state->renderer.packPixelStorage.reset(); } /* Nothing to reset for renderer yet */ if(states & State::Shaders) { /* Nothing to reset for shaders */ - _state->shaderProgram->reset(); + _state->shaderProgram.reset(); } if(states & State::Textures) - _state->texture->reset(); + _state->texture.reset(); #ifndef MAGNUM_TARGET_GLES2 if(states & State::TransformFeedback) - _state->transformFeedback->reset(); + _state->transformFeedback.reset(); #endif } diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 3da9fcdf2..9d38e146a 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -31,9 +31,9 @@ #include #include +#include #include #include -#include #include #include "Magnum/Magnum.h" @@ -853,7 +853,8 @@ class MAGNUM_GL_EXPORT Context { Containers::Array _supportedExtensions; #endif - Containers::Pointer _state; + Containers::ArrayTuple _stateData; + Implementation::State* _state; Containers::Optional _detectedDrivers; diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index 7c27bd656..f92e634a5 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -53,7 +53,7 @@ Vector2i CubeMapTexture::maxSize() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i CubeMapTexture::imageSize(const Int level) { - const Implementation::TextureState& state = *Context::current().state().texture; + const Implementation::TextureState& state = Context::current().state().texture; Vector2i value; (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); @@ -75,8 +75,8 @@ void CubeMapTexture::image(const Int level, Image3D& image) { data = Containers::Array{dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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()); + 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()); 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(), ); Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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()); + 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()); } 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.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getFullCubeImageImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, 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()); } 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 needs to go slice-by-slice, advancing the offset each time */ 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); /* Internal texture 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 */ Containers::Array data{image.release()}; @@ -146,8 +146,8 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image) data = Containers::Array{dataOffsetSize.first + dataOffsetSize.second}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, 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 needs to go slice-by-slice, advancing the offset each time */ 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); 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 /* Internal texture 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), "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); #endif Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data()); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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) { @@ -207,12 +207,12 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i nv-cubemap-broken-full-compressed-image-query workaround, where it needs to go slice-by-slice, advancing the offset each time */ 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); /* Internal texture 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 */ 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.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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) { @@ -240,8 +240,8 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, data = Containers::Array{dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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); + 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); 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(), ); Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - 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()); + 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()); } 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.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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) { @@ -289,7 +289,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I the compression, we need to ask GL for it */ std::size_t dataSize; 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 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 extra shitty (Intel Windows drivers, I'm talking about you). */ 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 */ Containers::Array data{image.release()}; @@ -305,8 +305,8 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I data = Containers::Array{dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), 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 */ std::size_t dataSize; 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 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 extra shitty (Intel Windows drivers, I'm talking about you). */ 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), "GL::CubeMapTexture::compressedImage(): expected image view format" << CompressedPixelFormat(format) << "but got" << compressedPixelFormat(image.format()), ); #endif Buffer::unbindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, image.data().size(), image.data()); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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) { @@ -357,7 +357,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I the compression, we need to ask GL for it */ std::size_t dataSize; 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 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 extra shitty (Intel Windows drivers, I'm talking about you). */ 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 */ 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.buffer().bindInternal(Buffer::TargetHint::PixelPack); - Context::current().state().renderer->applyPixelStoragePack(image.storage()); - (this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); + Context::current().state().renderer.applyPixelStoragePack(image.storage()); + (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) { @@ -400,7 +400,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ 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 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{dataSize}; 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); 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 extra shitty (Intel Windows drivers, I'm talking about you). */ 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), "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 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()); } @@ -468,7 +468,7 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, already wrapped in compressedPixelFormatWrap() later if the drivers are extra shitty (Intel Windows drivers, I'm talking about you). */ 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 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.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); } @@ -498,8 +498,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off createIfNotAlready(); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); - 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()); + 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()); return *this; } @@ -507,8 +507,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off createIfNotAlready(); image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture->cubeSubImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, 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()); return *this; } @@ -516,7 +516,7 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Int level, const Vec createIfNotAlready(); 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()); return *this; } @@ -525,7 +525,7 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Int level, const Vec createIfNotAlready(); 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); return *this; } @@ -535,8 +535,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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() + 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() #ifdef MAGNUM_TARGET_GLES2 + Magnum::Implementation::pixelStorageSkipOffset(image) #endif @@ -547,8 +547,8 @@ CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, #ifndef MAGNUM_TARGET_GLES2 CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - Context::current().state().renderer->applyPixelStorageUnpack(image.storage()); - (this->*Context::current().state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); + Context::current().state().renderer.applyPixelStorageUnpack(image.storage()); + (this->*Context::current().state().texture.cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); return *this; } #endif @@ -557,16 +557,16 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate co #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif - 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())); + 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())); return *this; } #ifndef MAGNUM_TARGET_GLES2 CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); - 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())); + 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())); return *this; } #endif diff --git a/src/Magnum/GL/DebugOutput.cpp b/src/Magnum/GL/DebugOutput.cpp index 992f4647f..e5a68e07e 100644 --- a/src/Magnum/GL/DebugOutput.cpp +++ b/src/Magnum/GL/DebugOutput.cpp @@ -114,7 +114,7 @@ Int DebugOutput::maxLoggedMessages() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().debug->maxLoggedMessages; + GLint& value = Context::current().state().debug.maxLoggedMessages; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 @@ -131,7 +131,7 @@ Int DebugOutput::maxMessageLength() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().debug->maxMessageLength; + GLint& value = Context::current().state().debug.maxMessageLength; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 @@ -145,7 +145,7 @@ Int DebugOutput::maxMessageLength() { } 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() { @@ -155,7 +155,7 @@ void DebugOutput::setDefaultCallback() { } void DebugOutput::setEnabledInternal(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list 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, bool) {} @@ -177,13 +177,13 @@ void DebugOutput::callbackImplementationNoOp(Callback, const void*) {} #ifndef MAGNUM_TARGET_GLES2 void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback, const void* userParam) { /* Replace the callback */ - const Callback original = Context::current().state().debug->messageCallback.callback; - Context::current().state().debug->messageCallback.callback = callback; - Context::current().state().debug->messageCallback.userParam = userParam; + const Callback original = Context::current().state().debug.messageCallback.callback; + Context::current().state().debug.messageCallback.callback = callback; + Context::current().state().debug.messageCallback.userParam = userParam; /* Adding callback */ if(!original && callback) - glDebugMessageCallback(callbackWrapper, &Context::current().state().debug->messageCallback); + glDebugMessageCallback(callbackWrapper, &Context::current().state().debug.messageCallback); /* Deleting callback */ else if(original && !callback) @@ -194,13 +194,13 @@ void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback, #ifdef MAGNUM_TARGET_GLES void DebugOutput::callbackImplementationKhrES(const Callback callback, const void* userParam) { /* Replace the callback */ - const Callback original = Context::current().state().debug->messageCallback.callback; - Context::current().state().debug->messageCallback.callback = callback; - Context::current().state().debug->messageCallback.userParam = userParam; + const Callback original = Context::current().state().debug.messageCallback.callback; + Context::current().state().debug.messageCallback.callback = callback; + Context::current().state().debug.messageCallback.userParam = userParam; /* Adding callback */ if(!original && callback) - glDebugMessageCallbackKHR(callbackWrapper, &Context::current().state().debug->messageCallback); + glDebugMessageCallbackKHR(callbackWrapper, &Context::current().state().debug.messageCallback); /* Deleting callback */ else if(original && !callback) @@ -267,7 +267,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Severity value) { #endif void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView 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) {} @@ -333,7 +333,7 @@ Int DebugGroup::maxStackDepth() { if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current().state().debug->maxStackDepth; + GLint& value = Context::current().state().debug.maxStackDepth; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 @@ -348,13 +348,13 @@ Int DebugGroup::maxStackDepth() { void DebugGroup::pushInternal(const Source source, const UnsignedInt id, const Containers::ArrayView message) { 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; } void DebugGroup::pop() { CORRADE_ASSERT(_active, "GL::DebugGroup::pop(): group is not active", ); - Context::current().state().debug->popGroupImplementation(); + Context::current().state().debug.popGroupImplementation(); _active = false; } diff --git a/src/Magnum/GL/DefaultFramebuffer.cpp b/src/Magnum/GL/DefaultFramebuffer.cpp index e5de6500f..b86c3b852 100644 --- a/src/Magnum/GL/DefaultFramebuffer.cpp +++ b/src/Magnum/GL/DefaultFramebuffer.cpp @@ -40,22 +40,22 @@ namespace Magnum { namespace GL { DefaultFramebuffer defaultFramebuffer; 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 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; } 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; } 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; } #endif @@ -73,22 +73,22 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); + (this->*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments); return *this; } DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const DrawAttachment attachment) { #ifndef MAGNUM_TARGET_GLES - (this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment)); #else - (this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) DefaultFramebuffer& DefaultFramebuffer::mapForRead(const ReadAttachment attachment) { - (this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment)); return *this; } @@ -98,7 +98,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current().state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); + (this->*Context::current().state().framebuffer.invalidateImplementation)(attachments.size(), _attachments); } #endif @@ -109,12 +109,12 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current().state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); + (this->*Context::current().state().framebuffer.invalidateSubImplementation)(attachments.size(), _attachments, rectangle); } #endif void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) { - Implementation::FramebufferState& state = *context.state().framebuffer; + Implementation::FramebufferState& state = context.state().framebuffer; /* Initial framebuffer size */ GLint viewport[4]; diff --git a/src/Magnum/GL/Framebuffer.cpp b/src/Magnum/GL/Framebuffer.cpp index 1125eaaa4..135534bdf 100644 --- a/src/Magnum/GL/Framebuffer.cpp +++ b/src/Magnum/GL/Framebuffer.cpp @@ -84,7 +84,7 @@ Int Framebuffer::maxColorAttachments() { #endif #endif - GLint& value = Context::current().state().framebuffer->maxColorAttachments; + GLint& value = Context::current().state().framebuffer.maxColorAttachments; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 @@ -100,7 +100,7 @@ Int Framebuffer::maxColorAttachments() { Framebuffer::Framebuffer(const Range2Di& viewport): AbstractFramebuffer{0, viewport, ObjectFlag::DeleteOnDestruction} { CORRADE_INTERNAL_ASSERT(viewport != Implementation::FramebufferState::DisengagedViewport); _viewport = viewport; - (this->*Context::current().state().framebuffer->createImplementation)(); + (this->*Context::current().state().framebuffer.createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -120,7 +120,7 @@ Framebuffer::~Framebuffer() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* 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; /* For draw binding reset also viewport */ @@ -140,33 +140,33 @@ Framebuffer::~Framebuffer() { #ifndef MAGNUM_TARGET_WEBGL std::string Framebuffer::label() { 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 label) { createIfNotAlready(); - Context::current().state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); + Context::current().state().debug.labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; } #endif 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 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; } 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; } 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; } #endif @@ -184,22 +184,22 @@ Framebuffer& Framebuffer::mapForDraw(std::initializer_list*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); + (this->*Context::current().state().framebuffer.drawBuffersImplementation)(max+1, _attachments); return *this; } Framebuffer& Framebuffer::mapForDraw(const DrawAttachment attachment) { #ifndef MAGNUM_TARGET_GLES - (this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer.drawBufferImplementation)(GLenum(attachment)); #else - (this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + (this->*Context::current().state().framebuffer.drawBuffersImplementation)(1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Framebuffer& Framebuffer::mapForRead(const ColorAttachment attachment) { - (this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer.readBufferImplementation)(GLenum(attachment)); return *this; } @@ -209,7 +209,7 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++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 @@ -219,116 +219,116 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++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 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; } #ifndef MAGNUM_TARGET_GLES 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; } #endif 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; } #ifndef MAGNUM_TARGET_GLES 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; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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; } #endif 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; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) 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; } #endif #ifndef MAGNUM_TARGET_GLES 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; } #endif #ifndef MAGNUM_TARGET_GLES2 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; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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; } 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; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) 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; } #ifndef MAGNUM_TARGET_GLES 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; } #endif 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; } 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; } 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; } 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; } #endif Framebuffer& Framebuffer::detach(const BufferAttachment attachment) { - (this->*Context::current().state().framebuffer->renderbufferImplementation)(attachment, 0); + (this->*Context::current().state().framebuffer.renderbufferImplementation)(attachment, 0); return *this; } diff --git a/src/Magnum/GL/Implementation/State.cpp b/src/Magnum/GL/Implementation/State.cpp index 558f87776..27d21cc55 100644 --- a/src/Magnum/GL/Implementation/State.cpp +++ b/src/Magnum/GL/Implementation/State.cpp @@ -25,6 +25,8 @@ #include "State.h" +#include + #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" #include "Magnum/GL/Implementation/BufferState.h" @@ -45,7 +47,43 @@ namespace Magnum { namespace GL { namespace Implementation { -State::State(Context& context, std::ostream* const out) { +std::pair State::allocate(Context& context, std::ostream* const out) { + /* I have to say, the ArrayTuple is quite a crazy thing */ + Containers::ArrayView stateView; + Containers::ArrayView bufferStateView; + Containers::ArrayView contextStateView; + #ifndef MAGNUM_TARGET_WEBGL + Containers::ArrayView debugStateView; + #endif + Containers::ArrayView framebufferStateView; + Containers::ArrayView meshStateView; + Containers::ArrayView queryStateView; + Containers::ArrayView rendererStateView; + Containers::ArrayView shaderStateView; + Containers::ArrayView shaderProgramStateView; + Containers::ArrayView textureStateView; + #ifndef MAGNUM_TARGET_GLES2 + Containers::ArrayView 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 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 @@ -53,27 +91,45 @@ State::State(Context& context, std::ostream* const out) { populating a heap array and then std::sort() it to remove duplicates. */ const char* extensions[Implementation::ExtensionCount]{}; - buffer.reset(new BufferState{context, extensions}); - this->context.reset(new ContextState{context, extensions}); + State& state = *(new(&stateView.front()) State{ + 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 - debug.reset(new DebugState{context, extensions}); + new(&state.debug) DebugState{context, extensions}; #endif - framebuffer.reset(new FramebufferState{context, extensions}); - mesh.reset(new MeshState{context, *this->context, extensions}); - query.reset(new QueryState{context, extensions}); - renderer.reset(new RendererState{context, *this->context, extensions}); - shader.reset(new ShaderState(context, extensions)); - shaderProgram.reset(new ShaderProgramState{context, extensions}); - texture.reset(new TextureState{context, extensions}); + new(&state.framebuffer) FramebufferState{context, extensions}; + new(&state.mesh) MeshState{context, stateView.front().context, extensions}; + new(&state.query) QueryState{context, extensions}; + new(&state.renderer) RendererState{context, stateView.front().context, extensions}; + new(&state.shader) ShaderState(context, extensions); + new(&state.shaderProgram) ShaderProgramState{context, extensions}; + new(&state.texture) TextureState{context, extensions}; #ifndef MAGNUM_TARGET_GLES2 - transformFeedback.reset(new TransformFeedbackState{context, extensions}); + new(&state.transformFeedback) TransformFeedbackState{context, extensions}; #endif Debug{out} << "Using optional features:"; for(const char* extension: extensions) if(extension) Debug(out) << " " << extension; -} -State::~State() = default; + return {std::move(data), state}; +} }}} diff --git a/src/Magnum/GL/Implementation/State.h b/src/Magnum/GL/Implementation/State.h index 6f1884ce0..f3bf2884f 100644 --- a/src/Magnum/GL/Implementation/State.h +++ b/src/Magnum/GL/Implementation/State.h @@ -25,7 +25,9 @@ DEALINGS IN THE SOFTWARE. */ -#include +#include +#include +#include #include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" @@ -49,27 +51,26 @@ struct TransformFeedbackState; #endif struct State { - /* Initializes context-based functionality */ - explicit State(Context& context, std::ostream* out); - - ~State(); + /* Initializes context-based functionality together with all nested classes + in a single allocation */ + static std::pair allocate(Context& context, std::ostream* out); enum: GLuint { DisengagedBinding = ~0u }; - Containers::Pointer buffer; - Containers::Pointer context; + BufferState& buffer; + ContextState& context; #ifndef MAGNUM_TARGET_WEBGL - Containers::Pointer debug; + DebugState& debug; #endif - Containers::Pointer framebuffer; - Containers::Pointer mesh; - Containers::Pointer query; - Containers::Pointer renderer; - Containers::Pointer shader; - Containers::Pointer shaderProgram; - Containers::Pointer texture; + FramebufferState& framebuffer; + MeshState& mesh; + QueryState& query; + RendererState& renderer; + ShaderState& shader; + ShaderProgramState& shaderProgram; + TextureState& texture; #ifndef MAGNUM_TARGET_GLES2 - Containers::Pointer transformFeedback; + TransformFeedbackState& transformFeedback; #endif }; diff --git a/src/Magnum/GL/Implementation/maxTextureSize.cpp b/src/Magnum/GL/Implementation/maxTextureSize.cpp index 458a23559..c268dca39 100644 --- a/src/Magnum/GL/Implementation/maxTextureSize.cpp +++ b/src/Magnum/GL/Implementation/maxTextureSize.cpp @@ -32,7 +32,7 @@ namespace Magnum { namespace GL { namespace Implementation { GLint maxTextureSideSize() { - GLint& value = Context::current().state().texture->maxSize; + GLint& value = Context::current().state().texture.maxSize; if(value == 0) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); @@ -42,7 +42,7 @@ GLint maxTextureSideSize() { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) GLint max3DTextureDepth() { - GLint& value = Context::current().state().texture->max3DSize; + GLint& value = Context::current().state().texture.max3DSize; if(value == 0) #ifndef MAGNUM_TARGET_GLES2 @@ -57,7 +57,7 @@ GLint max3DTextureDepth() { #ifndef MAGNUM_TARGET_GLES2 GLint maxTextureArrayLayers() { - GLint& value = Context::current().state().texture->maxArrayLayers; + GLint& value = Context::current().state().texture.maxArrayLayers; if(value == 0) glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &value); @@ -67,7 +67,7 @@ GLint maxTextureArrayLayers() { #endif GLint maxCubeMapTextureSideSize() { - GLint& value = Context::current().state().texture->maxCubeMapSize; + GLint& value = Context::current().state().texture.maxCubeMapSize; if(value == 0) glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value); diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 3fa160a1f..c236f51eb 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -181,7 +181,7 @@ UnsignedInt Mesh::maxVertexAttributeStride() { } #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 */ if(value == 0) @@ -209,7 +209,7 @@ Int Mesh::maxElementIndex() #else GLint& value = #endif - Context::current().state().mesh->maxElementIndex; + Context::current().state().mesh.maxElementIndex; /* Get the value, if not already cached */ if(value == 0) { @@ -224,7 +224,7 @@ Int Mesh::maxElementIndex() } Int Mesh::maxElementsIndices() { - GLint& value = Context::current().state().mesh->maxElementsIndices; + GLint& value = Context::current().state().mesh.maxElementsIndices; /* Get the value, if not already cached */ if(value == 0) @@ -234,7 +234,7 @@ Int Mesh::maxElementsIndices() { } Int Mesh::maxElementsVertices() { - GLint& value = Context::current().state().mesh->maxElementsVertices; + GLint& value = Context::current().state().mesh.maxElementsVertices; /* Get the value, if not already cached */ if(value == 0) @@ -245,7 +245,7 @@ Int Mesh::maxElementsVertices() { #endif 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} {} @@ -256,11 +256,11 @@ Mesh::~Mesh() { /* Moved out or not deleting on destruction, nothing to do */ if(deleteObject) { /* 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(_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}, @@ -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)} { 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; } @@ -298,13 +298,13 @@ Mesh& Mesh::operator=(Mesh&& other) noexcept { swap(_indexBuffer, other._indexBuffer); if(_constructed || other._constructed) - (this->*Context::current().state().mesh->moveAssignImplementation)(std::move(other)); + (this->*Context::current().state().mesh.moveAssignImplementation)(std::move(other)); return *this; } 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() { @@ -323,18 +323,18 @@ inline void Mesh::createIfNotAlready() { std::string Mesh::label() { createIfNotAlready(); #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 - return Context::current().state().debug->getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id); + return Context::current().state().debug.getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id); #endif } Mesh& Mesh::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); #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 - Context::current().state().debug->labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label); + Context::current().state().debug.labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label); #endif 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 bindVAO() function called from here is resetting element buffer state tracker to _indexBuffer.id(). */ - (this->*Context::current().state().mesh->bindIndexBufferImplementation)(buffer); + (this->*Context::current().state().mesh.bindIndexBufferImplementation)(buffer); _indexBuffer = std::move(buffer); _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) #endif { - const Implementation::MeshState& state = *Context::current().state().mesh; + const Implementation::MeshState& state = Context::current().state().mesh; (this->*state.bindImplementation)(); @@ -548,7 +548,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #ifndef MAGNUM_TARGET_GLES 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)(); @@ -605,11 +605,11 @@ void Mesh::bindVAOImplementationVAO(const GLuint id) { #else glBindVertexArrayOES #endif - (Context::current().state().mesh->currentVAO = id); + (Context::current().state().mesh.currentVAO = id); } void Mesh::bindVAO() { - GLuint& current = Context::current().state().mesh->currentVAO; + GLuint& current = Context::current().state().mesh.currentVAO; if(current != _id) { /* Binding the VAO finally creates it */ _flags |= ObjectFlag::Created; @@ -622,7 +622,7 @@ void Mesh::bindVAO() { particular, the setIndexBuffer() buffers call this function *and then* sets the _indexBuffer, which means at this point the ID will 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) { CORRADE_ASSERT(attribute.buffer.id(), "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) { @@ -775,7 +775,7 @@ void Mesh::attributePointerImplementationVAODSA(AttributeLayout&& attribute) { glVertexArrayVertexBuffer(_id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride); 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 @@ -811,7 +811,7 @@ void Mesh::vertexAttribPointer(AttributeLayout& attribute) { #ifndef MAGNUM_TARGET_GLES2 glVertexAttribDivisor(attribute.location, attribute.divisor); #else - (this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); + (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); #endif } } @@ -839,7 +839,7 @@ void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint #endif 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) { @@ -895,7 +895,7 @@ void Mesh::unbindImplementationDefault() { #ifndef MAGNUM_TARGET_GLES2 glVertexAttribDivisor(attribute.location, 0); #else - (this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, 0); + (this->*Context::current().state().mesh.vertexAttribDivisorImplementation)(attribute.location, 0); #endif } } diff --git a/src/Magnum/GL/MeshView.cpp b/src/Magnum/GL/MeshView.cpp index 1b16ce9d2..19c4fffc0 100644 --- a/src/Magnum/GL/MeshView.cpp +++ b/src/Magnum/GL/MeshView.cpp @@ -88,7 +88,7 @@ MeshView& MeshView::draw(AbstractShaderProgram&& shader, TransformFeedback& xfb, void MeshView::multiDrawImplementationDefault(Containers::ArrayView> meshes) { 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; Containers::Array count{meshes.size()}; diff --git a/src/Magnum/GL/RectangleTexture.cpp b/src/Magnum/GL/RectangleTexture.cpp index c2aa39eeb..902b83f69 100644 --- a/src/Magnum/GL/RectangleTexture.cpp +++ b/src/Magnum/GL/RectangleTexture.cpp @@ -40,7 +40,7 @@ Vector2i RectangleTexture::maxSize() { if(!Context::current().isExtensionSupported()) return {}; - GLint& value = Context::current().state().texture->maxRectangleSize; + GLint& value = Context::current().state().texture.maxRectangleSize; if(value == 0) glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &value); diff --git a/src/Magnum/GL/Renderbuffer.cpp b/src/Magnum/GL/Renderbuffer.cpp index a9350c9f0..ae53cf779 100644 --- a/src/Magnum/GL/Renderbuffer.cpp +++ b/src/Magnum/GL/Renderbuffer.cpp @@ -37,7 +37,7 @@ namespace Magnum { namespace GL { Int Renderbuffer::maxSize() { - GLint& value = Context::current().state().framebuffer->maxRenderbufferSize; + GLint& value = Context::current().state().framebuffer.maxRenderbufferSize; /* Get the value, if not already cached */ if(value == 0) @@ -53,7 +53,7 @@ Int Renderbuffer::maxSamples() { return 0; #endif - GLint& value = Context::current().state().framebuffer->maxSamples; + GLint& value = Context::current().state().framebuffer.maxSamples; /* Get the value, if not already cached */ if(value == 0) { @@ -69,7 +69,7 @@ Int Renderbuffer::maxSamples() { #endif Renderbuffer::Renderbuffer(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().framebuffer->createRenderbufferImplementation)(); + (this->*Context::current().state().framebuffer.createRenderbufferImplementation)(); } void Renderbuffer::createImplementationDefault() { @@ -88,7 +88,7 @@ Renderbuffer::~Renderbuffer() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* 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; glDeleteRenderbuffers(1, &_id); @@ -108,28 +108,28 @@ inline void Renderbuffer::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string Renderbuffer::label() { 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 label) { createIfNotAlready(); - Context::current().state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); + Context::current().state().debug.labelImplementation(GL_RENDERBUFFER, _id, label); return *this; } #endif 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)) 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 void Renderbuffer::bind() { - GLuint& binding = Context::current().state().framebuffer->renderbufferBinding; + GLuint& binding = Context::current().state().framebuffer.renderbufferBinding; if(binding == _id) return; diff --git a/src/Magnum/GL/Renderer.cpp b/src/Magnum/GL/Renderer.cpp index 583336b04..438f8053d 100644 --- a/src/Magnum/GL/Renderer.cpp +++ b/src/Magnum/GL/Renderer.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace GL { Range1D Renderer::lineWidthRange() { - auto& state = *Context::current().state().renderer; + Implementation::RendererState& state = Context::current().state().renderer; Range1D& value = state.lineWidthRange; /* 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)) 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) { - 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) { @@ -101,7 +101,7 @@ void Renderer::setClearDepth(const Double depth) { #endif void Renderer::setClearDepth(Float depth) { - Context::current().state().renderer->clearDepthfImplementation(depth); + Context::current().state().renderer.clearDepthfImplementation(depth); } 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) void Renderer::setMinSampleShading(const Float value) { - (Context::current().state().renderer->minSampleShadingImplementation)(value); + (Context::current().state().renderer.minSampleShadingImplementation)(value); } void Renderer::minSampleShadingImplementationDefault(const GLfloat value) { @@ -173,7 +173,7 @@ UnsignedInt Renderer::maxPatchVertexCount() { return 0; #endif - GLint& value = Context::current().state().renderer->maxPatchVertexCount; + GLint& value = Context::current().state().renderer.maxPatchVertexCount; /* Get the value, if not already cached */ if(value == 0) @@ -183,7 +183,7 @@ UnsignedInt Renderer::maxPatchVertexCount() { } void Renderer::setPatchVertexCount(UnsignedInt count) { - Context::current().state().renderer->patchParameteriImplementation(GL_PATCH_VERTICES, count); + Context::current().state().renderer.patchParameteriImplementation(GL_PATCH_VERTICES, count); } #endif @@ -210,7 +210,7 @@ UnsignedInt Renderer::maxClipDistances() { return 0; #endif - GLint& value = Context::current().state().renderer->maxClipDistances; + GLint& value = Context::current().state().renderer.maxClipDistances; /* Get the value, if not already cached */ if(value == 0) @@ -238,7 +238,7 @@ UnsignedInt Renderer::maxCullDistances() { return 0; #endif - GLint& value = Context::current().state().renderer->maxCullDistances; + GLint& value = Context::current().state().renderer.maxCullDistances; /* Get the value, if not already cached */ if(value == 0) @@ -262,7 +262,7 @@ UnsignedInt Renderer::maxCombinedClipAndCullDistances() { return 0; #endif - GLint& value = Context::current().state().renderer->maxCombinedClipAndCullDistances; + GLint& value = Context::current().state().renderer.maxCombinedClipAndCullDistances; /* Get the value, if not already cached */ 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)) 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 @@ -342,19 +342,19 @@ void Renderer::setBlendFunction(const BlendFunction sourceRgb, const BlendFuncti #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) 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) { - 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) { - 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) { - 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 @@ -388,7 +388,7 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { #endif return ResetNotificationStrategy::NoResetNotification; - ResetNotificationStrategy& strategy = Context::current().state().renderer->resetNotificationStrategy; + ResetNotificationStrategy& strategy = Context::current().state().renderer.resetNotificationStrategy; if(strategy == ResetNotificationStrategy()) { #ifndef MAGNUM_TARGET_GLES @@ -402,7 +402,7 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { } Renderer::GraphicsResetStatus Renderer::graphicsResetStatus() { - return Context::current().state().renderer->graphicsResetStatusImplementation(); + return Context::current().state().renderer.graphicsResetStatusImplementation(); } #endif diff --git a/src/Magnum/GL/Sampler.cpp b/src/Magnum/GL/Sampler.cpp index 2120337ee..11d0c0703 100644 --- a/src/Magnum/GL/Sampler.cpp +++ b/src/Magnum/GL/Sampler.cpp @@ -107,7 +107,7 @@ SamplerWrapping samplerWrapping(const Magnum::SamplerWrapping wrapping) { } Float Sampler::maxMaxAnisotropy() { - GLfloat& value = Context::current().state().texture->maxMaxAnisotropy; + GLfloat& value = Context::current().state().texture.maxMaxAnisotropy; /* Get the value, if not already cached */ if(value == 0.0f) { diff --git a/src/Magnum/GL/Shader.cpp b/src/Magnum/GL/Shader.cpp index 046c1905d..5ac59a46e 100644 --- a/src/Magnum/GL/Shader.cpp +++ b/src/Magnum/GL/Shader.cpp @@ -113,7 +113,7 @@ constexpr bool isTypeSupported(Shader::Type) { return true; } } Int Shader::maxVertexOutputComponents() { - GLint& value = Context::current().state().shader->maxVertexOutputComponents; + GLint& value = Context::current().state().shader.maxVertexOutputComponents; /* Get the value, if not already cached */ if(value == 0) { @@ -143,7 +143,7 @@ Int Shader::maxTessellationControlInputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxTessellationControlInputComponents; + GLint& value = Context::current().state().shader.maxTessellationControlInputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -161,7 +161,7 @@ Int Shader::maxTessellationControlOutputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxTessellationControlOutputComponents; + GLint& value = Context::current().state().shader.maxTessellationControlOutputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -179,7 +179,7 @@ Int Shader::maxTessellationControlTotalOutputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxTessellationControlTotalOutputComponents; + GLint& value = Context::current().state().shader.maxTessellationControlTotalOutputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -197,7 +197,7 @@ Int Shader::maxTessellationEvaluationInputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxTessellationEvaluationInputComponents; + GLint& value = Context::current().state().shader.maxTessellationEvaluationInputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -215,7 +215,7 @@ Int Shader::maxTessellationEvaluationOutputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxTessellationEvaluationOutputComponents; + GLint& value = Context::current().state().shader.maxTessellationEvaluationOutputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -233,7 +233,7 @@ Int Shader::maxGeometryInputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxGeometryInputComponents; + GLint& value = Context::current().state().shader.maxGeometryInputComponents; /* 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?) */ @@ -252,7 +252,7 @@ Int Shader::maxGeometryOutputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxGeometryOutputComponents; + GLint& value = Context::current().state().shader.maxGeometryOutputComponents; /* 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?) */ @@ -271,7 +271,7 @@ Int Shader::maxGeometryTotalOutputComponents() { return 0; #endif - GLint& value = Context::current().state().shader->maxGeometryTotalOutputComponents; + GLint& value = Context::current().state().shader.maxGeometryTotalOutputComponents; /* Get the value, if not already cached */ if(value == 0) @@ -282,7 +282,7 @@ Int Shader::maxGeometryTotalOutputComponents() { #endif Int Shader::maxFragmentInputComponents() { - GLint& value = Context::current().state().shader->maxFragmentInputComponents; + GLint& value = Context::current().state().shader.maxFragmentInputComponents; /* Get the value, if not already cached */ if(value == 0) { @@ -316,7 +316,7 @@ Int Shader::maxAtomicCounterBuffers(const Type 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 */ constexpr static GLenum what[] = { @@ -341,7 +341,7 @@ Int Shader::maxCombinedAtomicCounterBuffers() { #endif return 0; - GLint& value = Context::current().state().shader->maxCombinedAtomicCounterBuffers; + GLint& value = Context::current().state().shader.maxCombinedAtomicCounterBuffers; /* Get the value, if not already cached */ if(value == 0) @@ -363,7 +363,7 @@ Int Shader::maxAtomicCounters(const Type 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 */ constexpr static GLenum what[] = { @@ -388,7 +388,7 @@ Int Shader::maxCombinedAtomicCounters() { #endif return 0; - GLint& value = Context::current().state().shader->maxCombinedAtomicCounters; + GLint& value = Context::current().state().shader.maxCombinedAtomicCounters; /* Get the value, if not already cached */ if(value == 0) @@ -410,7 +410,7 @@ Int Shader::maxImageUniforms(const Type 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 */ constexpr static GLenum what[] = { @@ -435,7 +435,7 @@ Int Shader::maxCombinedImageUniforms() { #endif return 0; - GLint& value = Context::current().state().shader->maxCombinedImageUniforms; + GLint& value = Context::current().state().shader.maxCombinedImageUniforms; /* Get the value, if not already cached */ if(value == 0) @@ -457,7 +457,7 @@ Int Shader::maxShaderStorageBlocks(const Type 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 */ constexpr static GLenum what[] = { @@ -482,7 +482,7 @@ Int Shader::maxCombinedShaderStorageBlocks() { #endif return 0; - GLint& value = Context::current().state().shader->maxCombinedShaderStorageBlocks; + GLint& value = Context::current().state().shader.maxCombinedShaderStorageBlocks; /* Get the value, if not already cached */ if(value == 0) @@ -497,7 +497,7 @@ Int Shader::maxTextureImageUnits(const Type type) { return 0; 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 */ constexpr static GLenum what[] = { @@ -517,7 +517,7 @@ Int Shader::maxTextureImageUnits(const Type type) { } Int Shader::maxCombinedTextureImageUnits() { - GLint& value = Context::current().state().shader->maxTextureImageUnitsCombined; + GLint& value = Context::current().state().shader.maxTextureImageUnitsCombined; /* Get the value, if not already cached */ if(value == 0) @@ -536,7 +536,7 @@ Int Shader::maxUniformBlocks(const Type type) { return 0; 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 */ constexpr static GLenum what[] = { @@ -561,7 +561,7 @@ Int Shader::maxCombinedUniformBlocks() { return 0; #endif - GLint& value = Context::current().state().shader->maxCombinedUniformBlocks; + GLint& value = Context::current().state().shader.maxCombinedUniformBlocks; /* Get the value, if not already cached */ if(value == 0) @@ -576,7 +576,7 @@ Int Shader::maxUniformComponents(const Type type) { return 0; 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 */ #ifndef MAGNUM_TARGET_GLES2 @@ -618,7 +618,7 @@ Int Shader::maxCombinedUniformComponents(const Type type) { return 0; 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 */ constexpr static GLenum what[] = { @@ -681,17 +681,17 @@ Shader::~Shader() { #ifndef MAGNUM_TARGET_WEBGL std::string Shader::label() const { #ifndef MAGNUM_TARGET_GLES2 - return Context::current().state().debug->getLabelImplementation(GL_SHADER, _id); + return Context::current().state().debug.getLabelImplementation(GL_SHADER, _id); #else - return Context::current().state().debug->getLabelImplementation(GL_SHADER_KHR, _id); + return Context::current().state().debug.getLabelImplementation(GL_SHADER_KHR, _id); #endif } Shader& Shader::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES2 - Context::current().state().debug->labelImplementation(GL_SHADER, _id, label); + Context::current().state().debug.labelImplementation(GL_SHADER, _id, label); #else - Context::current().state().debug->labelImplementation(GL_SHADER_KHR, _id, label); + Context::current().state().debug.labelImplementation(GL_SHADER_KHR, _id, label); #endif return *this; } @@ -701,7 +701,7 @@ std::vector Shader::sources() const { return _sources; } Shader& Shader::addSource(std::string source) { 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) in case shader version was not Version::None, because then source 0 @@ -789,7 +789,7 @@ bool Shader::compile(std::initializer_list> shader /* Some drivers are chatty and can't keep shut when there's nothing to be said, handle that as well. */ - Context::current().state().shader->cleanLogImplementation(message); + Context::current().state().shader.cleanLogImplementation(message); /* Show error log */ if(!success) { diff --git a/src/Magnum/GL/TransformFeedback.cpp b/src/Magnum/GL/TransformFeedback.cpp index 4e137d154..3b8ae5cb4 100644 --- a/src/Magnum/GL/TransformFeedback.cpp +++ b/src/Magnum/GL/TransformFeedback.cpp @@ -47,7 +47,7 @@ Int TransformFeedback::maxInterleavedComponents() { return 0; #endif - GLint& value = Context::current().state().transformFeedback->maxInterleavedComponents; + GLint& value = Context::current().state().transformFeedback.maxInterleavedComponents; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &value); @@ -61,7 +61,7 @@ Int TransformFeedback::maxSeparateAttributes() { return 0; #endif - GLint& value = Context::current().state().transformFeedback->maxSeparateAttributes; + GLint& value = Context::current().state().transformFeedback.maxSeparateAttributes; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &value); @@ -75,7 +75,7 @@ Int TransformFeedback::maxSeparateComponents() { return 0; #endif - GLint& value = Context::current().state().transformFeedback->maxSeparateComponents; + GLint& value = Context::current().state().transformFeedback.maxSeparateComponents; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, &value); @@ -88,7 +88,7 @@ Int TransformFeedback::maxBuffers() { if(!Context::current().isExtensionSupported()) return maxSeparateAttributes(); - GLint& value = Context::current().state().transformFeedback->maxBuffers; + GLint& value = Context::current().state().transformFeedback.maxBuffers; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &value); @@ -100,7 +100,7 @@ Int TransformFeedback::maxVertexStreams() { if(!Context::current().isExtensionSupported()) return 1; - GLint& value = Context::current().state().transformFeedback->maxVertexStreams; + GLint& value = Context::current().state().transformFeedback.maxVertexStreams; if(value == 0) glGetIntegerv(GL_MAX_VERTEX_STREAMS, &value); @@ -110,7 +110,7 @@ Int TransformFeedback::maxVertexStreams() { #endif TransformFeedback::TransformFeedback(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current().state().transformFeedback->createImplementation)(); + (this->*Context::current().state().transformFeedback.createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -130,14 +130,14 @@ TransformFeedback::~TransformFeedback() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* 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; glDeleteTransformFeedbacks(1, &_id); } void TransformFeedback::bindInternal() { - GLuint& bound = Context::current().state().transformFeedback->binding; + GLuint& bound = Context::current().state().transformFeedback.binding; /* Already bound, nothing to do */ if(bound == _id) return; @@ -162,23 +162,23 @@ inline void TransformFeedback::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string TransformFeedback::label() { 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 label) { createIfNotAlready(); - Context::current().state().debug->labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); + Context::current().state().debug.labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); return *this; } #endif 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; } 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; } @@ -206,13 +206,13 @@ void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buff /** @todoc const std::initializer_list makes Doxygen grumpy */ TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list> buffers) { - (this->*Context::current().state().transformFeedback->attachRangesImplementation)(firstIndex, buffers); + (this->*Context::current().state().transformFeedback.attachRangesImplementation)(firstIndex, buffers); return *this; } /** @todoc const std::initializer_list makes Doxygen grumpy */ TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list buffers) { - (this->*Context::current().state().transformFeedback->attachBasesImplementation)(firstIndex, buffers); + (this->*Context::current().state().transformFeedback.attachBasesImplementation)(firstIndex, buffers); return *this; }