From: David Steele Date: Thu, 29 Apr 2021 09:18:48 +0000 (+0100) Subject: Cleanup in Aisle #1 X-Git-Tag: dali_2.0.28~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32f4a41e7c6bb956ae61e99ba4468192bdd33026;p=platform%2Fcore%2Fuifw%2Fdali-core.git Cleanup in Aisle #1 Change-Id: I7f344f89b05240ac215ca5add36600245e36a9e5 --- diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 4916657..19121d0 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -181,12 +181,10 @@ void Core::RecoverFromContextLoss() void Core::ContextCreated() { - mRenderManager->ContextCreated(); } void Core::ContextDestroyed() { - mRenderManager->ContextDestroyed(); } void Core::Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo) diff --git a/dali/internal/file.list b/dali/internal/file.list index 689d591..d46c512 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -107,11 +107,8 @@ SET( internal_src_files ${internal_src_dir}/render/common/render-tracker.cpp ${internal_src_dir}/render/common/render-manager.cpp ${internal_src_dir}/render/data-providers/render-data-provider.cpp - ${internal_src_dir}/render/gl-resources/context.cpp - ${internal_src_dir}/render/gl-resources/frame-buffer-state-cache.cpp - ${internal_src_dir}/render/gl-resources/gl-call-debug.cpp - ${internal_src_dir}/render/gl-resources/gpu-buffer.cpp ${internal_src_dir}/render/queue/render-queue.cpp + ${internal_src_dir}/render/renderers/gpu-buffer.cpp ${internal_src_dir}/render/renderers/render-frame-buffer.cpp ${internal_src_dir}/render/renderers/render-geometry.cpp ${internal_src_dir}/render/renderers/render-renderer.cpp diff --git a/dali/internal/render/common/render-algorithms.cpp b/dali/internal/render/common/render-algorithms.cpp index c5adcda..ad80970 100644 --- a/dali/internal/render/common/render-algorithms.cpp +++ b/dali/internal/render/common/render-algorithms.cpp @@ -352,8 +352,8 @@ inline void SetupDepthBuffer(const RenderItem& item, Graphics::CommandBuffer& co // If this is the first use of the depth buffer this RenderTask, perform a clear. // Note: We could do this at the beginning of the RenderTask and rely on the - // context cache to ignore the clear if not required, but, we would have to enable - // the depth buffer to do so, which could be a redundant enable. + // graphics implementation to ignore the clear if not required, but, we would + // have to enable the depth buffer to do so, which could be a redundant enable. if(DALI_UNLIKELY(firstDepthBufferUse)) { // This is the first time the depth buffer is being written to or read. @@ -365,7 +365,6 @@ inline void SetupDepthBuffer(const RenderItem& item, Graphics::CommandBuffer& co } // Set up the depth mask based on our depth write setting. - //context.DepthMask(enableDepthWrite); commandBuffer.SetDepthWriteEnable(enableDepthWrite); } else diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 188ed7e..077af4f 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -64,9 +64,7 @@ struct RenderManager::Impl Integration::DepthBufferAvailable depthBufferAvailableParam, Integration::StencilBufferAvailable stencilBufferAvailableParam, Integration::PartialUpdateAvailable partialUpdateAvailableParam) - : context(graphicsController.GetGlAbstraction(), &sceneContextContainer), - currentContext(&context), - graphicsController(graphicsController), + : graphicsController(graphicsController), renderQueue(), renderAlgorithms(graphicsController), frameCount(0u), @@ -105,33 +103,6 @@ struct RenderManager::Impl mRenderTrackers.EraseObject(renderTracker); } - Context* CreateSceneContext() - { - Context* context = new Context(graphicsController.GetGlAbstraction()); - sceneContextContainer.PushBack(context); - return context; - } - - void DestroySceneContext(Context* sceneContext) - { - auto iter = std::find(sceneContextContainer.Begin(), sceneContextContainer.End(), sceneContext); - if(iter != sceneContextContainer.End()) - { - (*iter)->GlContextDestroyed(); - sceneContextContainer.Erase(iter); - } - } - - Context* ReplaceSceneContext(Context* oldSceneContext) - { - Context* newContext = new Context(graphicsController.GetGlAbstraction()); - - oldSceneContext->GlContextDestroyed(); - - std::replace(sceneContextContainer.begin(), sceneContextContainer.end(), oldSceneContext, newContext); - return newContext; - } - void UpdateTrackers() { for(auto&& iter : mRenderTrackers) @@ -141,12 +112,8 @@ struct RenderManager::Impl } // the order is important for destruction, - // programs are owned by context at the moment. - Context context; ///< Holds the GL state of the share resource context - Context* currentContext; ///< Holds the GL state of the current context for rendering - OwnerContainer sceneContextContainer; ///< List of owned contexts holding the GL state per scene - Graphics::Controller& graphicsController; - RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread. + Graphics::Controller& graphicsController; + RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread. std::vector sceneContainer; ///< List of pointers to the scene graph objects of the scenes @@ -208,39 +175,6 @@ RenderQueue& RenderManager::GetRenderQueue() return mImpl->renderQueue; } -void RenderManager::ContextCreated() -{ - mImpl->context.GlContextCreated(); - mImpl->programController.GlContextCreated(); - - // renderers, textures and gpu buffers cannot reinitialize themselves - // so they rely on someone reloading the data for them -} - -void RenderManager::ContextDestroyed() -{ - mImpl->context.GlContextDestroyed(); - mImpl->programController.GlContextDestroyed(); - - //Inform textures - for(auto&& texture : mImpl->textureContainer) - { - texture->Destroy(); - } - - //Inform framebuffers - for(auto&& framebuffer : mImpl->frameBufferContainer) - { - framebuffer->Destroy(); - } - - // inform context - for(auto&& context : mImpl->sceneContextContainer) - { - context->GlContextDestroyed(); - } -} - void RenderManager::SetShaderSaver(ShaderSaver& upstream) { mImpl->programController.SetShaderSaver(upstream); @@ -341,14 +275,12 @@ void RenderManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer) void RenderManager::InitializeScene(SceneGraph::Scene* scene) { - scene->Initialize(*mImpl->CreateSceneContext(), mImpl->graphicsController, mImpl->depthBufferAvailable, mImpl->stencilBufferAvailable); + scene->Initialize(mImpl->graphicsController, mImpl->depthBufferAvailable, mImpl->stencilBufferAvailable); mImpl->sceneContainer.push_back(scene); } void RenderManager::UninitializeScene(SceneGraph::Scene* scene) { - mImpl->DestroySceneContext(scene->GetContext()); - auto iter = std::find(mImpl->sceneContainer.begin(), mImpl->sceneContainer.end(), scene); if(iter != mImpl->sceneContainer.end()) { @@ -358,8 +290,7 @@ void RenderManager::UninitializeScene(SceneGraph::Scene* scene) void RenderManager::SurfaceReplaced(SceneGraph::Scene* scene) { - Context* newContext = mImpl->ReplaceSceneContext(scene->GetContext()); - scene->Initialize(*newContext, mImpl->graphicsController, mImpl->depthBufferAvailable, mImpl->stencilBufferAvailable); + scene->Initialize(mImpl->graphicsController, mImpl->depthBufferAvailable, mImpl->stencilBufferAvailable); } void RenderManager::AttachColorTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer) @@ -466,9 +397,6 @@ void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear { DALI_PRINT_RENDER_START(mImpl->renderBufferIndex); - // Core::Render documents that GL context must be current before calling Render - DALI_ASSERT_DEBUG(mImpl->context.IsGlContextCreated()); - // Increment the frame count at the beginning of each frame ++mImpl->frameCount; @@ -490,15 +418,6 @@ void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear { DALI_LOG_INFO(gLogFilter, Debug::General, "Render: Processing\n"); - // Switch to the shared context - if(mImpl->currentContext != &mImpl->context) - { - mImpl->currentContext = &mImpl->context; - - // Clear the current cached program when the context is switched - mImpl->programController.ClearCurrentProgram(); - } - // Upload the geometries for(uint32_t i = 0; i < mImpl->sceneContainer.size(); ++i) { @@ -856,30 +775,9 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: // offscreen buffer currentRenderTarget = instruction.mFrameBuffer->GetGraphicsRenderTarget(); currentRenderPass = instruction.mFrameBuffer->GetGraphicsRenderPass(loadOp, Graphics::AttachmentStoreOp::STORE); - - if(mImpl->currentContext != &mImpl->context) - { - // Switch to shared context for off-screen buffer - mImpl->currentContext = &mImpl->context; - - // Clear the current cached program when the context is switched - mImpl->programController.ClearCurrentProgram(); - } } else // no framebuffer { - if(mImpl->currentContext->IsSurfacelessContextSupported()) - { - if(mImpl->currentContext != sceneObject->GetContext()) - { - // Switch the correct context if rendering to a surface - mImpl->currentContext = sceneObject->GetContext(); - - // Clear the current cached program when the context is switched - mImpl->programController.ClearCurrentProgram(); - } - } - // surface auto& clearValues = sceneObject->GetGraphicsRenderPassClearValues(); @@ -913,9 +811,6 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: targetstoPresent.emplace_back(currentRenderTarget); - // Make sure that GL context must be created - mImpl->currentContext->GlContextCreated(); - // reset the program matrices for all programs once per frame // this ensures we will set view and projection matrix once per program per camera mImpl->programController.ResetProgramMatrices(); @@ -960,7 +855,8 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: } // Set surface orientation - mImpl->currentContext->SetSurfaceOrientation(surfaceOrientation); + // @todo Inform graphics impl by another route. + // was: mImpl->currentContext->SetSurfaceOrientation(surfaceOrientation); /*** Clear region of framebuffer or surface before drawing ***/ @@ -1022,56 +918,54 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: clippingRect, surfaceOrientation); - // Synchronise the FBO/Texture access when there are multiple contexts - if(mImpl->currentContext->IsSurfacelessContextSupported()) - { - // Check whether any bound texture is in the dependency list - bool textureFound = false; + // Synchronise the FBO/Texture access - if(mImpl->boundTextures.Count() > 0u && mImpl->textureDependencyList.Count() > 0u) + // Check whether any bound texture is in the dependency list + bool textureFound = false; + + if(mImpl->boundTextures.Count() > 0u && mImpl->textureDependencyList.Count() > 0u) + { + for(auto texture : mImpl->textureDependencyList) { - for(auto texture : mImpl->textureDependencyList) - { - textureFound = std::find_if(mImpl->boundTextures.Begin(), mImpl->boundTextures.End(), [texture](Graphics::Texture* graphicsTexture) { - return texture == graphicsTexture; - }) != mImpl->boundTextures.End(); - } + textureFound = std::find_if(mImpl->boundTextures.Begin(), mImpl->boundTextures.End(), [texture](Graphics::Texture* graphicsTexture) { + return texture == graphicsTexture; + }) != mImpl->boundTextures.End(); } + } - if(textureFound) + if(textureFound) + { + if(instruction.mFrameBuffer) { - if(instruction.mFrameBuffer) + // For off-screen buffer + + // Clear the dependency list + mImpl->textureDependencyList.Clear(); + } + else + { + // Worker thread lambda function + auto& glContextHelperAbstraction = mImpl->graphicsController.GetGlContextHelperAbstraction(); + auto workerFunction = [&glContextHelperAbstraction](int workerThread) { + // Switch to the shared context in the worker thread + glContextHelperAbstraction.MakeSurfacelessContextCurrent(); + + // Wait until all rendering calls for the shared context are executed + glContextHelperAbstraction.WaitClient(); + + // Must clear the context in the worker thread + // Otherwise the shared context cannot be switched to from the render thread + glContextHelperAbstraction.MakeContextNull(); + }; + + auto future = mImpl->threadPool->SubmitTask(0u, workerFunction); + if(future) { - // For off-screen buffer + mImpl->threadPool->Wait(); // Clear the dependency list mImpl->textureDependencyList.Clear(); } - else - { - // Worker thread lambda function - auto& glContextHelperAbstraction = mImpl->graphicsController.GetGlContextHelperAbstraction(); - auto workerFunction = [&glContextHelperAbstraction](int workerThread) { - // Switch to the shared context in the worker thread - glContextHelperAbstraction.MakeSurfacelessContextCurrent(); - - // Wait until all rendering calls for the shared context are executed - glContextHelperAbstraction.WaitClient(); - - // Must clear the context in the worker thread - // Otherwise the shared context cannot be switched to from the render thread - glContextHelperAbstraction.MakeContextNull(); - }; - - auto future = mImpl->threadPool->SubmitTask(0u, workerFunction); - if(future) - { - mImpl->threadPool->Wait(); - - // Clear the dependency list - mImpl->textureDependencyList.Clear(); - } - } } } @@ -1080,6 +974,7 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: // This will create a sync object every frame this render tracker // is alive (though it should be now be created only for // render-once render tasks) + // @todo Add syncing to Graphics API instruction.mRenderTracker->CreateSyncObject(mImpl->graphicsController.GetGlSyncAbstraction()); instruction.mRenderTracker = nullptr; // Only create once. } diff --git a/dali/internal/render/common/render-manager.h b/dali/internal/render/common/render-manager.h index e3b2297..4243b4c 100644 --- a/dali/internal/render/common/render-manager.h +++ b/dali/internal/render/common/render-manager.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -42,7 +41,6 @@ struct Vector4; namespace Internal { -class Context; class ProgramCache; class ShaderSaver; @@ -94,16 +92,6 @@ public: RenderQueue& GetRenderQueue(); /** - * @copydoc Dali::Integration::Core::ContextCreated() - */ - void ContextCreated(); - - /** - * @copydoc Dali::Integration::Core::ContextToBeDestroyed() - */ - void ContextDestroyed(); - - /** * Set the upstream interface for compiled shader binaries to be sent back to for eventual * caching and saving. * @param[in] upstream The abstract interface to send any received ShaderDatas onwards to.. @@ -341,7 +329,7 @@ public: * This is called before rendering any scene in the next frame. This method should be preceded * by a call up Update. * Multi-threading note: this method should be called from a dedicated rendering thread. - * @pre The GL context must have been created, and made current. + * @pre The graphics implementation must be initialized * @param[out] status showing whether update is required to run. * @param[in] forceClear force the Clear on the framebuffer even if nothing is rendered. * @param[in] uploadOnly uploadOnly Upload the resource only without rendering. @@ -354,7 +342,7 @@ public: * This is called before rendering any scene in the next frame. This method should be preceded * by a call up Update. * Multi-threading note: this method should be called from a dedicated rendering thread. - * @pre The GL context must have been created, and made current. + * @pre The graphics implementation must be initialized * @param[in] scene The scene to be rendered. * @param[out] damagedRects The list of damaged rects for the current render pass. */ @@ -367,7 +355,7 @@ public: * This method should be called twice. The first pass to render off-screen frame buffers if any, * and the second pass to render the surface. * Multi-threading note: this method should be called from a dedicated rendering thread. - * @pre The GL context must have been created, and made current. + * @pre The graphics implementation must be initialized * @param[out] status contains the rendering flags. * @param[in] scene The scene to be rendered. * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only. @@ -379,7 +367,7 @@ public: * This method should be called twice. The first pass to render off-screen frame buffers if any, * and the second pass to render the surface. * Multi-threading note: this method should be called from a dedicated rendering thread. - * @pre The GL context must have been created, and made current. + * @pre The graphics implementation must be initialized * @param[out] status contains the rendering flags. * @param[in] scene The scene to be rendered. * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only. @@ -393,7 +381,7 @@ public: * This is called after rendering all the scenes in the next frame. This method should be * followed by a call up RenderScene. * Multi-threading note: this method should be called from a dedicated rendering thread. - * @pre The GL context must have been created, and made current. + * @pre The graphics implementation must be initialized * @param[in] uploadOnly uploadOnly Upload the resource only without rendering. */ void PostRender(bool uploadOnly); diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp deleted file mode 100644 index 53d504f..0000000 --- a/dali/internal/render/gl-resources/context.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace // unnamed namespace -{ -static_assert(TEXTURE_UNIT_LAST <= Context::MAX_TEXTURE_UNITS, "TEXTURE_UNIT_LAST is greater than Context::MAX_TEXTURE_UNITS"); - -/** - * GL error strings - */ -struct errorStrings -{ - const GLenum errorCode; - const char* errorString; -}; -errorStrings errors[] = - { - {GL_NO_ERROR, "GL_NO_ERROR"}, - {GL_INVALID_ENUM, "GL_INVALID_ENUM"}, - {GL_INVALID_VALUE, "GL_INVALID_VALUE"}, - {GL_INVALID_OPERATION, "GL_INVALID_OPERATION"}, - {GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY"}}; - -} // unnamed namespace - -#ifdef DEBUG_ENABLED -Debug::Filter* gContextLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CONTEXT_STATE"); -#endif - -Context::Context(Integration::GlAbstraction& glAbstraction) -: Context(glAbstraction, nullptr) -{ -} - -Context::Context(Integration::GlAbstraction& glAbstraction, OwnerContainer* contexts) -: mGlAbstraction(glAbstraction), - mGlContextCreated(false), - mColorMask(true), - mStencilMask(0xFF), - mBlendEnabled(false), - mDepthBufferEnabled(false), - mDepthMaskEnabled(false), - mDitherEnabled(true), // This the only GL capability which defaults to true - mPolygonOffsetFillEnabled(false), - mSampleAlphaToCoverageEnabled(false), - mSampleCoverageEnabled(false), - mScissorTestEnabled(false), - mStencilBufferEnabled(false), - mClearColorSet(false), - mUsingDefaultBlendColor(true), - mBoundArrayBufferId(0), - mBoundElementArrayBufferId(0), - mBoundTransformFeedbackBufferId(0), - mActiveTextureUnit(TEXTURE_UNIT_LAST), - mBlendColor(Color::TRANSPARENT), - mBlendFuncSeparateSrcRGB(GL_ONE), - mBlendFuncSeparateDstRGB(GL_ZERO), - mBlendFuncSeparateSrcAlpha(GL_ONE), - mBlendFuncSeparateDstAlpha(GL_ZERO), - mBlendEquationSeparateModeRGB(GL_FUNC_ADD), - mBlendEquationSeparateModeAlpha(GL_FUNC_ADD), - mStencilFunc(GL_ALWAYS), - mStencilFuncRef(0), - mStencilFuncMask(0xFFFFFFFF), - mStencilOpFail(GL_KEEP), - mStencilOpDepthFail(GL_KEEP), - mStencilOpDepthPass(GL_KEEP), - mDepthFunction(GL_LESS), - mMaxTextureSize(0), - mClearColor(Color::WHITE), // initial color, never used until it's been set by the user - mCullFaceMode(FaceCullingMode::NONE), - mViewPort(0, 0, 0, 0), - mSceneContexts(contexts), - mSurfaceOrientation(0) -{ -} - -Context::~Context() = default; - -void Context::GlContextCreated() -{ - DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextCreated()\n"); - - if(!mGlContextCreated) - { - mGlContextCreated = true; - - // Set the initial GL state, and check it. - InitializeGlState(); - -#ifdef DEBUG_ENABLED - PrintCurrentState(); -#endif - } -} - -void Context::GlContextDestroyed() -{ - DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextDestroyed()\n"); - mGlContextCreated = false; -} - -const char* Context::ErrorToString(GLenum errorCode) -{ - for(unsigned int i = 0; i < sizeof(errors) / sizeof(errors[0]); ++i) - { - if(errorCode == errors[i].errorCode) - { - return errors[i].errorString; - } - } - return "Unknown Open GLES error"; -} - -const Rect& Context::GetViewport() -{ - return mViewPort; -} - -void Context::FlushVertexAttributeLocations() -{ - for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i) - { - // see if our cached state is different to the actual state - if(mVertexAttributeCurrentState[i] != mVertexAttributeCachedState[i]) - { - // it's different so make the change to the driver - // and update the cached state - mVertexAttributeCurrentState[i] = mVertexAttributeCachedState[i]; - - if(mVertexAttributeCurrentState[i]) - { - LOG_GL("EnableVertexAttribArray %d\n", i); - CHECK_GL(mGlAbstraction, mGlAbstraction.EnableVertexAttribArray(i)); - } - else - { - LOG_GL("DisableVertexAttribArray %d\n", i); - CHECK_GL(mGlAbstraction, mGlAbstraction.DisableVertexAttribArray(i)); - } - } - } -} - -void Context::SetVertexAttributeLocation(unsigned int location, bool state) -{ - if(location >= MAX_ATTRIBUTE_CACHE_SIZE) - { - // not cached, make the gl call through context - if(state) - { - LOG_GL("EnableVertexAttribArray %d\n", location); - CHECK_GL(mGlAbstraction, mGlAbstraction.EnableVertexAttribArray(location)); - } - else - { - LOG_GL("DisableVertexAttribArray %d\n", location); - CHECK_GL(mGlAbstraction, mGlAbstraction.DisableVertexAttribArray(location)); - } - } - else - { - // set the cached state, it will be set at the next draw call - // if it's different from the current driver state - mVertexAttributeCachedState[location] = state; - } -} - -void Context::InitializeGlState() -{ - DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::InitializeGlState()\n"); - DALI_ASSERT_DEBUG(mGlContextCreated); - - mClearColorSet = false; - mColorMask = true; - mStencilMask = 0xFF; - mBlendEnabled = false; - mDepthBufferEnabled = false; - mDepthMaskEnabled = false; - mPolygonOffsetFillEnabled = false; - mSampleAlphaToCoverageEnabled = false; - mSampleCoverageEnabled = false; - mScissorTestEnabled = false; - mStencilBufferEnabled = false; - mDitherEnabled = false; // This and GL_MULTISAMPLE are the only GL capability which defaults to true - mGlAbstraction.Disable(GL_DITHER); - - mBoundArrayBufferId = 0; - mBoundElementArrayBufferId = 0; - mBoundTransformFeedbackBufferId = 0; - mActiveTextureUnit = TEXTURE_UNIT_IMAGE; - - mUsingDefaultBlendColor = true; //Default blend color is (0,0,0,0) - - mBlendFuncSeparateSrcRGB = GL_ONE; - mBlendFuncSeparateDstRGB = GL_ZERO; - mBlendFuncSeparateSrcAlpha = GL_ONE; - mBlendFuncSeparateDstAlpha = GL_ZERO; - - // initial state is GL_FUNC_ADD for both RGB and Alpha blend modes - mBlendEquationSeparateModeRGB = GL_FUNC_ADD; - mBlendEquationSeparateModeAlpha = GL_FUNC_ADD; - - mCullFaceMode = FaceCullingMode::NONE; //By default cullface is disabled, front face is set to CCW and cull face is set to back - - // get maximum texture size - mGlAbstraction.GetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); - - // reset viewport, this will be set to something useful when rendering - mViewPort.x = mViewPort.y = mViewPort.width = mViewPort.height = 0; - - //Initialze vertex attribute cache - memset(&mVertexAttributeCachedState, 0, sizeof(mVertexAttributeCachedState)); - memset(&mVertexAttributeCurrentState, 0, sizeof(mVertexAttributeCurrentState)); - - //Initialize bound 2d texture cache - memset(&mBoundTextureId, 0, sizeof(mBoundTextureId)); - - mFrameBufferStateCache.Reset(); -} - -#ifdef DEBUG_ENABLED - -void Context::PrintCurrentState() -{ - const char* cullFaceModes[] = {"CullNone", "CullFront", "CullBack", "CullFrontAndBack"}; - DALI_LOG_INFO(gContextLogFilter, Debug::General, - "\n----------------- Context State BEGIN -----------------\n" - "Blend = %s\n" - "Cull Face = %s\n" - "Depth Test = %s\n" - "Depth Mask = %s\n" - "Dither = %s\n" - "Polygon Offset Fill = %s\n" - "Sample Alpha To Coverage = %s\n" - "Sample Coverage = %s\n" - "Scissor Test = %s\n" - "Stencil Test = %s\n" - "----------------- Context State END -----------------\n", - mBlendEnabled ? "Enabled" : "Disabled", - cullFaceModes[mCullFaceMode], - mDepthBufferEnabled ? "Enabled" : "Disabled", - mDepthMaskEnabled ? "Enabled" : "Disabled", - mDitherEnabled ? "Enabled" : "Disabled", - mPolygonOffsetFillEnabled ? "Enabled" : "Disabled", - mSampleAlphaToCoverageEnabled ? "Enabled" : "Disabled", - mSampleCoverageEnabled ? "Enabled" : "Disabled", - mScissorTestEnabled ? "Enabled" : "Disabled", - mStencilBufferEnabled ? "Enabled" : "Disabled"); -} - -#endif // DALI_CONTEXT_LOGGING - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h deleted file mode 100644 index 4052a14..0000000 --- a/dali/internal/render/gl-resources/context.h +++ /dev/null @@ -1,1874 +0,0 @@ -#ifndef DALI_INTERNAL_CONTEXT_H -#define DALI_INTERNAL_CONTEXT_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ -/** - * Context records the current GL state, and provides access to the OpenGL ES 2.0 API. - * Context avoids duplicate GL calls, if the same setting etc. is requested repeatedly. - */ -class Context -{ -public: - /** - * FrameBuffer Clear mode - */ - enum ClearMode - { - FORCE_CLEAR, ///< always perform the glClear regardless of current state - CHECK_CACHED_VALUES ///< check the Frame buffers cached state to see if a clear is required - }; - - /** - * Size of the VertexAttributeArray enables - * GLES specification states that there's minimum of 8 - */ - static constexpr unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 8; - - static constexpr unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 8 is guaranteed, which is more than DALi uses anyways - static constexpr unsigned int MAX_TEXTURE_TARGET = 3; // We support only GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP and GL_TEXTURE_EXTERNAL_OES now - - /** - * Creates the Dali Context object for surface rendering only. - * This method does not create an OpenGL context i.e. that is done from outside dali-core. - * @pre Context has not been created. - * @exception Context already created. - * @param glAbstraction the gl abstraction. - */ - Context(Integration::GlAbstraction& glAbstraction); - - /** - * Creates the Dali Context object for texture (and surface rendering if required). - * This method does not create an OpenGL context i.e. that is done from outside dali-core. - * @pre Context has not been created. - * @exception Context already created. - * @param glAbstraction the gl abstraction. - * @param contexts The list of scene contexts (for surface rendering) - */ - Context(Integration::GlAbstraction& glAbstraction, OwnerContainer* contexts); - - /** - * Destructor - */ - ~Context(); - - /** - * Called when the GL context has been created. - */ - void GlContextCreated(); - - /** - * Called when the GL context has been destroyed. - */ - void GlContextDestroyed(); - - /** - * Query whether the OpenGL context has been created. - * @return True if the OpenGL context has been created. - */ - bool IsGlContextCreated() - { - return mGlContextCreated; - } - - /** - * @return the GLAbstraction - */ - Integration::GlAbstraction& GetAbstraction() - { - return mGlAbstraction; - } - -#ifdef DEBUG_ENABLED - - /** - * Debug helper which prints the currently cached GL state. - */ - void PrintCurrentState(); - -#endif - - /** - * Helper to convert GL error code to string - * @param errorCode to convert - * @return C string - */ - const char* ErrorToString(GLenum errorCode); - - /** - * Helper to print GL string to debug log - */ - void PrintGlString(const char* stringName, GLenum stringId) - { - DALI_LOG_INFO(Debug::Filter::gRender, Debug::General, "GL %s = %s\n", stringName, reinterpret_cast(GetString(stringId))); - } - - /** - * Reset the cached buffer ids. - */ - void ResetBufferCache() - { - // reset the cached buffer id's - // fixes problem where some drivers will a generate a buffer with the - // same id, as the last deleted buffer id. - mBoundArrayBufferId = 0; - mBoundElementArrayBufferId = 0; - mBoundTransformFeedbackBufferId = 0; - } - - /** - * Reset the cached texture ids. - */ - void ResetTextureCache() - { - // reset the cached texture id's in case the driver re-uses them - // when creating new textures - for(unsigned int i = 0; i < MAX_TEXTURE_UNITS; ++i) - { - for(unsigned int j = 0; j < MAX_TEXTURE_TARGET; ++j) - { - mBoundTextureId[i][j] = 0; - } - } - } - - /** - * Get an index of the cached texture list from the texture target. - * @param target The texture target - * @return The index of the cached texture list - */ - static constexpr int16_t GetTextureIndexFromGlFormat(int target) - { - switch(target) - { - case GL_TEXTURE_2D: - { - return 0; - } - case GL_TEXTURE_CUBE_MAP: - { - return 1; - } - case GL_TEXTURE_EXTERNAL_OES: - { - return 2; - } - default: - { - return -1; - } - } - } - - /**************************************************************************************** - * The following methods are forwarded to Dali::Integration::GlAbstraction. - * In some cases the GL state is recorded, to avoid duplicate calls with the same state. - * All Shader, Program, Uniform and Attribute related calls are not here, Program class - * handles them and optimizes any program related state changes - ****************************************************************************************/ - - /** - * Wrapper for IsSurfacelessContextSupported of Dali::Integration::GlAbstraction - */ - bool IsSurfacelessContextSupported() const - { - return mGlAbstraction.IsSurfacelessContextSupported(); - } - - /** - * Wrapper for TextureRequiresConverting of Dali::Integration::GlAbstraction - */ - bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const - { - return mGlAbstraction.TextureRequiresConverting(imageGlFormat, textureGlFormat, isSubImage); - } - - /** - * Wrapper for OpenGL ES 2.0 glActiveTexture() - */ - void ActiveTexture(TextureUnit textureUnit) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mActiveTextureUnit = textureUnit; - LOG_GL("ActiveTexture %x\n", textureUnit); - CHECK_GL(mGlAbstraction, mGlAbstraction.ActiveTexture(TextureUnitAsGLenum(textureUnit))); - } - - /** - * Wrapper for OpenGL ES 3.0 glBeginQuery() - */ - void BeginQuery(GLenum target, GLuint id) - { - LOG_GL("BeginQuery %d %d\n", target, id); - CHECK_GL(mGlAbstraction, mGlAbstraction.BeginQuery(target, id)); - } - - /** - * Wrapper for OpenGL ES 3.0 glBeginTransformFeedback() - */ - void BeginTransformFeedback(GLenum primitiveMode) - { - LOG_GL("BeginTransformFeedback %x\n", primitiveMode); - CHECK_GL(mGlAbstraction, mGlAbstraction.BeginTransformFeedback(primitiveMode)); - } - - /** - * The wrapper for OpenGL ES 2.0 glBindBuffer() has been replaced by BindArrayBuffer & BindElementArrayBuffer & BindTransformFeedbackBuffer. - */ - - /** - * Wrapper for OpenGL ES 2.0 glBindBuffer(GL_ARRAY_BUFFER, ...) - */ - void BindArrayBuffer(GLuint buffer) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBoundArrayBufferId = buffer; - - LOG_GL("BindBuffer GL_ARRAY_BUFFER %d\n", buffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindBuffer(GL_ARRAY_BUFFER, buffer)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ...) - */ - void BindElementArrayBuffer(GLuint buffer) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBoundElementArrayBufferId = buffer; - - LOG_GL("BindBuffer GL_ELEMENT_ARRAY_BUFFER %d\n", buffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer)); - } - - /** - * Wrapper for OpenGL ES 3.0 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, ...) - */ - void BindTransformFeedbackBuffer(GLuint buffer) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBoundTransformFeedbackBufferId = buffer; - - LOG_GL("BindBuffer GL_TRANSFORM_FEEDBACK_BUFFER %d\n", buffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buffer)); - } - - /** - * Wrapper for OpenGL ES 3.0 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, ...) - */ - void BindTransformFeedbackBufferBase(GLuint index, GLuint buffer) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBoundTransformFeedbackBufferId = buffer; - - LOG_GL("BindBufferBase GL_TRANSFORM_FEEDBACK_BUFFER %d %d\n", index, buffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, index, buffer)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBindFramebuffer() - */ - void BindFramebuffer(GLenum target, GLuint framebuffer) - { - mFrameBufferStateCache.SetCurrentFrameBuffer(framebuffer); - - LOG_GL("BindFramebuffer %d %d\n", target, framebuffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindFramebuffer(target, framebuffer)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBindRenderbuffer() - */ - void BindRenderbuffer(GLenum target, GLuint renderbuffer) - { - LOG_GL("BindRenderbuffer %d %d\n", target, renderbuffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindRenderbuffer(target, renderbuffer)); - } - - /** - * Wrapper for OpenGL ES 3.0 glBindTransformFeedback() - */ - void BindTransformFeedback(GLenum target, GLuint id) - { - LOG_GL("BindTransformFeedback %d %d\n", target, id); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindTransformFeedback(target, id)); - } - - /** - * Helper to bind texture for rendering. If given texture is - * already bound in the given textureunit, this method does nothing. - * Otherwise changes the active texture unit and binds the texture. - * Note! after this call active texture unit may not necessarily be the one - * passed in as argument so you cannot change texture unit state!! - * @param textureunit to bind to - * @param texture to bind - */ - void BindTextureForUnit(TextureUnit textureunit, int target, GLuint texture) - { - ActiveTexture(textureunit); - BindTexture(target, texture); - } - - /** - * Wrapper for OpenGL ES 2.0 glBindTexture( target ) - */ - void BindTexture(int target, GLuint texture) - { - int16_t index = GetTextureIndexFromGlFormat(target); - if(index >= 0) - { - mBoundTextureId[mActiveTextureUnit][index] = texture; - } - - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - LOG_GL("BindTexture target(%d) %d\n", target, texture); - CHECK_GL(mGlAbstraction, mGlAbstraction.BindTexture(target, texture)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendColor() - */ - void SetDefaultBlendColor() - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - SetCustomBlendColor(Color::TRANSPARENT); - mUsingDefaultBlendColor = true; - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendColor() - */ - void SetCustomBlendColor(const Vector4& color) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - LOG_GL("BlendColor %f %f %f %f\n", color.r, color.g, color.b, color.a); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlendColor(color.r, color.g, color.b, color.a)); - mUsingDefaultBlendColor = false; - mBlendColor = color; - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendEquation() - */ - void BlendEquation(GLenum mode) - { - // DO NOT USE BlendEquationSeparate to set the same rgb and alpha modes - // KHR blending extensions require use of glBlendEquation - - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBlendEquationSeparateModeRGB = mode; - mBlendEquationSeparateModeAlpha = mode; - LOG_GL("BlendEquation %d\n", mode); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlendEquation(mode)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendEquationSeparate() - */ - void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBlendEquationSeparateModeRGB = modeRGB; - mBlendEquationSeparateModeAlpha = modeAlpha; - LOG_GL("BlendEquationSeparate %d %d\n", modeRGB, modeAlpha); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlendEquationSeparate(modeRGB, modeAlpha)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendFunc() - */ - void BlendFunc(GLenum sfactor, GLenum dfactor) - { - // reuse the BlendFuncSeparate as thats what the DDK does anyways - BlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendFuncSeparate() - */ - void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBlendFuncSeparateSrcRGB = srcRGB; - mBlendFuncSeparateDstRGB = dstRGB; - mBlendFuncSeparateSrcAlpha = srcAlpha; - mBlendFuncSeparateDstAlpha = dstAlpha; - - LOG_GL("BlendFuncSeparate %d %d %d %d\n", srcRGB, dstRGB, srcAlpha, dstAlpha); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)); - } - - /** - * Wrapper for OpenGL ES 3.0 glBlitFramebuffer() - */ - void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) - { - LOG_GL("BlitFramebuffer %d %d %d %d %d %d %d %d %x %d\n", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBufferData() - */ - void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) - { - LOG_GL("BufferData %d %d %p %d\n", target, size, data, usage); - CHECK_GL(mGlAbstraction, mGlAbstraction.BufferData(target, size, data, usage)); - } - - /** - * Wrapper for OpenGL ES 2.0 glBufferSubData() - */ - void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) - { - LOG_GL("BufferSubData %d %d %d %p\n", target, offset, size, data); - CHECK_GL(mGlAbstraction, mGlAbstraction.BufferSubData(target, offset, size, data)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCheckFramebufferStatus() - */ - GLenum CheckFramebufferStatus(GLenum target) - { - LOG_GL("CheckFramebufferStatus %d\n", target); - GLenum value = CHECK_GL(mGlAbstraction, mGlAbstraction.CheckFramebufferStatus(target)); - return value; - } - - /** - * Wrapper for OpenGL ES 2.0 glClear() - */ - void Clear(GLbitfield mask, ClearMode mode) - { - bool forceClear = (mode == FORCE_CLEAR); - mask = mFrameBufferStateCache.GetClearMask(mask, forceClear, mScissorTestEnabled); - - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - LOG_GL("Clear %d\n", mask); - CHECK_GL(mGlAbstraction, mGlAbstraction.Clear(mask)); - } - - /** - * Wrapper for OpenGL ES 2.0 glClearColor() - */ - void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) - { - Vector4 newCol(red, green, blue, alpha); - - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - LOG_GL("ClearColor %f %f %f %f\n", red, green, blue, alpha); - CHECK_GL(mGlAbstraction, mGlAbstraction.ClearColor(red, green, blue, alpha)); - - mClearColorSet = true; - mClearColor = newCol; - } - - /** - * Wrapper for OpenGL ES 2.0 glClearDepthf() - */ - void ClearDepthf(GLclampf depth) - { - LOG_GL("ClearDepthf %f\n", depth); - CHECK_GL(mGlAbstraction, mGlAbstraction.ClearDepthf(depth)); - } - - /** - * Wrapper for OpenGL ES 2.0 glClearStencil() - */ - void ClearStencil(GLint s) - { - LOG_GL("ClearStencil %d\n", s); - CHECK_GL(mGlAbstraction, mGlAbstraction.ClearStencil(s)); - } - - /** - * Wrapper for OpenGL ES 2.0 glColorMask() - * @note This has been optimized to a single boolean value (masking individual channels is not required) - */ - void ColorMask(bool flag) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mColorMask = flag; - LOG_GL("ColorMask %s %s %s %s\n", flag ? "True" : "False", flag ? "True" : "False", flag ? "True" : "False", flag ? "True" : "False"); - CHECK_GL(mGlAbstraction, mGlAbstraction.ColorMask(flag, flag, flag, flag)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCompressedTexImage2D() - */ - void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) - { - LOG_GL("CompressedTexImage2D %d %d %x %d %d %d %d %p\n", target, level, internalformat, width, height, border, imageSize, data); - CHECK_GL(mGlAbstraction, mGlAbstraction.CompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data)); - } - - /** - * Wrapper for OpenGL ES 3.0 glCompressedTexImage3D() - */ - void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data) - { - LOG_GL("CompressedTexImage3D %d %d %x %d %d %d %d %d %p\n", target, level, internalformat, width, height, depth, border, imageSize, data); - CHECK_GL(mGlAbstraction, mGlAbstraction.CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCompressedTexSubImage2D() - */ - void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) - { - LOG_GL("CompressedTexSubImage2D %x %d %d %d %d %d %x %d %p\n", target, level, xoffset, yoffset, width, height, format, imageSize, data); - CHECK_GL(mGlAbstraction, mGlAbstraction.CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data)); - } - - /** - * Wrapper for OpenGL ES 3.0 glCompressedTexSubImage3D() - */ - void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data) - { - LOG_GL("CompressedTexSubImage3D %x %d %d %d %d %d %d %d %x %d %p\n", target, level, xoffset, yoffset, xoffset, width, height, depth, format, imageSize, data); - CHECK_GL(mGlAbstraction, mGlAbstraction.CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCopyTexImage2D() - */ - void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) - { - LOG_GL("CopyTexImage2D %x %d %x %d %d %d %d %d\n", target, level, internalformat, x, y, width, height, border); - CHECK_GL(mGlAbstraction, mGlAbstraction.CopyTexImage2D(target, level, internalformat, x, y, width, height, border)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCopyTexSubImage2D() - */ - void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) - { - LOG_GL("CopyTexSubImage2D %x %d %d %d %d %d %d %d\n", target, level, xoffset, yoffset, x, y, width, height); - CHECK_GL(mGlAbstraction, mGlAbstraction.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height)); - } - - /** - * Wrapper for OpenGL ES 3.0 glCopyTexSubImage3D() - */ - void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) - { - LOG_GL("CopyTexSubImage3D %x %d %d %d %d %d %d %d %d\n", target, level, xoffset, yoffset, zoffset, x, y, width, height); - CHECK_GL(mGlAbstraction, mGlAbstraction.CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height)); - } - - /** - * Wrapper for OpenGL ES 2.0 glCullFace() - * enables GL_CULL_FACE if in any of the face culling modes - * otherwise disables GL_CULL_FACE - */ - void CullFace(Dali::FaceCullingMode::Type mode) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mCullFaceMode = mode; - switch(mode) - { - case Dali::FaceCullingMode::NONE: - { - LOG_GL("Disable GL_CULL_FACE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_CULL_FACE)); - break; - } - - case Dali::FaceCullingMode::FRONT: - { - LOG_GL("Enable GL_CULL_FACE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE)); - LOG_GL("Enable GL_FRONT\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.CullFace(GL_FRONT)); - break; - } - - case Dali::FaceCullingMode::BACK: - { - LOG_GL("Enable GL_CULL_FACE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE)); - LOG_GL("Enable GL_BACK\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.CullFace(GL_BACK)); - break; - } - - case Dali::FaceCullingMode::FRONT_AND_BACK: - { - LOG_GL("Enable GL_CULL_FACE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE)); - LOG_GL("Enable GL_FRONT_AND_BACK\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.CullFace(GL_FRONT_AND_BACK)); - break; - } - - default: - break; - } - } - - /** - * Wrapper for OpenGL ES 2.0 glDeleteBuffers() - */ - void DeleteBuffers(GLsizei n, const GLuint* buffers) - { - if(this->IsGlContextCreated()) - { - LOG_GL("DeleteBuffers %d %p\n", n, buffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteBuffers(n, buffers)); - } - - ResetBufferCache(); - - // Need to reset the buffer cache in the surface contexts - // This will only be executed by the surfaceless context when there are contexts for surface rendering - if(mSceneContexts) - { - for(auto&& context : *mSceneContexts) - { - if(context) - { - context->ResetBufferCache(); - } - } - } - } - - /** - * Wrapper for OpenGL ES 2.0 glDeleteFramebuffers() - */ - void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) - { - mFrameBufferStateCache.FrameBuffersDeleted(n, framebuffers); - - LOG_GL("DeleteFramebuffers %d %p\n", n, framebuffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteFramebuffers(n, framebuffers)); - } - - /** - * Wrapper for OpenGL ES 3.0 glDeleteQueries() - */ - void DeleteQueries(GLsizei n, GLuint* ids) - { - LOG_GL("DeleteQueries %d %p\n", n, ids); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteQueries(n, ids)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDeleteRenderbuffers() - */ - void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) - { - LOG_GL("DeleteRenderbuffers %d %p\n", n, renderbuffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteRenderbuffers(n, renderbuffers)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDeleteTextures() - */ - void DeleteTextures(GLsizei n, const GLuint* textures) - { - LOG_GL("DeleteTextures %d %p\n", n, textures); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteTextures(n, textures)); - - ResetTextureCache(); - - // Need to reset the texture cache in the scene contexts - // This will only be executed by the surfaceless context when there are contexts for surface rendering - if(mSceneContexts) - { - for(auto&& context : *mSceneContexts) - { - if(context) - { - context->ResetTextureCache(); - } - } - } - } - - /** - * Wrapper for OpenGL ES 3.0 glDeleteTransformFeedbacks() - */ - void DeleteTransformFeedbacks(GLsizei n, GLuint* ids) - { - LOG_GL("DeleteTransformFeedbacks %d %p\n", n, ids); - CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteTransformFeedbacks(n, ids)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDepthFunc() - */ - void DepthFunc(GLenum func) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mDepthFunction = func; - LOG_GL("DepthFunc %x\n", func); - CHECK_GL(mGlAbstraction, mGlAbstraction.DepthFunc(func)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDepthMask() - */ - void DepthMask(GLboolean flag) - { - bool booleanFlag = flag != GL_FALSE; - - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mDepthMaskEnabled = booleanFlag; - LOG_GL("DepthMask %s\n", booleanFlag ? "True" : "False"); - CHECK_GL(mGlAbstraction, mGlAbstraction.DepthMask(mDepthMaskEnabled)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDepthRangef() - */ - void DepthRangef(GLclampf zNear, GLclampf zFar) - { - LOG_GL("DepthRangef %f %f\n", zNear, zFar); - CHECK_GL(mGlAbstraction, mGlAbstraction.DepthRangef(zNear, zFar)); - } - - /** - * The wrapper for OpenGL ES 2.0 glDisable() has been replaced by SetBlend, SetCullFace, SetDepthTest, - * SetDither, SetPolygonOffsetFill, SetSampleAlphaToCoverage, SetSampleCoverage, SetScissorTest & SetStencilTest. - */ - - /** - * Wrapper for OpenGL ES 2.0 glDrawArrays() - */ - void DrawArrays(GLenum mode, GLint first, GLsizei count) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - FlushVertexAttributeLocations(); - - LOG_GL("DrawArrays %x %d %d\n", mode, first, count); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawArrays(mode, first, count)); - } - - /** - * Wrapper for OpenGL ES 3.0 glDrawArraysInstanced() - */ - void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - FlushVertexAttributeLocations(); - - LOG_GL("DrawArraysInstanced %x %d %d %d\n", mode, first, count, instanceCount); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawArraysInstanced(mode, first, count, instanceCount)); - } - - /** - * Wrapper for OpenGL ES 3.0 glDrawBuffers() - */ - void DrawBuffers(GLsizei n, const GLenum* bufs) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - LOG_GL("DrawBuffers %d %p\n", n, bufs); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawBuffers(n, bufs)); - } - - /** - * Wrapper for OpenGL ES 2.0 glDrawElements() - */ - void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - - FlushVertexAttributeLocations(); - - LOG_GL("DrawElements %x %d %d %p\n", mode, count, type, indices); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawElements(mode, count, type, indices)); - } - - /** - * Wrapper for OpenGL ES 3.0 glDrawElementsInstanced() - */ - void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instanceCount) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - - FlushVertexAttributeLocations(); - - LOG_GL("DrawElementsInstanced %x %d %d %p %d\n", mode, count, type, indices, instanceCount); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawElementsInstanced(mode, count, type, indices, instanceCount)); - } - - /** - * Wrapper for OpenGL ES 3.0 glDrawRangeElements() - */ - void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) - { - mFrameBufferStateCache.DrawOperation(mColorMask, DepthBufferWriteEnabled(), StencilBufferWriteEnabled()); - FlushVertexAttributeLocations(); - - LOG_GL("DrawRangeElements %x %u %u %d %d %p\n", mode, start, end, count, type, indices); - CHECK_GL(mGlAbstraction, mGlAbstraction.DrawRangeElements(mode, start, end, count, type, indices)); - } - - /** - * Wrapper for OpenGL ES 3.0 glGenQuerieS() - */ - void GenQueries(GLsizei n, GLuint* ids) - { - LOG_GL("GenQueries %d %p\n", n, ids); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenQueries(n, ids)); - } - - /** - * Wrapper for OpenGL ES 3.0 glGenTransformFeedbacks() - */ - void GenTransformFeedbacks(GLsizei n, GLuint* ids) - { - LOG_GL("GenTransformFeedbacks %d %p\n", n, ids); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenTransformFeedbacks(n, ids)); - } - - /** - * @return the current buffer bound for a given target - */ - GLuint GetCurrentBoundArrayBuffer(GLenum target) - { - GLuint result(0); - switch(target) - { - case GL_ARRAY_BUFFER: - { - result = mBoundArrayBufferId; - break; - } - case GL_ELEMENT_ARRAY_BUFFER: - { - result = mBoundElementArrayBufferId; - break; - } - case GL_TRANSFORM_FEEDBACK_BUFFER: - { - result = mBoundTransformFeedbackBufferId; - break; - } - default: - { - DALI_ASSERT_DEBUG(0 && "target buffer type not supported"); - } - } - return result; - } - - void EnableVertexAttributeArray(GLuint location) - { - SetVertexAttributeLocation(location, true); - } - - void DisableVertexAttributeArray(GLuint location) - { - SetVertexAttributeLocation(location, false); - } - - /** - * Wrapper for OpenGL ES 3.0 glVertexAttribDivisor() - */ - void VertexAttribDivisor(GLuint index, GLuint divisor) - { - LOG_GL("VertexAttribDivisor(%d, %d)\n", index, divisor); - CHECK_GL(mGlAbstraction, mGlAbstraction.VertexAttribDivisor(index, divisor)); - } - - /** - * Wrapper for OpenGL ES 2.0 glVertexAttribPointer() - */ - void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) - { - LOG_GL("VertexAttribPointer(%d, %d, %d, %d, %d, %x)\n", index, size, type, normalized, stride, ptr); - CHECK_GL(mGlAbstraction, mGlAbstraction.VertexAttribPointer(index, size, type, normalized, stride, ptr)); - } - - /** - * Wrapper for OpenGL ES 3.0 glInvalidateFramebuffer() - */ - void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) - { - LOG_GL("InvalidateFramebuffer\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.InvalidateFramebuffer(target, numAttachments, attachments)); - } - - /** - * The wrapper for OpenGL ES 2.0 glEnable() has been replaced by SetBlend, SetCullFace, SetDepthTest, - * SetDither, SetPolygonOffsetFill, SetSampleAlphaToCoverage, SetSampleCoverage, SetScissorTest & SetStencilTest. - */ - - /** - * This method replaces glEnable(GL_BLEND) and glDisable(GL_BLEND). - * @param[in] enable True if GL_BLEND should be enabled. - */ - void SetBlend(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mBlendEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_BLEND\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_BLEND)); - } - else - { - LOG_GL("Disable GL_BLEND\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_BLEND)); - } - } - - /** - * This method replaces glEnable(GL_DEPTH_TEST) and glDisable(GL_DEPTH_TEST). - * Note GL_DEPTH_TEST means enable the depth buffer for writing and or testing. - * glDepthMask is used to enable / disable writing to depth buffer. - * glDepthFunc us used to control if testing is enabled and how it is performed ( default GL_LESS) - * - * @param[in] enable True if GL_DEPTH_TEST should be enabled. - */ - void EnableDepthBuffer(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mDepthBufferEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_DEPTH_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_DEPTH_TEST)); - } - else - { - LOG_GL("Disable GL_DEPTH_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_DEPTH_TEST)); - } - } - - /** - * This method replaces glEnable(GL_DITHER) and glDisable(GL_DITHER). - * @param[in] enable True if GL_DITHER should be enabled. - */ - void SetDither(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mDitherEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_DITHER\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_DITHER)); - } - else - { - LOG_GL("Disable GL_DITHER\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_DITHER)); - } - } - - /** - * This method replaces glEnable(GL_POLYGON_OFFSET_FILL) and glDisable(GL_POLYGON_OFFSET_FILL). - * @param[in] enable True if GL_POLYGON_OFFSET_FILL should be enabled. - */ - void SetPolygonOffsetFill(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mPolygonOffsetFillEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_POLYGON_OFFSET_FILL\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_POLYGON_OFFSET_FILL)); - } - else - { - LOG_GL("Disable GL_POLYGON_OFFSET_FILL\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_POLYGON_OFFSET_FILL)); - } - } - - /** - * This method replaces glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE) and glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE). - * @param[in] enable True if GL_SAMPLE_ALPHA_TO_COVERAGE should be enabled. - */ - void SetSampleAlphaToCoverage(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mSampleAlphaToCoverageEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_SAMPLE_ALPHA_TO_COVERAGE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_SAMPLE_ALPHA_TO_COVERAGE)); - } - else - { - LOG_GL("Disable GL_SAMPLE_ALPHA_TO_COVERAGE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_SAMPLE_ALPHA_TO_COVERAGE)); - } - } - - /** - * This method replaces glEnable(GL_SAMPLE_COVERAGE) and glDisable(GL_SAMPLE_COVERAGE). - * @param[in] enable True if GL_SAMPLE_COVERAGE should be enabled. - */ - void SetSampleCoverage(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mSampleCoverageEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_SAMPLE_COVERAGE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_SAMPLE_COVERAGE)); - } - else - { - LOG_GL("Disable GL_SAMPLE_COVERAGE\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_SAMPLE_COVERAGE)); - } - } - - /** - * This method replaces glEnable(GL_SCISSOR_TEST) and glDisable(GL_SCISSOR_TEST). - * @param[in] enable True if GL_SCISSOR_TEST should be enabled. - */ - void SetScissorTest(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mScissorTestEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_SCISSOR_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_SCISSOR_TEST)); - } - else - { - LOG_GL("Disable GL_SCISSOR_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_SCISSOR_TEST)); - } - } - - /** - * This method replaces glEnable(GL_STENCIL_TEST) and glDisable(GL_STENCIL_TEST). - * Note GL_STENCIL_TEST means enable the stencil buffer for writing and or testing. - * glStencilMask is used to control how bits are written to the stencil buffer. - * glStencilFunc is used to control if testing is enabled and how it is performed ( default GL_ALWAYS ) - * @param[in] enable True if GL_STENCIL_TEST should be enabled. - */ - void EnableStencilBuffer(bool enable) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mStencilBufferEnabled = enable; - - if(enable) - { - LOG_GL("Enable GL_STENCIL_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Enable(GL_STENCIL_TEST)); - } - else - { - LOG_GL("Disable GL_STENCIL_TEST\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Disable(GL_STENCIL_TEST)); - } - } - - /** - * Wrapper for OpenGL ES 3.0 glEndQuery() - */ - void EndQuery(GLenum target) - { - LOG_GL("EndQuery %d\n", target); - CHECK_GL(mGlAbstraction, mGlAbstraction.EndQuery(target)); - } - - /** - * Wrapper for OpenGL ES 3.0 glEndTransformFeedback() - */ - void EndTransformFeedback() - { - LOG_GL("EndTransformFeedback\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.EndTransformFeedback()); - } - - /** - * Wrapper for OpenGL ES 2.0 glFinish() - */ - void Finish(void) - { - LOG_GL("Finish\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Finish()); - } - - /** - * Wrapper for OpenGL ES 2.0 glFlush() - */ - void Flush(void) - { - LOG_GL("Flush\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.Flush()); - } - - /** - * Wrapper for OpenGL ES 2.0 glFramebufferRenderbuffer() - */ - void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) - { - LOG_GL("FramebufferRenderbuffer %x %x %x %d\n", target, attachment, renderbuffertarget, renderbuffer); - CHECK_GL(mGlAbstraction, mGlAbstraction.FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer)); - } - - /** - * Wrapper for OpenGL ES 2.0 glFramebufferTexture2D() - */ - void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) - { - LOG_GL("FramebufferTexture2D %x %x %x %d %d\n", target, attachment, textarget, texture, level); - CHECK_GL(mGlAbstraction, mGlAbstraction.FramebufferTexture2D(target, attachment, textarget, texture, level)); - } - - /** - * Wrapper for OpenGL ES 3.0 glFramebufferTextureLayer() - */ - void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) - { - LOG_GL("FramebufferTextureLayer %x %x %d %d %d\n", target, attachment, texture, level, layer); - CHECK_GL(mGlAbstraction, mGlAbstraction.FramebufferTextureLayer(target, attachment, texture, level, layer)); - } - - /** - * Wrapper for OpenGL ES 2.0 glFrontFace() - */ - void FrontFace(GLenum mode) - { - LOG_GL("FrontFace %x\n", mode); - CHECK_GL(mGlAbstraction, mGlAbstraction.FrontFace(mode)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGenBuffers() - */ - void GenBuffers(GLsizei n, GLuint* buffers) - { - LOG_GL("GenBuffers %d\n", n, buffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenBuffers(n, buffers)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGenerateMipmap() - */ - void GenerateMipmap(GLenum target) - { - LOG_GL("GenerateMipmap %x\n", target); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenerateMipmap(target)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGenFramebuffers() - */ - void GenFramebuffers(GLsizei n, GLuint* framebuffers) - { - LOG_GL("GenFramebuffers %d %p\n", n, framebuffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenFramebuffers(n, framebuffers)); - - mFrameBufferStateCache.FrameBuffersCreated(n, framebuffers); - } - - /** - * Wrapper for OpenGL ES 2.0 glGenRenderbuffers() - */ - void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) - { - LOG_GL("GenRenderbuffers %d %p\n", n, renderbuffers); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenRenderbuffers(n, renderbuffers)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGenTextures() - */ - void GenTextures(GLsizei n, GLuint* textures) - { - LOG_GL("GenTextures %d %p\n", n, textures); - CHECK_GL(mGlAbstraction, mGlAbstraction.GenTextures(n, textures)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetBooleanv() - */ - void GetBooleanv(GLenum pname, GLboolean* params) - { - LOG_GL("GetBooleanv %x\n", pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetBooleanv(pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetBufferParameteriv() - */ - void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) - { - LOG_GL("GetBufferParameteriv %x %x %p\n", target, pname, params); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetBufferParameteriv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 3.0 glGetBufferPointer() - */ - void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) - { - LOG_GL("GetBufferPointerv %x %x %p\n", target, pname, params); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetBufferPointerv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetError() - */ - GLenum GetError(void) - { - // Not worth logging here - return mGlAbstraction.GetError(); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetFloatv() - */ - void GetFloatv(GLenum pname, GLfloat* params) - { - LOG_GL("GetFloatv %x\n", pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetFloatv(pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetFramebufferAttachmentParameteriv() - */ - void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) - { - LOG_GL("GetFramebufferAttachmentParameteriv %x %x %x\n", target, attachment, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetFramebufferAttachmentParameteriv(target, attachment, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetIntegerv() - */ - void GetIntegerv(GLenum pname, GLint* params) - { - LOG_GL("GetIntegerv %x\n", pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetIntegerv(pname, params)); - } - - /** - * Wrapper for OpenGL ES 3.0 glGetQueryiv() - */ - void GetQueryiv(GLenum target, GLenum pname, GLint* params) - { - LOG_GL("GetQueryiv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetQueryiv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 3.0 glGetQueryObjectuiv() - */ - void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) - { - LOG_GL("GetQueryObjectuiv %u %x %p\n", id, pname, params); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetQueryObjectuiv(id, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetRenderbufferParameteriv() - */ - void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) - { - LOG_GL("GetRenderbufferParameteriv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetRenderbufferParameteriv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetString() - */ - const GLubyte* GetString(GLenum name) - { - LOG_GL("GetString %x\n", name); - const GLubyte* str = CHECK_GL(mGlAbstraction, mGlAbstraction.GetString(name)); - return str; - } - - /** - * Wrapper for OpenGL ES 2.0 glGetTexParameterfv() - */ - void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) - { - LOG_GL("GetTexParameterfv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetTexParameterfv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glGetTexParameteriv() - */ - void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) - { - LOG_GL("GetTexParameteriv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.GetTexParameteriv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glHint() - */ - void Hint(GLenum target, GLenum mode) - { - LOG_GL("Hint %x %x\n", target, mode); - CHECK_GL(mGlAbstraction, mGlAbstraction.Hint(target, mode)); - } - - /** - * Wrapper for OpenGL ES 2.0 glIsBuffer() - */ - GLboolean IsBuffer(GLuint buffer) - { - LOG_GL("IsBuffer %d\n", buffer); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsBuffer(buffer)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glIsEnabled() - */ - GLboolean IsEnabled(GLenum cap) - { - LOG_GL("IsEnabled %x\n", cap); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsEnabled(cap)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glIsFramebuffer() - */ - GLboolean IsFramebuffer(GLuint framebuffer) - { - LOG_GL("IsFramebuffer %d\n", framebuffer); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsFramebuffer(framebuffer)); - return val; - } - - /** - * Wrapper for OpenGL ES 3.0 glIsQuery() - */ - GLboolean IsQuery(GLuint id) - { - LOG_GL("IsQuery %u\n", id); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsQuery(id)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glIsRenderbuffer() - */ - GLboolean IsRenderbuffer(GLuint renderbuffer) - { - LOG_GL("IsRenderbuffer %d\n", renderbuffer); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsRenderbuffer(renderbuffer)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glIsTexture() - */ - GLboolean IsTexture(GLuint texture) - { - LOG_GL("IsTexture %d\n", texture); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsTexture(texture)); - return val; - } - - /** - * Wrapper for OpenGL ES 3.0 glIsTransformFeedback() - */ - GLboolean IsTransformFeedback(GLuint id) - { - LOG_GL("IsTransformFeedback %u\n", id); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.IsTransformFeedback(id)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glLineWidth() - */ - void LineWidth(GLfloat width) - { - LOG_GL("LineWidth %f\n", width); - CHECK_GL(mGlAbstraction, mGlAbstraction.LineWidth(width)); - } - - /** - * Wrapper for OpenGL ES 3.0 glPauseTransformFeedback() - */ - void PauseTransformFeedback() - { - LOG_GL("PauseTransformFeedback\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.PauseTransformFeedback()); - } - - /** - * Wrapper for OpenGL ES 2.0 glPixelStorei() - */ - void PixelStorei(GLenum pname, GLint param) - { - LOG_GL("PixelStorei %x %d\n", pname, param); - CHECK_GL(mGlAbstraction, mGlAbstraction.PixelStorei(pname, param)); - } - - /** - * Wrapper for OpenGL ES 2.0 glPolygonOffset() - */ - void PolygonOffset(GLfloat factor, GLfloat units) - { - LOG_GL("PolygonOffset %f %f\n", factor, units); - CHECK_GL(mGlAbstraction, mGlAbstraction.PolygonOffset(factor, units)); - } - - /** - * Wrapper for OpenGL ES 2.0 glReadPixels() - */ - void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) - { - LOG_GL("ReadPixels %d %d %d %d %x %x\n", x, y, width, height, format, type); - CHECK_GL(mGlAbstraction, mGlAbstraction.ReadPixels(x, y, width, height, format, type, pixels)); - } - - /** - * Wrapper for OpenGL ES 2.0 glRenderbufferStorage() - */ - void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) - { - LOG_GL("RenderbufferStorage %x %x %d %d\n", target, internalformat, width, height); - CHECK_GL(mGlAbstraction, mGlAbstraction.RenderbufferStorage(target, internalformat, width, height)); - } - - /** - * Wrapper for OpenGL ES 3.0 glRenderbufferStorageMultisample() - */ - void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) - { - LOG_GL("RenderbufferStorageMultisample %x %u %x %d %d\n", target, samples, internalformat, width, height); - CHECK_GL(mGlAbstraction, mGlAbstraction.RenderbufferStorageMultisample(target, samples, internalformat, width, height)); - } - - /** - * Wrapper for OpenGL ES 3.0 glResumeTransformFeedback() - */ - void ResumeTransformFeedback() - { - LOG_GL("ResumeTransformFeedback\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.ResumeTransformFeedback()); - } - - /** - * Wrapper for OpenGL ES 2.0 glSampleCoverage() - */ - void SampleCoverage(GLclampf value, GLboolean invert) - { - LOG_GL("SampleCoverage %f %s\n", value, invert ? "True" : "False"); - CHECK_GL(mGlAbstraction, mGlAbstraction.SampleCoverage(value, invert)); - } - - /** - * Wrapper for OpenGL ES 2.0 glScissor() - */ - void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) - { - GLint cx, cy, cw, ch; - - // scissor's value should be set based on the default system coordinates. - // when the surface is rotated, the input valus already were set with the rotated angle. - // So, re-calculation is needed. - if(mSurfaceOrientation == 90) - { - cx = mViewPort.height - (y + height); - cy = x; - cw = height; - ch = width; - } - else if(mSurfaceOrientation == 180) - { - cx = mViewPort.width - (x + width); - cy = mViewPort.height - (y + height); - cw = width; - ch = height; - } - else if(mSurfaceOrientation == 270) - { - cx = y; - cy = mViewPort.width - (x + width); - cw = height; - ch = width; - } - else - { - cx = x; - cy = y; - cw = width; - ch = height; - } - - LOG_GL("Scissor %d %d %d %d\n", cx, cy, cw, ch); - CHECK_GL(mGlAbstraction, mGlAbstraction.Scissor(cx, cy, cw, ch)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilFunc() - */ - void StencilFunc(GLenum func, GLint ref, GLuint mask) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mStencilFunc = func; - mStencilFuncRef = ref; - mStencilFuncMask = mask; - - LOG_GL("StencilFunc %x %d %d\n", func, ref, mask); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilFunc(func, ref, mask)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilFuncSeparate() - */ - void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) - { - LOG_GL("StencilFuncSeparate %x %x %d %d\n", face, func, ref, mask); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilFuncSeparate(face, func, ref, mask)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilMask() - */ - void StencilMask(GLuint mask) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mStencilMask = mask; - - LOG_GL("StencilMask %d\n", mask); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilMask(mask)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilMaskSeparate() - */ - void StencilMaskSeparate(GLenum face, GLuint mask) - { - LOG_GL("StencilMaskSeparate %x %d\n", face, mask); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilMaskSeparate(face, mask)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilOp() - */ - void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) - { - // TODO: Temporarily removed caching and will need to add it back to avoid unnecessary GL call. - mStencilOpFail = fail; - mStencilOpDepthFail = zfail; - mStencilOpDepthPass = zpass; - - LOG_GL("StencilOp %x %x %x\n", fail, zfail, zpass); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilOp(fail, zfail, zpass)); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilOpSeparate() - */ - void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) - { - LOG_GL("StencilOpSeparate %x %x %x %x\n", face, fail, zfail, zpass); - CHECK_GL(mGlAbstraction, mGlAbstraction.StencilOpSeparate(face, fail, zfail, zpass)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexImage2D() - */ - void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) - { - LOG_GL("TexImage2D %x %d %d %dx%d %d %x %x %p\n", target, level, internalformat, width, height, border, format, type, pixels); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexImage2D(target, level, internalformat, width, height, border, format, type, pixels)); - } - - /** - * Wrapper for OpenGL ES 3.0 glTexImage3D() - */ - void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) - { - LOG_GL("TexImage3D %x %d %d %dx%dx%d %d %x %x %p\n", target, level, internalformat, width, height, depth, border, format, type, pixels); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexParameterf() - */ - void TexParameterf(GLenum target, GLenum pname, GLfloat param) - { - LOG_GL("TexParameterf %x %x %f\n", target, pname, param); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexParameterf(target, pname, param)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexParameterfv() - */ - void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) - { - LOG_GL("TexParameterfv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexParameterfv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexParameteri() - */ - void TexParameteri(GLenum target, GLenum pname, GLint param) - { - LOG_GL("TexParameteri %x %x %d\n", target, pname, param); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexParameteri(target, pname, param)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexParameteriv() - */ - void TexParameteriv(GLenum target, GLenum pname, const GLint* params) - { - LOG_GL("TexParameteriv %x %x\n", target, pname); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexParameteriv(target, pname, params)); - } - - /** - * Wrapper for OpenGL ES 2.0 glTexSubImage2D() - */ - void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) - { - LOG_GL("TexSubImage2D %x %d %d %d %d %d %x %x %p\n", target, level, xoffset, yoffset, width, height, format, type, pixels); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels)); - } - - /** - * Wrapper for OpenGL ES 3.0 glTexSubImage3D() - */ - void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) - { - LOG_GL("TexSubImage3D %x %d %d %d %d %d %d %d %x %x %p\n", target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); - CHECK_GL(mGlAbstraction, mGlAbstraction.TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels)); - } - - /** - * Wrapper for OpenGL ES 3.0 glUnmapBuffer() - */ - GLboolean UnmapBuffer(GLenum target) - { - LOG_GL("UnmapBuffer %x \n", target); - GLboolean val = CHECK_GL(mGlAbstraction, mGlAbstraction.UnmapBuffer(target)); - return val; - } - - /** - * Wrapper for OpenGL ES 2.0 glViewport() - */ - void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) - { - // check if its same as already set - GLsizei cw, ch; - - // viewport's value shoud be set based on the default system size. - // when the surface is rotated, the input width and height already were swapped. - // So, re-swapping is needed. - if(mSurfaceOrientation == 90 || mSurfaceOrientation == 270) - { - cw = height; - ch = width; - } - else - { - cw = width; - ch = height; - } - - // User uses the rotated viewport size. - Rect newViewport(x, y, width, height); - - // Temporarily disable the viewport caching, as the implementation of GLES driver in Tizen platform - // share a global viewport between multiple contexts, therefore glViewport has to be called every - // time after glBindFramebuffer regardless of the same vewport size in the same context. - // if( mViewPort != newViewport ) - { - // set new one - LOG_GL("Viewport %d %d %d %d\n", x, y, cw, ch); - CHECK_GL(mGlAbstraction, mGlAbstraction.Viewport(x, y, cw, ch)); - mViewPort = newViewport; // remember new one - } - } - - /** - * Wrapper for OpenGL ES 3.2 and GL_KHR_blend_equation_advanced extention glBlendBarrier() - */ - void BlendBarrier() - { - LOG_GL("BlendBarrier\n"); - CHECK_GL(mGlAbstraction, mGlAbstraction.BlendBarrier()); - } - - /** - * Get the implementation defined MAX_TEXTURE_SIZE. This values is cached when the context is created - * @return The implementation defined MAX_TEXTURE_SIZE - */ - GLint CachedMaxTextureSize() const - { - return mMaxTextureSize; - } - - void SetSurfaceOrientation(int orientation) - { - LOG_GL("SetSurfaceOrientation: orientation: %d\n", orientation); - mSurfaceOrientation = orientation; - } - - /** - * Get the current viewport. - * @return Viewport rectangle. - */ - const Rect& GetViewport(); - -private: // Implementation - /** - * @return true if next draw operation will write to depth buffer - */ - bool DepthBufferWriteEnabled() const - { - return mDepthBufferEnabled && mDepthMaskEnabled; - } - - /** - * @return true if next draw operation will write to stencil buffer - */ - bool StencilBufferWriteEnabled() const - { - return mStencilBufferEnabled && (mStencilMask > 0); - } - - /** - * Flushes vertex attribute location changes to the driver - */ - void FlushVertexAttributeLocations(); - - /** - * Either enables or disables a vertex attribute location in the cache - * The cahnges won't take affect until FlushVertexAttributeLocations is called - * @param location attribute location - * @param state attribute state - */ - void SetVertexAttributeLocation(unsigned int location, bool state); - - /** - * Sets the initial GL state. - */ - void InitializeGlState(); - -private: // Data - Integration::GlAbstraction& mGlAbstraction; - - bool mGlContextCreated; ///< True if the OpenGL context has been created - - // glEnable/glDisable states - bool mColorMask; - GLuint mStencilMask; - bool mBlendEnabled; - bool mDepthBufferEnabled; - bool mDepthMaskEnabled; - bool mDitherEnabled; - bool mPolygonOffsetFillEnabled; - bool mSampleAlphaToCoverageEnabled; - bool mSampleCoverageEnabled; - bool mScissorTestEnabled; - bool mStencilBufferEnabled; - bool mClearColorSet; - bool mUsingDefaultBlendColor; - - // glBindBuffer() state - GLuint mBoundArrayBufferId; ///< The ID passed to glBindBuffer(GL_ARRAY_BUFFER) - GLuint mBoundElementArrayBufferId; ///< The ID passed to glBindBuffer(GL_ELEMENT_ARRAY_BUFFER) - GLuint mBoundTransformFeedbackBufferId; ///< The ID passed to glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER) - - // glBindTexture() state - TextureUnit mActiveTextureUnit; - GLuint mBoundTextureId[MAX_TEXTURE_UNITS][MAX_TEXTURE_TARGET]; ///< The ID passed to glBindTexture() - - // glBlendColor() state - Vector4 mBlendColor; ///< Blend color - - // glBlendFuncSeparate() state - GLenum mBlendFuncSeparateSrcRGB; ///< The srcRGB parameter passed to glBlendFuncSeparate() - GLenum mBlendFuncSeparateDstRGB; ///< The dstRGB parameter passed to glBlendFuncSeparate() - GLenum mBlendFuncSeparateSrcAlpha; ///< The srcAlpha parameter passed to glBlendFuncSeparate() - GLenum mBlendFuncSeparateDstAlpha; ///< The dstAlpha parameter passed to glBlendFuncSeparate() - - // glBlendEquationSeparate state - GLenum mBlendEquationSeparateModeRGB; ///< Controls RGB blend mode - GLenum mBlendEquationSeparateModeAlpha; ///< Controls Alpha blend mode - - // glStencilFunc() and glStencilOp() state. - GLenum mStencilFunc; - GLint mStencilFuncRef; - GLuint mStencilFuncMask; - GLenum mStencilOpFail; - GLenum mStencilOpDepthFail; - GLenum mStencilOpDepthPass; - - GLenum mDepthFunction; ///The depth function - - GLint mMaxTextureSize; ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE) - Vector4 mClearColor; ///< clear color - - // Face culling mode - Dali::FaceCullingMode::Type mCullFaceMode; - - // cached viewport size - Rect mViewPort; - - // Vertex Attribute Buffer enable caching - bool mVertexAttributeCachedState[MAX_ATTRIBUTE_CACHE_SIZE]; ///< Value cache for Enable Vertex Attribute - bool mVertexAttributeCurrentState[MAX_ATTRIBUTE_CACHE_SIZE]; ///< Current state on the driver for Enable Vertex Attribute - - FrameBufferStateCache mFrameBufferStateCache; ///< frame buffer state cache - - OwnerContainer* mSceneContexts; ///< The pointer of the container of contexts for surface rendering - - int mSurfaceOrientation; -}; - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_CONTEXT_H diff --git a/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp b/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp deleted file mode 100644 index e770d4a..0000000 --- a/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "frame-buffer-state-cache.h" - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ -namespace -{ -const uint32_t INITIAL_FRAMEBUFFER_STATE = 0u; - -} - -namespace Internal -{ -FrameBufferStateCache::FrameBufferStateCache() -: mCurrentFrameBufferId(0) -{ -} - -FrameBufferStateCache::~FrameBufferStateCache() = default; - -GLbitfield FrameBufferStateCache::GetClearMask(GLbitfield mask, bool forceClear, bool scissorTestEnabled) -{ - if(scissorTestEnabled) - { - // don't do anything if scissor test is enabled, in the future we could - // potentially keep track of frame buffer size vs scissor test size to see if the entire - // buffer is cleared or not. - return mask; - } - FrameBufferState* state = GetFrameBufferState(mCurrentFrameBufferId); - if(!state) - { - DALI_LOG_ERROR("FrameBuffer not found %d \n", mCurrentFrameBufferId); - return mask; - } - - // if we are forcing the clear operation, then just update the internal cached values - if(forceClear) - { - SetClearState(state, mask); - return mask; - } - - // use the cached values - if(mask & GL_COLOR_BUFFER_BIT) - { - // check if color buffer is currently clean - if(state->mState & COLOR_BUFFER_CLEAN) - { - // remove clear color buffer flag from bitmask, no need to clear twice - mask &= ~GL_COLOR_BUFFER_BIT; - } - } - if(mask & GL_DEPTH_BUFFER_BIT) - { - // check if depth buffer is currently clean - if(state->mState & DEPTH_BUFFER_CLEAN) - { - // remove clear depth buffer flag from bitmask, no need to clear twice - mask &= ~GL_DEPTH_BUFFER_BIT; - } - } - if(mask & GL_STENCIL_BUFFER_BIT) - { - // check if stencil buffer is currently clean - if(state->mState & STENCIL_BUFFER_CLEAN) - { - // remove clear stencil buffer flag from bitmask, no need to clear twice - - mask &= ~GL_STENCIL_BUFFER_BIT; - } - } - - // set the clear state based, what's about to be cleared - SetClearState(state, mask); - - return mask; -} - -void FrameBufferStateCache::SetCurrentFrameBuffer(GLuint frameBufferId) -{ - mCurrentFrameBufferId = frameBufferId; -} - -void FrameBufferStateCache::FrameBuffersDeleted(GLsizei count, const GLuint* const frameBuffers) -{ - for(GLsizei i = 0; i < count; ++i) - { - DeleteFrameBuffer(frameBuffers[i]); - } -} -void FrameBufferStateCache::FrameBuffersCreated(GLsizei count, const GLuint* const frameBuffers) -{ - for(GLsizei i = 0; i < count; ++i) - { - // check the frame buffer doesn't exist already - GLuint id = frameBuffers[i]; - - FrameBufferState* state = GetFrameBufferState(id); - if(state) - { - DALI_LOG_ERROR("FrameBuffer already exists%d \n", id); - // reset its state - state->mState = INITIAL_FRAMEBUFFER_STATE; - continue; - } - - FrameBufferState newFrameBuffer(frameBuffers[i]); - mFrameBufferStates.PushBack(newFrameBuffer); - } -} - -void FrameBufferStateCache::DrawOperation(bool colorBuffer, bool depthBuffer, bool stencilBuffer) -{ - FrameBufferState* state = GetFrameBufferState(mCurrentFrameBufferId); - if(!state) - { - // an error will have already been logged by the clear operation - return; - } - - if(colorBuffer) - { - // un-set the clean bit - state->mState &= ~COLOR_BUFFER_CLEAN; - } - if(depthBuffer) - { - // un-set the clean bit - state->mState &= ~DEPTH_BUFFER_CLEAN; - } - if(stencilBuffer) - { - // un-set the clean bit - state->mState &= ~STENCIL_BUFFER_CLEAN; - } -} - -void FrameBufferStateCache::Reset() -{ - mFrameBufferStates.Clear(); - - // create the default frame buffer - GLuint id = 0; // 0 == default frame buffer id - FrameBuffersCreated(1, &id); -} - -void FrameBufferStateCache::SetClearState(FrameBufferState* state, GLbitfield mask) -{ - if(mask & GL_COLOR_BUFFER_BIT) - { - // set the color buffer to clean - state->mState |= COLOR_BUFFER_CLEAN; - } - if(mask & GL_DEPTH_BUFFER_BIT) - { - // set the depth buffer to clean - state->mState |= DEPTH_BUFFER_CLEAN; - } - if(mask & GL_STENCIL_BUFFER_BIT) - { - // set the stencil buffer to clean - state->mState |= STENCIL_BUFFER_CLEAN; - } -} - -FrameBufferStateCache::FrameBufferState* FrameBufferStateCache::GetFrameBufferState(GLuint frameBufferId) -{ - for(FrameBufferStateVector::SizeType i = 0; i < mFrameBufferStates.Count(); ++i) - { - FrameBufferState& state = mFrameBufferStates[i]; - if(state.mId == frameBufferId) - { - return &state; - } - } - return nullptr; -} - -void FrameBufferStateCache::DeleteFrameBuffer(GLuint frameBufferId) -{ - FrameBufferStateVector::Iterator iter = mFrameBufferStates.Begin(); - FrameBufferStateVector::Iterator endIter = mFrameBufferStates.End(); - - for(; iter != endIter; ++iter) - { - if((*iter).mId == frameBufferId) - { - mFrameBufferStates.Erase(iter); - return; - } - } - DALI_LOG_ERROR("FrameBuffer not found %d \n", frameBufferId); -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/gl-resources/frame-buffer-state-cache.h b/dali/internal/render/gl-resources/frame-buffer-state-cache.h deleted file mode 100644 index a9fc6d3..0000000 --- a/dali/internal/render/gl-resources/frame-buffer-state-cache.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H -#define DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ -namespace Internal -{ -/** - * @brief Keeps track of color, depth and stencil buffer state within each frame buffer. - * Used to avoid redundant glClear calls. - * - */ -class FrameBufferStateCache -{ -public: - /** - * @brief Constructor - */ - FrameBufferStateCache(); - - /** - * @brief non-virtual destructor - */ - ~FrameBufferStateCache(); - - /** - * @brief Get the bitmask to pass to glClear based on the mask requested - * and the current state of the frame buffer - * @param[in] mask glClear bit mask - * @param[in] forceClear whether to force the clear ( ignore cached state) - * @param[in] scissorTestEnabled whether scissor test is enabled - * @return new bitmask to pass to glClear - */ - GLbitfield GetClearMask(GLbitfield mask, bool forceClear, bool scissorTestEnabled); - - /** - * @brief Set the current bound frame buffer - * @param[in] frameBufferId frame buffer id - */ - void SetCurrentFrameBuffer(GLuint frameBufferId); - - /** - * @brief Called when frame buffers are deleted - * @param[in] count number of frame buffers - * @param[in] framebuffers array of frame buffer ids - */ - void FrameBuffersDeleted(GLsizei count, const GLuint* const frameBuffers); - - /** - * @brief Called when frame buffers are created - * @param[in] count number of frame buffers - * @param[in] framebuffers array of frame buffer ids - */ - void FrameBuffersCreated(GLsizei count, const GLuint* const frameBuffers); - - /** - * @brief Draw operation performed on the current frame buffer - * @param[in] colorBufferUsed whether the color buffer is being written to (glColorMask ) - * @param[in] depthBufferUsed whether the depth buffer is being written to (glDepthMask ) - * @param[in] stencilBufferUsed whether the stencil buffer is being written to (glStencilMask ) - */ - void DrawOperation(bool colorBufferUsed, bool depthBufferUsed, bool stencilBufferUsed); - - /** - * Reset the cache - */ - void Reset(); - -private: - /** - * Current status of the frame buffer - */ - enum FrameBufferStatus - { - COLOR_BUFFER_CLEAN = 1 << 0, ///< color buffer clean - DEPTH_BUFFER_CLEAN = 1 << 1, ///< depth buffer clean - STENCIL_BUFFER_CLEAN = 1 << 2, ///< stencil buffer clean - }; - - /** - * POD to store the status of frame buffer regarding color,depth and stencil buffers - */ - struct FrameBufferState - { - /** - * Constructor - */ - FrameBufferState(GLuint id) - : mId(id), - mState(0) - { - } - GLuint mId; ///< Frame buffer id - unsigned int mState; ///< State, bitmask of FrameBufferStatus flags - }; - - using FrameBufferStateVector = Dali::Vector; - - /** - * @brief Set the clear state - * @param[in] pointer to frame buffer state object - * @param[in] mask clear mask - */ - void SetClearState(FrameBufferState* state, GLbitfield mask); - - /** - * @brief Helper - * @param[in] frameBufferId frame buffer id - * @return pointer to frame buffer state object ( NULL if it doesn't exist) - */ - FrameBufferState* GetFrameBufferState(GLuint frameBufferId); - - /** - * @brief Helper to delete a frame buffer state object - * @param[in] frameBufferId frame buffer id - */ - void DeleteFrameBuffer(GLuint frameBufferId); - - FrameBufferStateCache(const FrameBufferStateCache&); ///< undefined copy constructor - - FrameBufferStateCache& operator=(const FrameBufferStateCache&); ///< undefined assignment operator - -private: // data - FrameBufferStateVector mFrameBufferStates; ///< state of the frame buffers - GLuint mCurrentFrameBufferId; ///< currently bound frame buffer -}; - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H diff --git a/dali/internal/render/gl-resources/gl-call-debug.cpp b/dali/internal/render/gl-resources/gl-call-debug.cpp deleted file mode 100644 index 1510cf1..0000000 --- a/dali/internal/render/gl-resources/gl-call-debug.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace -{ -/** - * GL error strings - */ -struct errorStrings -{ - const Dali::GLenum errorCode; - const char* errorString; -}; -errorStrings errors[] = - { - {GL_NO_ERROR, "GL_NO_ERROR"}, - {GL_INVALID_ENUM, "GL_INVALID_ENUM"}, - {GL_INVALID_VALUE, "GL_INVALID_VALUE"}, - {GL_INVALID_OPERATION, "GL_INVALID_OPERATION"}, - {GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY"}}; - -const char* ErrorToString(Dali::GLenum errorCode) -{ - for(unsigned int i = 0; i < sizeof(errors) / sizeof(errors[0]); ++i) - { - if(errorCode == errors[i].errorCode) - { - return errors[i].errorString; - } - } - return "Unknown Open GLES error"; -} - -} // namespace - -namespace Dali -{ -namespace Internal -{ -#ifdef DEBUG_ENABLED -/// Switch debug level to Concise to disable, General to enable. Note, enabling snapshot logging will do this on the fly. -Debug::Filter* gGlLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CONTEXT"); -#endif // DEBUG_ENABLED - -void CheckGlError(Integration::GlAbstraction& glAbstraction, const char* operation) -{ - bool foundError = false; - while(GLint error = glAbstraction.GetError()) - { - DALI_LOG_ERROR("glError (0x%x) %s - after %s\n", error, ErrorToString(error), operation); - foundError = true; - } - DALI_ASSERT_ALWAYS(!foundError && "GL ERROR"); // if errors are being checked we should assert -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/gl-resources/gl-call-debug.h b/dali/internal/render/gl-resources/gl-call-debug.h deleted file mode 100644 index bc04bd6..0000000 --- a/dali/internal/render/gl-resources/gl-call-debug.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef DALI_INTERNAL_GL_CALL_DEBUG_H -#define DALI_INTERNAL_GL_CALL_DEBUG_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Integration -{ -class GlAbstraction; -} - -namespace Internal -{ -/** - * Helper to check GL errors - * @param glAbstraction to use for error check - * @param operation to be logged - */ -void CheckGlError(Integration::GlAbstraction& glAbstraction, const char* operation); - -// wrap gl calls with CHECK_GL e.g. "CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(mProgramId) );" -// will LOG any glErrors eg "glError (0x0501) GL_INVALID_VALUE - glBindTexture(textureId)" -// only enable if specifically enabled as it can slow down GL a lot! -#ifdef DALI_GL_ERROR_CHECK -#define CHECK_GL(c, a) \ - (a); \ - CheckGlError(c, #a) -#else -#define CHECK_GL(c, a) (a) -#endif - -#ifdef DEBUG_ENABLED -/// Switch debug level to Concise to disable, General to enable. Note, enabling snapshot logging will do this on the fly. -extern Debug::Filter* gGlLogFilter; -#endif // DEBUG_ENABLED - -// Don't put guards around here (LOG_INFO has it's own guards) -#define LOG_GL(format, ...) \ - DALI_LOG_INFO(gGlLogFilter, Debug::General, format, ##__VA_ARGS__) - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_GL_CALL_DEBUG_H diff --git a/dali/internal/render/gl-resources/gl-resource-owner.h b/dali/internal/render/gl-resources/gl-resource-owner.h deleted file mode 100644 index 0ed2733..0000000 --- a/dali/internal/render/gl-resources/gl-resource-owner.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef DALI_INTERNAL_GL_RESOURCE_OWNER_H -#define DALI_INTERNAL_GL_RESOURCE_OWNER_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -namespace Dali -{ -namespace Internal -{ -/** - * Abstract interface for objects which own GL resources. - * These objects must release their GL resources in the render-thread. - */ -class GlResourceOwner -{ -public: - /** - * Virtual destructor. - */ - virtual ~GlResourceOwner() = default; - - /** - * Reset all GL resources. - * This method is called when context is or has been deleted. - * Context cannot be called from this method. - * @pre This method can only be called from the render-thread. - */ - virtual void GlContextDestroyed() = 0; - - /** - * Release all GL resources. - * This means releasing buffer objects, textures. etc - * Context can be used, unless GlContextDestroyed has been called - * @pre This method can only be called from the render-thread. - */ - virtual void GlCleanup() = 0; -}; - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_GL_RESOURCE_OWNER_H diff --git a/dali/internal/render/gl-resources/texture-units.h b/dali/internal/render/gl-resources/texture-units.h deleted file mode 100644 index a48cf6e..0000000 --- a/dali/internal/render/gl-resources/texture-units.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef DALI_INTERNAL_TEXTURE_UNITS_H -#define DALI_INTERNAL_TEXTURE_UNITS_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Internal -{ -enum TextureUnit -{ - TEXTURE_UNIT_IMAGE = 0, - TEXTURE_UNIT_TEXT, - TEXTURE_UNIT_MATERIAL_DIFFUSE, - TEXTURE_UNIT_MATERIAL_OPACITY, - TEXTURE_UNIT_MATERIAL_NORMAL_MAP, - TEXTURE_UNIT_SHADER, - TEXTURE_UNIT_UPLOAD, - TEXTURE_UNIT_FRAMEBUFFER, - TEXTURE_UNIT_LAST -}; - -inline unsigned int TextureUnitAsGLenum(TextureUnit unit) -{ - // GL texture units are #defines in growing order to converting that to index - return GL_TEXTURE0 + static_cast(unit); -} - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_TEXTURE_UNITS_H diff --git a/dali/internal/render/gl-resources/gpu-buffer.cpp b/dali/internal/render/renderers/gpu-buffer.cpp similarity index 97% rename from dali/internal/render/gl-resources/gpu-buffer.cpp rename to dali/internal/render/renderers/gpu-buffer.cpp index 3b7791c..7e7aeba 100644 --- a/dali/internal/render/gl-resources/gpu-buffer.cpp +++ b/dali/internal/render/renderers/gpu-buffer.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include diff --git a/dali/internal/render/gl-resources/gpu-buffer.h b/dali/internal/render/renderers/gpu-buffer.h similarity index 100% rename from dali/internal/render/gl-resources/gpu-buffer.h rename to dali/internal/render/renderers/gpu-buffer.h diff --git a/dali/internal/render/renderers/render-frame-buffer.h b/dali/internal/render/renderers/render-frame-buffer.h index 06ee3ea..89efc3f 100644 --- a/dali/internal/render/renderers/render-frame-buffer.h +++ b/dali/internal/render/renderers/render-frame-buffer.h @@ -20,7 +20,6 @@ // INTERNAL INCLUDES #include #include -#include #include #include diff --git a/dali/internal/render/renderers/render-geometry.cpp b/dali/internal/render/renderers/render-geometry.cpp index a8970a0..cae66e1 100644 --- a/dali/internal/render/renderers/render-geometry.cpp +++ b/dali/internal/render/renderers/render-geometry.cpp @@ -19,7 +19,6 @@ // INTERNAL INCLUDES #include -#include #include #include diff --git a/dali/internal/render/renderers/render-geometry.h b/dali/internal/render/renderers/render-geometry.h index 21b11fc..adaa940 100644 --- a/dali/internal/render/renderers/render-geometry.h +++ b/dali/internal/render/renderers/render-geometry.h @@ -31,7 +31,6 @@ namespace Dali { namespace Internal { -class Context; class Program; class GpuBuffer; @@ -116,10 +115,8 @@ public: /** * Set up the attributes and perform the Draw call corresponding to the geometry type. * - * @param[in] context The GL context @todo remove * @param[in] graphicsController The graphics controller * @param[in] bufferIndex The current buffer index - * @param[in] attributeLocation The location for the attributes in the shader * @param[in] elementBufferOffset The index of first element to draw if index buffer bound * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0 * @return true if the draw command was issued, false otherwise diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index ec314d2..9ce65ce 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -1077,11 +1077,8 @@ Graphics::Pipeline& Renderer::PrepareGraphicsPipeline( break; } - // @todo How to signal a blend barrier is needed? - //if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled) - //{ - // context.BlendBarrier(); - //} + // @todo Add blend barrier to the Graphics API if we are using advanced + // blending options. Command? Graphics::ColorBlendState colorBlendState{}; colorBlendState.SetBlendEnable(false); diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h index 01a4001..285c4b6 100644 --- a/dali/internal/render/renderers/render-renderer.h +++ b/dali/internal/render/renderers/render-renderer.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -515,7 +514,6 @@ private: Graphics::Controller* mGraphicsController; OwnerPointer mRenderDataProvider; - Context* mContext; Render::Geometry* mGeometry; Graphics::UniquePtr mGraphicsCommandBuffer{}; diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index 2cfa49e..013a380 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -21,6 +21,7 @@ #include //floor, log2 // INTERNAL INCLUDES +#include namespace Dali { diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h index cbf0e2b..34363e4 100644 --- a/dali/internal/render/renderers/render-texture.h +++ b/dali/internal/render/renderers/render-texture.h @@ -32,7 +32,6 @@ #include #include #include -#include #include namespace Dali @@ -142,7 +141,6 @@ public: private: /** * Helper method to apply a sampler to the texture - * @param[in] context The GL context * @param[in] sampler The sampler */ void ApplySampler(Render::Sampler* sampler); diff --git a/dali/internal/render/renderers/render-vertex-buffer.h b/dali/internal/render/renderers/render-vertex-buffer.h index a02c493..6138841 100644 --- a/dali/internal/render/renderers/render-vertex-buffer.h +++ b/dali/internal/render/renderers/render-vertex-buffer.h @@ -18,15 +18,13 @@ */ // INTERNAL INCLUDES -#include #include -#include +#include #include #include #include -#include -#include +#include namespace Dali { diff --git a/dali/internal/render/shaders/program-cache.h b/dali/internal/render/shaders/program-cache.h index 6122512..2ebf63c 100644 --- a/dali/internal/render/shaders/program-cache.h +++ b/dali/internal/render/shaders/program-cache.h @@ -46,11 +46,6 @@ public: public: // API /** - * @return GlAbstraction - */ - virtual Integration::GlAbstraction& GetGlAbstraction() = 0; - - /** * Get the program from cache with hash * @param shaderHash to use * @return program diff --git a/dali/internal/render/shaders/program-controller.cpp b/dali/internal/render/shaders/program-controller.cpp index 00ed24c..2d638cc 100644 --- a/dali/internal/render/shaders/program-controller.cpp +++ b/dali/internal/render/shaders/program-controller.cpp @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include #include -#include #include namespace Dali @@ -52,47 +51,6 @@ void ProgramController::ResetProgramMatrices() } } -void ProgramController::GlContextCreated() -{ - // reset any potential previous errors - LOG_GL("GetError()\n"); - Integration::GlAbstraction& glAbstraction = GetGlAbstraction(); - CHECK_GL(glAbstraction, glAbstraction.GetError()); - - // find out if program binaries are supported and the format enum as well - Dali::Vector programBinaryFormats; - - CHECK_GL(glAbstraction(), glAbstraction.GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &mNumberOfProgramBinaryFormats)); - LOG_GL("GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES) = %d\n", mNumberOfProgramBinaryFormats); - - if(GL_NO_ERROR == glAbstraction.GetError() && 0 < mNumberOfProgramBinaryFormats) - { - programBinaryFormats.Resize(mNumberOfProgramBinaryFormats); - CHECK_GL(glAbstraction, glAbstraction.GetIntegerv(GL_PROGRAM_BINARY_FORMATS_OES, &programBinaryFormats[0])); - LOG_GL("GetIntegerv(GL_PROGRAM_BINARY_FORMATS_OES) = %d\n", programBinaryFormats[0]); - mProgramBinaryFormat = programBinaryFormats[0]; - } -} - -void ProgramController::GlContextDestroyed() -{ - mNumberOfProgramBinaryFormats = 0; - mProgramBinaryFormat = 0; - - SetCurrentProgram(nullptr); - // Inform programs they are no longer valid - const ProgramIterator end = mProgramCache.End(); - for(ProgramIterator iter = mProgramCache.Begin(); iter != end; ++iter) - { - (*iter)->GetProgram()->GlContextDestroyed(); - } -} - -Integration::GlAbstraction& ProgramController::GetGlAbstraction() -{ - return mGraphicsController.GetGlAbstraction(); -} - Program* ProgramController::GetProgram(size_t shaderHash) { Program* program = nullptr; diff --git a/dali/internal/render/shaders/program-controller.h b/dali/internal/render/shaders/program-controller.h index dad9a44..1f4a434 100644 --- a/dali/internal/render/shaders/program-controller.h +++ b/dali/internal/render/shaders/program-controller.h @@ -107,16 +107,6 @@ public: // API void ResetProgramMatrices(); /** - * Notifies the cache that context is (re)created - */ - void GlContextCreated(); - - /** - * Notifies cache that context is lost - */ - void GlContextDestroyed(); - - /** * Set the destination for compiler shader binaries so they can be saved. * @note Must be called during initialisation. */ @@ -129,11 +119,6 @@ public: // API private: // From ProgramCache /** - * @copydoc ProgramCache::GetGlAbstraction - */ - Integration::GlAbstraction& GetGlAbstraction() override; - - /** * @copydoc ProgramCache::GetProgram */ Program* GetProgram(size_t shaderHash) override; diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 349b76a..1c8bacc 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -119,15 +118,6 @@ uint32_t Program::RegisterUniform(ConstString name) return index; } -void Program::GlContextCreated() -{ -} - -void Program::GlContextDestroyed() -{ - ResetUniformCache(); -} - bool Program::ModifiesGeometry() { return mModifiesGeometry; @@ -135,7 +125,6 @@ bool Program::ModifiesGeometry() Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& controller, Graphics::UniquePtr&& gfxProgram, bool modifiesGeometry) : mCache(cache), - mGlAbstraction(mCache.GetGlAbstraction()), mProjectionMatrix(nullptr), mViewMatrix(nullptr), mProgramId(0), diff --git a/dali/internal/render/shaders/program.h b/dali/internal/render/shaders/program.h index db4fe7c..d606b05 100644 --- a/dali/internal/render/shaders/program.h +++ b/dali/internal/render/shaders/program.h @@ -129,16 +129,6 @@ public: uint32_t RegisterUniform(ConstString name); /** - * Needs to be called when GL context is (re)created - */ - void GlContextCreated(); - - /** - * Needs to be called when GL context is destroyed - */ - void GlContextDestroyed(); - - /** * @return true if this program modifies geometry */ bool ModifiesGeometry(); @@ -255,7 +245,6 @@ private: private: // Data ProgramCache& mCache; ///< The program cache - Integration::GlAbstraction& mGlAbstraction; ///< The OpenGL Abstraction layer const Matrix* mProjectionMatrix; ///< currently set projection matrix const Matrix* mViewMatrix; ///< currently set view matrix GLuint mProgramId; ///< GL identifier for program diff --git a/dali/internal/update/common/discard-queue.cpp b/dali/internal/update/common/discard-queue.cpp index 93e6acb..8b645ba 100644 --- a/dali/internal/update/common/discard-queue.cpp +++ b/dali/internal/update/common/discard-queue.cpp @@ -20,7 +20,6 @@ // INTERNAL INCLUDES #include -#include #include #include #include diff --git a/dali/internal/update/common/scene-graph-scene.cpp b/dali/internal/update/common/scene-graph-scene.cpp index 3526f5d..224bddb 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -19,7 +19,6 @@ // INTERNAL INCLUDES #include -#include #include namespace Dali @@ -29,8 +28,7 @@ namespace Internal namespace SceneGraph { Scene::Scene() -: mContext(nullptr), - mFrameRenderedCallbacks(), +: mFrameRenderedCallbacks(), mFramePresentedCallbacks(), mSkipRendering(false), mSurfaceRect(), @@ -45,10 +43,8 @@ Scene::~Scene() mFramePresentedCallbacks.clear(); } -void Scene::Initialize(Context& context, Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable) +void Scene::Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable) { - mContext = &context; - // Create the render pass for the surface std::vector attachmentDescriptions; @@ -97,11 +93,6 @@ void Scene::Initialize(Context& context, Graphics::Controller& graphicsControlle mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr } -Context* Scene::GetContext() -{ - return mContext; -} - RenderInstructionContainer& Scene::GetRenderInstructions() { return mInstructions; diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index e580490..0aaf50e 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -30,8 +30,6 @@ namespace Dali { namespace Internal { -class Context; - namespace SceneGraph { class RenderInstructionContainer; @@ -52,18 +50,11 @@ public: /** * Creates a scene object in the GPU. - * @param[in] context The GL context * @param[in] graphicsController The graphics controller * @param[in] depthBufferAvailable True if there is a depth buffer * @param[in] stencilBufferAvailable True if there is a stencil buffer */ - void Initialize(Context& context, Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable); - - /** - * Gets the context holding the GL state of rendering for the scene - * @return the context - */ - Context* GetContext(); + void Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable); /** * Gets the render instructions for the scene @@ -213,8 +204,6 @@ public: } private: - Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned - // Render instructions describe what should be rendered during RenderManager::RenderScene() // Update manager updates instructions for the next frame while we render the current one