From 3d6004a410ab436e8fe7b1a99555fa50f3830eee Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 25 Apr 2018 20:48:09 +0100 Subject: [PATCH] Removing rendering backend Removed the rendering backend from dali-core, migrating the data providers, render-frame-buffer.cpp, render-geometry.cpp, render-property-buffer.cpp, render-texture.cpp, render-sampler.h, render-instruction-container.cpp, render-instruction.cpp, render-item.cpp, render-list.h to Update. Removed gl-abstraction.h, gl-sync-abstraction.h, gl-defines.h Changed Core integration API to remove references to Context, GlAbstraction, GlSyncAbstraction. Removed render-renderer.cpp. Extracted StencilParameters struct to a new header stencil-parameters.h Moved performance-monitor.h to internal/common Removed gl abstraction from test suite (not updating test cases in this patch) Renamed render-frame-buffer.cpp, render-geometry.cpp, render-property-buffer.cpp, render-texture.cpp, render-sampler.h to SceneGraph variants, tidied up UpdateManager. Moved Event->Update messages to these objects from UpdateManager. Removed shader saving feature from UpdateManager Change-Id: I6844a8f615f629d093ca3066fcf52ec29a91748b Signed-off-by: David Steele --- .../dali-test-suite-utils/test-application.cpp | 22 +- .../dali/dali-test-suite-utils/test-application.h | 12 +- .../dali-test-suite-utils/test-gl-abstraction.cpp | 123 - .../dali-test-suite-utils/test-gl-abstraction.h | 2386 -------------------- .../test-gl-sync-abstraction.cpp | 141 -- .../test-gl-sync-abstraction.h | 123 - build/tizen/dali-core/Makefile.am | 5 +- build/tizen/dali-core/graphics/Makefile.am | 13 +- .../graphics/vulkan/vulkan-graphics-controller.cpp | 5 +- dali/integration-api/bitmap.cpp | 402 +--- dali/integration-api/bitmap.h | 10 +- dali/integration-api/context-notifier.h | 63 - dali/integration-api/core.cpp | 47 +- dali/integration-api/core.h | 78 +- dali/integration-api/file.list | 5 - dali/integration-api/gl-abstraction.h | 381 ---- dali/integration-api/gl-defines.h | 867 ------- dali/integration-api/gl-sync-abstraction.h | 80 - dali/integration-api/graphics/graphics.cpp | 4 +- dali/integration-api/profiling.cpp | 19 +- dali/internal/common/core-impl.cpp | 43 +- dali/internal/common/core-impl.h | 18 +- dali/internal/common/math.cpp | 6 +- .../{render => }/common/performance-monitor.h | 2 +- dali/internal/event/actors/actor-impl.cpp | 4 +- .../internal/event/common/property-buffer-impl.cpp | 19 +- dali/internal/event/common/property-buffer-impl.h | 13 +- .../event/render-tasks/render-task-impl.cpp | 4 +- .../internal/event/rendering/frame-buffer-impl.cpp | 8 +- dali/internal/event/rendering/frame-buffer-impl.h | 13 +- dali/internal/event/rendering/geometry-impl.cpp | 18 +- dali/internal/event/rendering/geometry-impl.h | 24 +- dali/internal/event/rendering/renderer-impl.cpp | 6 +- dali/internal/event/rendering/renderer-impl.h | 20 +- dali/internal/event/rendering/sampler-impl.cpp | 14 +- dali/internal/event/rendering/sampler-impl.h | 13 +- dali/internal/event/rendering/shader-impl.cpp | 5 +- dali/internal/event/rendering/texture-impl.cpp | 21 +- dali/internal/event/rendering/texture-impl.h | 14 +- dali/internal/event/rendering/texture-set-impl.cpp | 6 +- dali/internal/file.list | 37 +- dali/internal/render/common/render-algorithms.cpp | 471 ---- dali/internal/render/common/render-algorithms.h | 124 - dali/internal/render/common/render-debug.cpp | 115 - dali/internal/render/common/render-debug.h | 126 -- dali/internal/render/common/render-manager.cpp | 551 ----- dali/internal/render/common/render-manager.h | 360 --- dali/internal/render/common/render-tracker-debug.h | 50 - dali/internal/render/common/render-tracker.cpp | 106 - dali/internal/render/gl-resources/context.cpp | 289 --- dali/internal/render/gl-resources/context.h | 1771 --------------- .../gl-resources/frame-buffer-state-cache.cpp | 224 -- .../render/gl-resources/frame-buffer-state-cache.h | 165 -- .../internal/render/gl-resources/gl-call-debug.cpp | 84 - dali/internal/render/gl-resources/gl-call-debug.h | 63 - .../render/gl-resources/gl-resource-owner.h | 63 - dali/internal/render/gl-resources/gpu-buffer.cpp | 189 -- dali/internal/render/gl-resources/gpu-buffer.h | 135 -- dali/internal/render/gl-resources/texture-units.h | 52 - dali/internal/render/queue/render-queue.cpp | 150 -- dali/internal/render/queue/render-queue.h | 104 - .../render/renderers/render-frame-buffer.cpp | 126 -- dali/internal/render/renderers/render-geometry.cpp | 248 -- dali/internal/render/renderers/render-geometry.h | 158 -- .../render/renderers/render-property-buffer.cpp | 249 -- dali/internal/render/renderers/render-renderer.cpp | 609 ----- dali/internal/render/renderers/render-renderer.h | 463 ---- dali/internal/render/renderers/render-sampler.h | 81 - dali/internal/render/renderers/render-texture.cpp | 947 -------- dali/internal/render/renderers/render-texture.h | 190 -- dali/internal/render/shaders/program-cache.h | 113 - .../internal/render/shaders/program-controller.cpp | 160 -- dali/internal/render/shaders/program-controller.h | 194 -- dali/internal/render/shaders/program.cpp | 857 ------- dali/internal/render/shaders/program.h | 399 ---- .../internal/render/shaders/scene-graph-shader.cpp | 103 - .../update/animation/scene-graph-animation.cpp | 4 +- .../update/animation/scene-graph-constraint.h | 4 +- dali/internal/update/common/discard-queue.cpp | 12 +- dali/internal/update/common/discard-queue.h | 8 +- .../controllers/render-message-dispatcher.cpp | 96 - .../update/controllers/render-message-dispatcher.h | 103 - .../update/controllers/scene-controller-impl.cpp | 10 +- .../update/controllers/scene-controller-impl.h | 29 +- .../internal/update/controllers/scene-controller.h | 16 +- .../update/graphics/graphics-algorithms.cpp | 18 +- .../internal/update/graphics/graphics-algorithms.h | 4 +- dali/internal/update/manager/node-depths.h | 61 + .../manager/render-instruction-processor.cpp | 34 +- .../update/manager/render-instruction-processor.h | 15 +- .../update/manager/render-task-processor.cpp | 11 +- dali/internal/update/manager/update-algorithms.cpp | 9 +- dali/internal/update/manager/update-algorithms.h | 8 +- dali/internal/update/manager/update-manager.cpp | 513 +---- dali/internal/update/manager/update-manager.h | 360 +-- dali/internal/update/nodes/node.h | 12 +- .../internal/update/queue/update-message-queue.cpp | 4 +- .../render-tasks/scene-graph-render-task-list.cpp | 10 +- .../render-tasks/scene-graph-render-task-list.h | 8 +- .../render-tasks/scene-graph-render-task.cpp | 38 +- .../update/render-tasks/scene-graph-render-task.h | 28 +- .../rendering}/data-providers/node-data-provider.h | 4 +- .../data-providers/property-buffer-data-provider.h | 2 +- .../data-providers/render-data-provider.cpp | 6 +- .../data-providers/render-data-provider.h | 25 +- .../data-providers/uniform-map-data-provider.h | 2 +- .../rendering}/render-instruction-container.cpp | 6 +- .../rendering}/render-instruction-container.h | 2 +- .../rendering}/render-instruction.cpp | 18 +- .../rendering}/render-instruction.h | 19 +- .../common => update/rendering}/render-item.cpp | 7 +- .../common => update/rendering}/render-item.h | 8 +- .../common => update/rendering}/render-list.h | 18 +- .../common => update/rendering}/render-tracker.h | 17 +- .../update/rendering/scene-graph-frame-buffer.cpp | 59 + .../rendering/scene-graph-frame-buffer.h} | 46 +- .../update/rendering/scene-graph-geometry.cpp | 79 + .../update/rendering/scene-graph-geometry.h | 238 ++ .../rendering/scene-graph-property-buffer.cpp | 108 + .../rendering/scene-graph-property-buffer.h} | 117 +- .../update/rendering/scene-graph-renderer.cpp | 215 +- .../update/rendering/scene-graph-renderer.h | 68 +- .../update/rendering/scene-graph-sampler.h | 133 ++ .../update/rendering/scene-graph-shader.cpp | 107 + .../rendering}/scene-graph-shader.h | 97 +- .../update/rendering/scene-graph-texture-set.cpp | 6 +- .../update/rendering/scene-graph-texture-set.h | 35 +- .../update/rendering/scene-graph-texture.cpp | 203 ++ .../update/rendering/scene-graph-texture.h | 173 ++ dali/internal/update/rendering/shader-cache.cpp | 57 + dali/internal/update/rendering/shader-cache.h | 69 + .../internal/update/rendering/stencil-parameters.h | 64 + dali/public-api/math/matrix.cpp | 4 +- dali/public-api/math/quaternion.cpp | 4 +- dali/public-api/math/vector2.cpp | 4 +- dali/public-api/math/vector3.cpp | 4 +- dali/public-api/math/vector4.cpp | 4 +- 137 files changed, 1998 insertions(+), 16628 deletions(-) delete mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp delete mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h delete mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp delete mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h delete mode 100644 dali/integration-api/context-notifier.h delete mode 100644 dali/integration-api/gl-abstraction.h delete mode 100644 dali/integration-api/gl-defines.h delete mode 100644 dali/integration-api/gl-sync-abstraction.h rename dali/internal/{render => }/common/performance-monitor.h (97%) delete mode 100644 dali/internal/render/common/render-algorithms.cpp delete mode 100644 dali/internal/render/common/render-algorithms.h delete mode 100644 dali/internal/render/common/render-debug.cpp delete mode 100644 dali/internal/render/common/render-debug.h delete mode 100644 dali/internal/render/common/render-manager.cpp delete mode 100644 dali/internal/render/common/render-manager.h delete mode 100644 dali/internal/render/common/render-tracker-debug.h delete mode 100644 dali/internal/render/common/render-tracker.cpp delete mode 100644 dali/internal/render/gl-resources/context.cpp delete mode 100644 dali/internal/render/gl-resources/context.h delete mode 100644 dali/internal/render/gl-resources/frame-buffer-state-cache.cpp delete mode 100644 dali/internal/render/gl-resources/frame-buffer-state-cache.h delete mode 100644 dali/internal/render/gl-resources/gl-call-debug.cpp delete mode 100644 dali/internal/render/gl-resources/gl-call-debug.h delete mode 100644 dali/internal/render/gl-resources/gl-resource-owner.h delete mode 100644 dali/internal/render/gl-resources/gpu-buffer.cpp delete mode 100644 dali/internal/render/gl-resources/gpu-buffer.h delete mode 100644 dali/internal/render/gl-resources/texture-units.h delete mode 100644 dali/internal/render/queue/render-queue.cpp delete mode 100644 dali/internal/render/queue/render-queue.h delete mode 100644 dali/internal/render/renderers/render-frame-buffer.cpp delete mode 100644 dali/internal/render/renderers/render-geometry.cpp delete mode 100644 dali/internal/render/renderers/render-geometry.h delete mode 100644 dali/internal/render/renderers/render-property-buffer.cpp delete mode 100644 dali/internal/render/renderers/render-renderer.cpp delete mode 100644 dali/internal/render/renderers/render-renderer.h delete mode 100644 dali/internal/render/renderers/render-sampler.h delete mode 100644 dali/internal/render/renderers/render-texture.cpp delete mode 100644 dali/internal/render/renderers/render-texture.h delete mode 100644 dali/internal/render/shaders/program-cache.h delete mode 100644 dali/internal/render/shaders/program-controller.cpp delete mode 100644 dali/internal/render/shaders/program-controller.h delete mode 100644 dali/internal/render/shaders/program.cpp delete mode 100644 dali/internal/render/shaders/program.h delete mode 100644 dali/internal/render/shaders/scene-graph-shader.cpp delete mode 100644 dali/internal/update/controllers/render-message-dispatcher.cpp delete mode 100644 dali/internal/update/controllers/render-message-dispatcher.h create mode 100644 dali/internal/update/manager/node-depths.h rename dali/internal/{render => update/rendering}/data-providers/node-data-provider.h (93%) rename dali/internal/{render => update/rendering}/data-providers/property-buffer-data-provider.h (98%) rename dali/internal/{render => update/rendering}/data-providers/render-data-provider.cpp (86%) rename dali/internal/{render => update/rendering}/data-providers/render-data-provider.h (77%) rename dali/internal/{render => update/rendering}/data-providers/uniform-map-data-provider.h (97%) rename dali/internal/{render/common => update/rendering}/render-instruction-container.cpp (92%) rename dali/internal/{render/common => update/rendering}/render-instruction-container.h (97%) rename dali/internal/{render/common => update/rendering}/render-instruction.cpp (88%) rename dali/internal/{render/common => update/rendering}/render-instruction.h (91%) rename dali/internal/{render/common => update/rendering}/render-item.cpp (96%) rename dali/internal/{render/common => update/rendering}/render-item.h (96%) rename dali/internal/{render/common => update/rendering}/render-list.h (93%) rename dali/internal/{render/common => update/rendering}/render-tracker.h (74%) create mode 100644 dali/internal/update/rendering/scene-graph-frame-buffer.cpp rename dali/internal/{render/renderers/render-frame-buffer.h => update/rendering/scene-graph-frame-buffer.h} (62%) create mode 100644 dali/internal/update/rendering/scene-graph-geometry.cpp create mode 100644 dali/internal/update/rendering/scene-graph-geometry.h create mode 100644 dali/internal/update/rendering/scene-graph-property-buffer.cpp rename dali/internal/{render/renderers/render-property-buffer.h => update/rendering/scene-graph-property-buffer.h} (61%) create mode 100644 dali/internal/update/rendering/scene-graph-sampler.h create mode 100644 dali/internal/update/rendering/scene-graph-shader.cpp rename dali/internal/{render/shaders => update/rendering}/scene-graph-shader.h (54%) create mode 100644 dali/internal/update/rendering/scene-graph-texture.cpp create mode 100644 dali/internal/update/rendering/scene-graph-texture.h create mode 100644 dali/internal/update/rendering/shader-cache.cpp create mode 100644 dali/internal/update/rendering/shader-cache.h create mode 100644 dali/internal/update/rendering/stencil-parameters.h diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp index 5a18b44..bfdfeb8 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -65,13 +65,10 @@ void TestApplication::Initialize() mCore = Dali::Integration::Core::New( mRenderController, mPlatformAbstraction, mGraphics, - mGlAbstraction, - mGlSyncAbstraction, mGestureManager, mDataRetentionPolicy, false ); - mCore->ContextCreated(); mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight ); mCore->SetDpi( mDpi.x, mDpi.y ); @@ -121,16 +118,6 @@ TestRenderController& TestApplication::GetRenderController() return mRenderController; } -TestGlAbstraction& TestApplication::GetGlAbstraction() -{ - return mGlAbstraction; -} - -TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction() -{ - return mGlSyncAbstraction; -} - TestGestureManager& TestApplication::GetGestureManager() { return mGestureManager; @@ -215,13 +202,6 @@ bool TestApplication::RenderOnly( ) return mRenderStatus.NeedsUpdate(); } -void TestApplication::ResetContext() -{ - mCore->ContextDestroyed(); - mGlAbstraction.Initialize(); - mCore->ContextCreated(); -} - unsigned int TestApplication::Wait( unsigned int durationToWait ) { int time = 0; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.h b/automated-tests/src/dali/dali-test-suite-utils/test-application.h index 6bb6ec9..497d639 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.h @@ -2,7 +2,7 @@ #define __DALI_TEST_APPLICATION_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,12 +21,12 @@ // INTERNAL INCLUDES #include #include "test-gesture-manager.h" -#include "test-gl-sync-abstraction.h" -#include "test-gl-abstraction.h" #include "test-render-controller.h" #include -#include +#include +#include #include +#include namespace Dali { @@ -70,8 +70,6 @@ public: Dali::Integration::Core& GetCore(); TestPlatformAbstraction& GetPlatform(); TestRenderController& GetRenderController(); - TestGlAbstraction& GetGlAbstraction(); - TestGlSyncAbstraction& GetGlSyncAbstraction(); TestGestureManager& GetGestureManager(); void ProcessEvent(const Integration::Event& event); void SendNotification(); @@ -92,8 +90,6 @@ protected: TestPlatformAbstraction mPlatformAbstraction; Integration::Graphics::Graphics mGraphics; TestRenderController mRenderController; - TestGlAbstraction mGlAbstraction; - TestGlSyncAbstraction mGlSyncAbstraction; TestGestureManager mGestureManager; Integration::UpdateStatus mStatus; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp deleted file mode 100644 index 02439bc..0000000 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2017 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. - * - */ - -#include "test-gl-abstraction.h" - -namespace Dali -{ - -TestGlAbstraction::TestGlAbstraction() -{ - Initialize(); -} - -TestGlAbstraction::~TestGlAbstraction() {} - -void TestGlAbstraction::Initialize() -{ - mCurrentProgram = 0; - mCompileStatus = GL_TRUE; - mLinkStatus = GL_TRUE; - mNumberOfActiveUniforms = 0; - mGetAttribLocationResult = 0; - mGetErrorResult = 0; - mGetStringResult = NULL; - mIsBufferResult = 0; - mIsEnabledResult = 0; - mIsFramebufferResult = 0; - mIsProgramResult = 0; - mIsRenderbufferResult = 0; - mIsShaderResult = 0; - mIsTextureResult = 0; - mActiveTextureUnit = 0; - mCheckFramebufferStatusResult = 0; - mFramebufferStatus = 0; - mFramebufferColorAttached = 0; - mFramebufferDepthAttached = 0; - mFramebufferStencilAttached = 0; - mNumBinaryFormats = 0; - mBinaryFormats = 0; - mProgramBinaryLength = 0; - - mVertexAttribArrayChanged = false; - mGetProgramBinaryCalled = false; - - mLastShaderCompiled = 0; - mLastClearBitMask = 0; - mClearCount = 0; - - mLastBlendEquationRgb = 0; - mLastBlendEquationAlpha = 0; - mLastBlendFuncSrcRgb = 0; - mLastBlendFuncDstRgb = 0; - mLastBlendFuncSrcAlpha = 0; - mLastBlendFuncDstAlpha = 0; - mLastAutoTextureIdUsed = 0; - mNumGeneratedTextures = 0; - mLastShaderIdUsed = 0; - mLastProgramIdUsed = 0; - mLastUniformIdUsed = 0; - mLastDepthMask = false; - - mUniforms.clear(); - mProgramUniforms1i.clear(); - mProgramUniforms1f.clear(); - mProgramUniforms2f.clear(); - mProgramUniforms3f.clear(); - mProgramUniforms4f.clear(); - - mCullFaceTrace.Reset(); - mDepthFunctionTrace.Reset(); - mEnableDisableTrace.Reset(); - mShaderTrace.Reset(); - mStencilFunctionTrace.Reset(); - mScissorTrace.Reset(); - mTextureTrace.Reset(); - mTexParamaterTrace.Reset(); - mDrawTrace.Reset(); - - for( unsigned int i=0; i -#include -#include -#include -#include -#include // for strcmp -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64; -static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] = -{ - "aPosition", // ATTRIB_POSITION - "aNormal", // ATTRIB_NORMAL - "aTexCoord", // ATTRIB_TEXCOORD - "aColor", // ATTRIB_COLOR - "aBoneWeights", // ATTRIB_BONE_WEIGHTS - "aBoneIndices" // ATTRIB_BONE_INDICES -}; - -class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction -{ -public: - TestGlAbstraction(); - ~TestGlAbstraction(); - void Initialize(); - - void PreRender(); - void PostRender(); - - /* OpenGL ES 2.0 */ - - inline void ActiveTexture( GLenum textureUnit ) - { - mActiveTextureUnit = textureUnit - GL_TEXTURE0; - } - - inline GLenum GetActiveTextureUnit() const - { - return mActiveTextureUnit + GL_TEXTURE0; - } - - inline void AttachShader( GLuint program, GLuint shader ) - { - std::stringstream out; - out << program << ", " << shader; - - TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); - namedParams["shader"] = ToString(shader); - mShaderTrace.PushCall("AttachShader", out.str(), namedParams); - } - - inline void BindAttribLocation( GLuint program, GLuint index, const char* name ) - { - } - - inline void BindBuffer( GLenum target, GLuint buffer ) - { - } - - inline void BindFramebuffer( GLenum target, GLuint framebuffer ) - { - //Add 010 bit; - mFramebufferStatus |= 2; - } - - inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) - { - } - - /** - * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture. - * @return A vector containing the IDs that were bound. - */ - inline const std::vector& GetBoundTextures() const - { - return mBoundTextures; - } - - /** - * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit. - * @param[in] activeTextureUnit The specific active texture unit. - * @return A vector containing the IDs that were bound. - */ - inline const std::vector& GetBoundTextures( GLuint activeTextureUnit ) const - { - return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures; - } - - /** - * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture. - */ - inline void ClearBoundTextures() - { - mBoundTextures.clear(); - - for( unsigned int i=0; i::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter) - { - if(*iter == textureId) - { - found = true; - break; - } - } - return found; - } - - inline void ClearDeletedTextures() - { - mDeletedTextureIds.clear(); - } - - inline void DepthFunc(GLenum func) - { - std::stringstream out; - out << func; - - TraceCallStack::NamedParams namedParams; - namedParams["func"] = ToString(func); - - mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams); - } - - inline void DepthMask(GLboolean flag) - { - mLastDepthMask = flag; - } - - inline bool GetLastDepthMask() const - { - return mLastDepthMask; - } - - inline void DepthRangef(GLclampf zNear, GLclampf zFar) - { - } - - inline void DetachShader(GLuint program, GLuint shader) - { - std::stringstream out; - out << program << ", " << shader; - TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); - namedParams["shader"] = ToString(shader); - mShaderTrace.PushCall("DetachShader", out.str(), namedParams); - } - - inline void Disable(GLenum cap) - { - std::stringstream out; - out << cap; - TraceCallStack::NamedParams namedParams; - namedParams["cap"] = ToString(cap); - mEnableDisableTrace.PushCall("Disable", out.str(), namedParams); - } - - inline void DisableVertexAttribArray(GLuint index) - { - SetVertexAttribArray( index, false ); - } - - inline void DrawArrays(GLenum mode, GLint first, GLsizei count) - { - std::stringstream out; - out << mode << ", " << first << ", " << count; - TraceCallStack::NamedParams namedParams; - namedParams["mode"] = ToString(mode); - namedParams["first"] = ToString(first); - namedParams["count"] = ToString(count); - mDrawTrace.PushCall("DrawArrays", out.str(), namedParams); - } - - inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) - { - std::stringstream out; - out << mode << ", " << count << ", " << type << ", indices"; - - TraceCallStack::NamedParams namedParams; - namedParams["mode"] = ToString(mode); - namedParams["count"] = ToString(count); - namedParams["type"] = ToString(type); - // Skip void pointers - are they of any use? - mDrawTrace.PushCall("DrawElements", out.str(), namedParams); - } - - inline void Enable(GLenum cap) - { - std::stringstream out; - out << cap; - TraceCallStack::NamedParams namedParams; - namedParams["cap"] = ToString(cap); - mEnableDisableTrace.PushCall("Enable", out.str(), namedParams); - } - - inline void EnableVertexAttribArray(GLuint index) - { - SetVertexAttribArray( index, true); - } - - inline void Finish(void) - { - } - - inline void Flush(void) - { - } - - inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) - { - if (attachment == GL_DEPTH_ATTACHMENT) - { - mFramebufferDepthAttached = true; - } - else if (attachment == GL_STENCIL_ATTACHMENT) - { - mFramebufferStencilAttached = true; - } - } - - inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) - { - //Add 100 bit; - mFramebufferStatus |= 4; - - //We check 4 attachment colors - if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4)) - { - mFramebufferColorAttached = true; - } - } - - inline void FrontFace(GLenum mode) - { - } - - inline void GenBuffers(GLsizei n, GLuint* buffers) - { - // avoids an assert in GpuBuffers - *buffers = 1u; - } - - inline void GenerateMipmap(GLenum target) - { - std::stringstream out; - out<& ids ) - { - mNextTextureIds = ids; - } - - inline const std::vector& GetNextTextureIds() - { - return mNextTextureIds; - } - - inline void GenTextures(GLsizei count, GLuint* textures) - { - for( int i=0; isecond; - UniformIDMap::iterator it2 = uniformIDs.find( name ); - if( it2 == uniformIDs.end() ) - { - // Uniform not found, so add it... - uniformIDs[name] = ++mLastUniformIdUsed; - return mLastUniformIdUsed; - } - - return it2->second; - } - - inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) - { - } - - inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) - { - } - - inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) - { - } - - inline void Hint(GLenum target, GLenum mode) - { - } - - inline GLboolean IsBuffer(GLuint buffer) - { - return mIsBufferResult; - } - - inline GLboolean IsEnabled(GLenum cap) - { - return mIsEnabledResult; - } - - inline GLboolean IsFramebuffer(GLuint framebuffer) - { - return mIsFramebufferResult; - } - - inline GLboolean IsProgram(GLuint program) - { - return mIsProgramResult; - } - - inline GLboolean IsRenderbuffer(GLuint renderbuffer) - { - return mIsRenderbufferResult; - } - - inline GLboolean IsShader(GLuint shader) - { - return mIsShaderResult; - } - - inline GLboolean IsTexture(GLuint texture) - { - return mIsTextureResult; - } - - inline void LineWidth(GLfloat width) - { - } - - inline void LinkProgram(GLuint program) - { - std::stringstream out; - out << program; - - TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); - mShaderTrace.PushCall("LinkProgram", out.str(), namedParams); - - mNumberOfActiveUniforms=3; - GetUniformLocation(program, "sTexture"); - GetUniformLocation(program, "sEffect"); - GetUniformLocation(program, "sGloss"); - } - - inline void PixelStorei(GLenum pname, GLint param) - { - } - - inline void PolygonOffset(GLfloat factor, GLfloat units) - { - } - - inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) - { - } - - inline void ReleaseShaderCompiler(void) - { - } - - inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) - { - } - - inline void SampleCoverage(GLclampf value, GLboolean invert) - { - } - - inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) - { - mScissorParams.x = x; - mScissorParams.y = y; - mScissorParams.width = width; - mScissorParams.height = height; - - std::stringstream out; - out << x << ", " << y << ", " << width << ", " << height; - TraceCallStack::NamedParams namedParams; - namedParams["x"] = ToString( x ); - namedParams["y"] = ToString( y ); - namedParams["width"] = ToString( width ); - namedParams["height"] = ToString( height ); - mScissorTrace.PushCall( "Scissor", out.str(), namedParams ); - } - - inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) - { - } - - inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) - { - std::string stringBuilder; - for(int i = 0; i < count; ++i) - { - stringBuilder += string[i]; - } - mShaderSources[shader] = stringBuilder; - mLastShaderCompiled = shader; - } - - inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) - { - const std::string shaderSource = mShaderSources[shader]; - const int shaderSourceLength = static_cast(shaderSource.length()); - if( shaderSourceLength < bufsize ) - { - strncpy( source, shaderSource.c_str(), shaderSourceLength ); - *length = shaderSourceLength; - } - else - { - *length = bufsize -1; - strncpy(source, shaderSource.c_str(), *length); - source[*length] = 0x0; - } - } - - inline std::string GetShaderSource(GLuint shader) - { - return mShaderSources[shader]; - } - - inline void StencilFunc(GLenum func, GLint ref, GLuint mask) - { - std::stringstream out; - out << func << ", " << ref << ", " << mask; - - TraceCallStack::NamedParams namedParams; - namedParams["func"] = ToString( func ); - namedParams["ref"] = ToString( ref ); - namedParams["mask"] = ToString( mask ); - - mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams ); - } - - inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) - { - std::stringstream out; - out << face << ", " << func << ", " << ref << ", " << mask; - - TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString( face ); - namedParams["func"] = ToString( func ); - namedParams["ref"] = ToString( ref ); - namedParams["mask"] = ToString( mask ); - - mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams ); - } - - inline void StencilMask(GLuint mask) - { - std::stringstream out; - out << mask; - - TraceCallStack::NamedParams namedParams; - namedParams["mask"] = ToString( mask ); - - mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams ); - } - - inline void StencilMaskSeparate(GLenum face, GLuint mask) - { - std::stringstream out; - out << face << ", " << mask; - - TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString( face ); - namedParams["mask"] = ToString( mask ); - - mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams ); - } - - inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) - { - std::stringstream out; - out << fail << ", " << zfail << ", " << zpass; - - TraceCallStack::NamedParams namedParams; - namedParams["fail"] = ToString( fail ); - namedParams["zfail"] = ToString( zfail ); - namedParams["zpass"] = ToString( zpass ); - - mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams ); - } - - inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) - { - std::stringstream out; - out << face << ", " << fail << ", " << zfail << "," << zpass; - - TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString( face ); - namedParams["fail"] = ToString( fail ); - namedParams["zfail"] = ToString( zfail ); - namedParams["zpass"] = ToString( zpass ); - - mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams ); - } - - inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) - { - std::stringstream out; - out << target<<", "<second == location ) - { - name = it->first; - matched = true; - break; - } - } - - if ( matched ) - { - mSetUniformTrace.PushCall( name, value ); - } - } - - -public: // TEST FUNCTIONS - inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; } - inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; } - inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; } - inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; } - inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; } - inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; } - inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; } - inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; } - inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; } - inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; } - inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; } - inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; } - inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; } - inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; } - inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; } - inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; } - - inline bool GetVertexAttribArrayState(GLuint index) - { - if( index >= MAX_ATTRIBUTE_CACHE_SIZE ) - { - // out of range - return false; - } - return mVertexAttribArrayState[ index ]; - } - inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; } - inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; } - - //Methods for CullFace verification - inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); } - inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); } - inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; } - - //Methods for Enable/Disable call verification - inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); } - inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); } - inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; } - - //Methods for Shader verification - inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); } - inline void ResetShaderCallStack() { mShaderTrace.Reset(); } - inline TraceCallStack& GetShaderTrace() { return mShaderTrace; } - - //Methods for Texture verification - inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); } - inline void ResetTextureCallStack() { mTextureTrace.Reset(); } - inline TraceCallStack& GetTextureTrace() { return mTextureTrace; } - - //Methods for Texture verification - inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); } - inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); } - inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; } - - //Methods for Draw verification - inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); } - inline void ResetDrawCallStack() { mDrawTrace.Reset(); } - inline TraceCallStack& GetDrawTrace() { return mDrawTrace; } - - //Methods for Depth function verification - inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); } - inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); } - inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; } - - //Methods for Stencil function verification - inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); } - inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); } - inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; } - - //Methods for Scissor verification - inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); } - inline void ResetScissorCallStack() { mScissorTrace.Reset(); } - inline TraceCallStack& GetScissorTrace() { return mScissorTrace; } - - //Methods for Uniform function verification - inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); } - inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); } - inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; } - - template - inline bool GetUniformValue( const char* name, T& value ) const - { - for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); - program_it != mUniforms.end(); - ++program_it ) - { - const UniformIDMap &uniformIDs = program_it->second; - - UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); - if( uniform_it != uniformIDs.end() ) - { - // found one matching uniform name, lets check the value... - GLuint programId = program_it->first; - GLint uniformId = uniform_it->second; - - const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); - return mProgramUniforms.GetUniformValue( programId, uniformId, value ); - } - } - return false; - } - - - template - inline bool CheckUniformValue( const char* name, const T& value ) const - { - for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); - program_it != mUniforms.end(); - ++program_it ) - { - const UniformIDMap &uniformIDs = program_it->second; - - UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); - if( uniform_it != uniformIDs.end() ) - { - // found one matching uniform name, lets check the value... - GLuint programId = program_it->first; - GLint uniformId = uniform_it->second; - - const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); - if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) ) - { - // the value matches - return true; - } - } - } - - fprintf(stderr, "Not found, printing possible values:\n" ); - for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); - program_it != mUniforms.end(); - ++program_it ) - { - const UniformIDMap &uniformIDs = program_it->second; - - UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); - if( uniform_it != uniformIDs.end() ) - { - // found one matching uniform name, lets check the value... - GLuint programId = program_it->first; - GLint uniformId = uniform_it->second; - - const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); - T origValue; - if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) ) - { - std::stringstream out; - out << uniform_it->first << ": " << origValue; - fprintf(stderr, "%s\n", out.str().c_str() ); - } - } - } - return false; - } - - template - inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const - { - const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( outValue ); - return mProgramUniforms.GetUniformValue( programId, uniformId, outValue ); - } - - inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const - { - for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); - program_it != mUniforms.end(); - ++program_it ) - { - const UniformIDMap &uniformIDs = program_it->second; - - UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); - if( uniform_it != uniformIDs.end() ) - { - programId = program_it->first; - uniformId = uniform_it->second; - return true; - } - } - return false; - } - - inline GLuint GetLastShaderCompiled() const - { - return mLastShaderCompiled; - } - - inline GLuint GetLastProgramCreated() const - { - return mLastProgramIdUsed; - } - - inline GLbitfield GetLastClearMask() const - { - return mLastClearBitMask; - } - - enum AttribType - { - ATTRIB_UNKNOWN = -1, - ATTRIB_POSITION, - ATTRIB_NORMAL, - ATTRIB_TEXCOORD, - ATTRIB_COLOR, - ATTRIB_BONE_WEIGHTS, - ATTRIB_BONE_INDICES, - ATTRIB_TYPE_LAST - }; - - struct ScissorParams - { - GLint x; - GLint y; - GLsizei width; - GLsizei height; - - ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { } - }; - - // Methods to check scissor tests - inline const ScissorParams& GetScissorParams() const { return mScissorParams; } - - struct ColorMaskParams - { - GLboolean red; - GLboolean green; - GLboolean blue; - GLboolean alpha; - - ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { } - }; - - inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; } - - inline unsigned int GetClearCountCalled() const { return mClearCount; } - - inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; } - - typedef std::vector BufferDataCalls; - inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; } - inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); } - - typedef std::vector BufferSubDataCalls; - inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; } - inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); } - -private: - GLuint mCurrentProgram; - GLuint mCompileStatus; - BufferDataCalls mBufferDataCalls; - BufferSubDataCalls mBufferSubDataCalls; - GLuint mLinkStatus; - GLint mNumberOfActiveUniforms; - GLint mGetAttribLocationResult; - GLenum mGetErrorResult; - GLubyte* mGetStringResult; - GLboolean mIsBufferResult; - GLboolean mIsEnabledResult; - GLboolean mIsFramebufferResult; - GLboolean mIsProgramResult; - GLboolean mIsRenderbufferResult; - GLboolean mIsShaderResult; - GLboolean mIsTextureResult; - GLenum mActiveTextureUnit; - GLenum mCheckFramebufferStatusResult; - GLint mFramebufferStatus; - GLenum mFramebufferColorAttached; - GLenum mFramebufferDepthAttached; - GLenum mFramebufferStencilAttached; - GLint mNumBinaryFormats; - GLint mBinaryFormats; - GLint mProgramBinaryLength; - bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE]; - bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed - bool mGetProgramBinaryCalled; - typedef std::map< GLuint, std::string> ShaderSourceMap; - ShaderSourceMap mShaderSources; - GLuint mLastShaderCompiled; - GLbitfield mLastClearBitMask; - unsigned int mClearCount; - - Vector4 mLastBlendColor; - GLenum mLastBlendEquationRgb; - GLenum mLastBlendEquationAlpha; - GLenum mLastBlendFuncSrcRgb; - GLenum mLastBlendFuncDstRgb; - GLenum mLastBlendFuncSrcAlpha; - GLenum mLastBlendFuncDstAlpha; - - GLboolean mLastDepthMask; - - // Data for manipulating the IDs returned by GenTextures - GLuint mLastAutoTextureIdUsed; - GLuint mNumGeneratedTextures; - std::vector mNextTextureIds; - std::vector mDeletedTextureIds; - std::vector mBoundTextures; - - struct ActiveTextureType - { - std::vector mBoundTextures; - }; - - ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; - - TraceCallStack mCullFaceTrace; - TraceCallStack mEnableDisableTrace; - TraceCallStack mShaderTrace; - TraceCallStack mTextureTrace; - TraceCallStack mTexParamaterTrace; - TraceCallStack mDrawTrace; - TraceCallStack mDepthFunctionTrace; - TraceCallStack mStencilFunctionTrace; - TraceCallStack mScissorTrace; - TraceCallStack mSetUniformTrace; - - // Shaders & Uniforms - GLuint mLastShaderIdUsed; - GLuint mLastProgramIdUsed; - GLuint mLastUniformIdUsed; - typedef std::map< std::string, GLint > UniformIDMap; - typedef std::map< GLuint, UniformIDMap > ProgramUniformMap; - ProgramUniformMap mUniforms; - - template - struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > > - { - public: - typedef std::map< GLint, T > UniformValueMap; - typedef std::map< GLuint, UniformValueMap > Map; - - bool SetUniformValue( GLuint program, GLuint uniform, const T& value ) - { - if( program == 0 ) - { - return false; - } - - typename Map::iterator it = Map::find( program ); - if( it == Map::end() ) - { - // if its the first uniform for this program add it - std::pair< typename Map::iterator, bool > result = - Map::insert( typename Map::value_type( program, UniformValueMap() ) ); - it = result.first; - } - - UniformValueMap& uniforms = it->second; - uniforms[uniform] = value; - - return true; - } - - bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const - { - T uniformValue; - if ( GetUniformValue( program, uniform, uniformValue ) ) - { - return CompareType(value, uniformValue, Math::MACHINE_EPSILON_10); - } - - return false; - } - - bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const - { - if( program == 0 ) - { - return false; - } - - typename Map::const_iterator it = Map::find( program ); - if( it == Map::end() ) - { - // Uniform values always initialised as 0 - value = GetZero(); - return true; - } - - const UniformValueMap& uniforms = it->second; - typename UniformValueMap::const_iterator it2 = uniforms.find( uniform ); - if( it2 == uniforms.end() ) - { - // Uniform values always initialised as 0 - value = GetZero(); - return true; - } - value = it2->second; - - return true; - } - - T GetZero() const; - }; - ProgramUniformValue mProgramUniforms1i; - ProgramUniformValue mProgramUniforms1f; - ProgramUniformValue mProgramUniforms2f; - ProgramUniformValue mProgramUniforms3f; - ProgramUniformValue mProgramUniforms4f; - ProgramUniformValue mProgramUniformsMat4; - ProgramUniformValue mProgramUniformsMat3; - - inline const ProgramUniformValue& GetProgramUniformsForType( const int ) const - { - return mProgramUniforms1i; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const float ) const - { - return mProgramUniforms1f; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const Vector2& ) const - { - return mProgramUniforms2f; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const Vector3& ) const - { - return mProgramUniforms3f; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const Vector4& ) const - { - return mProgramUniforms4f; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const Matrix& ) const - { - return mProgramUniformsMat4; - } - inline const ProgramUniformValue& GetProgramUniformsForType( const Matrix3& ) const - { - return mProgramUniformsMat3; - } - inline void SetVertexAttribArray(GLuint index, bool state) - { - if( index >= MAX_ATTRIBUTE_CACHE_SIZE ) - { - // out of range - return; - } - mVertexAttribArrayState[ index ] = state; - mVertexAttribArrayChanged = true; - } - - ScissorParams mScissorParams; - ColorMaskParams mColorMaskParams; -}; - -template <> -inline int TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return 0; -} - -template <> -inline float TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return 0.0f; -} - -template <> -inline Vector2 TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return Vector2::ZERO; -} - -template <> -inline Vector3 TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return Vector3::ZERO; -} - -template <> -inline Vector4 TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return Vector4::ZERO; -} - -template <> -inline Matrix TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return Matrix(); -} - -template <> -inline Matrix3 TestGlAbstraction::ProgramUniformValue::GetZero() const -{ - return Matrix3( Matrix() ); -} - -} // namespace Dali - -bool BlendEnabled(const Dali::TraceCallStack& callStack); -bool BlendDisabled(const Dali::TraceCallStack& callStack); - - -#endif // TEST_GL_ABSTRACTION_H diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp deleted file mode 100644 index 65a884e..0000000 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include "test-gl-sync-abstraction.h" - -namespace Dali -{ - -TestSyncObject::TestSyncObject(TraceCallStack& trace) -: synced(false), - mTrace(trace) -{ -} - -TestSyncObject::~TestSyncObject() -{ -} - -bool TestSyncObject::IsSynced() -{ - mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method - return synced; -} - - - -TestGlSyncAbstraction::TestGlSyncAbstraction() -{ - Initialize(); -} - -/** - * Destructor - */ -TestGlSyncAbstraction::~TestGlSyncAbstraction() -{ - for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter ) - { - delete *iter; - } -} - -/** - * Initialize the sync objects - clear down the map - */ -void TestGlSyncAbstraction::Initialize() -{ - mSyncObjects.clear(); -} - -/** - * Create a sync object - * @return the sync object - */ -Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject( ) -{ - mTrace.PushCall("CreateSyncObject", ""); // Trace the method - - TestSyncObject* syncObject = new TestSyncObject(mTrace); - mSyncObjects.push_back( syncObject ); - return syncObject; -} - -/** - * Destroy a sync object - * @param[in] syncObject The object to destroy - */ -void TestGlSyncAbstraction::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject ) -{ - std::stringstream out; - out << syncObject; - mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method - - for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter ) - { - if( *iter == syncObject ) - { - delete *iter; - mSyncObjects.erase(iter); - break; - } - } -} - - -Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject( ) -{ - if( !mSyncObjects.empty() ) - { - return mSyncObjects.back(); - } - return NULL; -} - -/** - * Test method to trigger the object sync behaviour. - * @param[in] - * @param[in] sync The sync value to set - */ -void TestGlSyncAbstraction::SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync ) -{ - TestSyncObject* testSyncObject = static_cast(syncObject); - testSyncObject->synced = sync; -} - -/** - * Turn trace on - */ -void TestGlSyncAbstraction::EnableTrace(bool enable) { mTrace.Enable(enable); } - -/** - * Reset the trace callstack - */ -void TestGlSyncAbstraction::ResetTrace() { mTrace.Reset(); } - -/** - * Get the trace object (allows test case to find methods on it) - */ -TraceCallStack& TestGlSyncAbstraction::GetTrace() { return mTrace; } - -int TestGlSyncAbstraction::GetNumberOfSyncObjects() -{ - return mSyncObjects.size(); -} - - -} // Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h deleted file mode 100644 index 8ce96a4..0000000 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef __TEST_GL_SYNC_ABSTRACTION_H__ -#define __TEST_GL_SYNC_ABSTRACTION_H__ - -/* - * Copyright (c) 2016 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include "test-trace-call-stack.h" - -namespace Dali -{ - -class DALI_IMPORT_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject -{ -public: - TestSyncObject(TraceCallStack& trace); - ~TestSyncObject(); - bool IsSynced(); - bool synced; - TraceCallStack& mTrace; -}; - -/** - * Class to emulate the GL sync functions with tracing - */ -class DALI_IMPORT_API TestGlSyncAbstraction: public Integration::GlSyncAbstraction -{ -public: - /** - * Constructor - */ - TestGlSyncAbstraction(); - - /** - * Destructor - */ - ~TestGlSyncAbstraction(); - - /** - * Initialize the sync objects - clear down the map - */ - void Initialize(); - - /** - * Create a sync object - * @return the sync object - */ - virtual Integration::GlSyncAbstraction::SyncObject* CreateSyncObject( ); - - /** - * Destroy a sync object - * @param[in] syncObject The object to destroy - */ - virtual void DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject ); - - -public: // TEST FUNCTIONS - Integration::GlSyncAbstraction::SyncObject* GetLastSyncObject( ); - - /** - * Test method to trigger the object sync behaviour. - * @param[in] - * @param[in] sync The sync value to set - */ - void SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync ); - - /** - * Turn trace on - */ - void EnableTrace(bool enable); - - /** - * Reset the trace callstack - */ - void ResetTrace(); - - /** - * Get the trace object (allows test case to find methods on it) - */ - TraceCallStack& GetTrace(); - - /** - * Get the number of sync objects - * - * @return the number of sync objects - */ - int GetNumberOfSyncObjects(); - -private: - - TestGlSyncAbstraction( const TestGlSyncAbstraction& ); ///< Undefined - TestGlSyncAbstraction& operator=( const TestGlSyncAbstraction& ); ///< Undefined - - typedef std::vector SyncContainer; - typedef SyncContainer::iterator SyncIter; - SyncContainer mSyncObjects; ///< The sync objects - TraceCallStack mTrace; ///< the trace call stack for testing -}; - -} // Dali - -#endif // __TEST_GL_SYNC_ABSTRACTION_H__ diff --git a/build/tizen/dali-core/Makefile.am b/build/tizen/dali-core/Makefile.am index 188dc23..5b4323b 100644 --- a/build/tizen/dali-core/Makefile.am +++ b/build/tizen/dali-core/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Samsung Electronics Co., Ltd. +# Copyright (c) 2018 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. @@ -152,9 +152,7 @@ linker_test_SOURCES = linker-test.cpp \ ../../../automated-tests/src/dali/dali-test-suite-utils/test-application.cpp \ ../../../automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp \ ../../../automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp \ - ../../../automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp \ ../../../automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp \ - ../../../automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp \ ../../../automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp linker_test_CXXFLAGS = \ @@ -194,4 +192,3 @@ install: install-am endif endif - diff --git a/build/tizen/dali-core/graphics/Makefile.am b/build/tizen/dali-core/graphics/Makefile.am index 361e827..11dd6de 100644 --- a/build/tizen/dali-core/graphics/Makefile.am +++ b/build/tizen/dali-core/graphics/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Samsung Electronics Co., Ltd. +# Copyright (c) 2018 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. @@ -46,15 +46,20 @@ gcc_flags = -Wno-return-local-addr -Wsuggest-final-types -Wsuggest-final-methods # -Wfloat-equal causes issues with vulkan.hpp, removed for now cxx_more_warnings = -Wold-style-cast -Woverloaded-virtual -Wdouble-promotion -Wswitch-enum \ -Wshadow \ - -Wlarger-than=1024 \ -Wcast-qual -Wcast-align \ -Wconversion -Wsign-conversion +#-Wlarger-than=1024 # Conflicts with --coverage + # the following warnings should not be enforced cxx_warnings_to_remove = \ -Wno-c++98-compat \ -Wno-unused-parameter \ - -Wno-unknown-warning-option + -Wno-unknown-warning-option \ + -Wno-switch \ + -Wno-switch-enum \ + -Wno-error=switch \ + -Wno-error=switch-enum #the following warnings should be added back when possible cxx_warnings_to_preserve = \ @@ -74,5 +79,3 @@ libdali_graphics_a_CXXFLAGS = $(cxx_flags) \ $(dali_core_includes) \ $(DALI_CFLAGS) \ $(vulkan_flags) - - diff --git a/dali/graphics/vulkan/vulkan-graphics-controller.cpp b/dali/graphics/vulkan/vulkan-graphics-controller.cpp index 9507c34..f234408 100644 --- a/dali/graphics/vulkan/vulkan-graphics-controller.cpp +++ b/dali/graphics/vulkan/vulkan-graphics-controller.cpp @@ -49,7 +49,10 @@ namespace Graphics namespace Vulkan { static const mat4 CLIP_MATRIX( - 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f ); + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.0f, 0.0f, 0.5f, 1.0f ); struct Controller::Impl { diff --git a/dali/integration-api/bitmap.cpp b/dali/integration-api/bitmap.cpp index 373af9c..3bf7cf0 100644 --- a/dali/integration-api/bitmap.cpp +++ b/dali/integration-api/bitmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -24,8 +24,6 @@ #include #include #include -#include -#include namespace Dali { @@ -34,404 +32,6 @@ namespace Integration { using namespace Dali::Pixel; -void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat ) -{ - // Compressed textures have no pixelDataType, so init to an invalid value: - pixelDataType = -1; - - switch( pixelformat ) - { - case A8: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_ALPHA; - break; - } - - case L8: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_LUMINANCE; - break; - } - - case LA88: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_LUMINANCE_ALPHA; - break; - } - - case RGB565: - { - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; - internalFormat= GL_RGB; - break; - } - - case BGR565: - { - DALI_LOG_ERROR("Pixel format BGR565 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; -#ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - internalFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case RGBA4444: - { - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; - internalFormat= GL_RGBA; - break; - } - - case BGRA4444: - { - DALI_LOG_ERROR("Pixel format BGRA4444 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; -#ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - internalFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case RGBA5551: - { - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; - internalFormat= GL_RGBA; - break; - } - - case BGRA5551: - { - DALI_LOG_ERROR("Pixel format BGRA5551 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; -#ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - internalFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case RGB888: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGB; - break; - } - - case RGB8888: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGBA; // alpha is reserved but not used - break; - } - - case BGR8888: - { - pixelDataType = GL_UNSIGNED_BYTE; -#ifdef GL_BGRA_EXT - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - internalFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case RGBA8888: - { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGBA; - break; - } - - case BGRA8888: - { - pixelDataType = GL_UNSIGNED_BYTE; -#ifdef GL_BGRA_EXT - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - internalFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - // GLES 2 extension compressed formats: - case COMPRESSED_RGB8_ETC1: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" ); - internalFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. - break; - } - case COMPRESSED_RGB_PVRTC_4BPPV1: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" ); - internalFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. - break; - } - - // GLES 3.0 standard compressed formats: - case COMPRESSED_R11_EAC: - { - DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.\n"); - internalFormat = GL_COMPRESSED_R11_EAC; - break; - } - case COMPRESSED_SIGNED_R11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" ); - internalFormat = GL_COMPRESSED_SIGNED_R11_EAC; - break; - } - case COMPRESSED_RG11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" ); - internalFormat = GL_COMPRESSED_RG11_EAC; - break; - } - case COMPRESSED_SIGNED_RG11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" ); - internalFormat = GL_COMPRESSED_SIGNED_RG11_EAC; - break; - } - case COMPRESSED_RGB8_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" ); - internalFormat = GL_COMPRESSED_RGB8_ETC2; - break; - } - case COMPRESSED_SRGB8_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ETC2; - break; - } - case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - internalFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; - break; - } - case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; - break; - } - case COMPRESSED_RGBA8_ETC2_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" ); - internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; - break; - } - - // GLES 3.1 extension compressed formats: - case COMPRESSED_RGBA_ASTC_4x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_5x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_5x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_6x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_6x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_8x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_8x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_8x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_10x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_10x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_10x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_10x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_12x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR; - break; - } - case COMPRESSED_RGBA_ASTC_12x12_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" ); - internalFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; - break; - } - case COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" ); - internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; - break; - } - - // GLES 3.0 floating point formats. - case RGB16F: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); - pixelDataType = GL_HALF_FLOAT; - internalFormat= GL_RGB; - break; - } - case RGB32F: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); - pixelDataType = GL_FLOAT; - internalFormat= GL_RGB; - break; - } - - case INVALID: - { - DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" ); - internalFormat = 0; - break; - } - } -} Bitmap* Bitmap::New( const Profile profile = BITMAP_2D_PACKED_PIXELS, ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_DISCARD ) diff --git a/dali/integration-api/bitmap.h b/dali/integration-api/bitmap.h index 1e1b9bc..4663ecf 100644 --- a/dali/integration-api/bitmap.h +++ b/dali/integration-api/bitmap.h @@ -2,7 +2,7 @@ #define __DALI_INTEGRATION_BITMAP_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -33,14 +33,6 @@ namespace Dali namespace Integration { -/** - * Returns GL data type and internal format for specified pixel format - * @param[in] pixelformat pixel format (eg. Pixel::RGBA32) - * @param[out] pixelDataType pixel data type (eg. GL_UNSIGNED_BYTE) - * @param[out] internalFormat pixel internal format (eg. GL_RGBA) - */ -DALI_IMPORT_API void ConvertToGlFormat(Pixel::Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat); - class Bitmap; typedef IntrusivePtr BitmapPtr; typedef unsigned char PixelBuffer; ///< Pixel data buffers are composed of these diff --git a/dali/integration-api/context-notifier.h b/dali/integration-api/context-notifier.h deleted file mode 100644 index 86cbc6d..0000000 --- a/dali/integration-api/context-notifier.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __DALI_INTEGRATION_CONTEXT_NOTIFIER_H__ -#define __DALI_INTEGRATION_CONTEXT_NOTIFIER_H__ - -/* - * Copyright (c) 2014 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 Integration -{ - -/** - * Interface to inform dali core of context loss and regain - */ -class ContextNotifierInterface -{ -public: - /** - * Notify that the GL context has been lost, e.g. during ReplaceSurface - * or Pause. - * - * Multi-threading note: this method should be called from the main thread - */ - virtual void NotifyContextLost() = 0; - - /** - * Notify that the GL context has been re-created, e.g. after ReplaceSurface - * or Context loss. - * - * In the case of ReplaceSurface, both ContextDestroyed() and ContextCreated() will have - * been called on the render thread before this is called on the event thread. - * - * Multi-threading note: this method should be called from the main thread - */ - virtual void NotifyContextRegained() = 0; - -protected: - - /** - * Virtual destructor, no deletion through this interface - */ - virtual ~ContextNotifierInterface() {} - -}; - -} // namespace Integration -} // namespace Dali - - -#endif // __DALI_INTEGRATION_CONTEXT_NOTIFICATION_H__ diff --git a/dali/integration-api/core.cpp b/dali/integration-api/core.cpp index a72bcc7..0fdc2fa 100644 --- a/dali/integration-api/core.cpp +++ b/dali/integration-api/core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include @@ -34,8 +34,6 @@ namespace Integration Core* Core::New( RenderController& renderController, PlatformAbstraction& platformAbstraction, Graphics::Graphics& graphics, - GlAbstraction& glAbstraction, - GlSyncAbstraction& glSyncAbstraction, GestureManager& gestureManager, ResourcePolicy::DataRetention policy, bool renderToFboEnabled ) @@ -44,8 +42,6 @@ Core* Core::New( RenderController& renderController, instance->mImpl = new Internal::Core( renderController, platformAbstraction, graphics, - glAbstraction, - glSyncAbstraction, gestureManager, policy, renderToFboEnabled ); @@ -58,27 +54,7 @@ Core::~Core() delete mImpl; } -ContextNotifierInterface* Core::GetContextNotifier() -{ - return mImpl->GetContextNotifier(); -} - -void Core::ContextCreated() -{ - mImpl->ContextCreated(); -} - -void Core::ContextDestroyed() -{ - mImpl->ContextDestroyed(); -} - -void Core::RecoverFromContextLoss() -{ - mImpl->RecoverFromContextLoss(); -} - -void Core::SurfaceResized(unsigned int width, unsigned int height) +void Core::SurfaceResized( unsigned int width, unsigned int height ) { mImpl->SurfaceResized(width, height); } @@ -88,7 +64,7 @@ void Core::SetTopMargin( unsigned int margin ) mImpl->SetTopMargin(margin); } -void Core::SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical) +void Core::SetDpi( unsigned int dpiHorizontal, unsigned int dpiVertical ) { mImpl->SetDpi(dpiHorizontal, dpiVertical); } @@ -98,7 +74,7 @@ void Core::SceneCreated() mImpl->SceneCreated(); } -void Core::QueueEvent(const Event& event) +void Core::QueueEvent( const Event& event ) { mImpl->QueueEvent(event); } @@ -113,14 +89,21 @@ unsigned int Core::GetMaximumUpdateCount() const return mImpl->GetMaximumUpdateCount(); } - void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo ) +void Core::Update( + float elapsedSeconds, + unsigned int lastVSyncTimeMilliseconds, + unsigned int nextVSyncTimeMilliseconds, + UpdateStatus& status, + bool renderToFboEnabled, + bool isRenderingToFbo ) { - mImpl->Update( elapsedSeconds, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds, status, renderToFboEnabled, isRenderingToFbo ); + mImpl->Update( elapsedSeconds, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds, status, + renderToFboEnabled, isRenderingToFbo ); } void Core::Render( RenderStatus& status ) { - mImpl->Render( status ); + DALI_LOG_ERROR("Core::Render() called in error"); } SystemOverlay& Core::GetSystemOverlay() diff --git a/dali/integration-api/core.h b/dali/integration-api/core.h index 3b2095e..867bbf2 100644 --- a/dali/integration-api/core.h +++ b/dali/integration-api/core.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_CORE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include #include -#include #include namespace Dali @@ -41,8 +40,6 @@ class Graphics; class Core; class GestureManager; -class GlAbstraction; -class GlSyncAbstraction; class PlatformAbstraction; class RenderController; class SystemOverlay; @@ -173,36 +170,34 @@ private: * Integration::Core is used for integration with the native windowing system. * The following integration tasks must be completed: * - * 1) Handle GL context creation, and notify the Core when this occurs. + * 1) Handle Graphics API * * 2) Provide suspend/resume behaviour (see below for more details). * * 3) Run an event loop, for passing events to the Core e.g. multi-touch input events. * Notification events should be sent after a frame is updated (see UpdateStatus). * - * 4) Run a rendering loop, instructing the Core to render each frame. - * A separate rendering thread is recommended; see multi-threading options below. + * 4) Run an animation loop, instructing the Core to process scene graph, animation and constraints + * A separate update thread is recommended; see multi-threading options below. * * 5) Provide an implementation of the PlatformAbstraction interface, used to access platform specific services. * - * 6) Provide an implementation of the GlAbstraction interface, used to access OpenGL services. - * - * 7) Provide an implementation of the GestureManager interface, used to register gestures provided by the platform. + * 6) Provide an implementation of the GestureManager interface, used to register gestures provided by the platform. * * Multi-threading notes: * - * The Dali API methods are not reentrant. If you access the API from multiple threads simultaneously, then the results - * are undefined. This means that your application might segfault, or behave unpredictably. + * The Dali API methods are not reentrant. If you access the API from multiple threads simultaneously, then + * the results are undefined. This means that your application might segfault, or behave unpredictably. * * Rendering strategies: * - * 1) Single-threaded. Call every Core method from the same thread. Event handling and rendering will occur in the same thread. - * This is not recommended, since processing input (slowly) can affect the smooth flow of animations. + * 1) Single-threaded. Call every Core method from the same thread. Event handling and animation will occur in + * the same thread. This is not recommended, since processing input (slowly) can affect the smooth flow of + * animations. * - * 2) Multi-threaded. The Core update & render operations can be processed in separate threads. - * See the method descriptions in Core to see which thread they should be called from. + * 2) Multi-threaded. The Core update operation can be processed in a separate thread. + * See the method description in Core to see which thread it should be called from. * This is the recommended option, so that input processing will not affect the smoothness of animations. - * Note that the rendering thread must be halted, before destroying the GL context. */ class DALI_IMPORT_API Core { @@ -213,8 +208,6 @@ public: * This object is used for integration with the native windowing system. * @param[in] renderController The interface to an object which controls rendering. * @param[in] platformAbstraction The interface providing platform specific services. - * @param[in] glAbstraction The interface providing OpenGL services. - * @param[in] glSyncAbstraction The interface providing OpenGL sync objects. * @param[in] gestureManager The interface providing gesture manager services. * @param[in] policy The data retention policy. This depends on application setting * and platform support. Dali should honour this policy when deciding to discard @@ -225,8 +218,6 @@ public: static Core* New( RenderController& renderController, PlatformAbstraction& platformAbstraction, Graphics::Graphics& graphics, - GlAbstraction& glAbstraction, - GlSyncAbstraction& glSyncAbstraction, GestureManager& gestureManager, ResourcePolicy::DataRetention policy, bool renderToFboEnabled ); @@ -236,44 +227,9 @@ public: */ ~Core(); - // GL Context Lifecycle - - /** - * Get the object that will notify the application/toolkit when context is lost/regained - */ - ContextNotifierInterface* GetContextNotifier(); - - /** - * Notify the Core that the GL context has been created. - * The context must be created before the Core can render. - * Multi-threading note: this method should be called from the rendering thread only - * @post The Core is aware of the GL context. - */ - void ContextCreated(); - /** - * Notify the Core that that GL context is about to be destroyed. - * The Core will free any previously allocated GL resources. - * Multi-threading note: this method should be called from the rendering thread only - * @post The Core is unaware of any GL context. - */ - void ContextDestroyed(); - - /** - * Notify the Core that the GL context has been re-created, e.g. after ReplaceSurface - * or Context loss. - * - * In the case of ReplaceSurface, both ContextToBeDestroyed() and ContextCreated() will have - * been called on the render thread before this is called on the event thread. - * - * Multi-threading note: this method should be called from the main thread - */ - void RecoverFromContextLoss(); - - /** - * Notify the Core that the GL surface has been resized. - * This should be done at least once i.e. after the first call to ContextCreated(). - * The Core will use the surface size for camera calculations, and to set the GL viewport. + * Notify the Core that the render surface has been resized. + * The Core will use the surface size for camera calculations, and to set the viewport. * Multi-threading note: this method should be called from the main thread * @param[in] width The new surface width. * @param[in] height The new surface height. @@ -310,8 +266,8 @@ public: /** * Queue an event with Core. - * Pre-processing of events may be beneficial e.g. a series of motion events could be throttled, so that only the last event is queued. - * Multi-threading note: this method should be called from the main thread. + * Pre-processing of events may be beneficial e.g. a series of motion events could be throttled, so that + * only the last event is queued. Multi-threading note: this method should be called from the main thread. * @param[in] event The new event. */ void QueueEvent(const Event& event); @@ -358,8 +314,8 @@ public: /** * Render 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. * @param[out] status showing whether update is required to run. + * @todo GRAPHICS - REMOVE */ void Render( RenderStatus& status ); diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 4dc626e..5ac1903 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -24,16 +24,12 @@ platform_abstraction_src_files = \ platform_abstraction_header_files = \ $(platform_abstraction_src_dir)/core.h \ - $(platform_abstraction_src_dir)/context-notifier.h \ $(platform_abstraction_src_dir)/debug.h \ $(platform_abstraction_src_dir)/profiling.h \ $(platform_abstraction_src_dir)/input-options.h \ $(platform_abstraction_src_dir)/bitmap.h \ $(platform_abstraction_src_dir)/resource-policies.h \ $(platform_abstraction_src_dir)/resource-types.h \ - $(platform_abstraction_src_dir)/gl-abstraction.h \ - $(platform_abstraction_src_dir)/gl-defines.h \ - $(platform_abstraction_src_dir)/gl-sync-abstraction.h \ $(platform_abstraction_src_dir)/gesture-manager.h \ $(platform_abstraction_src_dir)/render-controller.h \ $(platform_abstraction_src_dir)/platform-abstraction.h \ @@ -66,4 +62,3 @@ graphics_integration_header_files = \ graphics_vulkan_integration_header_files = \ $(platform_abstraction_src_dir)/graphics/vulkan/vk-surface-factory.h \ $(platform_abstraction_src_dir)/graphics/vulkan/vulkan-hpp-wrapper.h - diff --git a/dali/integration-api/gl-abstraction.h b/dali/integration-api/gl-abstraction.h deleted file mode 100644 index a5d81f3..0000000 --- a/dali/integration-api/gl-abstraction.h +++ /dev/null @@ -1,381 +0,0 @@ -#ifndef __DALI_INTEGRATION_GL_ABSTRACTION_H__ -#define __DALI_INTEGRATION_GL_ABSTRACTION_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -#include - -/* - * This file is based on gl3.h, the following licence is included for conformance. - */ -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - - -/* OpenGL ES 3.0 */ -struct __GLsync; - -namespace Dali -{ - -/** - * These types are equivalent to those in the GLES2 API. - * Dali objects should only access GL indirectly, through the Context API. - */ - -/* OpenGL ES 2.0 */ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef float GLfloat; -typedef float GLclampf; -typedef int GLfixed; -typedef signed long int GLintptr; -typedef signed long int GLsizeiptr; - -/* OpenGL ES 3.0 */ - -typedef unsigned short GLhalf; -typedef int64_t GLint64; -typedef uint64_t GLuint64; -typedef __GLsync* GLsync; - -namespace Integration -{ - -/** - * GlAbstraction is an abstract interface, used to access OpenGL services. - * A concrete implementation must be created for each platform, and provided when creating the - * Dali::Integration::Core object. - */ -class GlAbstraction -{ -protected: - - /** - * Virtual protected destructor, no deletion through this interface - */ - virtual ~GlAbstraction() {} - -public: - /** - * Invoked by Render thread before Core::Render. - */ - virtual void PreRender() = 0; - - /** - * Invoked by Render thread after Core::Render - * Inform the gl implementation that the rendering in this frame has finished, - * and how much time was spent. - */ - virtual void PostRender() = 0; - - /** - * The number of texture units an implementation supports is implementation dependent, but must be at least 8. - */ - static const unsigned int MIN_TEXTURE_UNIT_LIMIT = 8; - - /* OpenGL ES 2.0 */ - - virtual void ActiveTexture (GLenum texture) = 0; - virtual void AttachShader (GLuint program, GLuint shader) = 0; - virtual void BindAttribLocation (GLuint program, GLuint index, const char* name) = 0; - virtual void BindBuffer (GLenum target, GLuint buffer) = 0; - virtual void BindFramebuffer (GLenum target, GLuint framebuffer) = 0; - virtual void BindRenderbuffer (GLenum target, GLuint renderbuffer) = 0; - virtual void BindTexture (GLenum target, GLuint texture) = 0; - virtual void BlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = 0; - virtual void BlendEquation ( GLenum mode ) = 0; - virtual void BlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) = 0; - virtual void BlendFunc (GLenum sfactor, GLenum dfactor) = 0; - virtual void BlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = 0; - virtual void BufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = 0; - virtual void BufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = 0; - virtual GLenum CheckFramebufferStatus (GLenum target) = 0; - virtual void Clear (GLbitfield mask) = 0; - virtual void ClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = 0; - virtual void ClearDepthf (GLclampf depth) = 0; - virtual void ClearStencil (GLint s) = 0; - virtual void ColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = 0; - virtual void CompileShader (GLuint shader) = 0; - virtual void CompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = 0; - virtual void CompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = 0; - virtual void CopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = 0; - virtual void CopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = 0; - virtual GLuint CreateProgram (void) = 0; - virtual GLuint CreateShader (GLenum type) = 0; - virtual void CullFace (GLenum mode) = 0; - virtual void DeleteBuffers (GLsizei n, const GLuint* buffers) = 0; - virtual void DeleteFramebuffers (GLsizei n, const GLuint* framebuffers) = 0; - virtual void DeleteProgram (GLuint program) = 0; - virtual void DeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers) = 0; - virtual void DeleteShader (GLuint shader) = 0; - virtual void DeleteTextures (GLsizei n, const GLuint* textures) = 0; - virtual void DepthFunc (GLenum func) = 0; - virtual void DepthMask (GLboolean flag) = 0; - virtual void DepthRangef (GLclampf zNear, GLclampf zFar) = 0; - virtual void DetachShader (GLuint program, GLuint shader) = 0; - virtual void Disable (GLenum cap) = 0; - virtual void DisableVertexAttribArray (GLuint index) = 0; - virtual void DrawArrays (GLenum mode, GLint first, GLsizei count) = 0; - virtual void DrawElements (GLenum mode, GLsizei count, GLenum type, const void* indices) = 0; - virtual void Enable (GLenum cap) = 0; - virtual void EnableVertexAttribArray (GLuint index) = 0; - virtual void Finish (void) = 0; - virtual void Flush (void) = 0; - virtual void FramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = 0; - virtual void FramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = 0; - virtual void FrontFace (GLenum mode) = 0; - virtual void GenBuffers (GLsizei n, GLuint* buffers) = 0; - virtual void GenerateMipmap (GLenum target) = 0; - virtual void GenFramebuffers (GLsizei n, GLuint* framebuffers) = 0; - virtual void GenRenderbuffers (GLsizei n, GLuint* renderbuffers) = 0; - virtual void GenTextures (GLsizei n, GLuint* textures) = 0; - virtual void GetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = 0; - virtual void GetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = 0; - virtual void GetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = 0; - virtual GLint GetAttribLocation (GLuint program, const char* name) = 0; - virtual void GetBooleanv (GLenum pname, GLboolean* params) = 0; - virtual void GetBufferParameteriv (GLenum target, GLenum pname, GLint* params) = 0; - virtual GLenum GetError (void) = 0; - virtual void GetFloatv (GLenum pname, GLfloat* params) = 0; - virtual void GetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params) = 0; - virtual void GetIntegerv (GLenum pname, GLint* params) = 0; - virtual void GetProgramiv (GLuint program, GLenum pname, GLint* params) = 0; - virtual void GetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = 0; - virtual void GetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params) = 0; - virtual void GetShaderiv (GLuint shader, GLenum pname, GLint* params) = 0; - virtual void GetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = 0; - virtual void GetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = 0; - virtual void GetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = 0; - virtual const GLubyte* GetString (GLenum name) = 0; - virtual void GetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) = 0; - virtual void GetTexParameteriv (GLenum target, GLenum pname, GLint* params) = 0; - virtual void GetUniformfv (GLuint program, GLint location, GLfloat* params) = 0; - virtual void GetUniformiv (GLuint program, GLint location, GLint* params) = 0; - virtual GLint GetUniformLocation (GLuint program, const char* name) = 0; - virtual void GetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params) = 0; - virtual void GetVertexAttribiv (GLuint index, GLenum pname, GLint* params) = 0; - virtual void GetVertexAttribPointerv (GLuint index, GLenum pname, void** pointer) = 0; - virtual void Hint (GLenum target, GLenum mode) = 0; - virtual GLboolean IsBuffer (GLuint buffer) = 0; - virtual GLboolean IsEnabled (GLenum cap) = 0; - virtual GLboolean IsFramebuffer (GLuint framebuffer) = 0; - virtual GLboolean IsProgram (GLuint program) = 0; - virtual GLboolean IsRenderbuffer (GLuint renderbuffer) = 0; - virtual GLboolean IsShader (GLuint shader) = 0; - virtual GLboolean IsTexture (GLuint texture) = 0; - virtual void LineWidth (GLfloat width) = 0; - virtual void LinkProgram (GLuint program) = 0; - virtual void PixelStorei (GLenum pname, GLint param) = 0; - virtual void PolygonOffset (GLfloat factor, GLfloat units) = 0; - virtual void ReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = 0; - virtual void ReleaseShaderCompiler (void) = 0; - virtual void RenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = 0; - virtual void SampleCoverage (GLclampf value, GLboolean invert) = 0; - virtual void Scissor (GLint x, GLint y, GLsizei width, GLsizei height) = 0; - virtual void ShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = 0; - virtual void ShaderSource (GLuint shader, GLsizei count, const char** string, const GLint* length) = 0; - virtual void StencilFunc (GLenum func, GLint ref, GLuint mask) = 0; - virtual void StencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask) = 0; - virtual void StencilMask (GLuint mask) = 0; - virtual void StencilMaskSeparate (GLenum face, GLuint mask) = 0; - virtual void StencilOp (GLenum fail, GLenum zfail, GLenum zpass) = 0; - virtual void StencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = 0; - virtual void TexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = 0; - virtual void TexParameterf (GLenum target, GLenum pname, GLfloat param) = 0; - virtual void TexParameterfv (GLenum target, GLenum pname, const GLfloat* params) = 0; - virtual void TexParameteri (GLenum target, GLenum pname, GLint param) = 0; - virtual void TexParameteriv (GLenum target, GLenum pname, const GLint* params) = 0; - virtual void TexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = 0; - virtual void Uniform1f (GLint location, GLfloat x) = 0; - virtual void Uniform1fv (GLint location, GLsizei count, const GLfloat* v) = 0; - virtual void Uniform1i (GLint location, GLint x) = 0; - virtual void Uniform1iv (GLint location, GLsizei count, const GLint* v) = 0; - virtual void Uniform2f (GLint location, GLfloat x, GLfloat y) = 0; - virtual void Uniform2fv (GLint location, GLsizei count, const GLfloat* v) = 0; - virtual void Uniform2i (GLint location, GLint x, GLint y) = 0; - virtual void Uniform2iv (GLint location, GLsizei count, const GLint* v) = 0; - virtual void Uniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z) = 0; - virtual void Uniform3fv (GLint location, GLsizei count, const GLfloat* v) = 0; - virtual void Uniform3i (GLint location, GLint x, GLint y, GLint z) = 0; - virtual void Uniform3iv (GLint location, GLsizei count, const GLint* v) = 0; - virtual void Uniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0; - virtual void Uniform4fv (GLint location, GLsizei count, const GLfloat* v) = 0; - virtual void Uniform4i (GLint location, GLint x, GLint y, GLint z, GLint w) = 0; - virtual void Uniform4iv (GLint location, GLsizei count, const GLint* v) = 0; - virtual void UniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UseProgram (GLuint program) = 0; - virtual void ValidateProgram (GLuint program) = 0; - virtual void VertexAttrib1f (GLuint indx, GLfloat x) = 0; - virtual void VertexAttrib1fv (GLuint indx, const GLfloat* values) = 0; - virtual void VertexAttrib2f (GLuint indx, GLfloat x, GLfloat y) = 0; - virtual void VertexAttrib2fv (GLuint indx, const GLfloat* values) = 0; - virtual void VertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = 0; - virtual void VertexAttrib3fv (GLuint indx, const GLfloat* values) = 0; - virtual void VertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0; - virtual void VertexAttrib4fv (GLuint indx, const GLfloat* values) = 0; - virtual void VertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = 0; - virtual void Viewport (GLint x, GLint y, GLsizei width, GLsizei height) = 0; - - /* OpenGL ES 3.0 */ - - virtual void ReadBuffer (GLenum mode) = 0; - virtual void DrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) = 0; - virtual void TexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) = 0; - virtual void TexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) = 0; - virtual void CopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = 0; - virtual void CompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) = 0; - virtual void CompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) = 0; - virtual void GenQueries (GLsizei n, GLuint* ids) = 0; - virtual void DeleteQueries (GLsizei n, const GLuint* ids) = 0; - virtual GLboolean IsQuery (GLuint id) = 0; - virtual void BeginQuery (GLenum target, GLuint id) = 0; - virtual void EndQuery (GLenum target) = 0; - virtual void GetQueryiv (GLenum target, GLenum pname, GLint* params) = 0; - virtual void GetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params) = 0; - virtual GLboolean UnmapBuffer (GLenum target) = 0; - virtual void GetBufferPointerv (GLenum target, GLenum pname, GLvoid** params) = 0; - virtual void DrawBuffers (GLsizei n, const GLenum* bufs) = 0; - virtual void UniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void UniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0; - virtual void BlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0; - virtual void RenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = 0; - virtual void FramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = 0; - virtual GLvoid* MapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = 0; - virtual void FlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length) = 0; - virtual void BindVertexArray (GLuint array) = 0; - virtual void DeleteVertexArrays (GLsizei n, const GLuint* arrays) = 0; - virtual void GenVertexArrays (GLsizei n, GLuint* arrays) = 0; - virtual GLboolean IsVertexArray (GLuint array) = 0; - virtual void GetIntegeri_v (GLenum target, GLuint index, GLint* data) = 0; - virtual void BeginTransformFeedback (GLenum primitiveMode) = 0; - virtual void EndTransformFeedback (void) = 0; - virtual void BindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = 0; - virtual void BindBufferBase (GLenum target, GLuint index, GLuint buffer) = 0; - virtual void TransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) = 0; - virtual void GetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) = 0; - virtual void VertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = 0; - virtual void GetVertexAttribIiv (GLuint index, GLenum pname, GLint* params) = 0; - virtual void GetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params) = 0; - virtual void VertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w) = 0; - virtual void VertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = 0; - virtual void VertexAttribI4iv (GLuint index, const GLint* v) = 0; - virtual void VertexAttribI4uiv (GLuint index, const GLuint* v) = 0; - virtual void GetUniformuiv (GLuint program, GLint location, GLuint* params) = 0; - virtual GLint GetFragDataLocation (GLuint program, const GLchar *name) = 0; - virtual void Uniform1ui (GLint location, GLuint v0) = 0; - virtual void Uniform2ui (GLint location, GLuint v0, GLuint v1) = 0; - virtual void Uniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2) = 0; - virtual void Uniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = 0; - virtual void Uniform1uiv (GLint location, GLsizei count, const GLuint* value) = 0; - virtual void Uniform2uiv (GLint location, GLsizei count, const GLuint* value) = 0; - virtual void Uniform3uiv (GLint location, GLsizei count, const GLuint* value) = 0; - virtual void Uniform4uiv (GLint location, GLsizei count, const GLuint* value) = 0; - virtual void ClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value) = 0; - virtual void ClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value) = 0; - virtual void ClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value) = 0; - virtual void ClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = 0; - virtual const GLubyte* GetStringi (GLenum name, GLuint index) = 0; - virtual void CopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = 0; - virtual void GetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) = 0; - virtual void GetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) = 0; - virtual GLuint GetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName) = 0; - virtual void GetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) = 0; - virtual void GetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) = 0; - virtual void UniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0; - virtual void DrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) = 0; - virtual void DrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) = 0; - virtual GLsync FenceSync (GLenum condition, GLbitfield flags) = 0; - virtual GLboolean IsSync (GLsync sync) = 0; - virtual void DeleteSync (GLsync sync) = 0; - virtual GLenum ClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout) = 0; - virtual void WaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout) = 0; - virtual void GetInteger64v (GLenum pname, GLint64* params) = 0; - virtual void GetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) = 0; - virtual void GetInteger64i_v (GLenum target, GLuint index, GLint64* data) = 0; - virtual void GetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params) = 0; - virtual void GenSamplers (GLsizei count, GLuint* samplers) = 0; - virtual void DeleteSamplers (GLsizei count, const GLuint* samplers) = 0; - virtual GLboolean IsSampler (GLuint sampler) = 0; - virtual void BindSampler (GLuint unit, GLuint sampler) = 0; - virtual void SamplerParameteri (GLuint sampler, GLenum pname, GLint param) = 0; - virtual void SamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param) = 0; - virtual void SamplerParameterf (GLuint sampler, GLenum pname, GLfloat param) = 0; - virtual void SamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param) = 0; - virtual void GetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params) = 0; - virtual void GetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params) = 0; - virtual void VertexAttribDivisor (GLuint index, GLuint divisor) = 0; - virtual void BindTransformFeedback (GLenum target, GLuint id) = 0; - virtual void DeleteTransformFeedbacks (GLsizei n, const GLuint* ids) = 0; - virtual void GenTransformFeedbacks (GLsizei n, GLuint* ids) = 0; - virtual GLboolean IsTransformFeedback (GLuint id) = 0; - virtual void PauseTransformFeedback (void) = 0; - virtual void ResumeTransformFeedback (void) = 0; - virtual void GetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) = 0; - virtual void ProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) = 0; - virtual void ProgramParameteri (GLuint program, GLenum pname, GLint value) = 0; - virtual void InvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments) = 0; - virtual void InvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) = 0; - virtual void TexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) = 0; - virtual void TexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0; - virtual void GetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) = 0; - -}; - -} // namespace Integration - -} // namespace Dali - -#endif // __DALI_INTEGRATION_GL_ABSTRACTION_H__ diff --git a/dali/integration-api/gl-defines.h b/dali/integration-api/gl-defines.h deleted file mode 100644 index 8a2f740..0000000 --- a/dali/integration-api/gl-defines.h +++ /dev/null @@ -1,867 +0,0 @@ -#ifndef __DALI_INTERNAL_GL_DEFINES_H__ -#define __DALI_INTERNAL_GL_DEFINES_H__ - -/* - * Copyright (c) 2016 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. - * - */ - -#include - -/* - * This file is based on gl3.h, the following licence is included for conformance. - */ -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* OpenGL ES 2.0 */ - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - -/* OpenGL ES 3.0 */ - -#define GL_READ_BUFFER 0x0C02 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_RED 0x1903 -#define GL_RGB8 0x8051 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#define GL_HALF_FLOAT 0x140B -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_RG8 0x822B -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER -#define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_SAMPLER_BINDING 0x8919 -#define GL_RGB10_A2UI 0x906F -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_INT_2_10_10_10_REV 0x8D9F -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x8D63 - -// From AstcTextures.h / GLES 3.1 -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_PROGRAM_BINARY_LENGTH_OES -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#endif - - -/* GL_OES_EGL_image_external */ -#ifndef GL_TEXTURE_EXTERNAL_OES -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#endif - -/* GL_SAMPLER_EXTERNAL_OES */ -#ifndef GL_SAMPLER_EXTERNAL_OES -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#endif - -#endif // __DALI_INTERNAL_GL_DEFINES_H__ diff --git a/dali/integration-api/gl-sync-abstraction.h b/dali/integration-api/gl-sync-abstraction.h deleted file mode 100644 index a06cf8b..0000000 --- a/dali/integration-api/gl-sync-abstraction.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef __DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H__ -#define __DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -#include - -namespace Dali -{ -namespace Integration -{ - -/** - * This abstraction defines an API for syncing CPU with GPU. - * A typical use case is to determine when GL draw calls have finished drawing - * to a framebuffer. - */ -class GlSyncAbstraction -{ -protected: - /** - * Virtual protected destructor, no deletion through this interface - */ - virtual ~GlSyncAbstraction() {} - -public: - - class SyncObject - { - protected: - /** - * Virtual protected destructor, no deletion through this interface. This prevents - * Core from deleting SyncObjects - only Adaptor implementation is able to delete - * them. - */ - virtual ~SyncObject() {} - - public: - - /** - * Determine if the synchronisation object has been signalled. - * @return false if the sync object has not been signalled, true if it has been signalled (and - * can now be destroyed) - */ - virtual bool IsSynced() = 0; - }; - - /** - * Create a synchronisation object based on the resource id, typically that of - * a framebuffer texture. It can then be polled using the same resource id. - * @return A pointer to an opaque sync object - */ - virtual SyncObject* CreateSyncObject() = 0; - - /** - * Destroy the synchronisation object. - * @param[in] syncObject The sync object to destroy - */ - virtual void DestroySyncObject(SyncObject* syncObject) = 0; -}; - -} // namespace Integration -} // namespace Dali - -#endif // __DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H__ diff --git a/dali/integration-api/graphics/graphics.cpp b/dali/integration-api/graphics/graphics.cpp index 68a9beb..a9e1bd5 100644 --- a/dali/integration-api/graphics/graphics.cpp +++ b/dali/integration-api/graphics/graphics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -107,4 +107,4 @@ void IncludeThisLibrary() } // Namespace Graphics } // Namespace Integration -} // Namespace Dali \ No newline at end of file +} // Namespace Dali diff --git a/dali/integration-api/profiling.cpp b/dali/integration-api/profiling.cpp index 8c1c74f..cb9d5cf 100644 --- a/dali/integration-api/profiling.cpp +++ b/dali/integration-api/profiling.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -42,11 +42,9 @@ #include #include - -#include -#include -#include -#include +#include +#include +#include #include using Dali::Internal::GestureEventProcessor; @@ -102,20 +100,19 @@ const int IMAGE_MEMORY_SIZE( sizeof( Integration::Bitmap ) ); const int RENDERER_MEMORY_SIZE( sizeof( Internal::Renderer ) + - sizeof( Internal::SceneGraph::Renderer ) + - sizeof( Internal::Render::Renderer ) ); + sizeof( Internal::SceneGraph::Renderer ) ); const int GEOMETRY_MEMORY_SIZE( sizeof( Internal::Geometry ) + - sizeof( Internal::Render::Geometry) ); + sizeof( Internal::SceneGraph::Geometry) ); const int PROPERTY_BUFFER_MEMORY_SIZE( sizeof( Internal::PropertyBuffer ) + - sizeof( Internal::Render::PropertyBuffer ) ); + sizeof( Internal::SceneGraph::PropertyBuffer ) ); const int TEXTURE_SET_MEMORY_SIZE( sizeof( Internal::TextureSet ) + sizeof( Internal::SceneGraph::TextureSet ) ); const int SAMPLER_MEMORY_SIZE( sizeof( Internal::Sampler ) + - sizeof( Internal::Render::Sampler ) ); + sizeof( Internal::SceneGraph::Sampler ) ); const int SHADER_MEMORY_SIZE( sizeof( Internal::Shader ) + sizeof( Internal::SceneGraph::Shader ) ); diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 8350f2b..1130a78 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -17,17 +17,18 @@ // CLASS HEADER #include -#include // INTERNAL INCLUDES -#include + #include #include #include -#include +#include #include #include -#include +#include + +#include #include #include @@ -46,14 +47,9 @@ #include #include -#include -#include -#include using Dali::Internal::SceneGraph::UpdateManager; -using Dali::Internal::SceneGraph::RenderManager; using Dali::Internal::SceneGraph::DiscardQueue; -using Dali::Internal::SceneGraph::RenderQueue; namespace { @@ -72,9 +68,7 @@ namespace Internal using Integration::RenderController; using Integration::PlatformAbstraction; -using Integration::GlSyncAbstraction; using Integration::GestureManager; -using Integration::GlAbstraction; using Integration::Event; using Integration::UpdateStatus; using Integration::RenderStatus; @@ -84,8 +78,6 @@ using Integration::Graphics::Graphics; Core::Core( RenderController& renderController, PlatformAbstraction& platform, Graphics& graphics, - GlAbstraction& glAbstraction, - GlSyncAbstraction& glSyncAbstraction, GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy, bool renderToFboEnabled ) @@ -111,23 +103,16 @@ Core::Core( RenderController& renderController, mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor(); - mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction ); - - RenderQueue& renderQueue = mRenderManager->GetRenderQueue(); - - mDiscardQueue = new DiscardQueue( renderQueue ); + mDiscardQueue = new DiscardQueue(); mUpdateManager = new UpdateManager( *mNotificationManager, *mAnimationPlaylist, *mPropertyNotificationManager, *mDiscardQueue, renderController, - *mRenderManager, - renderQueue, *mRenderTaskProcessor, graphics ); - mRenderManager->SetShaderSaver( *mUpdateManager ); mStage = IntrusivePtr( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager, mRenderController ) ); @@ -140,7 +125,6 @@ Core::Core( RenderController& renderController, mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor ); mShaderFactory = new ShaderFactory(); - mUpdateManager->SetShaderSaver( *mShaderFactory ); GetImplementation(Dali::TypeRegistry::Get()).CallInitFunctions(); } @@ -186,12 +170,14 @@ void Core::RecoverFromContextLoss() void Core::ContextCreated() { - mRenderManager->ContextCreated(); + // TODO: + DALI_LOG_ERROR("TODO: NOTIFY CONTEXT CREATED\n"); } void Core::ContextDestroyed() { - mRenderManager->ContextDestroyed(); + // TODO: + DALI_LOG_ERROR("TODO: NOTIFY CONTEXT DESTROYED\n"); } void Core::SurfaceResized( unsigned int width, unsigned int height ) @@ -240,7 +226,8 @@ void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, void Core::Render( RenderStatus& status ) { - mRenderManager->Render( status ); + DALI_LOG_ERROR("Render()!"); + (void)status; } void Core::SceneCreated() @@ -349,10 +336,6 @@ UpdateManager& Core::GetUpdateManager() return *(mUpdateManager); } -RenderManager& Core::GetRenderManager() -{ - return *(mRenderManager); -} NotificationManager& Core::GetNotificationManager() { diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index 1fe927a..cfe4b8c 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_CORE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,13 +19,13 @@ */ // INTERNAL INCLUDES +#include #include #include +#include #include #include #include -#include -#include namespace Dali { @@ -39,8 +39,7 @@ class Graphics; class RenderController; class PlatformAbstraction; class GestureManager; -class GlAbstraction; -class GlSyncAbstraction; + class SystemOverlay; class UpdateStatus; class RenderStatus; @@ -63,7 +62,6 @@ class RelayoutController; namespace SceneGraph { class UpdateManager; -class RenderManager; class DiscardQueue; class RenderTaskProcessor; } @@ -81,8 +79,6 @@ public: Core( Integration::RenderController& renderController, Integration::PlatformAbstraction& platform, Integration::Graphics::Graphics& graphics, - Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction, Integration::GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy, bool renderToFboEnabled ); @@ -209,11 +205,6 @@ private: // for use by ThreadLocalStorage */ SceneGraph::UpdateManager& GetUpdateManager(); - /** - * Returns the render manager. - * @return A reference to the render manager. - */ - SceneGraph::RenderManager& GetRenderManager(); /** * Returns the notification manager. @@ -264,7 +255,6 @@ private: bool mProcessingEvent : 1; ///< True during ProcessEvents() OwnerPointer mRenderTaskProcessor; ///< Handles the processing of render tasks - OwnerPointer mRenderManager; ///< Render manager OwnerPointer mUpdateManager; ///< Update manager OwnerPointer mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use. OwnerPointer mShaderFactory; ///< Shader resource factory diff --git a/dali/internal/common/math.cpp b/dali/internal/common/math.cpp index f856a37..bba1dea 100644 --- a/dali/internal/common/math.cpp +++ b/dali/internal/common/math.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include #include @@ -78,5 +78,3 @@ float Dali::Internal::Length( const Vec3 v ) { return sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); } - - diff --git a/dali/internal/render/common/performance-monitor.h b/dali/internal/common/performance-monitor.h similarity index 97% rename from dali/internal/render/common/performance-monitor.h rename to dali/internal/common/performance-monitor.h index cba8ec0..3e2a9b1 100644 --- a/dali/internal/render/common/performance-monitor.h +++ b/dali/internal/common/performance-monitor.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_PERFORMANCE_MONITOR_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index d36e103..38fc1d8 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -150,7 +150,7 @@ namespace // unnamed namespace /** * We want to discourage the use of property strings (minimize string comparisons), * particularly for the default properties. - * Name Type writable animatable constraint-input enum for index-checking + * Name Type writable animatable constraint-input enum for index-checking */ DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "parentOrigin", VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN ) diff --git a/dali/internal/event/common/property-buffer-impl.cpp b/dali/internal/event/common/property-buffer-impl.cpp index 86e184f..1417b72 100644 --- a/dali/internal/event/common/property-buffer-impl.cpp +++ b/dali/internal/event/common/property-buffer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -139,7 +139,7 @@ void PropertyBuffer::SetData( const void* data, std::size_t size ) unsigned int bufferSize = mBufferFormatSize * mSize; // create a new DALi vector to store the buffer data - // the heap allocated vector will end up being owned by Render::PropertyBuffer + // the heap allocated vector will end up being owned by SceneGraph::PropertyBuffer OwnerPointer< Vector > bufferCopy = new Dali::Vector(); bufferCopy->Resize( bufferSize ); @@ -149,7 +149,7 @@ void PropertyBuffer::SetData( const void* data, std::size_t size ) std::copy( source, source + bufferSize, destination ); // Ownership of the bufferCopy is passed to the message ( uses an owner pointer ) - SceneGraph::SetPropertyBufferData( mEventThreadServices.GetUpdateManager(), *mRenderObject, bufferCopy, mSize ); + SceneGraph::SetPropertyBufferDataMessage( mEventThreadServices, *mRenderObject, bufferCopy, mSize ); } std::size_t PropertyBuffer::GetSize() const @@ -157,7 +157,7 @@ std::size_t PropertyBuffer::GetSize() const return mSize; } -const Render::PropertyBuffer* PropertyBuffer::GetRenderObject() const +const SceneGraph::PropertyBuffer* PropertyBuffer::GetRenderObject() const { return mRenderObject; } @@ -180,16 +180,14 @@ PropertyBuffer::PropertyBuffer() void PropertyBuffer::Initialize( Dali::Property::Map& formatMap ) { - // Old - - mRenderObject = new Render::PropertyBuffer(); - OwnerPointer< Render::PropertyBuffer > transferOwnership( mRenderObject ); + mRenderObject = new SceneGraph::PropertyBuffer(); + OwnerPointer< SceneGraph::PropertyBuffer > transferOwnership( mRenderObject ); SceneGraph::AddPropertyBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership ); size_t numComponents = formatMap.Count(); // Create the format - OwnerPointer< Render::PropertyBuffer::Format> format = new Render::PropertyBuffer::Format(); + OwnerPointer< SceneGraph::PropertyBuffer::Format> format = new SceneGraph::PropertyBuffer::Format(); format->components.resize( numComponents ); unsigned int currentAlignment = 0u; @@ -258,7 +256,8 @@ void PropertyBuffer::Initialize( Dali::Property::Map& formatMap ) mBufferFormatSize = format->size; - SceneGraph::SetPropertyBufferFormat(mEventThreadServices.GetUpdateManager(), *mRenderObject, format ); + // @todo Why isn't this in the initial render object New?! + SceneGraph::SetPropertyBufferFormatMessage( mEventThreadServices, *mRenderObject, format ); } unsigned int GetPropertyImplementationSize( Property::Type& propertyType ) diff --git a/dali/internal/event/common/property-buffer-impl.h b/dali/internal/event/common/property-buffer-impl.h index aeac543..6bcf199 100644 --- a/dali/internal/event/common/property-buffer-impl.h +++ b/dali/internal/event/common/property-buffer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_PROPERTY_BUFFER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -23,8 +23,9 @@ #include // Dali::IntrusivePtr #include #include // Dali::Property::Map +#include // Dali::Property::Map #include -#include +#include namespace Dali { @@ -64,7 +65,7 @@ public: // Default property extensions from Object * * @return The render thread side of this PropertyBuffer */ - const Render::PropertyBuffer* GetRenderObject() const; + const SceneGraph::PropertyBuffer* GetRenderObject() const; protected: /** @@ -89,7 +90,7 @@ private: // unimplemented methods private: // data EventThreadServices& mEventThreadServices; ///(object); } -inline const Internal::PropertyBuffer& GetImplementation(const Dali::PropertyBuffer& handle) +inline const Internal::PropertyBuffer& GetImplementation( const Dali::PropertyBuffer& handle ) { DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty"); diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 8da4425..9b765d2 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -162,7 +162,7 @@ void RenderTask::SetTargetFrameBuffer( FrameBufferImagePtr image ) void RenderTask::SetFrameBuffer( FrameBufferPtr frameBuffer ) { mFrameBuffer = frameBuffer; - Render::FrameBuffer* renderFrameBufferPtr( NULL ); + SceneGraph::FrameBuffer* renderFrameBufferPtr( NULL ); if( frameBuffer ) { renderFrameBufferPtr = mFrameBuffer->GetRenderObject(); diff --git a/dali/internal/event/rendering/frame-buffer-impl.cpp b/dali/internal/event/rendering/frame-buffer-impl.cpp index 20d09d3..a1d43d8 100644 --- a/dali/internal/event/rendering/frame-buffer-impl.cpp +++ b/dali/internal/event/rendering/frame-buffer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { @@ -36,7 +36,7 @@ FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, unsign } -Render::FrameBuffer* FrameBuffer::GetRenderObject() const +SceneGraph::FrameBuffer* FrameBuffer::GetRenderObject() const { return mRenderObject; } @@ -53,7 +53,7 @@ FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int void FrameBuffer::Initialize() { - mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments ); + mRenderObject = new SceneGraph::FrameBuffer( mWidth, mHeight, mAttachments ); AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject ); } diff --git a/dali/internal/event/rendering/frame-buffer-impl.h b/dali/internal/event/rendering/frame-buffer-impl.h index 8b0f776..4f65b65 100644 --- a/dali/internal/event/rendering/frame-buffer-impl.h +++ b/dali/internal/event/rendering/frame-buffer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_FRAME_BUFFER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -30,7 +30,7 @@ namespace Dali { namespace Internal { -namespace Render +namespace SceneGraph { class FrameBuffer; } @@ -57,7 +57,7 @@ public: * * @return the FrameBuffer render object */ - Render::FrameBuffer* GetRenderObject() const; + SceneGraph::FrameBuffer* GetRenderObject() const; /** * @copydoc Dali::FrameBuffer::AttachColorTexture() @@ -97,14 +97,13 @@ private: // unimplemented methods private: // data - Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread - Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture + EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread + SceneGraph::FrameBuffer* mRenderObject; ///< The Render::Framebuffer associated with this framebuffer TexturePtr mColor; unsigned int mWidth; unsigned int mHeight; - unsigned int mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask - + unsigned int mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask }; } // namespace Internal diff --git a/dali/internal/event/rendering/geometry-impl.cpp b/dali/internal/event/rendering/geometry-impl.cpp index 787c5b0..1c2fe32 100644 --- a/dali/internal/event/rendering/geometry-impl.cpp +++ b/dali/internal/event/rendering/geometry-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -39,7 +39,7 @@ GeometryPtr Geometry::New() std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer ) { mVertexBuffers.push_back( &vertexBuffer ); - SceneGraph::AttachVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject() ); + SceneGraph::AttachVertexBufferMessage( mEventThreadServices, *mRenderObject, *vertexBuffer.GetRenderObject() ); return mVertexBuffers.size() - 1u; } @@ -50,8 +50,8 @@ std::size_t Geometry::GetNumberOfVertexBuffers() const void Geometry::RemoveVertexBuffer( std::size_t index ) { - const Render::PropertyBuffer& renderPropertyBuffer = static_cast( *(mVertexBuffers[index]->GetRenderObject()) ); - SceneGraph::RemoveVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, renderPropertyBuffer ); + const SceneGraph::PropertyBuffer& renderPropertyBuffer = static_cast( *(mVertexBuffers[index]->GetRenderObject()) ); + SceneGraph::RemoveVertexBufferMessage( mEventThreadServices, *mRenderObject, renderPropertyBuffer ); mVertexBuffers.erase( mVertexBuffers.begin() + index ); } @@ -65,14 +65,14 @@ void Geometry::SetIndexBuffer( const unsigned short* indices, size_t count ) std::copy( indices, indices + count, indexData.Begin() ); } - SceneGraph::SetIndexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, indexData ); + SceneGraph::SetIndexBufferMessage( mEventThreadServices, *mRenderObject, indexData ); } void Geometry::SetType( Dali::Geometry::Type geometryType ) { if( geometryType != mType ) { - SceneGraph::SetGeometryTypeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, geometryType ); + SceneGraph::SetGeometryTypeMessage(mEventThreadServices, *mRenderObject, geometryType ); mType = geometryType; } @@ -83,7 +83,7 @@ Dali::Geometry::Type Geometry::GetType() const return mType; } -const Render::Geometry* Geometry::GetRenderObject() const +const SceneGraph::Geometry* Geometry::GetRenderObject() const { return mRenderObject; } @@ -97,8 +97,8 @@ Geometry::Geometry() void Geometry::Initialize() { - mRenderObject = new Render::Geometry(); - OwnerPointer< Render::Geometry > transferOwnership( mRenderObject ); + mRenderObject = new SceneGraph::Geometry(); + OwnerPointer< SceneGraph::Geometry > transferOwnership( mRenderObject ); AddGeometry( mEventThreadServices.GetUpdateManager(), transferOwnership ); } diff --git a/dali/internal/event/rendering/geometry-impl.h b/dali/internal/event/rendering/geometry-impl.h index 8a1f90a..98e94e0 100644 --- a/dali/internal/event/rendering/geometry-impl.h +++ b/dali/internal/event/rendering/geometry-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_GEOMETRY_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,17 +19,17 @@ */ // EXTERNAL INCLUDES -#include // std::vector +#include // INTERNAL INCLUDES -#include // DALI_ASSERT_ALWAYS -#include // Dali::IntrusivePtr -#include // Dali::Geometry -#include // Dali::Internal::Connectable -#include // Dali::Internal::ObjectConnector -#include // Dali::Internal::Object -#include // Dali::Internal::PropertyBuffer -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace Dali { @@ -92,7 +92,7 @@ public: * * @return the geometry scene object */ - const Render::Geometry* GetRenderObject() const; + const SceneGraph::Geometry* GetRenderObject() const; private: // implementation @@ -120,7 +120,7 @@ private: // unimplemented methods private: // data EventThreadServices& mEventThreadServices; /// mVertexBuffers; ///< Vector of intrusive pointers to vertex buffers Dali::Geometry::Type mType; ///< Geometry type (cached) diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index 62c517c..a6115ec 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,7 +25,7 @@ #include // Dali::Internal::ObjectHelper #include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END #include -#include +#include #include #include @@ -181,7 +181,7 @@ void Renderer::SetGeometry( Geometry& geometry ) { mGeometry = &geometry; - const Render::Geometry* geometrySceneObject = geometry.GetRenderObject(); + const SceneGraph::Geometry* geometrySceneObject = geometry.GetRenderObject(); SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject ); } diff --git a/dali/internal/event/rendering/renderer-impl.h b/dali/internal/event/rendering/renderer-impl.h index ad487d3..7c52036 100644 --- a/dali/internal/event/rendering/renderer-impl.h +++ b/dali/internal/event/rendering/renderer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_RENDERER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,15 +19,15 @@ */ // INTERNAL INCLUDES -#include // DALI_ASSERT_ALWAYS -#include // Dali::IntrusivePtr -#include // Dali::Renderer +#include +#include +#include #include -#include // Dali::Internal::ObjectConnector -#include // Dali::Internal::Object -#include // Dali::Internal::TextureSet -#include // Dali::Internal::Geometry -#include // Dali::Render::Renderer::StencilParameters +#include +#include +#include +#include +#include namespace Dali { @@ -299,7 +299,7 @@ private: // data size_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer size_t mIndexedDrawElementCount; ///< Number of elements to draw - Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options + SceneGraph::StencilParameters mStencilParameters; ///< Struct containing all stencil related options BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask DepthFunction::Type mDepthFunction:3; ///< Local copy of the depth function diff --git a/dali/internal/event/rendering/sampler-impl.cpp b/dali/internal/event/rendering/sampler-impl.cpp index d6e8af0..0bede78 100644 --- a/dali/internal/event/rendering/sampler-impl.cpp +++ b/dali/internal/event/rendering/sampler-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { @@ -39,7 +39,7 @@ void Sampler::SetFilterMode( Dali::FilterMode::Type minFilter, Dali::FilterMode: { if( NULL != mRenderObject ) { - SetFilterModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast< unsigned int >( minFilter ), static_cast< unsigned int >( magFilter ) ); + SetFilterModeMessage( mEventThreadServices, *mRenderObject, static_cast< unsigned int >( minFilter ), static_cast< unsigned int >( magFilter ) ); } } @@ -47,11 +47,11 @@ void Sampler::SetWrapMode( Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWra { if( NULL != mRenderObject ) { - SetWrapModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast< unsigned int >( rWrap ), static_cast< unsigned int >( sWrap ), static_cast< unsigned int >( tWrap ) ); + SetWrapModeMessage( mEventThreadServices, *mRenderObject, static_cast< unsigned int >( rWrap ), static_cast< unsigned int >( sWrap ), static_cast< unsigned int >( tWrap ) ); } } -Render::Sampler* Sampler::GetSamplerRenderObject() +SceneGraph::Sampler* Sampler::GetSamplerRenderObject() { return mRenderObject; } @@ -67,8 +67,8 @@ void Sampler::Initialize() { SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager(); - mRenderObject = new Render::Sampler(); - OwnerPointer< Render::Sampler > transferOwnership( mRenderObject ); + mRenderObject = new SceneGraph::Sampler(); + OwnerPointer< SceneGraph::Sampler > transferOwnership( mRenderObject ); AddSamplerMessage( updateManager, transferOwnership ); } diff --git a/dali/internal/event/rendering/sampler-impl.h b/dali/internal/event/rendering/sampler-impl.h index fc43ebd..09a5d04 100644 --- a/dali/internal/event/rendering/sampler-impl.h +++ b/dali/internal/event/rendering/sampler-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SAMPLER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -31,9 +31,9 @@ namespace Dali { namespace Internal { -namespace Render +namespace SceneGraph { -struct Sampler; +class Sampler; } class Sampler; @@ -68,7 +68,7 @@ public: * * @return The render thread sampler */ - Render::Sampler* GetSamplerRenderObject(); + SceneGraph::Sampler* GetSamplerRenderObject(); private: Sampler(); @@ -85,9 +85,8 @@ protected: virtual ~Sampler(); private: // data - EventThreadServices& mEventThreadServices; /// +#include #include #include @@ -44,7 +45,7 @@ TexturePtr Texture::New( NativeImageInterface& nativeImageInterface ) return texture; } -Render::Texture* Texture::GetRenderObject() const +SceneGraph::Texture* Texture::GetRenderObject() const { return mRenderObject; } @@ -75,15 +76,15 @@ void Texture::Initialize() { if( mNativeImage ) { - mRenderObject = new Render::Texture( mNativeImage ); + mRenderObject = new SceneGraph::Texture( mNativeImage ); } else { - mRenderObject = new Render::Texture( mType, mFormat, mSize ); + mRenderObject = new SceneGraph::Texture( mType, mFormat, mSize ); } - OwnerPointer< Render::Texture > transferOwnership( mRenderObject ); - AddTexture( mEventThreadServices.GetUpdateManager(), transferOwnership ); + OwnerPointer< SceneGraph::Texture > transferOwnership( mRenderObject ); + AddTextureMessage( mEventThreadServices.GetUpdateManager(), transferOwnership ); } } @@ -91,7 +92,7 @@ Texture::~Texture() { if( EventThreadServices::IsCoreRunning() && mRenderObject ) { - RemoveTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject ); + RemoveTextureMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject ); } } @@ -151,8 +152,8 @@ bool Texture::Upload( PixelDataPtr pixelData, static_cast< uint16_t >( yOffset ), static_cast< uint16_t >( width ), static_cast< uint16_t >( height ) }; - //UploadTextureMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params ); - UploadTextureMessageV2( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params ); + + UploadTextureMessage( mEventThreadServices, *mRenderObject, pixelData, params ); // Request event processing and update forcely mEventThreadServices.GetRenderController().RequestProcessEventsOnIdle( true ); @@ -176,7 +177,7 @@ void Texture::GenerateMipmaps() { if( EventThreadServices::IsCoreRunning() && mRenderObject ) { - GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject ); + GenerateMipmapsMessage( mEventThreadServices, *mRenderObject ); } } diff --git a/dali/internal/event/rendering/texture-impl.h b/dali/internal/event/rendering/texture-impl.h index 5fe5e5f..5adce62 100644 --- a/dali/internal/event/rendering/texture-impl.h +++ b/dali/internal/event/rendering/texture-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_NEW_TEXTURE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -24,7 +24,7 @@ #include #include #include // Dali::ImageDimensions -#include // Dali::Internal::Render::Texture +#include // Dali::Internal::SceneGraph::Texture #include #include @@ -32,7 +32,7 @@ namespace Dali { namespace Internal { -namespace Render +namespace SceneGraph { class Texture; } @@ -80,7 +80,7 @@ public: * * @return the texture render object */ - Render::Texture* GetRenderObject() const; + SceneGraph::Texture* GetRenderObject() const; /** * @copydoc Dali::Texture::Upload() @@ -144,14 +144,12 @@ private: // unimplemented methods private: // data - Internal::EventThreadServices& mEventThreadServices; ///GetRenderObject(); @@ -101,7 +101,7 @@ void TextureSet::SetSampler( size_t index, SamplerPtr sampler ) mSamplers[index] = sampler; - Render::Sampler* renderSampler(0); + SceneGraph::Sampler* renderSampler(0); if( sampler ) { renderSampler = sampler->GetSamplerRenderObject(); diff --git a/dali/internal/file.list b/dali/internal/file.list index bb006c2..133d9f9 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -87,28 +87,6 @@ internal_src_files = \ $(internal_src_dir)/event/size-negotiation/memory-pool-relayout-container.cpp \ $(internal_src_dir)/event/size-negotiation/relayout-controller-impl.cpp \ \ - $(internal_src_dir)/render/common/render-algorithms.cpp \ - $(internal_src_dir)/render/common/render-debug.cpp \ - $(internal_src_dir)/render/common/render-instruction.cpp \ - $(internal_src_dir)/render/common/render-instruction-container.cpp \ - $(internal_src_dir)/render/common/render-item.cpp \ - $(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/render-frame-buffer.cpp \ - $(internal_src_dir)/render/renderers/render-geometry.cpp \ - $(internal_src_dir)/render/renderers/render-property-buffer.cpp \ - $(internal_src_dir)/render/renderers/render-renderer.cpp \ - $(internal_src_dir)/render/renderers/render-texture.cpp \ - $(internal_src_dir)/render/shaders/program.cpp \ - $(internal_src_dir)/render/shaders/program-controller.cpp \ - $(internal_src_dir)/render/shaders/scene-graph-shader.cpp \ - \ $(internal_src_dir)/update/animation/scene-graph-animation.cpp \ $(internal_src_dir)/update/animation/scene-graph-constraint-base.cpp \ $(internal_src_dir)/update/common/discard-queue.cpp \ @@ -122,7 +100,6 @@ internal_src_files = \ $(internal_src_dir)/update/common/scene-graph-connection-change-propagator.cpp \ $(internal_src_dir)/update/common/scene-graph-property-notification.cpp \ $(internal_src_dir)/update/common/uniform-map.cpp \ - $(internal_src_dir)/update/controllers/render-message-dispatcher.cpp \ $(internal_src_dir)/update/controllers/scene-controller-impl.cpp \ $(internal_src_dir)/update/gestures/pan-gesture-profiling.cpp \ $(internal_src_dir)/update/gestures/scene-graph-pan-gesture.cpp \ @@ -134,11 +111,21 @@ internal_src_files = \ $(internal_src_dir)/update/manager/update-algorithms.cpp \ $(internal_src_dir)/update/manager/update-manager.cpp \ $(internal_src_dir)/update/manager/update-manager-debug.cpp \ - $(internal_src_dir)/update/render-tasks/scene-graph-camera.cpp \ $(internal_src_dir)/update/nodes/node.cpp \ $(internal_src_dir)/update/nodes/node-messages.cpp \ $(internal_src_dir)/update/nodes/scene-graph-layer.cpp \ + $(internal_src_dir)/update/render-tasks/scene-graph-camera.cpp \ $(internal_src_dir)/update/render-tasks/scene-graph-render-task.cpp \ $(internal_src_dir)/update/render-tasks/scene-graph-render-task-list.cpp \ + $(internal_src_dir)/update/rendering/data-providers/render-data-provider.cpp \ + $(internal_src_dir)/update/rendering/render-instruction-container.cpp \ + $(internal_src_dir)/update/rendering/render-instruction.cpp \ + $(internal_src_dir)/update/rendering/render-item.cpp \ + $(internal_src_dir)/update/rendering/scene-graph-frame-buffer.cpp \ + $(internal_src_dir)/update/rendering/scene-graph-geometry.cpp \ + $(internal_src_dir)/update/rendering/scene-graph-property-buffer.cpp \ + $(internal_src_dir)/update/rendering/scene-graph-texture.cpp \ + $(internal_src_dir)/update/rendering/scene-graph-shader.cpp \ $(internal_src_dir)/update/rendering/scene-graph-texture-set.cpp \ - $(internal_src_dir)/update/rendering/scene-graph-renderer.cpp + $(internal_src_dir)/update/rendering/scene-graph-renderer.cpp \ + $(internal_src_dir)/update/rendering/shader-cache.cpp diff --git a/dali/internal/render/common/render-algorithms.cpp b/dali/internal/render/common/render-algorithms.cpp deleted file mode 100644 index 7c5063f..0000000 --- a/dali/internal/render/common/render-algorithms.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -using Dali::Internal::SceneGraph::RenderItem; -using Dali::Internal::SceneGraph::RenderList; -using Dali::Internal::SceneGraph::RenderListContainer; -using Dali::Internal::SceneGraph::RenderInstruction; - -namespace Dali -{ - -namespace Internal -{ - -namespace Render -{ - -namespace -{ - -// Table for fast look-up of Dali::DepthFunction enum to a GL depth function. -// Note: These MUST be in the same order as Dali::DepthFunction enum. -const int DaliDepthToGLDepthTable[] = { GL_NEVER, GL_ALWAYS, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL }; - -// Table for fast look-up of Dali::StencilFunction enum to a GL stencil function. -// Note: These MUST be in the same order as Dali::StencilFunction enum. -const int DaliStencilFunctionToGL[] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS }; - -// Table for fast look-up of Dali::StencilOperation enum to a GL stencil operation. -// Note: These MUST be in the same order as Dali::StencilOperation enum. -const int DaliStencilOperationToGL[] = { GL_ZERO, GL_KEEP, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP }; - -/** - * @brief Find the intersection of two AABB rectangles. - * This is a logical AND operation. IE. The intersection is the area overlapped by both rectangles. - * @param[in] aabbA Rectangle A - * @param[in] aabbB Rectangle B - * @return The intersection of rectangle A & B (result is a rectangle) - */ -inline ClippingBox IntersectAABB( const ClippingBox& aabbA, const ClippingBox& aabbB ) -{ - ClippingBox intersectionBox; - - // First calculate the largest starting positions in X and Y. - intersectionBox.x = std::max( aabbA.x, aabbB.x ); - intersectionBox.y = std::max( aabbA.y, aabbB.y ); - - // Now calculate the smallest ending positions, and take the largest starting - // positions from the result, to get the width and height respectively. - // If the two boxes do not intersect at all, then we need a 0 width and height clipping area. - // We use max here to clamp both width and height to >= 0 for this use-case. - intersectionBox.width = std::max( std::min( aabbA.x + aabbA.width, aabbB.x + aabbB.width ) - intersectionBox.x, 0 ); - intersectionBox.height = std::max( std::min( aabbA.y + aabbA.height, aabbB.y + aabbB.height ) - intersectionBox.y, 0 ); - - return intersectionBox; -} - -/** - * @brief Set up the stencil and color buffer for automatic clipping (StencilMode::AUTO). - * @param[in] item The current RenderItem about to be rendered - * @param[in] context The context - * @param[in/out] lastClippingDepth The stencil depth of the last renderer drawn. - * @param[in/out] lastClippingId The clipping ID of the last renderer drawn. - */ -inline void SetupStencilClipping( const RenderItem& item, Context& context, uint32_t& lastClippingDepth, uint32_t& lastClippingId ) -{ - const Dali::Internal::SceneGraph::Node* node = item.mNode; - const uint32_t clippingId = node->GetClippingId(); - // If there is no clipping Id, then either we haven't reached a clipping Node yet, or there aren't any. - // Either way we can skip clipping setup for this renderer. - if( clippingId == 0u ) - { - // Exit immediately if there are no clipping actions to perform (EG. we have not yet hit a clipping node). - context.EnableStencilBuffer( false ); - return; - } - - context.EnableStencilBuffer( true ); - - const uint32_t clippingDepth = node->GetClippingDepth(); - - // Pre-calculate a mask which has all bits set up to and including the current clipping depth. - // EG. If depth is 3, the mask would be "111" in binary. - const uint32_t currentDepthMask = ( 1u << clippingDepth ) - 1u; - - // Are we are writing to the stencil buffer? - if( item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_CHILDREN ) - { - // We are writing to the stencil buffer. - // If clipping Id is 1, this is the first clipping renderer within this render-list. - if( clippingId == 1u ) - { - // We are enabling the stencil-buffer for the first time within this render list. - // Clear the buffer at this point. - context.StencilMask( 0xff ); - context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES ); - } - else if( ( clippingDepth < lastClippingDepth ) || - ( ( clippingDepth == lastClippingDepth ) && ( clippingId > lastClippingId ) ) ) - { - // The above if() statement tests if we need to clear some (not all) stencil bit-planes. - // We need to do this if either of the following are true: - // 1) We traverse up the scene-graph to a previous stencil depth - // 2) We are at the same stencil depth but the clipping Id has increased. - // - // This calculation takes the new depth to move to, and creates an inverse-mask of that number of consecutive bits. - // This has the effect of clearing everything except the bit-planes up to (and including) our current depth. - const uint32_t stencilClearMask = ( currentDepthMask >> 1u ) ^ 0xff; - - context.StencilMask( stencilClearMask ); - context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES ); - } - - // We keep track of the last clipping Id and depth so we can determine when we are - // moving back up the scene graph and require some of the stencil bit-planes to be deleted. - lastClippingDepth = clippingDepth; - lastClippingId = clippingId; - - // We only ever write to bit-planes up to the current depth as we may need - // to erase individual bit-planes and revert to a previous clipping area. - // Our reference value for testing (in StencilFunc) is written to to the buffer, but we actually - // want to test a different value. IE. All the bit-planes up to but not including the current depth. - // So we use the Mask parameter of StencilFunc to mask off the top bit-plane when testing. - // Here we create our test mask to innore the top bit of the reference test value. - // As the mask is made up of contiguous "1" values, we can do this quickly with a bit-shift. - const uint32_t testMask = currentDepthMask >> 1u; - - context.StencilFunc( GL_EQUAL, currentDepthMask, testMask ); // Test against existing stencil bit-planes. All must match up to (but not including) this depth. - context.StencilMask( currentDepthMask ); // Write to the new stencil bit-plane (the other previous bit-planes are also written to). - context.StencilOp( GL_KEEP, GL_REPLACE, GL_REPLACE ); - } - else - { - // We are reading from the stencil buffer. Set up the stencil accordingly - // This calculation sets all the bits up to the current depth bit. - // This has the effect of testing that the pixel being written to exists in every bit-plane up to the current depth. - context.StencilFunc( GL_EQUAL, currentDepthMask, 0xff ); - context.StencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); - } -} - -/** - * @brief Sets up the depth buffer for reading and writing based on the current render item. - * The items read and write mode are used if specified. - * - If AUTO is selected for reading, the decision will be based on the Layer Behavior. - * - If AUTO is selected for writing, the decision will be based on the items opacity. - * @param[in] item The RenderItem to set up the depth buffer for. - * @param[in] context The context used to execute GL commands. - * @param[in] depthTestEnabled True if depth testing has been enabled. - * @param[in/out] firstDepthBufferUse Initialize to true on the first call, this method will set it to false afterwards. - */ -inline void SetupDepthBuffer( const RenderItem& item, Context& context, bool depthTestEnabled, bool& firstDepthBufferUse ) -{ - // Set up whether or not to write to the depth buffer. - const DepthWriteMode::Type depthWriteMode = item.mRenderer->GetDepthWriteMode(); - // Most common mode (AUTO) is tested first. - const bool enableDepthWrite = ( ( depthWriteMode == DepthWriteMode::AUTO ) && depthTestEnabled && item.mIsOpaque ) || - ( depthWriteMode == DepthWriteMode::ON ); - - // Set up whether or not to read from (test) the depth buffer. - const DepthTestMode::Type depthTestMode = item.mRenderer->GetDepthTestMode(); - // Most common mode (AUTO) is tested first. - const bool enableDepthTest = ( ( depthTestMode == DepthTestMode::AUTO ) && depthTestEnabled ) || - ( depthTestMode == DepthTestMode::ON ); - - // Is the depth buffer in use? - if( enableDepthWrite || enableDepthTest ) - { - // The depth buffer must be enabled if either reading or writing. - context.EnableDepthBuffer( true ); - - // Set up the depth mask based on our depth write setting. - context.DepthMask( enableDepthWrite ); - - // Look-up the GL depth function from the Dali::DepthFunction enum, and set it. - context.DepthFunc( DaliDepthToGLDepthTable[ item.mRenderer->GetDepthFunction() ] ); - - // 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. - if( DALI_UNLIKELY( firstDepthBufferUse ) ) - { - // This is the first time the depth buffer is being written to or read. - firstDepthBufferUse = false; - - // Note: The buffer will only be cleared if written to since a previous clear. - context.Clear( GL_DEPTH_BUFFER_BIT, Context::CHECK_CACHED_VALUES ); - } - } - else - { - // The depth buffer is not being used by this renderer, so we must disable it to stop it being tested. - context.EnableDepthBuffer( false ); - } -} - -} // Unnamed namespace - - -/** - * @brief This method is responsible for making decisions on when to apply and unapply scissor clipping, and what rectangular dimensions should be used. - * A stack of scissor clips at each depth of clipping is maintained, so it can be applied and unapplied. - * As the clips are hierarchical, this RenderItems AABB is clipped against the current "active" scissor bounds via an intersection operation. - * @param[in] item The current RenderItem about to be rendered - * @param[in] context The context - */ -inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Context& context ) -{ - // Get the number of child scissors in the stack (do not include layer or root box). - size_t childStackDepth = mScissorStack.size() - 1u; - const uint32_t scissorDepth = item.mNode->GetScissorDepth(); - const bool clippingNode = item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_TO_BOUNDING_BOX; - bool traversedUpTree = false; - - // If we are using scissor clipping and we are at the same depth (or less), we need to undo previous clips. - // We do this by traversing up the scissor clip stack and then apply the appropriate clip for the current render item. - // To know this, we use clippingDepth. This value is set on *every* node, but only increased as clipping nodes are hit depth-wise. - // So we know if we are at depth 4 and the stackDepth is 5, that we have gone up. - // If the depth is the same then we are effectively part of a different sub-tree from the parent, we must also remove the current clip. - // Note: Stack depth must always be at least 1, as we will have the layer or stage size as the root value. - if( ( childStackDepth > 0u ) && ( scissorDepth < childStackDepth ) ) - { - while( scissorDepth < childStackDepth ) - { - mScissorStack.pop_back(); - --childStackDepth; - } - - // We traversed up the tree, we need to apply a new scissor rectangle (unless we are at the root). - traversedUpTree = true; - } - else if( clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth ) // case of sibling clip area - { - mScissorStack.pop_back(); - --childStackDepth; - } - - // If we are on a clipping node, or we have traveled up the tree and gone back past a clipping node, may need to apply a new scissor clip. - if( clippingNode || traversedUpTree ) - { - // First, check if we are a clipping node. - if( clippingNode ) - { - // This is a clipping node. We generate the AABB for this node and intersect it with the previous intersection further up the tree. - - // Get the AABB bounding box for the current render item. - const ClippingBox scissorBox( item.CalculateViewportSpaceAABB( mViewportRectangle.width, mViewportRectangle.height ) ); - - // Get the AABB for the parent item that we must intersect with. - const ClippingBox& parentBox( mScissorStack.back() ); - - // We must reduce the clipping area based on the parents area to allow nested clips. This is a set intersection function. - // We add the new scissor box to the stack so we can return to it if needed. - mScissorStack.emplace_back( IntersectAABB( parentBox, scissorBox ) ); - } - - // The scissor test is enabled if we have any children on the stack, OR, if there are none but it is a user specified layer scissor box. - // IE. It is not enabled if we are at the top of the stack and the layer does not have a specified clipping box. - const bool scissorEnabled = ( mScissorStack.size() > 0u ) || mHasLayerScissor; - - // Enable the scissor test based on the above calculation - context.SetScissorTest( scissorEnabled ); - - // If scissor is enabled, we use the calculated screen-space coordinates (now in the stack). - if( scissorEnabled ) - { - ClippingBox useScissorBox( mScissorStack.back() ); - context.Scissor( useScissorBox.x, useScissorBox.y, useScissorBox.width, useScissorBox.height ); - } - } -} - -inline void RenderAlgorithms::SetupClipping( const RenderItem& item, Context& context, bool& usedStencilBuffer, uint32_t& lastClippingDepth, uint32_t& lastClippingId ) -{ - RenderMode::Type renderMode = RenderMode::AUTO; - const Renderer *renderer = item.mRenderer; - if( renderer ) - { - renderMode = renderer->GetRenderMode(); - } - - // Setup the stencil using either the automatic clipping feature, or, the manual per-renderer stencil API. - // Note: This switch is in order of most likely value first. - switch( renderMode ) - { - case RenderMode::AUTO: - { - // Turn the color buffer on as we always want to render this renderer, regardless of clipping hierarchy. - context.ColorMask( true ); - - // The automatic clipping feature will manage the scissor and stencil functions. - // As both scissor and stencil clips can be nested, we may be simultaneously traversing up the scissor tree, requiring a scissor to be un-done. Whilst simultaneously adding a new stencil clip. - // We process both based on our current and old clipping depths for each mode. - // Both methods with return rapidly if there is nothing to be done for that type of clipping. - SetupScissorClipping( item, context ); - SetupStencilClipping( item, context, lastClippingDepth, lastClippingId ); - break; - } - - case RenderMode::NONE: - case RenderMode::COLOR: - { - // No clipping is performed for these modes. - // Note: We do not turn off scissor clipping as it may be used for the whole layer. - // The stencil buffer will not be used at all. - context.EnableStencilBuffer( false ); - - // Setup the color buffer based on the RenderMode. - context.ColorMask( renderMode == RenderMode::COLOR ); - break; - } - - case RenderMode::STENCIL: - case RenderMode::COLOR_STENCIL: - { - // We are using the low-level Renderer Stencil API. - // The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it. - // Note: As the command state is cached, it is only sent when needed. - context.EnableStencilBuffer( true ); - - // Setup the color buffer based on the RenderMode. - context.ColorMask( renderMode == RenderMode::COLOR_STENCIL ); - - // If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears). - if( !usedStencilBuffer ) - { - context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES ); - usedStencilBuffer = true; - } - - // Setup the stencil buffer based on the renderers properties. - context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ], - renderer->GetStencilFunctionReference(), - renderer->GetStencilFunctionMask() ); - context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ], - DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ], - DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] ); - context.StencilMask( renderer->GetStencilMask() ); - break; - } - } -} - -inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList, - Context& context, - BufferIndex bufferIndex, - const Matrix& viewMatrix, - const Matrix& projectionMatrix ) -{ - DALI_PRINT_RENDER_LIST( renderList ); - - // Note: The depth buffer is enabled or disabled on a per-renderer basis. - // Here we pre-calculate the value to use if these modes are set to AUTO. - const bool autoDepthTestMode( !( renderList.GetSourceLayer()->IsDepthTestDisabled() ) && renderList.HasColorRenderItems() ); - const std::size_t count = renderList.Count(); - uint32_t lastClippingDepth( 0u ); - uint32_t lastClippingId( 0u ); - bool usedStencilBuffer( false ); - bool firstDepthBufferUse( true ); - mViewportRectangle = context.GetViewport(); - mHasLayerScissor = false; - - // Setup Scissor testing (for both viewport and per-node scissor) - mScissorStack.clear(); - if( renderList.IsClipping() ) - { - context.SetScissorTest( true ); - const ClippingBox& layerScissorBox = renderList.GetClippingBox(); - context.Scissor( layerScissorBox.x, layerScissorBox.y, layerScissorBox.width, layerScissorBox.height ); - mScissorStack.push_back( layerScissorBox ); - mHasLayerScissor = true; - } - else - { - // We are not performing a layer clip. Add the viewport as the root scissor rectangle. - context.SetScissorTest( false ); - mScissorStack.push_back( mViewportRectangle ); - } - - // Loop through all RenderList in the RenderList, set up any prerequisites to render them, then perform the render. - for( size_t index( 0u ); index < count; ++index ) - { - const RenderItem& item = renderList.GetItem( index ); - DALI_PRINT_RENDER_ITEM( item ); - - // Set up clipping based on both the Renderer and Actor APIs. - // The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used. - SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId ); - - if( DALI_LIKELY( item.mRenderer ) ) - { - // Set up the depth buffer based on per-renderer flags. - // If the per renderer flags are set to "ON" or "OFF", they will always override any Layer depth mode or - // draw-mode state, such as Overlays. - // If the flags are set to "AUTO", the behavior then depends on the type of renderer. Overlay Renderers will always - // disable depth testing and writing. Color Renderers will enable them if the Layer does. - SetupDepthBuffer( item, context, autoDepthTestMode, firstDepthBufferUse ); - - // Render the item. - item.mRenderer->Render( context, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, - viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque ); - } - } -} - -RenderAlgorithms::RenderAlgorithms() - : mViewportRectangle(), - mHasLayerScissor( false ) -{ -} - -void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instruction, Context& context, BufferIndex bufferIndex ) -{ - DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex ); - - const Matrix* viewMatrix = instruction.GetViewMatrix( bufferIndex ); - const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex ); - - DALI_ASSERT_DEBUG( viewMatrix ); - DALI_ASSERT_DEBUG( projectionMatrix ); - - if( viewMatrix && projectionMatrix ) - { - const RenderListContainer::SizeType count = instruction.RenderListCount(); - - // Iterate through each render list in order. If a pair of render lists - // are marked as interleaved, then process them together. - for( RenderListContainer::SizeType index = 0; index < count; ++index ) - { - const RenderList* renderList = instruction.GetRenderList( index ); - - if( renderList && !renderList->IsEmpty() ) - { - ProcessRenderList( *renderList, context, bufferIndex, *viewMatrix, *projectionMatrix ); - } - } - } -} - - -} // namespace Render - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/common/render-algorithms.h b/dali/internal/render/common/render-algorithms.h deleted file mode 100644 index 5d4e44f..0000000 --- a/dali/internal/render/common/render-algorithms.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef DALI_INTERNAL_RENDER_ALGORITHMS_H -#define DALI_INTERNAL_RENDER_ALGORITHMS_H - -/* - * Copyright (c) 2017 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 -{ -class Context; - -namespace SceneGraph -{ -class RenderInstruction; -struct RenderItem; -} - -namespace Render -{ - -/** - * @brief The responsibility of the RenderAlgorithms object is to action renders required by a RenderInstruction. - */ -class RenderAlgorithms -{ - public: - - /** - * Constructor. - */ - RenderAlgorithms(); - - /** - * Process a render-instruction. - * @param[in] instruction The render-instruction to process. - * @param[in] context The GL context. - * @param[in] bufferIndex The current render buffer index (previous update buffer) - */ - void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction, Context& context, BufferIndex bufferIndex ); - - private: - - /** - * @brief Calculate a 2D AABB (axis aligned bounding box) in screen space. - * The RenderItems dimensions are translated and a Z value of 0 is assumed for this purpose. - * No projection is performed, but rotation on Z is supported. - * @param[in] item The RenderItem to generate an AABB for - * @return The generated AABB in screen space - */ - inline Dali::ClippingBox CalculateScreenSpaceAABB( const Dali::Internal::SceneGraph::RenderItem& item ); - - /** - * @brief Perform any scissor clipping related operations based on the current RenderItem. - * This includes: - * - Determining if any action is to be taken (so the method can be exited early if not). - * - If the node is a clipping node, apply the nodes clip intersected with the current/parent scissor clip. - * - If we have gone up the scissor hierarchy, and need to un-apply a scissor clip. - * - Disable scissor clipping completely if it is not needed - * @param[in] item The current RenderItem (about to be rendered) - * @param[in] context The current Context - */ - inline void SetupScissorClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context ); - - /** - * @brief Set up the clipping based on the specified clipping settings. - * @param[in] item The current RenderItem (about to be rendered) - * @param[in] context The context - * @param[in/out] usedStencilBuffer True if the stencil buffer has been used so far within this RenderList. Used by StencilMode::ON. - * @param[in/out] lastClippingDepth The stencil depth of the last renderer drawn. Used by the clipping feature. - * @param[in/out] lastClippingId The clipping ID of the last renderer drawn. Used by the clipping feature. - */ - inline void SetupClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context, bool& usedStencilBuffer, uint32_t& lastClippingDepth, uint32_t& lastClippingId ); - - /** - * @brief Process a render-list. - * @param[in] renderList The render-list to process. - * @param[in] context The GL context. - * @param[in] buffer The current render buffer index (previous update buffer) - * @param[in] viewMatrix The view matrix from the appropriate camera. - * @param[in] projectionMatrix The projection matrix from the appropriate camera. - */ - inline void ProcessRenderList( const Dali::Internal::SceneGraph::RenderList& renderList, Context& context, BufferIndex bufferIndex, const Matrix& viewMatrix, const Matrix& projectionMatrix ); - - // Prevent copying: - RenderAlgorithms( RenderAlgorithms& rhs ); - RenderAlgorithms& operator=( const RenderAlgorithms& rhs ); - - - // Member variables: - - using ScissorStackType = std::vector; ///< The container type used to maintain the applied scissor hierarchy - - ScissorStackType mScissorStack; ///< Contains the currently applied scissor hierarchy (so we can undo clips) - Dali::ClippingBox mViewportRectangle; ///< The viewport dimensions, used to translate AABBs to scissor coordinates - bool mHasLayerScissor:1; ///< Marks if the currently process render instruction has a layer-based clipping region -}; - -} // namespace Render - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_RENDER_ALGORITHMS_H diff --git a/dali/internal/render/common/render-debug.cpp b/dali/internal/render/common/render-debug.cpp deleted file mode 100644 index e418a6b..0000000 --- a/dali/internal/render/common/render-debug.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2016 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include - -using Dali::Internal::SceneGraph::Node; -using Dali::Internal::SceneGraph::RenderList; - -namespace Dali -{ - -namespace Internal -{ - -namespace Render -{ - -// These functions should only be defined if they are being used by the #define in the header. -// Otherwise they will contribute negatively to code coverage. -#ifdef DALI_PRINT_RENDER_INFO - -void PrintFrameStart( BufferIndex bufferIndex ) -{ - DALI_LOG_RENDER_INFO( "RENDER START - bufferIndex: %d\n", bufferIndex ); -} - -void PrintFrameEnd() -{ - DALI_LOG_RENDER_INFO( "RENDER END\n\n" ); -} - -void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index ) -{ - const char* target = (nullptr != instruction.mFrameBuffer) ? "FrameBuffer" : "Screen"; - - std::stringstream debugStream; - debugStream << "Rendering to " << target << ", View: " << *(instruction.GetViewMatrix(index)) << " Projection: " << *(instruction.GetProjectionMatrix(index)); - - if( instruction.mIsViewportSet ) - { - debugStream << " Viewport: " << instruction.mViewport.x << "," << instruction.mViewport.y << " " << instruction.mViewport.width << "x" << instruction.mViewport.height; - } - - if( instruction.mIsClearColorSet ) - { - debugStream << " ClearColor: " << instruction.mClearColor; - } - - std::string debugString( debugStream.str() ); - DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() ); -} - -void PrintRenderList( const RenderList& list ) -{ - std::stringstream debugStream; - debugStream << "Rendering items"; - - if( list.IsClipping() ) - { - debugStream << ", ClippingBox: " << list.GetClippingBox().x << "," << list.GetClippingBox().y << " " << list.GetClippingBox().width << "x" << list.GetClippingBox().height; - } - - std::string debugString( debugStream.str() ); - DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() ); -} - -void PrintRenderItem( const SceneGraph::RenderItem& item ) -{ - std::stringstream debugStream; - debugStream << "Rendering item, ModelView: " << item.mModelViewMatrix; - - std::string debugString( debugStream.str() ); - DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() ); -} - -void PrintRendererCount( unsigned int frameCount, unsigned int rendererCount ) -{ - if( frameCount % 120 == 30 ) // Print every 2 seconds reg - { - Debug::LogMessage( Debug::DebugInfo, "Renderer Total # renderers: %u\n", rendererCount ); - } -} - -#endif - -} // Render - -} // Internal - -} // Dali diff --git a/dali/internal/render/common/render-debug.h b/dali/internal/render/common/render-debug.h deleted file mode 100644 index 5cb25be..0000000 --- a/dali/internal/render/common/render-debug.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef __DALI_INTERNAL_RENDER_DEBUG_H__ -#define __DALI_INTERNAL_RENDER_DEBUG_H__ - -/* - * Copyright (c) 2015 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 - -// define this to print information about the items rendered each frame -#undef DALI_PRINT_RENDER_INFO - -#ifdef DALI_PRINT_RENDER_INFO - -#define DALI_PRINT_RENDER_START(x) Render::PrintFrameStart(x); -#define DALI_PRINT_RENDER_END() Render::PrintFrameEnd(); -#define DALI_PRINT_RENDER_INSTRUCTION(x,index) Render::PrintRenderInstruction(x,index); -#define DALI_PRINT_RENDER_LIST(x) Render::PrintRenderList(x); -#define DALI_PRINT_RENDER_ITEM(x) Render::PrintRenderItem(x); - -#else // DALI_PRINT_RENDER_INFO - -#define DALI_PRINT_RENDER_START(x) -#define DALI_PRINT_RENDER_END() -#define DALI_PRINT_RENDER_INSTRUCTION(x,index) -#define DALI_PRINT_RENDER_LIST(x) -#define DALI_PRINT_RENDER_ITEM(x) - -#endif // DALI_PRINT_RENDER_INFO - -#undef DALI_PRINT_RENDERERS - -// Turn this on to see a snapshot of # renderers every 2 seconds -//#define DALI_PRINT_RENDERERS 1 - -#ifdef DALI_PRINT_RENDERERS -#define DALI_PRINT_RENDERER_COUNT(x, y) Render::PrintRendererCount(x, y) -#else // DALI_PRINT_RENDERERS -#define DALI_PRINT_RENDERER_COUNT(x, y) -#endif // DALI_PRINT_RENDERERS - - -namespace Dali -{ - -namespace Internal -{ - -class PropertyInputImpl; - -namespace SceneGraph -{ -class Node; -class RenderInstruction; -struct RenderList; -struct RenderItem; -} - -namespace Render -{ - -/** - * Print a debug message at the start of the render-thread. - * @param[in] buffer The current render buffer index (previous update buffer) - */ -void PrintFrameStart( BufferIndex bufferIndex ); - -/** - * Print a debug message at the end of the render-thread. - */ -void PrintFrameEnd(); - -/** - * Print some information about a render-instruction. - * @param[in] instruction The render-instruction. - * @param[in] index to use - */ -void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index ); - -/** - * Print some information about a render-list. - * @param[in] instruction The render-list. - */ -void PrintRenderList( const SceneGraph::RenderList& list ); - -/** - * Print some information about a render-item. - * @param[in] instruction The render-item. - */ -void PrintRenderItem( const SceneGraph::RenderItem& item ); - -/** - * Print the number of image renderers - * @param[in] frameCount The frame counter - * @param[in] rendererCount The number of image renderers - */ -void PrintRendererCount( unsigned int frameCount, unsigned int rendererCount ); - -/** - * Recursively dumps a Node tree. - * @param[in] node The starting node to dump from - * @param[in] indent Optional. Leave unset for default indent (used internally while recursing) - */ -void DumpNode( const SceneGraph::Node* node, unsigned int indent = 0 ); - -} // Render - -} // Internal - -} // Dali - -#endif // __DALI_INTERNAL_RENDER_DEBUG_H__ diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp deleted file mode 100644 index a4ddb84..0000000 --- a/dali/internal/render/common/render-manager.cpp +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace SceneGraph -{ - -/** - * Structure to contain internal data - */ -struct RenderManager::Impl -{ - Impl( Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction ) - : context( glAbstraction ), - glSyncAbstraction( glSyncAbstraction ), - renderQueue(), - instructions(), - renderAlgorithms(), - backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), - frameCount( 0u ), - renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ), - defaultSurfaceRect(), - rendererContainer(), - samplerContainer(), - textureContainer(), - frameBufferContainer(), - lastFrameWasRendered( false ), - programController( glAbstraction ) - { - } - - ~Impl() - { - } - - void AddRenderTracker( Render::RenderTracker* renderTracker ) - { - DALI_ASSERT_DEBUG( renderTracker != NULL ); - mRenderTrackers.PushBack( renderTracker ); - } - - void RemoveRenderTracker( Render::RenderTracker* renderTracker ) - { - mRenderTrackers.EraseObject( renderTracker ); - } - - void UpdateTrackers() - { - for( auto&& iter : mRenderTrackers ) - { - iter->PollSyncObject(); - } - } - - // the order is important for destruction, - // programs are owned by context at the moment. - Context context; ///< holds the GL state - Integration::GlSyncAbstraction& glSyncAbstraction; ///< GL sync abstraction - RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread. - - // Render instructions describe what should be rendered during RenderManager::Render() - // Owned by RenderManager. Update manager updates instructions for the next frame while we render the current one - RenderInstructionContainer instructions; - Render::RenderAlgorithms renderAlgorithms; ///< The RenderAlgorithms object is used to action the renders required by a RenderInstruction - - Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame. - - unsigned int frameCount; ///< The current frame count - BufferIndex renderBufferIndex; ///< The index of the buffer to read from; this is opposite of the "update" buffer - - Rect defaultSurfaceRect; ///< Rectangle for the default surface we are rendering to - - OwnerContainer< Render::Renderer* > rendererContainer; ///< List of owned renderers - OwnerContainer< Render::Sampler* > samplerContainer; ///< List of owned samplers - OwnerContainer< Render::Texture* > textureContainer; ///< List of owned textures - OwnerContainer< Render::FrameBuffer* > frameBufferContainer; ///< List of owned framebuffers - OwnerContainer< Render::PropertyBuffer* > propertyBufferContainer; ///< List of owned property buffers - OwnerContainer< Render::Geometry* > geometryContainer; ///< List of owned Geometries - - bool lastFrameWasRendered; ///< Keeps track of the last frame being rendered due to having render instructions - - OwnerContainer< Render::RenderTracker* > mRenderTrackers; ///< List of render trackers - - ProgramController programController; ///< Owner of the GL programs - -}; - -RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction ) -{ - RenderManager* manager = new RenderManager; - manager->mImpl = new Impl( glAbstraction, - glSyncAbstraction ); - return manager; -} - -RenderManager::RenderManager() -: mImpl(NULL) -{ -} - -RenderManager::~RenderManager() -{ - delete mImpl; -} - -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->GlContextDestroyed(); - } - - //Inform framebuffers - for( auto&& framebuffer : mImpl->frameBufferContainer ) - { - framebuffer->GlContextDestroyed(); - } - - // inform renderers - for( auto&& renderer : mImpl->rendererContainer ) - { - renderer->GlContextDestroyed(); - } -} - -void RenderManager::SetShaderSaver( ShaderSaver& upstream ) -{ - mImpl->programController.SetShaderSaver( upstream ); -} - -RenderInstructionContainer& RenderManager::GetRenderInstructionContainer() -{ - return mImpl->instructions; -} - -void RenderManager::SetBackgroundColor( const Vector4& color ) -{ - mImpl->backgroundColor = color; -} - -void RenderManager::SetDefaultSurfaceRect(const Rect& rect) -{ - mImpl->defaultSurfaceRect = rect; -} - -void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer ) -{ - // Initialize the renderer as we are now in render thread - renderer->Initialize( mImpl->context ); - - mImpl->rendererContainer.PushBack( renderer.Release() ); -} - -void RenderManager::RemoveRenderer( Render::Renderer* renderer ) -{ - mImpl->rendererContainer.EraseObject( renderer ); -} - -void RenderManager::AddSampler( OwnerPointer< Render::Sampler >& sampler ) -{ - mImpl->samplerContainer.PushBack( sampler.Release() ); -} - -void RenderManager::RemoveSampler( Render::Sampler* sampler ) -{ - mImpl->samplerContainer.EraseObject( sampler ); -} - -void RenderManager::AddTexture( OwnerPointer< Render::Texture >& texture ) -{ - texture->Initialize( mImpl->context ); - mImpl->textureContainer.PushBack( texture.Release() ); -} - -void RenderManager::RemoveTexture( Render::Texture* texture ) -{ - DALI_ASSERT_DEBUG( NULL != texture ); - - // Find the texture, use reference to pointer so we can do the erase safely - for ( auto&& iter : mImpl->textureContainer ) - { - if ( iter == texture ) - { - texture->Destroy( mImpl->context ); - mImpl->textureContainer.Erase( &iter ); // Texture found; now destroy it - return; - } - } -} - -void RenderManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) -{ - texture->Upload( mImpl->context, pixelData, params ); -} - -void RenderManager::GenerateMipmaps( Render::Texture* texture ) -{ - texture->GenerateMipmaps( mImpl->context ); -} - -void RenderManager::SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode ) -{ - sampler->mMinificationFilter = static_cast(minFilterMode); - sampler->mMagnificationFilter = static_cast(magFilterMode ); -} - -void RenderManager::SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) -{ - sampler->mRWrapMode = static_cast(rWrapMode); - sampler->mSWrapMode = static_cast(sWrapMode); - sampler->mTWrapMode = static_cast(tWrapMode); -} - -void RenderManager::AddFrameBuffer( Render::FrameBuffer* frameBuffer ) -{ - mImpl->frameBufferContainer.PushBack( frameBuffer ); - frameBuffer->Initialize(mImpl->context); -} - -void RenderManager::RemoveFrameBuffer( Render::FrameBuffer* frameBuffer ) -{ - DALI_ASSERT_DEBUG( NULL != frameBuffer ); - - // Find the sampler, use reference so we can safely do the erase - for ( auto&& iter : mImpl->frameBufferContainer ) - { - if ( iter == frameBuffer ) - { - frameBuffer->Destroy( mImpl->context ); - mImpl->frameBufferContainer.Erase( &iter ); // frameBuffer found; now destroy it - break; - } - } -} - -void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) -{ - frameBuffer->AttachColorTexture( mImpl->context, texture, mipmapLevel, layer ); -} - -void RenderManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer ) -{ - mImpl->propertyBufferContainer.PushBack( propertyBuffer.Release() ); -} - -void RenderManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer ) -{ - mImpl->propertyBufferContainer.EraseObject( propertyBuffer ); -} - -void RenderManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ) -{ - propertyBuffer->SetFormat( format.Release() ); -} - -void RenderManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ) -{ - propertyBuffer->SetData( data.Release(), size ); -} - -void RenderManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& indices ) -{ - geometry->SetIndexBuffer( indices ); -} - -void RenderManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry ) -{ - mImpl->geometryContainer.PushBack( geometry.Release() ); -} - -void RenderManager::RemoveGeometry( Render::Geometry* geometry ) -{ - mImpl->geometryContainer.EraseObject( geometry ); -} - -void RenderManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ) -{ - DALI_ASSERT_DEBUG( NULL != geometry ); - - // Find the geometry - for ( auto&& iter : mImpl->geometryContainer ) - { - if ( iter == geometry ) - { - iter->AddPropertyBuffer( propertyBuffer ); - break; - } - } -} - -void RenderManager::RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ) -{ - DALI_ASSERT_DEBUG( NULL != geometry ); - - // Find the geometry - for ( auto&& iter : mImpl->geometryContainer ) - { - if ( iter == geometry ) - { - iter->RemovePropertyBuffer( propertyBuffer ); - break; - } - } -} - -void RenderManager::SetGeometryType( Render::Geometry* geometry, unsigned int geometryType ) -{ - geometry->SetType( Render::Geometry::Type(geometryType) ); -} - -void RenderManager::AddRenderTracker( Render::RenderTracker* renderTracker ) -{ - mImpl->AddRenderTracker(renderTracker); -} - -void RenderManager::RemoveRenderTracker( Render::RenderTracker* renderTracker ) -{ - mImpl->RemoveRenderTracker(renderTracker); -} - -ProgramCache* RenderManager::GetProgramCache() -{ - return &(mImpl->programController); -} - -void RenderManager::Render( Integration::RenderStatus& status ) -{ - 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; - - // Process messages queued during previous update - mImpl->renderQueue.ProcessMessages( mImpl->renderBufferIndex ); - - const size_t count = mImpl->instructions.Count( mImpl->renderBufferIndex ); - const bool haveInstructions = count > 0u; - - // Only render if we have instructions to render, or the last frame was rendered (and therefore a clear is required). - if( haveInstructions || mImpl->lastFrameWasRendered ) - { - // Mark that we will require a post-render step to be performed (includes swap-buffers). - status.SetNeedsPostRender( true ); - - // switch rendering to adaptor provided (default) buffer - mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0u ); - - mImpl->context.Viewport( mImpl->defaultSurfaceRect.x, - mImpl->defaultSurfaceRect.y, - mImpl->defaultSurfaceRect.width, - mImpl->defaultSurfaceRect.height ); - - mImpl->context.ClearColor( mImpl->backgroundColor.r, - mImpl->backgroundColor.g, - mImpl->backgroundColor.b, - mImpl->backgroundColor.a ); - - mImpl->context.ClearStencil( 0 ); - - // Clear the entire color, depth and stencil buffers for the default framebuffer. - // It is important to clear all 3 buffers, for performance on deferred renderers like Mali - // e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit", - // and then stall. That problem is only noticeable when rendering a large number of vertices per frame. - mImpl->context.SetScissorTest( false ); - mImpl->context.ColorMask( true ); - mImpl->context.DepthMask( true ); - mImpl->context.StencilMask( 0xFF ); // 8 bit stencil mask, all 1's - mImpl->context.Clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, Context::FORCE_CLEAR ); - - // 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(); - - for( size_t i = 0; i < count; ++i ) - { - RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i ); - - DoRender( instruction ); - } - - GLenum attachments[] = { GL_DEPTH, GL_STENCIL }; - mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments); - - mImpl->UpdateTrackers(); - - //Notify RenderGeometries that rendering has finished - for ( auto&& iter : mImpl->geometryContainer ) - { - iter->OnRenderFinished(); - } - } - - // If this frame was rendered due to instructions existing, we mark this so we know to clear the next frame. - mImpl->lastFrameWasRendered = haveInstructions; - - /** - * The rendering has finished; swap to the next buffer. - * Ideally the update has just finished using this buffer; otherwise the render thread - * should block until the update has finished. - */ - mImpl->renderBufferIndex = (0 != mImpl->renderBufferIndex) ? 0 : 1; - - DALI_PRINT_RENDER_END(); -} - -void RenderManager::DoRender( RenderInstruction& instruction ) -{ - Rect viewportRect; - Vector4 clearColor; - - if ( instruction.mIsClearColorSet ) - { - clearColor = instruction.mClearColor; - } - else - { - clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR; - } - - if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) ) - { - instruction.mFrameBuffer->Bind( mImpl->context ); - if ( instruction.mIsViewportSet ) - { - // For glViewport the lower-left corner is (0,0) - const int y = ( instruction.mFrameBuffer->GetHeight() - instruction.mViewport.height ) - instruction.mViewport.y; - viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); - } - else - { - viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() ); - } - } - else // !(instruction.mOffscreenTexture) - { - // switch rendering to adaptor provided (default) buffer - mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); - - // Check whether a viewport is specified, otherwise the full surface size is used - if ( instruction.mIsViewportSet ) - { - // For glViewport the lower-left corner is (0,0) - const int y = ( mImpl->defaultSurfaceRect.height - instruction.mViewport.height ) - instruction.mViewport.y; - viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); - } - else - { - viewportRect = mImpl->defaultSurfaceRect; - } - } - - mImpl->context.Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height); - - if ( instruction.mIsClearColorSet ) - { - mImpl->context.ClearColor( clearColor.r, - clearColor.g, - clearColor.b, - clearColor.a ); - - // Clear the viewport area only - mImpl->context.SetScissorTest( true ); - mImpl->context.Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height ); - mImpl->context.ColorMask( true ); - mImpl->context.Clear( GL_COLOR_BUFFER_BIT , Context::CHECK_CACHED_VALUES ); - mImpl->context.SetScissorTest( false ); - } - - mImpl->renderAlgorithms.ProcessRenderInstruction( instruction, mImpl->context, mImpl->renderBufferIndex ); - - if( instruction.mRenderTracker && ( instruction.mFrameBuffer != NULL ) ) - { - // 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) - instruction.mRenderTracker->CreateSyncObject( mImpl->glSyncAbstraction ); - instruction.mRenderTracker = NULL; // Only create once. - } -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/common/render-manager.h b/dali/internal/render/common/render-manager.h deleted file mode 100644 index 4b35aa8..0000000 --- a/dali/internal/render/common/render-manager.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__ - -/* - * Copyright (c) 2017 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 - -namespace Dali -{ - -namespace Integration -{ -class GlAbstraction; -class GlSyncAbstraction; -class RenderStatus; -} - -struct Vector4; - -namespace Internal -{ -class Context; -class ProgramCache; -class ShaderSaver; - -namespace Render -{ -class FrameBuffer; -class Renderer; -struct Sampler; -class RenderTracker; -class Geometry; -class Texture; -} - -namespace SceneGraph -{ -class RenderQueue; -class RenderInstruction; -class RenderInstructionContainer; -class Shader; -class PropertyBufferDataProvider; - -/** - * RenderManager is responsible for rendering the result of the previous "update", which - * is provided in a RenderCommand during UpdateManager::Update(). - */ -class RenderManager -{ -public: - - /** - * Construct a new RenderManager. - * @param[in] glAbstraction The GL abstraction used for rendering. - * @param[in] glSyncAbstraction The GL sync abstraction used fence sync creation/deletion. - * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.* - */ - static RenderManager* New( Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction ); - - /** - * Non-virtual destructor; not intended as a base class - */ - ~RenderManager(); - - /** - * Retrieve the RenderQueue. Messages should only be added to this from the update-thread. - * @return The render queue. - */ - 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.. - * @note This should be called during core initialisation if shader binaries are to be used. - */ - void SetShaderSaver( ShaderSaver& upstream ); - - /** - * Retrieve the render instructions; these should be set during each "update" traversal. - * @return The render instruction container. - */ - RenderInstructionContainer& GetRenderInstructionContainer(); - - // The following methods should be called via RenderQueue messages - - /** - * Set the background color i.e. the glClear color used at the beginning of each frame. - * @param[in] color The new background color. - */ - void SetBackgroundColor( const Vector4& color ); - - /* - * Set the frame time delta (time elapsed since the last frame. - * @param[in] deltaTime the delta time - */ - void SetFrameDeltaTime( float deltaTime ); - - /** - * Returns the rectangle for the default surface (probably the application window). - * @return Rectangle for the surface. - */ - void SetDefaultSurfaceRect( const Rect& rect ); - - /** - * Add a Renderer to the render manager. - * @param[in] renderer The renderer to add. - * @post renderer is owned by RenderManager - */ - void AddRenderer( OwnerPointer< Render::Renderer >& renderer ); - - /** - * Remove a Renderer from the render manager. - * @param[in] renderer The renderer to remove. - * @post renderer is destroyed. - */ - void RemoveRenderer( Render::Renderer* renderer ); - - /** - * Add a sampler to the render manager. - * @param[in] sampler The sampler to add. - * @post sampler is owned by RenderManager - */ - void AddSampler( OwnerPointer< Render::Sampler >& sampler ); - - /** - * Remove a sampler from the render manager. - * @param[in] sampler The sampler to remove. - * @post sampler is destroyed. - */ - void RemoveSampler( Render::Sampler* sampler ); - - /** - * Set minification and magnification filter modes for a sampler - * @param[in] minFilterMode Filter mode to use when the texture is minificated - * @param[in] magFilterMode Filter mode to use when the texture is magnified - */ - void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode ); - - /** - * Set wrapping mode for a sampler - * @param[in] rWrapMode Wrap mode in the z direction - * @param[in] uWrapMode Wrap mode in the x direction - * @param[in] vWrapMode Wrap mode in the y direction - */ - void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ); - - /** - * Add a property buffer to the render manager. - * @param[in] propertyBuffer The property buffer to add. - * @post propertBuffer is owned by RenderManager - */ - void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer ); - - /** - * Remove a property buffer from the render manager. - * @param[in] propertyBuffer The property buffer to remove. - * @post propertyBuffer is destroyed. - */ - void RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer ); - - /** - * Add a geometry to the render manager. - * @param[in] geometry The geometry to add. - * @post geometry is owned by RenderManager - */ - void AddGeometry( OwnerPointer< Render::Geometry >& geometry ); - - /** - * Remove a geometry from the render manager. - * @param[in] geometry The geometry to remove. - * @post geometry is destroyed. - */ - void RemoveGeometry( Render::Geometry* geometry ); - - /** - * Adds a property buffer to a geometry from the render manager. - * @param[in] geometry The geometry - * @param[in] propertyBuffer The property buffer to remove. - */ - void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); - - /** - * Remove a property buffer from a Render::Geometry from the render manager. - * @param[in] geometry The geometry - * @param[in] propertyBuffer The property buffer to remove. - * @post property buffer is destroyed. - */ - void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); - - /** - * Sets the format of an existing property buffer - * @param[in] propertyBuffer The property buffer. - * @param[in] format The new format of the buffer - */ - void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ); - - /** - * Sets the data of an existing property buffer - * @param[in] propertyBuffer The property buffer. - * @param[in] data The new data of the buffer - * @param[in] size The new size of the buffer - */ - void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ); - - /** - * Sets the data for the index buffer of an existing geometry - * @param[in] geometry The geometry - * @param[in] data A vector containing the indices - */ - void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& data ); - - /** - * Set the geometry type of an existing render geometry - * @param[in] geometry The render geometry - * @param[in] geometryType The new geometry type - */ - void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType ); - - /** - * Adds a texture to the render manager - * @param[in] texture The texture to add - */ - void AddTexture( OwnerPointer< Render::Texture >& texture ); - - /** - * Removes a texture from the render manager - * @param[in] texture The texture to remove - */ - void RemoveTexture( Render::Texture* texture ); - - /** - * Uploads data to an existing texture - * @param[in] texture The texture - * @param[in] pixelData The pixel data object - * @param[in] params The parameters for the upload - */ - void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ); - - /** - * Generates mipmaps for a given texture - * @param[in] texture The texture - */ - void GenerateMipmaps( Render::Texture* texture ); - - /** - * Adds a framebuffer to the render manager - * @param[in] frameBuffer The framebuffer to add - */ - void AddFrameBuffer( Render::FrameBuffer* frameBuffer ); - - /** - * Removes a framebuffer from the render manager - * @param[in] frameBuffer The framebuffer to remove - */ - void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer ); - - /** - * Attach a texture as color output to an existing FrameBuffer - * @param[in] frameBuffer The FrameBuffer - * @param[in] texture The texture that will be used as output when rendering - * @param[in] mipmapLevel The mipmap of the texture to be attached - * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures - */ - void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ); - - /** - * Adds a render tracker to the RenderManager. RenderManager takes ownership of the - * tracker. The lifetime of the tracker is related to the lifetime of the tracked - * object, usually an offscreen render task. - * @param[in] renderTracker The render tracker - */ - void AddRenderTracker( Render::RenderTracker* renderTracker ); - - /** - * Removes a render tracker from the RenderManager. - * @param[in] renderTracker The render tracker to remove. - */ - void RemoveRenderTracker( Render::RenderTracker* renderTracker ); - - /** - * returns the Program controller for sending program messages - * @return the ProgramController - */ - ProgramCache* GetProgramCache(); - - // This method should be called from Core::Render() - - /** - * Renders the results of the previous "update" traversal. - * @param[out] status contains the rendering flags. - */ - void Render( Integration::RenderStatus& status ); - -private: - - /** - * Helper to process a single RenderInstruction. - * @param[in] instruction A description of the rendering operation. - */ - void DoRender( RenderInstruction& instruction ); - -private: - - /** - * Construct a new RenderManager. - */ - RenderManager(); - - // Undefined - RenderManager( const RenderManager& ); - - // Undefined - RenderManager& operator=( const RenderManager& rhs ); - -private: - - struct Impl; - Impl* mImpl; - -}; - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__ diff --git a/dali/internal/render/common/render-tracker-debug.h b/dali/internal/render/common/render-tracker-debug.h deleted file mode 100644 index 498e8f2..0000000 --- a/dali/internal/render/common/render-tracker-debug.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_TRACKER_DEBUG_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TRACKER_DEBUG_H__ - -/* - * Copyright (c) 2015 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. - * - */ - -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -#if defined(DEBUG_ENABLED) - -Debug::Filter* gRenderTrackerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_RENDER_TRACKER"); - -#define TRACKER_LOG(level) \ - DALI_LOG_INFO(gRenderTrackerLogFilter, level, "RenderTracker::%s: this:%p\n", __FUNCTION__, this) - -#define TRACKER_LOG_FMT(level, format, args...) \ - DALI_LOG_INFO(gRenderTrackerLogFilter, level, "RenderTracker::%s: this:%p " format, __FUNCTION__, this, ## args) -#else -#define TRACKER_LOG(level) -#define TRACKER_LOG_FMT(level, format, args...) -#endif - -} // Render - -} // Internal - -} // Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_TRACKER_DEBUG_H__ diff --git a/dali/internal/render/common/render-tracker.cpp b/dali/internal/render/common/render-tracker.cpp deleted file mode 100644 index a7a356e..0000000 --- a/dali/internal/render/common/render-tracker.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 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 - -// INTERNAL INCLUDES -#include -#include - -// EXTERNAL INCLUDES - -namespace Dali -{ - -namespace Internal -{ - -namespace Render -{ - -RenderTracker::RenderTracker() -: mGlSyncAbstraction( NULL ), - mSyncObject( NULL ), - mSyncTrigger( 0 ) -{ - TRACKER_LOG(Debug::Verbose); -} - -RenderTracker::~RenderTracker() -{ - TRACKER_LOG(Debug::Verbose); - if( mSyncObject ) - { - mGlSyncAbstraction->DestroySyncObject( mSyncObject ); - mSyncObject = NULL; - } -} - -void RenderTracker::CreateSyncObject( Integration::GlSyncAbstraction& glSyncAbstraction ) -{ - mGlSyncAbstraction = &glSyncAbstraction; - TRACKER_LOG(Debug::General); - - // Destroy any previous sync object - if( mSyncObject ) - { - mGlSyncAbstraction->DestroySyncObject( mSyncObject ); - mSyncObject = NULL; - } - ResetSyncFlag(); - mSyncObject = mGlSyncAbstraction->CreateSyncObject(); -} - -void RenderTracker::PollSyncObject() -{ - if( mSyncObject && mSyncObject->IsSynced() ) - { - SetSyncFlag(); - mGlSyncAbstraction->DestroySyncObject( mSyncObject ); - mSyncObject = NULL; - - TRACKER_LOG_FMT(Debug::General, " Synced\n"); - return; - } - TRACKER_LOG_FMT(Debug::General, " Not Synced\n"); -} - -bool RenderTracker::IsSynced() -{ - int x = __sync_val_compare_and_swap(&mSyncTrigger, 0xFF, 0x0); - - TRACKER_LOG_FMT(Debug::General, " = %s\n", x!=0?"T":"F"); - return x != 0; -} - -void RenderTracker::ResetSyncFlag() -{ - TRACKER_LOG(Debug::General); - (void)__sync_lock_test_and_set(&mSyncTrigger, 0x0); -} - -void RenderTracker::SetSyncFlag() -{ - (void)__sync_lock_test_and_set(&mSyncTrigger, 0xFF); -} - -} // Render - -} // Internal - -} // Dali diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp deleted file mode 100644 index c3116bf..0000000 --- a/dali/internal/render/gl-resources/context.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2017 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) -: 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 ) -{ -} - -Context::~Context() -{ -} - -void Context::GlContextCreated() -{ - DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextCreated()\n"); - - DALI_ASSERT_DEBUG(!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< int >& 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 81561ba..0000000 --- a/dali/internal/render/gl-resources/context.h +++ /dev/null @@ -1,1771 +0,0 @@ -#ifndef __DALI_INTERNAL_CONTEXT_H__ -#define __DALI_INTERNAL_CONTEXT_H__ - -/* - * Copyright (c) 2017 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 - -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 const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 8; - - static const unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 8 is guaranteed, which is more than DALi uses anyways - - /** - * Creates the Dali Context object. - * 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 ); - - /** - * 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< const char * >( GetString( stringId ) ) ); - } - - /**************************************************************************************** - * 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 OpenGL ES 2.0 glActiveTexture() - */ - void ActiveTexture( TextureUnit textureUnit ) - { - if ( textureUnit != mActiveTextureUnit ) - { - 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) - { - // Avoid unecessary calls to BindBuffer - if (mBoundArrayBufferId != buffer) - { - 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) - { - // Avoid unecessary calls to BindBuffer - if (mBoundElementArrayBufferId!= buffer) - { - 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) - { - // Avoid unecessary calls to BindBuffer - if (mBoundTransformFeedbackBufferId != buffer) - { - 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) - { - // Avoid unecessary calls to BindBufferBase - if (mBoundTransformFeedbackBufferId != buffer) - { - 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 ) - { - if( mBoundTextureId[ textureunit ] != texture ) - { - ActiveTexture( textureunit ); - BindTexture( target, texture ); - } - } - - /** - * Wrapper for OpenGL ES 2.0 glBindTexture( target ) - */ - void BindTexture( int target, GLuint texture ) - { - if (mBoundTextureId[ mActiveTextureUnit ] != texture) - { - mBoundTextureId[ mActiveTextureUnit ] = texture; - - 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() - { - if( ! mUsingDefaultBlendColor ) - { - SetCustomBlendColor( Color::TRANSPARENT ); - mUsingDefaultBlendColor = true; - } - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendColor() - */ - void SetCustomBlendColor( const Vector4& color ) - { - if( mUsingDefaultBlendColor || mBlendColor != color ) - { - 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) - { - // use BlendEquationSeparate to set the rgb and alpha modes the same - BlendEquationSeparate( mode, mode ); - } - - /** - * Wrapper for OpenGL ES 2.0 glBlendEquationSeparate() - */ - void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) - { - if( ( modeRGB != mBlendEquationSeparateModeRGB ) || - ( modeAlpha != mBlendEquationSeparateModeAlpha ) ) - { - 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 ) - { - if( ( mBlendFuncSeparateSrcRGB != srcRGB )||( mBlendFuncSeparateDstRGB != dstRGB )|| - ( mBlendFuncSeparateSrcAlpha != srcAlpha )||( mBlendFuncSeparateDstAlpha != dstAlpha ) ) - { - 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 ); - - if( mask > 0 ) - { - 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); - - if (!mClearColorSet || mClearColor !=newCol ) - { - 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 ) - { - // only change state if needed - if( flag != mColorMask ) - { - 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 ) - { - // Avoid unnecessary calls to gl - if(mCullFaceMode != mode) - { - 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) - { - // @todo: this is to prevent mesh destructor from doing GL calls when DALi core is being deleted - // can be taken out once render manages either knows about meshes or gpubuffers and can tell them directly that context is lost - if( this->IsGlContextCreated() ) - { - LOG_GL("DeleteBuffers %d %p\n", n, buffers); - CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteBuffers(n, buffers) ); - } - // 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; - } - - /** - * 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) ); - - // reset the cached texture id's incase the driver re-uses them - // when creating new textures - for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i ) - { - mBoundTextureId[ i ] = 0; - } - } - - /** - * 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) - { - if( func != mDepthFunction ) - { - 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; - // only change state if needed - if( booleanFlag != mDepthMaskEnabled ) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mBlendEnabled) - { - 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 ) - { - // Avoid unecessary calls to glEnable/glDisable - if( enable != mDepthBufferEnabled ) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mDitherEnabled) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mPolygonOffsetFillEnabled) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mSampleAlphaToCoverageEnabled) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mSampleCoverageEnabled) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if (enable != mScissorTestEnabled) - { - 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) - { - // Avoid unecessary calls to glEnable/glDisable - if( enable != mStencilBufferEnabled ) - { - 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) - { - LOG_GL("Scissor %d %d %d %d\n", x, y, width, height); - CHECK_GL( mGlAbstraction, mGlAbstraction.Scissor(x, y, width, height) ); - } - - /** - * Wrapper for OpenGL ES 2.0 glStencilFunc() - */ - void StencilFunc(GLenum func, GLint ref, GLuint mask) - { - if( ( func != mStencilFunc ) || ( ref != mStencilFuncRef ) || ( mask != mStencilFuncMask ) ) - { - 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) - { - if( mask != mStencilMask ) - { - 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) - { - if( ( fail != mStencilOpFail ) || ( zfail != mStencilOpDepthFail ) || ( zpass != mStencilOpDepthPass ) ) - { - 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 glUnmapBubffer() - */ - 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 - Rect newViewport( x, y, width, height ); - if( mViewPort != newViewport ) - { - // set new one - LOG_GL("Viewport %d %d %d %d\n", x, y, width, height); - CHECK_GL( mGlAbstraction, mGlAbstraction.Viewport(x, y, width, height) ); - mViewPort = newViewport; // remember new one - } - } - - /** - * 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; - } - - /** - * Get the current viewport. - * @return Viewport rectangle. - */ - const Rect< int >& 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 ]; ///< 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< int > 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 -}; - -} // 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 0ba565f..0000000 --- a/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2015 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 Internal -{ - -FrameBufferStateCache::FrameBufferStateCache() -:mCurrentFrameBufferId(0) -{ -} - -FrameBufferStateCache::~FrameBufferStateCache() -{ -} - -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 = GetInitialFrameBufferState(); - continue; - } - - FrameBufferState newFrameBuffer( frameBuffers[i], GetInitialFrameBufferState() ); - 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 NULL; -} - -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); -} - -unsigned int FrameBufferStateCache::GetInitialFrameBufferState() -{ - return COLOR_BUFFER_CLEAN | DEPTH_BUFFER_CLEAN | STENCIL_BUFFER_CLEAN; -} - - -} // 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 2594aa9..0000000 --- a/dali/internal/render/gl-resources/frame-buffer-state-cache.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef __DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H__ -#define __DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H__ - -/* - * Copyright (c) 2015 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, unsigned int state) - :mId( id ), - mState( state ) - { - } - GLuint mId; ///< Frame buffer id - unsigned int mState; ///< State, bitmask of FrameBufferStatus flags - }; - - typedef Dali::Vector< FrameBufferState > FrameBufferStateVector; - - /** - * @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 ); - - /** - * @brief Get the default state of a frame buffer, before it's used - * @return initial state - */ - unsigned int GetInitialFrameBufferState(); - - 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 c043122..0000000 --- a/dali/internal/render/gl-resources/gl-call-debug.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016 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 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 -} - -} - -} 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 866d5ea..0000000 --- a/dali/internal/render/gl-resources/gl-call-debug.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __DALI_INTERNAL_GL_CALL_DEBUG_H__ -#define __DALI_INTERNAL_GL_CALL_DEBUG_H__ - -/* - * Copyright (c) 2016 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, args...) \ - DALI_LOG_INFO(gGlLogFilter, Debug::General, format, ## args) - -} - -} - -#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 59cef51..0000000 --- a/dali/internal/render/gl-resources/gl-resource-owner.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __DALI_INTERNAL_GL_RESOURCE_OWNER_H__ -#define __DALI_INTERNAL_GL_RESOURCE_OWNER_H__ - -/* - * Copyright (c) 2014 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() - { } - - /** - * 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/gpu-buffer.cpp b/dali/internal/render/gl-resources/gpu-buffer.cpp deleted file mode 100644 index 257b12a..0000000 --- a/dali/internal/render/gl-resources/gpu-buffer.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ - -/** - * Helper to get our drawmode enum as GL enum - * @param type to convert - * @return the corresponding GL enum or -1 - */ -inline GLenum ModeAsGlEnum( GpuBuffer::Usage type ) -{ - GLenum retval( -1 ); - switch( type ) - { - case GpuBuffer::STREAM_DRAW : - { - retval = GL_STREAM_DRAW; - break; - } - case GpuBuffer::STATIC_DRAW : - { - retval = GL_STATIC_DRAW; - break; - } - case GpuBuffer::DYNAMIC_DRAW : - { - retval = GL_DYNAMIC_DRAW; - break; - } - } - return retval; -} - -} - -GpuBuffer::GpuBuffer( Context& context ) -: mContext( context ), - mCapacity( 0 ), - mSize( 0 ), - mBufferId( 0 ), - mBufferCreated( false ) -{ -} - -GpuBuffer::~GpuBuffer() -{ - // If we have a buffer then delete it. - if (mBufferId) - { - // If a buffer object that is currently bound is deleted, the binding reverts to 0 - // (the absence of any buffer object, which reverts to client memory usage) - mContext.DeleteBuffers(1,&mBufferId); - } -} - -/* - * Creates or updates the buffer data depending on whether it - * already exists or not. - */ -void GpuBuffer::UpdateDataBuffer(GLsizeiptr size, const GLvoid *data, Usage usage, Target target) -{ - DALI_ASSERT_DEBUG( size > 0 ); - mSize = size; - // make sure we have a buffer name/id before uploading - if (mBufferId == 0) - { - mContext.GenBuffers(1,&mBufferId); - DALI_ASSERT_DEBUG(mBufferId); - } - - GLenum glTargetEnum = GL_ARRAY_BUFFER; - - // make sure the buffer is bound, don't perform any checks because size may be zero - if(ARRAY_BUFFER == target) - { - mContext.BindArrayBuffer( mBufferId ); - } - else if(ELEMENT_ARRAY_BUFFER == target) - { - glTargetEnum = GL_ELEMENT_ARRAY_BUFFER; - mContext.BindElementArrayBuffer( mBufferId ); - } - else if(TRANSFORM_FEEDBACK_BUFFER == target) - { - glTargetEnum = GL_TRANSFORM_FEEDBACK_BUFFER; - mContext.BindTransformFeedbackBuffer( mBufferId ); - } - - // if the buffer has already been created, just update the data providing it fits - if (mBufferCreated ) - { - // if the data will fit in the existing buffer, just update it - if (size <= mCapacity ) - { - mContext.BufferSubData( glTargetEnum, 0, size, data ); - } - else - { - // create a new buffer of the larger size, - // gl should automatically deallocate the old buffer - mContext.BufferData( glTargetEnum, size, data, ModeAsGlEnum( usage ) ); - mCapacity = size; - } - } - else - { - // create the buffer - mContext.BufferData( glTargetEnum, size, data, ModeAsGlEnum( usage ) ); - mBufferCreated = true; - mCapacity = size; - } - - if(ARRAY_BUFFER == target) - { - mContext.BindArrayBuffer( 0 ); - } - else if(ELEMENT_ARRAY_BUFFER == target) - { - mContext.BindElementArrayBuffer( 0 ); - } - else if(TRANSFORM_FEEDBACK_BUFFER == target) - { - mContext.BindTransformFeedbackBuffer( 0 ); - } -} - -void GpuBuffer::Bind(Target target) const -{ - DALI_ASSERT_DEBUG(mCapacity); - - if (target == ARRAY_BUFFER) - { - mContext.BindArrayBuffer(mBufferId); - } - else if (target == ELEMENT_ARRAY_BUFFER) - { - mContext.BindElementArrayBuffer(mBufferId); - } - else if (target == TRANSFORM_FEEDBACK_BUFFER) - { - mContext.BindTransformFeedbackBuffer(mBufferId); - } -} - -bool GpuBuffer::BufferIsValid() const -{ - return mBufferCreated && (0 != mCapacity ); -} - -void GpuBuffer::GlContextDestroyed() -{ - // If the context is destroyed, GL would have released the buffer. - mCapacity = 0; - mSize = 0; - mBufferId = 0; - mBufferCreated = false; -} - -} // namespace Internal - -} //namespace Dali diff --git a/dali/internal/render/gl-resources/gpu-buffer.h b/dali/internal/render/gl-resources/gpu-buffer.h deleted file mode 100644 index 7c32719..0000000 --- a/dali/internal/render/gl-resources/gpu-buffer.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef __DALI_INTERNAL_GPU_BUFFER_H__ -#define __DALI_INTERNAL_GPU_BUFFER_H__ - -/* - * Copyright (c) 2014 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 -{ - -/** - * Used to create and update a GPU memory buffer. - * - * The buffer can be used for storing vertex data, index arrays (indices) - * or pixel data (PBO). - * - * The buffer allows data to be stored in high-performance - * graphics memory on the server side and - * promotes efficient data transfer. - */ -class GpuBuffer -{ -public: - - /** - * Enum to encapsulate the GL buffer type. This is to avoid having to store a whole int for type - */ - enum Target - { - ARRAY_BUFFER, ///< GL_ARRAY_BUFFER - ELEMENT_ARRAY_BUFFER, ///< GL_ELEMENT_ARRAY_BUFFER - TRANSFORM_FEEDBACK_BUFFER ///< GL_TRANSFORM_FEEDBACK_BUFFER - }; - - /** - * Enum to encapsulate the GL draw mode. This is to avoid having to store a whole int for mode - */ - enum Usage - { - STREAM_DRAW, ///< GL_STREAM_DRAW - STATIC_DRAW, ///< GL_STATIC_DRAW - DYNAMIC_DRAW, ///< GL_DYNAMIC_DRAW - }; - -public: - - /** - * constructor - * @param context drawing context - */ - GpuBuffer( Context& context ); - - /** - * Destructor, non virtual as no virtual methods or inheritance - */ - ~GpuBuffer(); - - /** - * - * Creates or updates a buffer object and binds it to the target. - * @param size Specifies the size in bytes of the buffer object's new data store. - * @param data pointer to the data to load - * @param usage How the buffer will be used - * @param target The target buffer to update - */ - void UpdateDataBuffer(GLsizeiptr size, const GLvoid *data, Usage usage, Target target); - - /** - * Bind the buffer object to the target - * Will assert if the buffer size is zero - */ - void Bind(Target target) const; - - /** - * @return true if the GPU buffer is valid, i.e. its created and not empty - */ - bool BufferIsValid() const; - - /** - * Get the size of the buffer - * @return size - */ - GLsizeiptr GetBufferSize() const - { - return mSize; - } - - /** - * Needs to be called when GL context is destroyed - */ - void GlContextDestroyed(); - -private: - - /** - * Perfoms a bind without checking the size of the buffer - * @param bufferId to bind - */ - void BindNoChecks(GLuint bufferId) const; - -private: // Data - - Context& mContext; ///< dali drawing context - GLsizeiptr mCapacity; ///< buffer capacity - GLsizeiptr mSize; ///< buffer size - GLuint mBufferId; ///< buffer object name(id) - - bool mBufferCreated:1; ///< whether buffer has been created - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GPU_BUFFER_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 6b8a44b..0000000 --- a/dali/internal/render/gl-resources/texture-units.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXTURE_UNITS_H__ -#define __DALI_INTERNAL_TEXTURE_UNITS_H__ - -/* - * Copyright (c) 2014 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 ); -} - -}//Internal - -}//Dali - -#endif // __DALI_INTERNAL_TEXTURE_UNITS_H__ diff --git a/dali/internal/render/queue/render-queue.cpp b/dali/internal/render/queue/render-queue.cpp deleted file mode 100644 index 0eda995..0000000 --- a/dali/internal/render/queue/render-queue.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace // unnamed namespace -{ - -static const std::size_t INITIAL_BUFFER_SIZE = 32768; -static const std::size_t MAX_BUFFER_SIZE = 32768; - -} // unnamed namespace - -namespace SceneGraph -{ - -RenderQueue::RenderQueue() -: container0( NULL ), - container1( NULL ) -{ - container0 = new MessageBuffer( INITIAL_BUFFER_SIZE ); - container1 = new MessageBuffer( INITIAL_BUFFER_SIZE ); -} - -RenderQueue::~RenderQueue() -{ - if( container0 ) - { - for( MessageBuffer::Iterator iter = container0->Begin(); iter.IsValid(); iter.Next() ) - { - MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() ); - - // Call virtual destructor explictly; since delete will not be called after placement new - message->~MessageBase(); - } - - delete container0; - } - - if( container1 ) - { - for( MessageBuffer::Iterator iter = container1->Begin(); iter.IsValid(); iter.Next() ) - { - MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() ); - - // Call virtual destructor explictly; since delete will not be called after placement new - message->~MessageBase(); - } - - delete container1; - } -} - -unsigned int* RenderQueue::ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size ) -{ - MessageBuffer* container = GetCurrentContainer( updateBufferIndex ); - - return container->ReserveMessageSlot( size ); -} - -void RenderQueue::ProcessMessages( BufferIndex bufferIndex ) -{ - MessageBuffer* container = GetCurrentContainer( bufferIndex ); - - for( MessageBuffer::Iterator iter = container->Begin(); iter.IsValid(); iter.Next() ) - { - MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() ); - - message->Process( bufferIndex ); - - // Call virtual destructor explictly; since delete will not be called after placement new - message->~MessageBase(); - } - - container->Reset(); - - LimitBufferCapacity( bufferIndex ); -} - -MessageBuffer* RenderQueue::GetCurrentContainer( BufferIndex bufferIndex ) -{ - MessageBuffer* container( NULL ); - - /** - * The update-thread queues messages with one container, - * whilst the render-thread is processing the other. - */ - if ( !bufferIndex ) - { - container = container0; - } - else - { - container = container1; - } - - return container; -} - -void RenderQueue::LimitBufferCapacity( BufferIndex bufferIndex ) -{ - if ( !bufferIndex ) - { - if( MAX_BUFFER_SIZE < container0->GetCapacity() ) - { - delete container0; - container0 = NULL; - container0 = new MessageBuffer( INITIAL_BUFFER_SIZE ); - } - } - else - { - if( MAX_BUFFER_SIZE < container1->GetCapacity() ) - { - delete container1; - container1 = NULL; - container1 = new MessageBuffer( INITIAL_BUFFER_SIZE ); - } - } -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/queue/render-queue.h b/dali/internal/render/queue/render-queue.h deleted file mode 100644 index 246f67f..0000000 --- a/dali/internal/render/queue/render-queue.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__ - -/* - * Copyright (c) 2014 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 -{ - -class MessageBase; - -namespace SceneGraph -{ - -/** - * Allows messages to be queued for RenderManager, during the scene-graph Update. - */ -class RenderQueue -{ -public: - - /** - * Create a new RenderQueue. - */ - RenderQueue(); - - /** - * Non-virtual destructor; RenderQueue is not suitable as a base class. - */ - ~RenderQueue(); - - /** - * Reserve space for another message in the queue; this must then be initialized by the caller. - * The message will be read from the next render-thread tick. - * @post Calling this method may invalidate any previously returned slots. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] size The message size with respect to the size of type "char". - * @return A pointer to the first char allocated for the message. - */ - unsigned int* ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size ); - - /** - * Process the batch of messages, which were queued in the previous update. - * @pre This message should only be called by RenderManager from within the render-thread. - * @param[in] bufferIndex The previous update buffer index. - */ - void ProcessMessages( BufferIndex bufferIndex ); - -private: - - /** - * Helper to retrieve the current container. - * The update-thread queues messages with one container, whilst the render-thread is processing the other. - * @param[in] bufferIndex The current buffer index. - * @return The container. - */ - MessageBuffer* GetCurrentContainer( BufferIndex bufferIndex ); - - /** - * Helper to limit the buffer capacity i.e. after a frame when an extreme number of messages have been sent. - * @param[in] bufferIndex The current buffer index. - */ - void LimitBufferCapacity( BufferIndex bufferIndex ); - - // Undefined - RenderQueue( const RenderQueue& ); - - // Undefined - RenderQueue& operator=( const RenderQueue& rhs ); - -private: - - MessageBuffer* container0; ///< Messages are queued here when the update buffer index == 0 - MessageBuffer* container1; ///< Messages are queued here when the update buffer index == 1 -}; - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__ diff --git a/dali/internal/render/renderers/render-frame-buffer.cpp b/dali/internal/render/renderers/render-frame-buffer.cpp deleted file mode 100644 index 238a8cf..0000000 --- a/dali/internal/render/renderers/render-frame-buffer.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments ) -:mId( 0u ), - mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ), - mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ), - mWidth( width ), - mHeight( height ) -{ -} - -FrameBuffer::~FrameBuffer() -{} - -void FrameBuffer::Destroy( Context& context ) -{ - if( mId ) - { - context.DeleteFramebuffers( 1, &mId ); - } -} - -void FrameBuffer::GlContextDestroyed() -{ - mId = 0u; -} - -void FrameBuffer::Initialize(Context& context) -{ - context.GenFramebuffers( 1, &mId ); - context.BindFramebuffer( GL_FRAMEBUFFER, mId ); - - if( mDepthBuffer ) - { - // Create a depth render target. - context.GenRenderbuffers( 1, &mDepthBuffer ); - context.BindRenderbuffer( GL_RENDERBUFFER, mDepthBuffer ); - context.RenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight ); - context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer ); - } - - if( mStencilBuffer ) - { - // Create a stencil render target. - context.GenRenderbuffers( 1, &mStencilBuffer ); - context.BindRenderbuffer( GL_RENDERBUFFER, mStencilBuffer ); - context.RenderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight ); - context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer ); - } - - context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); -} - -void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) -{ - context.BindFramebuffer( GL_FRAMEBUFFER, mId ); - - // Create a color attachment. - if( texture->GetType() == TextureType::TEXTURE_2D ) - { - if( !texture->IsNativeImage() ) - { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); - } - else - { - // If it's a native image we need to use GL_TEXTURE_EXTERNAL_OES as the texture target parameter - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, texture->GetId(), mipmapLevel ); - } - } - else - { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, texture->GetId(), mipmapLevel ); - } - - context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); -} - -void FrameBuffer::Bind( Context& context ) -{ - context.BindFramebuffer( GL_FRAMEBUFFER, mId ); -} - -unsigned int FrameBuffer::GetWidth() const -{ - return mWidth; -} - -unsigned int FrameBuffer::GetHeight() const -{ - return mHeight; -} - - -} //Render - -} //Internal - -} //Dali diff --git a/dali/internal/render/renderers/render-geometry.cpp b/dali/internal/render/renderers/render-geometry.cpp deleted file mode 100644 index f674fb7..0000000 --- a/dali/internal/render/renderers/render-geometry.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ - -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -Geometry::Geometry() -: mIndices(), - mIndexBuffer(NULL), - mGeometryType( Dali::Geometry::TRIANGLES ), - mIndicesChanged(false), - mHasBeenUpdated(false), - mAttributesChanged(true) -{ -} - -Geometry::~Geometry() -{ -} - -void Geometry::AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer ) -{ - mVertexBuffers.PushBack( propertyBuffer ); - mAttributesChanged = true; -} - -void Geometry::SetIndexBuffer( Dali::Vector& indices ) -{ - mIndices.Swap( indices ); - mIndicesChanged = true; -} - -void Geometry::RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer ) -{ - size_t bufferCount = mVertexBuffers.Size(); - for( size_t i(0); i& attributeLocation, Program& program, BufferIndex bufferIndex ) const -{ - attributeLocation.Clear(); - - for( size_t i(0); i< mVertexBuffers.Size(); ++i ) - { - unsigned int attributeCount = mVertexBuffers[i]->GetAttributeCount(); - for( unsigned int j = 0; j < attributeCount; ++j ) - { - const std::string& attributeName = mVertexBuffers[i]->GetAttributeName( j ); - unsigned int index = program.RegisterCustomAttribute( attributeName ); - GLint location = program.GetCustomAttributeLocation( index ); - - if( -1 == location ) - { - DALI_LOG_WARNING( "Attribute not found in the shader: %s\n", attributeName.c_str() ); - } - - attributeLocation.PushBack( location ); - } - } -} - -void Geometry::OnRenderFinished() -{ - mHasBeenUpdated = false; - mAttributesChanged = false; -} - -void Geometry::UploadAndDraw( - Graphics::API::Controller& controller, - BufferIndex bufferIndex, - Vector& attributeLocation, - size_t elementBufferOffset, - size_t elementBufferCount ) -{ -#if 0 - if( !mHasBeenUpdated ) - { - // Update buffers - if( mIndicesChanged ) - { - if( mIndices.Empty() ) - { - mIndexBuffer = NULL; - } - else - { - if ( mIndexBuffer == NULL ) - { - mIndexBuffer = new GpuBuffer( context ); - } - - std::size_t bufferSize = sizeof( unsigned short ) * mIndices.Size(); - mIndexBuffer->UpdateDataBuffer( bufferSize, &mIndices[0], GpuBuffer::STATIC_DRAW, GpuBuffer::ELEMENT_ARRAY_BUFFER ); - } - - mIndicesChanged = false; - } - - size_t count = mVertexBuffers.Count(); - for( unsigned int i = 0; i < count; ++i ) - { - - if( !mVertexBuffers[i]->Update( ) ) - { - //Vertex buffer is not ready ( Size, data or format has not been specified yet ) - return; - } - } - - mHasBeenUpdated = true; - } - - //Bind buffers to attribute locations - unsigned int base = 0u; - size_t vertexBufferCount(mVertexBuffers.Count()); - for( unsigned int i = 0; i < vertexBufferCount; ++i ) - { - mVertexBuffers[i]->BindBuffer( GpuBuffer::ARRAY_BUFFER ); - base += mVertexBuffers[i]->EnableVertexAttributes( context, attributeLocation, base ); - } - - size_t numIndices(0u); - intptr_t firstIndexOffset(0u); - if( mIndexBuffer ) - { - numIndices = mIndices.Size(); - - if( elementBufferOffset != 0u ) - { - elementBufferOffset = elementBufferOffset >= numIndices ? numIndices - 1 : elementBufferOffset; - firstIndexOffset = elementBufferOffset * sizeof(GLushort); - numIndices -= elementBufferOffset; - } - - if( elementBufferCount != 0u ) - { - numIndices = std::min( elementBufferCount, numIndices ); - } - } - - GLenum geometryGLType(GL_NONE); - switch(mGeometryType) - { - case Dali::Geometry::TRIANGLES: - { - geometryGLType = GL_TRIANGLES; - break; - } - case Dali::Geometry::LINES: - { - geometryGLType = GL_LINES; - break; - } - case Dali::Geometry::POINTS: - { - geometryGLType = GL_POINTS; - break; - } - case Dali::Geometry::TRIANGLE_STRIP: - { - geometryGLType = GL_TRIANGLE_STRIP; - break; - } - case Dali::Geometry::TRIANGLE_FAN: - { - geometryGLType = GL_TRIANGLE_FAN; - break; - } - case Dali::Geometry::LINE_LOOP: - { - geometryGLType = GL_LINE_LOOP; - break; - } - case Dali::Geometry::LINE_STRIP: - { - geometryGLType = GL_LINE_STRIP; - break; - } - } - - //Draw call - if( mIndexBuffer && geometryGLType != GL_POINTS ) - { - //Indexed draw call - mIndexBuffer->Bind( GpuBuffer::ELEMENT_ARRAY_BUFFER ); - context.DrawElements(geometryGLType, numIndices, GL_UNSIGNED_SHORT, reinterpret_cast(firstIndexOffset)); - } - else - { - //Unindex draw call - unsigned int numVertices(0u); - if( vertexBufferCount > 0 ) - { - numVertices = mVertexBuffers[0]->GetElementCount(); - } - - context.DrawArrays( geometryGLType, 0, numVertices ); - } - - //Disable attributes - for( unsigned int i = 0; i < attributeLocation.Count(); ++i ) - { - if( attributeLocation[i] != -1 ) - { - context.DisableVertexAttributeArray( attributeLocation[i] ); - } - } -#endif -} - -} // namespace SceneGraph -} // namespace Internal -} // namespace Dali diff --git a/dali/internal/render/renderers/render-geometry.h b/dali/internal/render/renderers/render-geometry.h deleted file mode 100644 index e503bda..0000000 --- a/dali/internal/render/renderers/render-geometry.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef DALI_INTERNAL_RENDER_GEOMETRY_H -#define DALI_INTERNAL_RENDER_GEOMETRY_H - -/* - * Copyright (c) 2016 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace Dali -{ -namespace Internal -{ -class Context; -class Program; -class GpuBuffer; - -namespace Render -{ -class PropertyBuffer; - -/** - * This class encapsulates the GPU buffers. It is used to upload vertex data - * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute - * bindings - */ -class Geometry -{ -public: - typedef Dali::Geometry::Type Type; - - Geometry(); - - /** - * Destructor - */ - ~Geometry(); - - - /** - * Adds a property buffer to the geometry - * @param[in] dataProvider The PropertyBuffer data provider - */ - void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer ); - - /** - * Set the data for the index buffer to be used by the geometry - * @param[in] indices A vector containing the indices - */ - void SetIndexBuffer( Dali::Vector& indices ); - - /** - * Removes a PropertyBuffer from the geometry - * @param[in] propertyBuffer The property buffer to be removed - */ - void RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer ); - - /** - * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers - * @param[out] attributeLocation The vector where the attributes locations will be stored - * @param[in] program The program - * @param[in] bufferIndex The current buffer index - */ - void GetAttributeLocationFromProgram( Vector& attributeLocation, Program& program, BufferIndex bufferIndex ) const; - - /** - * Called from RenderManager to notify the geometry that current rendering pass has finished. - */ - void OnRenderFinished(); - - /** - * Chack if the attributes for the geometry have changed - * @return True if vertex buffers have been added or removed since last frame, false otherwise - */ - bool AttributesChanged() const - { - return mAttributesChanged; - } - - /** - * Sets the geometry type - * @param[in] type The new geometry type - */ - void SetType( Type type ) - { - mGeometryType = type; - } - - /** - * Upload the geometry if it has changed, set up the attributes and perform - * the Draw call corresponding to the geometry type - * @param[in] context The GL context - * @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 - */ - void UploadAndDraw(Graphics::API::Controller& controller, - BufferIndex bufferIndex, - Vector& attributeLocation, - size_t elementBufferOffset, - size_t elementBufferCount ); - - /** - * - * @return - */ - const Vector< Render::PropertyBuffer* >& GetVertexBuffers() const - { - return mVertexBuffers; - } - - const Dali::Vector< unsigned short>& GetIndices() const - { - return mIndices; - } - -private: - - // PropertyBuffers - Vector< Render::PropertyBuffer* > mVertexBuffers; - - Dali::Vector< unsigned short> mIndices; - OwnerPointer< GpuBuffer > mIndexBuffer; - Type mGeometryType; - - // Booleans - bool mIndicesChanged : 1; - bool mHasBeenUpdated : 1; - bool mAttributesChanged : 1; -}; - -} // namespace Render -} // namespace Internal -} // namespace Dali - -#endif // DALI_INTERNAL_RENDER_GEOMETRY_H diff --git a/dali/internal/render/renderers/render-property-buffer.cpp b/dali/internal/render/renderers/render-property-buffer.cpp deleted file mode 100644 index f0fa948..0000000 --- a/dali/internal/render/renderers/render-property-buffer.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2017 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. - * - */ - -#include -#include // Dali::Internal::PropertyBuffer -#include -#include -namespace -{ - -using namespace Dali; -using Dali::Property; -using Dali::Internal::PropertyImplementationType; - -Dali::GLenum GetPropertyImplementationGlType( Property::Type propertyType ) -{ - Dali::GLenum type = GL_BYTE; - - switch( propertyType ) - { - case Property::NONE: - case Property::STRING: - case Property::ARRAY: - case Property::MAP: - case Property::EXTENTS: - case Property::RECTANGLE: - case Property::ROTATION: - { - // types not supported by gl - break; - } - case Property::BOOLEAN: - { - type = GL_BYTE; - break; - } - case Property::INTEGER: - { - type = GL_SHORT; - break; - } - case Property::FLOAT: - case Property::VECTOR2: - case Property::VECTOR3: - case Property::VECTOR4: - case Property::MATRIX3: - case Property::MATRIX: - { - type = GL_FLOAT; - break; - } - } - - return type; -} - -size_t GetPropertyImplementationGlSize( Property::Type propertyType ) -{ - size_t size = 1u; - - switch( propertyType ) - { - case Property::NONE: - case Property::STRING: - case Property::ARRAY: - case Property::MAP: - case Property::EXTENTS: - case Property::RECTANGLE: - case Property::ROTATION: - { - // types not supported by gl - break; - } - case Property::BOOLEAN: - { - size = 1u; - break; - } - case Property::INTEGER: - { - size = 2u; - break; - } - case Property::FLOAT: - case Property::VECTOR2: - case Property::VECTOR3: - case Property::VECTOR4: - case Property::MATRIX3: - case Property::MATRIX: - { - size = 4u; - break; - } - } - - return size; -} -} //Unnamed namespace - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -PropertyBuffer::PropertyBuffer() -:mFormat(NULL), - mData(NULL), - mGpuBuffer(NULL), - mSize(0), - mDataChanged(true), - mGfxBuffer{ nullptr }, - mGfxBufferUsage{ Graphics::API::Buffer::UsageHint::ATTRIBUTES } -{ -} - -PropertyBuffer::~PropertyBuffer() -{ -} - -void PropertyBuffer::SetUsage( Graphics::API::Buffer::UsageHint usage ) -{ - mGfxBufferUsage = usage; -} - -void PropertyBuffer::SetFormat( PropertyBuffer::Format* format ) -{ - mFormat = format; - mDataChanged = true; -} - -void PropertyBuffer::SetData( Dali::Vector* data, size_t size ) -{ - mData = data; - mSize = size; - mDataChanged = true; -} - -bool PropertyBuffer::Update( Dali::Graphics::API::Controller& controller ) -{ - if( !mData || !mFormat || !mSize ) - { - return false; - } - - if( mDataChanged || !mGfxBuffer ) - { - if( !mGfxBuffer ) - { - mGfxBuffer = controller.CreateBuffer( controller.GetBufferFactory() - .SetUsage( mGfxBufferUsage ) - .SetSize( GetDataSize() ) ); - } - - // schedule deferred write - mGfxBuffer.Get().Write( mData.Get()->begin(), GetDataSize(), 0u ); - - mDataChanged = false; - } - - return true; -} - -#if 0 -bool PropertyBuffer::Update( Context& context ) -{ - if( !mData || !mFormat || !mSize ) - { - return false; - } - - if( !mGpuBuffer || mDataChanged ) - { - if ( ! mGpuBuffer ) - { - mGpuBuffer = new GpuBuffer( context ); - } - - // Update the GpuBuffer - if ( mGpuBuffer ) - { - DALI_ASSERT_DEBUG( mSize && "No data in the property buffer!" ); - mGpuBuffer->UpdateDataBuffer( GetDataSize(), &((*mData)[0]), GpuBuffer::STATIC_DRAW, GpuBuffer::ARRAY_BUFFER ); - } - - mDataChanged = false; - } - - return true; -} -#endif - -void PropertyBuffer::BindBuffer(GpuBuffer::Target target) -{ - if(mGpuBuffer) - { - mGpuBuffer->Bind(target); - } -} - -unsigned int PropertyBuffer::EnableVertexAttributes( Context& context, Vector& vAttributeLocation, unsigned int locationBase ) -{ - - unsigned int attributeCount = mFormat->components.size(); - - GLsizei elementSize = mFormat->size; - - for( unsigned int i = 0; i < attributeCount; ++i ) - { - GLint attributeLocation = vAttributeLocation[i+locationBase]; - if( attributeLocation != -1 ) - { - context.EnableVertexAttributeArray( attributeLocation ); - - const GLint attributeSize = mFormat->components[i].size; - size_t attributeOffset = mFormat->components[i].offset; - const Property::Type attributeType = mFormat->components[i].type; - - context.VertexAttribPointer( attributeLocation, - attributeSize / GetPropertyImplementationGlSize(attributeType), - GetPropertyImplementationGlType(attributeType), - GL_FALSE, // Not normalized - elementSize, - reinterpret_cast< void* >( attributeOffset ) ); - } - } - - return attributeCount; - -} - -} //Render -} //Internal -} //Dali diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp deleted file mode 100644 index 3f09153..0000000 --- a/dali/internal/render/renderers/render-renderer.cpp +++ /dev/null @@ -1,609 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ - -static Matrix gModelViewProjectionMatrix( false ); ///< a shared matrix to calculate the MVP matrix, dont want to store it in object to reduce storage overhead -static Matrix3 gNormalMatrix; ///< a shared matrix to calculate normal matrix, dont want to store it in object to reduce storage overhead - -/** - * Helper to set view and projection matrices once per program - * @param program to set the matrices to - * @param modelMatrix to set - * @param viewMatrix to set - * @param projectionMatrix to set - * @param modelViewMatrix to set - * @param modelViewProjectionMatrix to set - */ -inline void SetMatrices( Program& program, - const Matrix& modelMatrix, - const Matrix& viewMatrix, - const Matrix& projectionMatrix, - const Matrix& modelViewMatrix ) -{ - GLint loc = program.GetUniformLocation( Program::UNIFORM_MODEL_MATRIX ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - program.SetUniformMatrix4fv( loc, 1, modelMatrix.AsFloat() ); - } - loc = program.GetUniformLocation( Program::UNIFORM_VIEW_MATRIX ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - if( program.GetViewMatrix() != &viewMatrix ) - { - program.SetViewMatrix( &viewMatrix ); - program.SetUniformMatrix4fv( loc, 1, viewMatrix.AsFloat() ); - } - } - // set projection matrix if program has not yet received it this frame or if it is dirty - loc = program.GetUniformLocation( Program::UNIFORM_PROJECTION_MATRIX ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - if( program.GetProjectionMatrix() != &projectionMatrix ) - { - program.SetProjectionMatrix( &projectionMatrix ); - program.SetUniformMatrix4fv( loc, 1, projectionMatrix.AsFloat() ); - } - } - loc = program.GetUniformLocation(Program::UNIFORM_MODELVIEW_MATRIX); - if( Program::UNIFORM_UNKNOWN != loc ) - { - program.SetUniformMatrix4fv( loc, 1, modelViewMatrix.AsFloat() ); - } - - loc = program.GetUniformLocation( Program::UNIFORM_MVP_MATRIX ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - Matrix::Multiply( gModelViewProjectionMatrix, modelViewMatrix, projectionMatrix ); - program.SetUniformMatrix4fv( loc, 1, gModelViewProjectionMatrix.AsFloat() ); - } - - loc = program.GetUniformLocation( Program::UNIFORM_NORMAL_MATRIX ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - gNormalMatrix = modelViewMatrix; - gNormalMatrix.Invert(); - gNormalMatrix.Transpose(); - program.SetUniformMatrix3fv( loc, 1, gNormalMatrix.AsFloat() ); - } -} - -} - -namespace Render -{ - -Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider, - Render::Geometry* geometry, - unsigned int blendingBitmask, - const Vector4& blendColor, - FaceCullingMode::Type faceCullingMode, - bool preMultipliedAlphaEnabled, - DepthWriteMode::Type depthWriteMode, - DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction, - StencilParameters& stencilParameters ) -{ - return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, - faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode, - depthFunction, stencilParameters ); -} - -Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, - Render::Geometry* geometry, - unsigned int blendingBitmask, - const Vector4& blendColor, - FaceCullingMode::Type faceCullingMode, - bool preMultipliedAlphaEnabled, - DepthWriteMode::Type depthWriteMode, - DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction, - StencilParameters& stencilParameters ) -: mRenderDataProvider( dataProvider ), - mContext( NULL), - mGeometry( geometry ), - mUniformIndexMap(), - mAttributesLocation(), - mStencilParameters( stencilParameters ), - mBlendingOptions(), - mIndexedDrawFirstElement( 0 ), - mIndexedDrawElementsCount( 0 ), - mDepthFunction( depthFunction ), - mFaceCullingMode( faceCullingMode ), - mDepthWriteMode( depthWriteMode ), - mDepthTestMode( depthTestMode ), - mUpdateAttributesLocation( true ), - mPremultipledAlphaEnabled( preMultipliedAlphaEnabled ) -{ - if( blendingBitmask != 0u ) - { - mBlendingOptions.SetBitmask( blendingBitmask ); - } - - mBlendingOptions.SetBlendColor( blendColor ); -} - -void Renderer::Initialize( Context& context ) -{ - mContext = &context; -} - -Renderer::~Renderer() -{ -} - -void Renderer::SetRenderDataProvider( OwnerPointer& dataProvider ) -{ - mRenderDataProvider = dataProvider; - mUpdateAttributesLocation = true; - - // Check that the number of textures match the number of samplers in the shader - size_t textureCount = mRenderDataProvider->GetTextures().size(); - Program* program = mRenderDataProvider->GetShader().GetProgram(); - if( program && program->GetActiveSamplerCount() != textureCount ) - { - DALI_LOG_WARNING("The number of active samplers in the shader(%lu) does not match the number of textures in the TextureSet(%lu)\n", - program->GetActiveSamplerCount(), - textureCount ); - } -} - -void Renderer::SetGeometry( Render::Geometry* geometry ) -{ - mGeometry = geometry; - mUpdateAttributesLocation = true; -} - -void Renderer::SetBlending( Context& context, bool blend ) -{ - context.SetBlend( blend ); - if( blend ) - { - // Blend color is optional and rarely used - const Vector4* blendColor = mBlendingOptions.GetBlendColor(); - if( blendColor ) - { - context.SetCustomBlendColor( *blendColor ); - } - else - { - context.SetDefaultBlendColor(); - } - - // Set blend source & destination factors - context.BlendFuncSeparate( mBlendingOptions.GetBlendSrcFactorRgb(), - mBlendingOptions.GetBlendDestFactorRgb(), - mBlendingOptions.GetBlendSrcFactorAlpha(), - mBlendingOptions.GetBlendDestFactorAlpha() ); - - // Set blend equations - context.BlendEquationSeparate( mBlendingOptions.GetBlendEquationRgb(), - mBlendingOptions.GetBlendEquationAlpha() ); - } -} - -void Renderer::GlContextDestroyed() -{ -} - -void Renderer::GlCleanup() -{ -} - -void Renderer::SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program ) -{ - // Check if the map has changed - - - -#if 0 - DALI_ASSERT_DEBUG( mRenderDataProvider && "No Uniform map data provider available" ); - - - const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMap(); - - if( uniformMapDataProvider.GetUniformMapChanged( bufferIndex ) || - node.GetUniformMapChanged(bufferIndex)) - { - const SceneGraph::CollectedUniformMap& uniformMap = uniformMapDataProvider.GetUniformMap( bufferIndex ); - const SceneGraph::CollectedUniformMap& uniformMapNode = node.GetUniformMap( bufferIndex ); - - unsigned int maxMaps = uniformMap.Count() + uniformMapNode.Count(); - mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size - mUniformIndexMap.Resize( maxMaps ); - - unsigned int mapIndex(0); - for(; mapIndex < uniformMap.Count() ; ++mapIndex ) - { - mUniformIndexMap[mapIndex].propertyValue = uniformMap[mapIndex]->propertyPtr; - mUniformIndexMap[mapIndex].uniformIndex = program.RegisterUniform( uniformMap[mapIndex]->uniformName ); - } - - for( unsigned int nodeMapIndex = 0; nodeMapIndex < uniformMapNode.Count() ; ++nodeMapIndex ) - { - unsigned int uniformIndex = program.RegisterUniform( uniformMapNode[nodeMapIndex]->uniformName ); - bool found(false); - for( unsigned int i(0); ipropertyPtr; - found = true; - break; - } - } - - if( !found ) - { - mUniformIndexMap[mapIndex].propertyValue = uniformMapNode[nodeMapIndex]->propertyPtr; - mUniformIndexMap[mapIndex].uniformIndex = uniformIndex; - ++mapIndex; - } - } - - mUniformIndexMap.Resize( mapIndex ); - } - - // Set uniforms in local map - for( UniformIndexMappings::Iterator iter = mUniformIndexMap.Begin(), - end = mUniformIndexMap.End() ; - iter != end ; - ++iter ) - { - SetUniformFromProperty( bufferIndex, program, *iter ); - } - - GLint sizeLoc = program.GetUniformLocation( Program::UNIFORM_SIZE ); - if( -1 != sizeLoc ) - { - program.SetSizeUniform3f( sizeLoc, size.x, size.y, size.z ); - } -#endif - -} - -void Renderer::SetUniformFromProperty( BufferIndex bufferIndex, Program& program, UniformIndexMap& map ) -{ - GLint location = program.GetUniformLocation(map.uniformIndex); - if( Program::UNIFORM_UNKNOWN != location ) - { - // switch based on property type to use correct GL uniform setter - switch ( map.propertyValue->GetType() ) - { - case Property::INTEGER: - { - program.SetUniform1i( location, map.propertyValue->GetInteger( bufferIndex ) ); - break; - } - case Property::FLOAT: - { - program.SetUniform1f( location, map.propertyValue->GetFloat( bufferIndex ) ); - break; - } - case Property::VECTOR2: - { - Vector2 value( map.propertyValue->GetVector2( bufferIndex ) ); - program.SetUniform2f( location, value.x, value.y ); - break; - } - - case Property::VECTOR3: - { - Vector3 value( map.propertyValue->GetVector3( bufferIndex ) ); - program.SetUniform3f( location, value.x, value.y, value.z ); - break; - } - - case Property::VECTOR4: - { - Vector4 value( map.propertyValue->GetVector4( bufferIndex ) ); - program.SetUniform4f( location, value.x, value.y, value.z, value.w ); - break; - } - - case Property::ROTATION: - { - Quaternion value( map.propertyValue->GetQuaternion( bufferIndex ) ); - program.SetUniform4f( location, value.mVector.x, value.mVector.y, value.mVector.z, value.mVector.w ); - break; - } - - case Property::MATRIX: - { - const Matrix& value = map.propertyValue->GetMatrix(bufferIndex); - program.SetUniformMatrix4fv(location, 1, value.AsFloat() ); - break; - } - - case Property::MATRIX3: - { - const Matrix3& value = map.propertyValue->GetMatrix3(bufferIndex); - program.SetUniformMatrix3fv(location, 1, value.AsFloat() ); - break; - } - - default: - { - // Other property types are ignored - break; - } - } - } -} - -bool Renderer::BindTextures( Context& context, Program& program ) -{ - unsigned int textureUnit = 0; - bool result = true; - - GLint uniformLocation(-1); - std::vector& samplers( mRenderDataProvider->GetSamplers() ); - std::vector& textures( mRenderDataProvider->GetTextures() ); - for( size_t i(0); iBind(context, textureUnit, samplers[i] ); - if( result && program.GetSamplerUniformLocation( i, uniformLocation ) ) - { - program.SetUniform1i( uniformLocation, textureUnit ); - ++textureUnit; - } - } - } - - return result; -} - -void Renderer::SetFaceCullingMode( FaceCullingMode::Type mode ) -{ - mFaceCullingMode = mode; -} - -void Renderer::SetBlendingBitMask( unsigned int bitmask ) -{ - mBlendingOptions.SetBitmask( bitmask ); -} - -void Renderer::SetBlendColor( const Vector4& color ) -{ - mBlendingOptions.SetBlendColor( color ); -} - -void Renderer::SetIndexedDrawFirstElement( size_t firstElement ) -{ - mIndexedDrawFirstElement = firstElement; -} - -void Renderer::SetIndexedDrawElementsCount( size_t elementsCount ) -{ - mIndexedDrawElementsCount = elementsCount; -} - -void Renderer::EnablePreMultipliedAlpha( bool enable ) -{ - mPremultipledAlphaEnabled = enable; -} - -void Renderer::SetDepthWriteMode( DepthWriteMode::Type depthWriteMode ) -{ - mDepthWriteMode = depthWriteMode; -} - -void Renderer::SetDepthTestMode( DepthTestMode::Type depthTestMode ) -{ - mDepthTestMode = depthTestMode; -} - -DepthWriteMode::Type Renderer::GetDepthWriteMode() const -{ - return mDepthWriteMode; -} - -DepthTestMode::Type Renderer::GetDepthTestMode() const -{ - return mDepthTestMode; -} - -void Renderer::SetDepthFunction( DepthFunction::Type depthFunction ) -{ - mDepthFunction = depthFunction; -} - -DepthFunction::Type Renderer::GetDepthFunction() const -{ - return mDepthFunction; -} - -void Renderer::SetRenderMode( RenderMode::Type renderMode ) -{ - mStencilParameters.renderMode = renderMode; -} - -RenderMode::Type Renderer::GetRenderMode() const -{ - return mStencilParameters.renderMode; -} - -void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction ) -{ - mStencilParameters.stencilFunction = stencilFunction; -} - -StencilFunction::Type Renderer::GetStencilFunction() const -{ - return mStencilParameters.stencilFunction; -} - -void Renderer::SetStencilFunctionMask( int stencilFunctionMask ) -{ - mStencilParameters.stencilFunctionMask = stencilFunctionMask; -} - -int Renderer::GetStencilFunctionMask() const -{ - return mStencilParameters.stencilFunctionMask; -} - -void Renderer::SetStencilFunctionReference( int stencilFunctionReference ) -{ - mStencilParameters.stencilFunctionReference = stencilFunctionReference; -} - -int Renderer::GetStencilFunctionReference() const -{ - return mStencilParameters.stencilFunctionReference; -} - -void Renderer::SetStencilMask( int stencilMask ) -{ - mStencilParameters.stencilMask = stencilMask; -} - -int Renderer::GetStencilMask() const -{ - return mStencilParameters.stencilMask; -} - -void Renderer::SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail ) -{ - mStencilParameters.stencilOperationOnFail = stencilOperationOnFail; -} - -StencilOperation::Type Renderer::GetStencilOperationOnFail() const -{ - return mStencilParameters.stencilOperationOnFail; -} - -void Renderer::SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail ) -{ - mStencilParameters.stencilOperationOnZFail = stencilOperationOnZFail; -} - -StencilOperation::Type Renderer::GetStencilOperationOnZFail() const -{ - return mStencilParameters.stencilOperationOnZFail; -} - -void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass ) -{ - mStencilParameters.stencilOperationOnZPass = stencilOperationOnZPass; -} - -StencilOperation::Type Renderer::GetStencilOperationOnZPass() const -{ - return mStencilParameters.stencilOperationOnZPass; -} - -void Renderer::Render( Context& context, - BufferIndex bufferIndex, - const SceneGraph::NodeDataProvider& node, - const Matrix& modelMatrix, - const Matrix& modelViewMatrix, - const Matrix& viewMatrix, - const Matrix& projectionMatrix, - const Vector3& size, - bool blend ) -{ - // TODO: AB: no callig any GL now, to avoid asserts whole function commented out - return; -#if 0 - // Get the program to use: - Program* program = mRenderDataProvider->GetShader().GetProgram(); - if( !program ) - { - return; - } - - //Set cull face mode - context.CullFace( mFaceCullingMode ); - - //Set blending mode - SetBlending( context, blend ); - - // Take the program into use so we can send uniforms to it - program->Use(); - - if( DALI_LIKELY( BindTextures( context, *program ) ) ) - { - // Only set up and draw if we have textures and they are all valid - - // set projection and view matrix if program has not yet received them yet this frame - SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix ); - - // set color uniform - GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR ); - if( Program::UNIFORM_UNKNOWN != loc ) - { - const Vector4& color = node.GetRenderColor( bufferIndex ); - if( mPremultipledAlphaEnabled ) - { - program->SetUniform4f( loc, color.r*color.a, color.g*color.a, color.b*color.a, color.a ); - } - else - { - program->SetUniform4f( loc, color.r, color.g, color.b, color.a ); - } - } - - SetUniforms( bufferIndex, node, size, *program ); - - if( mUpdateAttributesLocation || mGeometry->AttributesChanged() ) - { - mGeometry->GetAttributeLocationFromProgram( mAttributesLocation, *program, bufferIndex ); - mUpdateAttributesLocation = false; - } - - mGeometry->UploadAndDraw( context, - bufferIndex, - mAttributesLocation, - mIndexedDrawFirstElement, - mIndexedDrawElementsCount ); - } -#endif -} - -void Renderer::SetSortAttributes( BufferIndex bufferIndex, - SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes ) const -{ - sortAttributes.shader = &( mRenderDataProvider->GetShader() ); - sortAttributes.geometry = mGeometry; -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h deleted file mode 100644 index 9be2e45..0000000 --- a/dali/internal/render/renderers/render-renderer.h +++ /dev/null @@ -1,463 +0,0 @@ -#ifndef DALI_INTERNAL_RENDER_RENDERER_H -#define DALI_INTERNAL_RENDER_RENDERER_H - -/* - * Copyright (c) 2017 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 - -namespace Dali -{ - -namespace Internal -{ -class Context; -class Texture; -class Program; - -namespace SceneGraph -{ -class SceneController; -class Shader; -class NodeDataProvider; -} - -namespace Render -{ - -/** - * Renderers are used to render meshes - * These objects are used during RenderManager::Render(), so properties modified during - * the Update must either be double-buffered, or set via a message added to the RenderQueue. - */ -class Renderer : public GlResourceOwner -{ -public: - - /** - * @brief Struct to encapsulate stencil parameters required for control of the stencil buffer. - */ - struct StencilParameters - { - StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask, - int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail, - StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass ) - : stencilFunctionMask ( stencilFunctionMask ), - stencilFunctionReference ( stencilFunctionReference ), - stencilMask ( stencilMask ), - renderMode ( renderMode ), - stencilFunction ( stencilFunction ), - stencilOperationOnFail ( stencilOperationOnFail ), - stencilOperationOnZFail ( stencilOperationOnZFail ), - stencilOperationOnZPass ( stencilOperationOnZPass ) - { - } - - int stencilFunctionMask; ///< The stencil function mask - int stencilFunctionReference; ///< The stencil function reference - int stencilMask; ///< The stencil mask - RenderMode::Type renderMode:3; ///< The render mode - StencilFunction::Type stencilFunction:3; ///< The stencil function - StencilOperation::Type stencilOperationOnFail:3; ///< The stencil operation for stencil test fail - StencilOperation::Type stencilOperationOnZFail:3; ///< The stencil operation for depth test fail - StencilOperation::Type stencilOperationOnZPass:3; ///< The stencil operation for depth test pass - }; - - /** - * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed() - */ - void GlContextDestroyed(); - - /** - * @copydoc Dali::Internal::GlResourceOwner::GlCleanup() - */ - void GlCleanup(); - - /** - * Create a new renderer instance - * @param[in] dataProviders The data providers for the renderer - * @param[in] geometry The geometry for the renderer - * @param[in] blendingBitmask A bitmask of blending options. - * @param[in] blendColor The blend color to pass to GL - * @param[in] faceCullingMode The face-culling mode. - * @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied. - * @param[in] depthWriteMode Depth buffer write mode - * @param[in] depthTestMode Depth buffer test mode - * @param[in] depthFunction Depth function - * @param[in] stencilParameters Struct containing all stencil related options - */ - static Renderer* New( SceneGraph::RenderDataProvider* dataProviders, - Render::Geometry* geometry, - unsigned int blendingBitmask, - const Vector4& blendColor, - FaceCullingMode::Type faceCullingMode, - bool preMultipliedAlphaEnabled, - DepthWriteMode::Type depthWriteMode, - DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction, - StencilParameters& stencilParameters ); - - /** - * Constructor. - * @param[in] dataProviders The data providers for the renderer - * @param[in] geometry The geometry for the renderer - * @param[in] blendingBitmask A bitmask of blending options. - * @param[in] blendColor The blend color to pass to GL - * @param[in] faceCullingMode The face-culling mode. - * @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied. - * @param[in] depthWriteMode Depth buffer write mode - * @param[in] depthTestMode Depth buffer test mode - * @param[in] depthFunction Depth function - * @param[in] stencilParameters Struct containing all stencil related options - */ - Renderer( SceneGraph::RenderDataProvider* dataProviders, - Render::Geometry* geometry, - unsigned int blendingBitmask, - const Vector4& blendColor, - FaceCullingMode::Type faceCullingMode, - bool preMultipliedAlphaEnabled, - DepthWriteMode::Type depthWriteMode, - DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction, - StencilParameters& stencilParameters ); - - /** - * Change the data providers of the renderer - * @param[in] dataProviders The data providers - */ - void SetRenderDataProvider( OwnerPointer& dataProviders ); - - /** - * Change the geometry used by the renderer - * @param[in] geometry The new geometry - */ - void SetGeometry( Render::Geometry* geometry ); - - /** - * Second-phase construction. - * This is called when the renderer is inside render thread - * @param[in] context Context used by the renderer - */ - void Initialize( Context& context ); - - /** - * Destructor - */ - ~Renderer(); - - /** - * Set the face-culling mode. - * @param[in] mode The face-culling mode. - */ - void SetFaceCullingMode( FaceCullingMode::Type mode ); - - /** - * Set the bitmask for blending options - * @param[in] bitmask A bitmask of blending options. - */ - void SetBlendingBitMask( unsigned int bitmask ); - - /** - * Set the blend color for blending options - * @param[in] blendColor The blend color to pass to GL - */ - void SetBlendColor( const Vector4& color ); - - /** - * Set the first element index to draw by the indexed draw - * @param[in] firstElement index of first element to draw - */ - void SetIndexedDrawFirstElement( size_t firstElement ); - - /** - * Set the number of elements to draw by the indexed draw - * @param[in] elementsCount number of elements to draw - */ - void SetIndexedDrawElementsCount( size_t elementsCount ); - - /** - * @brief Set whether the Pre-multiplied Alpha Blending is required - * - * @param[in] preMultipled whether alpha is pre-multiplied. - */ - void EnablePreMultipliedAlpha( bool preMultipled ); - - /** - * Sets the depth write mode - * @param[in] depthWriteMode The depth write mode - */ - void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode ); - - /** - * Query the Renderer's depth write mode - * @return The renderer depth write mode - */ - DepthWriteMode::Type GetDepthWriteMode() const; - - /** - * Sets the depth test mode - * @param[in] depthTestMode The depth test mode - */ - void SetDepthTestMode( DepthTestMode::Type depthTestMode ); - - /** - * Query the Renderer's depth test mode - * @return The renderer depth test mode - */ - DepthTestMode::Type GetDepthTestMode() const; - - /** - * Sets the depth function - * @param[in] depthFunction The depth function - */ - void SetDepthFunction( DepthFunction::Type depthFunction ); - - /** - * Query the Renderer's depth function - * @return The renderer depth function - */ - DepthFunction::Type GetDepthFunction() const; - - /** - * Sets the render mode - * @param[in] renderMode The render mode - */ - void SetRenderMode( RenderMode::Type mode ); - - /** - * Gets the render mode - * @return The render mode - */ - RenderMode::Type GetRenderMode() const; - - /** - * Sets the stencil function - * @param[in] stencilFunction The stencil function - */ - void SetStencilFunction( StencilFunction::Type stencilFunction ); - - /** - * Gets the stencil function - * @return The stencil function - */ - StencilFunction::Type GetStencilFunction() const; - - /** - * Sets the stencil function mask - * @param[in] stencilFunctionMask The stencil function mask - */ - void SetStencilFunctionMask( int stencilFunctionMask ); - - /** - * Gets the stencil function mask - * @return The stencil function mask - */ - int GetStencilFunctionMask() const; - - /** - * Sets the stencil function reference - * @param[in] stencilFunctionReference The stencil function reference - */ - void SetStencilFunctionReference( int stencilFunctionReference ); - - /** - * Gets the stencil function reference - * @return The stencil function reference - */ - int GetStencilFunctionReference() const; - - /** - * Sets the stencil mask - * @param[in] stencilMask The stencil mask - */ - void SetStencilMask( int stencilMask ); - - /** - * Gets the stencil mask - * @return The stencil mask - */ - int GetStencilMask() const; - - /** - * Sets the stencil operation for when the stencil test fails - * @param[in] stencilOperationOnFail The stencil operation - */ - void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail ); - - /** - * Gets the stencil operation for when the stencil test fails - * @return The stencil operation - */ - StencilOperation::Type GetStencilOperationOnFail() const; - - /** - * Sets the stencil operation for when the depth test fails - * @param[in] stencilOperationOnZFail The stencil operation - */ - void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail ); - - /** - * Gets the stencil operation for when the depth test fails - * @return The stencil operation - */ - StencilOperation::Type GetStencilOperationOnZFail() const; - - /** - * Sets the stencil operation for when the depth test passes - * @param[in] stencilOperationOnZPass The stencil operation - */ - void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass ); - - /** - * Gets the stencil operation for when the depth test passes - * @return The stencil operation - */ - StencilOperation::Type GetStencilOperationOnZPass() const; - - /** - * Called to render during RenderManager::Render(). - * @param[in] context The context used for rendering - * @param[in] bufferIndex The index of the previous update buffer. - * @param[in] node The node using this renderer - * @param[in] modelViewMatrix The model-view matrix. - * @param[in] viewMatrix The view matrix. - * @param[in] projectionMatrix The projection matrix. - * @param[in] size Size of the render item - * @param[in] blend If true, blending is enabled - */ - void Render( Context& context, - BufferIndex bufferIndex, - const SceneGraph::NodeDataProvider& node, - const Matrix& modelMatrix, - const Matrix& modelViewMatrix, - const Matrix& viewMatrix, - const Matrix& projectionMatrix, - const Vector3& size, - bool blend ); - - /** - * Write the renderer's sort attributes to the passed in reference - * - * @param[in] bufferIndex The current update buffer index. - * @param[out] sortAttributes - */ - void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes ) const; - - inline const SceneGraph::RenderDataProvider& GetRenderDataProvider() const - { - return *mRenderDataProvider.Get(); - }; - - inline const Geometry* GetRenderGeometry() const - { - return mGeometry; - }; - -private: - - struct UniformIndexMap; - - // Undefined - Renderer( const Renderer& ); - - // Undefined - Renderer& operator=( const Renderer& rhs ); - - /** - * Sets blending options - * @param context to use - * @param blend Wheter blending should be enabled or not - */ - void SetBlending( Context& context, bool blend ); - - /** - * Set the uniforms from properties according to the uniform map - * @param[in] bufferIndex The index of the previous update buffer. - * @param[in] node The node using the renderer - * @param[in] size The size of the renderer - * @param[in] program The shader program on which to set the uniforms. - */ - void SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program ); - - /** - * Set the program uniform in the map from the mapped property - * @param[in] bufferIndex The index of the previous update buffer. - * @param[in] program The shader program - * @param[in] map The uniform - */ - void SetUniformFromProperty( BufferIndex bufferIndex, Program& program, UniformIndexMap& map ); - - /** - * Bind the textures and setup the samplers - * @param[in] context The GL context - * @param[in] program The shader program - * @return False if create or bind failed, true if success. - */ - bool BindTextures( Context& context, Program& program ); - -private: - - OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider; - - Context* mContext; - Render::Geometry* mGeometry; - - struct UniformIndexMap - { - unsigned int uniformIndex; ///< The index of the cached location in the Program - const PropertyInputImpl* propertyValue; - }; - - typedef Dali::Vector< UniformIndexMap > UniformIndexMappings; - - UniformIndexMappings mUniformIndexMap; - Vector mAttributesLocation; - - StencilParameters mStencilParameters; ///< Struct containing all stencil related options - BlendingOptions mBlendingOptions; ///< Blending options including blend color, blend func and blend equation - - size_t mIndexedDrawFirstElement; ///< Offset of first element to draw - size_t mIndexedDrawElementsCount; ///< Number of elements to draw - - DepthFunction::Type mDepthFunction:3; ///< The depth function - FaceCullingMode::Type mFaceCullingMode:2; ///< The mode of face culling - DepthWriteMode::Type mDepthWriteMode:2; ///< The depth write mode - DepthTestMode::Type mDepthTestMode:2; ///< The depth test mode - bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed - bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required - -}; - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_RENDER_RENDERER_H diff --git a/dali/internal/render/renderers/render-sampler.h b/dali/internal/render/renderers/render-sampler.h deleted file mode 100644 index c5040ae..0000000 --- a/dali/internal/render/renderers/render-sampler.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef DALI_INTERNAL_RENDER_SAMPLER_H -#define DALI_INTERNAL_RENDER_SAMPLER_H - -/* - * Copyright (c) 2016 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. - */ - -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -struct Sampler -{ - - typedef Dali::FilterMode::Type FilterMode; - typedef Dali::WrapMode::Type WrapMode; - - /** - * Constructor - */ - Sampler() - :mMinificationFilter(FilterMode::DEFAULT), - mMagnificationFilter(FilterMode::DEFAULT), - mSWrapMode(WrapMode::DEFAULT), - mTWrapMode(WrapMode::DEFAULT), - mRWrapMode(WrapMode::DEFAULT) - {} - - /** - * Destructor - */ - ~Sampler() - {} - - bool operator==(const Sampler& rhs) const - { - return ( ( mMinificationFilter == rhs.mMinificationFilter ) && - ( mMagnificationFilter == rhs.mMagnificationFilter ) && - ( mSWrapMode == rhs.mSWrapMode ) && - ( mTWrapMode == rhs.mTWrapMode ) && - ( mRWrapMode == rhs.mRWrapMode ) ); - } - - bool operator!=(const Sampler& rhs) const - { - return !(*this == rhs); - } - - FilterMode mMinificationFilter : 4; ///< The minify filter - FilterMode mMagnificationFilter : 4; ///< The magnify filter - WrapMode mSWrapMode : 4; ///< The horizontal wrap mode - WrapMode mTWrapMode : 4; ///< The vertical wrap mode - WrapMode mRWrapMode : 4; ///< The vertical wrap mode -}; - -} // namespace Render - -} // namespace Internal - -} // namespace Dali - - -#endif // DALI_INTERNAL_RENDER_SAMPLER_H diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp deleted file mode 100644 index 21bcbe9..0000000 --- a/dali/internal/render/renderers/render-texture.cpp +++ /dev/null @@ -1,947 +0,0 @@ -/* - * Copyright (c) 2017 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 //floor, log2 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ - -namespace -{ - -// These match the GL specification -const GLint GL_MINIFY_DEFAULT = GL_NEAREST_MIPMAP_LINEAR; -const GLint GL_MAGNIFY_DEFAULT = GL_LINEAR; -const GLint GL_WRAP_DEFAULT = GL_CLAMP_TO_EDGE; - -// These are the Dali defaults -const GLint DALI_MINIFY_DEFAULT = GL_LINEAR; -const GLint DALI_MAGNIFY_DEFAULT = GL_LINEAR; - -/** - * @brief Convert a FilterMode to its corresponding GL type. - * - * @param[in] filterMode The FilterMode type. - * @param[in] daliDefault The filter mode to use if filterMode is DEFAULT. - * @param[in] glDefault The filter mode to use if filterMode is NONE. - * @return the equivalent GL filter mode. - */ -GLint FilterModeToGL( FilterMode::Type filterMode, GLint daliDefault, GLint glDefault ) -{ - switch( filterMode ) - { - case FilterMode::NEAREST: - { - return GL_NEAREST; - } - case FilterMode::LINEAR: - { - return GL_LINEAR; - } - case FilterMode::NONE: - { - return glDefault; - } - case FilterMode::NEAREST_MIPMAP_NEAREST: - { - return GL_NEAREST_MIPMAP_NEAREST; - } - case FilterMode::LINEAR_MIPMAP_NEAREST: - { - return GL_LINEAR_MIPMAP_NEAREST; - } - case FilterMode::NEAREST_MIPMAP_LINEAR: - { - return GL_NEAREST_MIPMAP_LINEAR; - } - case FilterMode::LINEAR_MIPMAP_LINEAR: - { - return GL_LINEAR_MIPMAP_LINEAR; - } - case FilterMode::DEFAULT: - { - return daliDefault; - } - } - - return daliDefault; -} - -/** - * @brief Convert from a WrapMode to its corresponding GL enumeration - * @param[in] wrapMode The wrap mode - * @param[in] defaultWrapMode The mode to use if WrapMode is Default - * @return The equivalent GL wrap mode - */ -GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode ) -{ - switch( wrapMode ) - { - case WrapMode::CLAMP_TO_EDGE: - { - return GL_CLAMP_TO_EDGE; - } - case WrapMode::REPEAT: - { - return GL_REPEAT; - } - case WrapMode::MIRRORED_REPEAT: - { - return GL_MIRRORED_REPEAT; - } - case WrapMode::DEFAULT: - { - return defaultWrapMode; - } - } - - return defaultWrapMode; -} - -/** - * @brief Retrives the GL format, GL internal format and pixel data type from a Pixel::Format - * @param[in] pixelFormat The pixel format. - * @param[out] glFormat The gl format. - * @param[out] glInternalFormat The gl internal format. - * @param[out] pixelDataType The data type of the pixel data. - */ -void PixelFormatToGl( Pixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType ) -{ - // Compressed textures have no pixelDataType, so init to an invalid value: - pixelDataType = -1; - - switch( pixelFormat ) - { - case Pixel::A8: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_ALPHA; - break; - } - - case Pixel::L8: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_LUMINANCE; - break; - } - - case Pixel::LA88: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_LUMINANCE_ALPHA; - break; - } - - case Pixel::RGB565: - { - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; - glFormat= GL_RGB; - break; - } - - case Pixel::BGR565: - { - DALI_LOG_ERROR("Pixel format BGR565 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; -#ifdef _ARCH_ARM_ - glFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - glFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case Pixel::RGBA4444: - { - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; - glFormat= GL_RGBA; - break; - } - - case Pixel::BGRA4444: - { - DALI_LOG_ERROR("Pixel format BGRA4444 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; -#ifdef _ARCH_ARM_ - glFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - glFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case Pixel::RGBA5551: - { - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; - glFormat= GL_RGBA; - break; - } - - case Pixel::BGRA5551: - { - DALI_LOG_ERROR("Pixel format BGRA5551 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; -#ifdef _ARCH_ARM_ - glFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - glFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case Pixel::RGB888: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_RGB; - break; - } - - case Pixel::RGB8888: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_RGBA; // alpha is reserved but not used - break; - } - - case Pixel::BGR8888: - { - pixelDataType = GL_UNSIGNED_BYTE; -#ifdef GL_BGRA_EXT - glFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - glFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - case Pixel::RGBA8888: - { - pixelDataType = GL_UNSIGNED_BYTE; - glFormat= GL_RGBA; - break; - } - - case Pixel::BGRA8888: - { - pixelDataType = GL_UNSIGNED_BYTE; -#ifdef GL_BGRA_EXT - glFormat= GL_BGRA_EXT; // alpha is reserved but not used -#else - glFormat= GL_RGBA; // alpha is reserved but not used -#endif - break; - } - - // GLES 2 extension compressed formats: - case Pixel::COMPRESSED_RGB8_ETC1: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" ); - glFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. - break; - } - case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" ); - glFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. - break; - } - - // GLES 3.0 standard compressed formats: - case Pixel::COMPRESSED_R11_EAC: - { - DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.\n"); - glFormat = GL_COMPRESSED_R11_EAC; - break; - } - case Pixel::COMPRESSED_SIGNED_R11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" ); - glFormat = GL_COMPRESSED_SIGNED_R11_EAC; - break; - } - case Pixel::COMPRESSED_RG11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" ); - glFormat = GL_COMPRESSED_RG11_EAC; - break; - } - case Pixel::COMPRESSED_SIGNED_RG11_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" ); - glFormat = GL_COMPRESSED_SIGNED_RG11_EAC; - break; - } - case Pixel::COMPRESSED_RGB8_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" ); - glFormat = GL_COMPRESSED_RGB8_ETC2; - break; - } - case Pixel::COMPRESSED_SRGB8_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ETC2; - break; - } - case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - glFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; - break; - } - case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - glFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; - break; - } - case Pixel::COMPRESSED_RGBA8_ETC2_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" ); - glFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; - break; - } - - // GLES 3.1 extension compressed formats: - case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR; - break; - } - case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" ); - glFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; - break; - } - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" ); - glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; - break; - } - - // GLES 3.0 floating point formats. - case Pixel::RGB16F: - { - glFormat = GL_RGB; - pixelDataType = GL_HALF_FLOAT; - break; - } - case Pixel::RGB32F: - { - glFormat = GL_RGB; - pixelDataType = GL_FLOAT; - break; - } - - case Pixel::INVALID: - { - DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" ); - glFormat = 0; - break; - } - } - - switch( pixelFormat ) - { - case Pixel::RGB16F: - case Pixel::RGB32F: // FALL THROUGH - { - glInternalFormat = GL_R11F_G11F_B10F; - break; - } - default: - { - glInternalFormat = glFormat; - } - } - -} - - -/** - * @brief Whether specified pixel format is compressed. - * - * @param [in] pixelformat Pixel format - * @return true if format is compressed, false otherwise - */ -bool IsCompressedFormat(Pixel::Format pixelFormat) -{ - switch (pixelFormat) - { - case Pixel::L8: - case Pixel::A8: - case Pixel::LA88: - case Pixel::RGB565: - case Pixel::RGBA4444: - case Pixel::RGBA5551: - case Pixel::BGR565: - case Pixel::BGRA4444: - case Pixel::BGRA5551: - case Pixel::RGB888: - case Pixel::RGB8888: - case Pixel::BGR8888: - case Pixel::RGBA8888: - case Pixel::BGRA8888: - case Pixel::RGB16F: - case Pixel::RGB32F: - case Pixel::INVALID: - { - return false; - } - - case Pixel::COMPRESSED_R11_EAC: - case Pixel::COMPRESSED_SIGNED_R11_EAC: - case Pixel::COMPRESSED_RG11_EAC: - case Pixel::COMPRESSED_SIGNED_RG11_EAC: - case Pixel::COMPRESSED_RGB8_ETC2: - case Pixel::COMPRESSED_SRGB8_ETC2: - case Pixel::COMPRESSED_RGB8_ETC1: - case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1: - case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case Pixel::COMPRESSED_RGBA8_ETC2_EAC: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR: - case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - { - return true; - } - } - - return false; -} - -} //Unnamed namespace - - -Texture::Texture( Type type, Pixel::Format format, ImageDimensions size ) -: mNativeImage(), - mSampler(), - mId( 0 ), - mTarget( ( type == TextureType::TEXTURE_2D ) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ), - mGlInternalFormat( GL_RGB ), - mGlFormat( GL_RGB ), - mPixelDataType( GL_UNSIGNED_BYTE ), - mWidth( size.GetWidth() ), - mHeight( size.GetHeight() ), - mMaxMipMapLevel( 0 ), - mType( type ), - mHasAlpha( HasAlpha( format ) ), - mIsCompressed( IsCompressedFormat( format ) ), - mGfxTexture( nullptr ) -{ - PixelFormatToGl( format, - mGlFormat, - mGlInternalFormat, - mPixelDataType ); -} - -Texture::Texture( NativeImageInterfacePtr nativeImageInterface ) -: mNativeImage( nativeImageInterface ), - mSampler(), - mId( 0 ), - mTarget( GL_TEXTURE_2D ), - mGlInternalFormat( GL_RGB ), - mGlFormat( GL_RGB ), - mPixelDataType( GL_UNSIGNED_BYTE ), - mWidth( nativeImageInterface->GetWidth() ), - mHeight( nativeImageInterface->GetHeight() ), - mMaxMipMapLevel( 0 ), - mType( TextureType::TEXTURE_2D ), - mHasAlpha( nativeImageInterface->RequiresBlending() ), - mIsCompressed( false ), - mGfxTexture( nullptr ) -{ -} - -Texture::~Texture() -{} - -void Texture::Destroy( Context& context ) -{ - if( mId ) - { - context.DeleteTextures( 1, &mId ); - - if( mNativeImage ) - { - mNativeImage->GlExtensionDestroy(); - } - } -} - -void Texture::GlContextDestroyed() -{ - mId = 0u; -} - -void Texture::Initialize(Context& context) -{ - if( mNativeImage ) - { - if( mNativeImage->GlExtensionCreate() ) - { - NativeImageInterface::Extension* extension = mNativeImage->GetExtension(); - if( extension ) - { - mTarget = extension->GetEglImageTextureTarget(); - } - - context.GenTextures( 1, &mId ); - context.BindTexture( mTarget, mId ); - context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data - - //Apply default sampling parameters - context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT ); - - // platform specific implementation decides on what GL extension to use - if( mNativeImage->TargetTexture() != 0u ) - { - context.DeleteTextures( 1, &mId ); - mNativeImage->GlExtensionDestroy(); - mId = 0u; - } - } - } - else - { - //Create the texture and reserve memory for the first mipmap level. - context.GenTextures( 1, &mId ); - context.BindTexture( mTarget, mId ); - context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data - - //Apply default sampling parameters - context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT ); - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT ); - - if( mType == TextureType::TEXTURE_2D ) - { - if( !mIsCompressed ) - { - context.TexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, 0 ); - } - else - { - context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 ); - } - } - else if( mType == TextureType::TEXTURE_CUBE ) - { - if( !mIsCompressed ) - { - for( unsigned int i(0); i<6; ++i ) - { - context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, 0 ); - } - } - else - { - for( unsigned int i(0); i<6; ++i ) - { - context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 ); - } - } - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT ); - } - } -} - -void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ) -{ - DALI_ASSERT_ALWAYS( mNativeImage == NULL ); - - //Get pointer to the data of the PixelData object - unsigned char* buffer( pixelData->GetBuffer() ); - - //This buffer is only used if manually converting from RGB to RGBA - unsigned char* tempBuffer(0); - - //Retrieves the pixel data element type, the gl format and gl internal format of the data contained in the PixelData object. - GLenum glFormat; - GLint glInternalFormat; - GLenum pixelDataElementType; - PixelFormatToGl( pixelData->GetPixelFormat(), glFormat, glInternalFormat, pixelDataElementType ); - - //Get the maximum mipmap level to set GL_TEXTURE_MAX_LEVEL parameter in GLES3x because is not - //necessary to upload all the mipmap levels - mMaxMipMapLevel = ( mMaxMipMapLevel > params.mipmap ) ? mMaxMipMapLevel : params.mipmap; - - const bool isSubImage = ( ( params.xOffset != 0 ) || - ( params.yOffset != 0 ) || - ( params.width != ( mWidth / ( 1 << params.mipmap ) ) ) || - ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) ); - - bool convert = ( ( glFormat == GL_RGB ) && ( mGlFormat == GL_RGBA ) ); -#if DALI_GLES_VERSION >= 30 - // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded. - convert = convert && !isSubImage; -#endif - - if( convert ) - { - size_t dataSize = static_cast< size_t >( params.width ) * params.height; - tempBuffer = new unsigned char[dataSize*4u]; - for( size_t i(0u); iGetBufferSize(), buffer ); - } - } - else - { - //Specifying part of the image for the mipmap - if( !mIsCompressed ) - { - context.TexSubImage2D( target, params.mipmap, - params.xOffset, params.yOffset, params.width, params.height, - glFormat, pixelDataElementType, buffer ); - } - else - { - context.CompressedTexSubImage2D( target, params.mipmap, - params.xOffset, params.yOffset, params.width, params.height, - glFormat, pixelData->GetBufferSize(), buffer ); - } - } - - - //Destroy temp buffer used for conversion RGB->RGBA - delete[] tempBuffer; -} - -bool Texture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler ) -{ - if( mNativeImage && mId == 0 ) - { - Initialize( context ); - } - - if( mId != 0 ) - { - context.BindTextureForUnit( static_cast( textureUnit ), mTarget, mId ); - ApplySampler( context, sampler ); - - if( mNativeImage ) - { - mNativeImage->PrepareTexture(); - } - - return true; - } - - return false; -} - -void Texture::ApplySampler( Context& context, Render::Sampler* sampler ) -{ - Render::Sampler oldSampler = mSampler; - mSampler = sampler ? *sampler : Sampler(); - - if( mSampler != oldSampler ) - { - GLint mode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT ); - if( mode != FilterModeToGL( oldSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT ) ) - { - context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, mode ); - } - - mode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT ); - if( mode != FilterModeToGL( oldSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT ) ) - { - context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, mode ); - } - - mode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT ); - if( mode != WrapModeToGL( oldSampler.mSWrapMode, GL_WRAP_DEFAULT ) ) - { - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, mode ); - } - - mode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT ); - if( mode != WrapModeToGL( oldSampler.mTWrapMode, GL_WRAP_DEFAULT ) ) - { - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, mode ); - } - - if( mType == TextureType::TEXTURE_CUBE ) - { - mode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT ); - if( mode != WrapModeToGL( oldSampler.mRWrapMode, GL_WRAP_DEFAULT ) ) - { - context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, mode ); - } - } - -#if DALI_GLES_VERSION >= 30 - //In GLES 3.0 we do not need to upload all of the mipmap levels, but GL_TEXTURE_MAX_LEVEL must be set - if(mMaxMipMapLevel) - { - context.TexParameteri( mTarget, GL_TEXTURE_MAX_LEVEL, mMaxMipMapLevel ); - } -#endif - - } -} - -bool Texture::HasAlphaChannel() -{ - return mHasAlpha; -} - -void Texture::GenerateMipmaps( Context& context ) -{ - //GL_TEXTURE_MAX_LEVEL does not need to be set when mipmaps are generated by GL - mMaxMipMapLevel = 0; - context.BindTexture( mTarget, mId ); - context.GenerateMipmap( mTarget ); -} - -} //Render - -} //Internal - -} //Dali diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h deleted file mode 100644 index d0e2253..0000000 --- a/dali/internal/render/renderers/render-texture.h +++ /dev/null @@ -1,190 +0,0 @@ -#ifndef DALI_INTERNAL_RENDER_TEXTURE_H -#define DALI_INTERNAL_RENDER_TEXTURE_H - -/* - * Copyright (c) 2018 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. - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include // Dali::ImageDimensions -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Render -{ -struct Sampler; - -class Texture -{ -public: - - typedef Dali::TextureType::Type Type; - - /** - * Constructor - * @param[in] type The type of the texture - * @param[in] format The format of the pixel data - * @param[in] size The size of the texture - */ - Texture( Type type, Pixel::Format format, ImageDimensions size ); - - /** - * Constructor from native image - * @param[in] nativeImageInterface The native image - */ - Texture( NativeImageInterfacePtr nativeImageInterface ); - - /** - * Destructor - */ - ~Texture(); - - /** - * Creates the texture in the GPU. - * Creates the texture and reserves memory for the first mipmap level - * @param[in] context The GL context - */ - void Initialize( Context& context ); - - /** - * Deletes the texture from the GPU - * @param[in] context The GL context - */ - void Destroy( Context& context ); - - /** - * Called by RenderManager to inform the texture that the context has been destroyed - */ - void GlContextDestroyed(); - - /** - * Uploads data to the texture. - * @param[in] context The GL context - * @param[in] pixelData A pixel data object - * @param[in] params Upload parameters. See UploadParams - */ - void Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ); - - /** - * Bind the texture to the given texture unit and applies the given sampler - * @param[in] context The GL context - * @param[in] textureUnit the texture unit - * @param[in] sampler The sampler to be used with the texture - * @return true if the bind succeeded, false otherwise - */ - bool Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler ); - - /** - * Auto generates mipmaps for the texture - * @param[in] context The GL context - */ - void GenerateMipmaps( Context& context ); - - /** - * Retrieve wheter the texture has an alpha channel - * @return True if the texture has alpha channel, false otherwise - */ - bool HasAlphaChannel(); - - /** - * Get the id of the texture - * @return Id of the texture - */ - GLuint GetId() - { - return mId; - } - - /** - * Get the type of the texture - * @return Type of the texture - */ - Type GetType() const - { - return mType; - } - - /** - * Check if the texture is a native image - * @return if the texture is a native image - */ - bool IsNativeImage() const - { - return mNativeImage; - } - - void SetId( uint32_t textureId ) - { - mId = textureId; - } - - void SetGfxObject( Graphics::API::Accessor texture ) - { - mGfxTexture = texture; - } - - const Graphics::API::Accessor& GetGfxObject() const - { - return mGfxTexture; - } - -private: - - /** - * Helper method to apply a sampler to the texture - * @param[in] context The GL context - * @param[in] sampler The sampler - */ - void ApplySampler( Context& context, Render::Sampler* sampler ); - - NativeImageInterfacePtr mNativeImage; ///< Pointer to native image - Render::Sampler mSampler; ///< The current sampler state - GLuint mId; ///< Id of the texture - GLuint mTarget; ///< Specifies the target to which the texture is bound. - GLint mGlInternalFormat; ///< The gl internal format of the pixel data - GLenum mGlFormat; ///< The gl format of the pixel data - GLenum mPixelDataType; ///< The data type of the pixel data - uint16_t mWidth; ///< Width of the texture - uint16_t mHeight; ///< Height of the texture - uint16_t mMaxMipMapLevel; ///< Maximum mipmap level - Type mType:2; ///< Type of the texture - bool mHasAlpha : 1; ///< Whether the format has an alpha channel - bool mIsCompressed : 1; ///< Whether the format is compressed - - Graphics::API::Accessor mGfxTexture; ///< TODO: find right place to store texture -}; - - -} // namespace Render - -} // namespace Internal - -} // namespace Dali - - -#endif // DALI_INTERNAL_RENDER_TEXTURE_H diff --git a/dali/internal/render/shaders/program-cache.h b/dali/internal/render/shaders/program-cache.h deleted file mode 100644 index 4a20377..0000000 --- a/dali/internal/render/shaders/program-cache.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef __DALI_INTERNAL_PROGRAM_CACHE_H__ -#define __DALI_INTERNAL_PROGRAM_CACHE_H__ - -/* - * Copyright (c) 2014 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 // for GLenum -#include - -namespace Dali -{ - -namespace Internal -{ - -class Program; - -/** - * This class is interface for caching Program objects - */ -class ProgramCache -{ -public: - - /** - * Constructor - */ - ProgramCache() - { } - - /** - * Destructor, virtual as this is an interface - */ - virtual ~ProgramCache() - { } - -public: // API - - /** - * @return GlAbstraction - */ - virtual Integration::GlAbstraction& GetGlAbstraction() = 0; - - /** - * Get the program from cache with hash - * @param shaderHash to use - * @return program - */ - virtual Program* GetProgram( size_t shaderHash ) = 0; - - /** - * Add a program to cache - * @param shaderHash of the program - * @param program to add - */ - virtual void AddProgram( size_t shaderHash, Program* program ) = 0; - - /** - * Get currently bound program - * @return program that is currently used - */ - virtual Program* GetCurrentProgram() = 0; - - /** - * Set the currently bound program - * @param program that is used - */ - virtual void SetCurrentProgram( Program* program ) = 0; - - /** - * @return true if program binaries are supported - */ - virtual bool IsBinarySupported() = 0; - - /** - * @return the binary format to use - */ - virtual GLenum ProgramBinaryFormat() = 0; - - /** - * @param programData to store/save - */ - virtual void StoreBinary( Internal::ShaderDataPtr programData ) = 0; - -private: // not implemented as non-copyable - - ProgramCache( const ProgramCache& rhs ); - ProgramCache& operator=( const ProgramCache& rhs ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_PROGRAM_CACHE_H__ - diff --git a/dali/internal/render/shaders/program-controller.cpp b/dali/internal/render/shaders/program-controller.cpp deleted file mode 100644 index 85230ba..0000000 --- a/dali/internal/render/shaders/program-controller.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -ProgramController::ProgramController( Integration::GlAbstraction& glAbstraction ) -: mShaderSaver( 0 ), - mGlAbstraction( glAbstraction ), - mCurrentProgram( NULL ), - mProgramBinaryFormat( 0 ), - mNumberOfProgramBinaryFormats( 0 ) -{ - // we have 17 default programs so make room for those and a few custom ones as well - mProgramCache.Reserve( 32 ); -} - -ProgramController::~ProgramController() -{ -} - -void ProgramController::ResetProgramMatrices() -{ - const ProgramIterator end = mProgramCache.End(); - for ( ProgramIterator iter = mProgramCache.Begin(); iter != end; ++iter ) - { - Program* program = (*iter)->GetProgram(); - program->SetProjectionMatrix( NULL ); - program->SetViewMatrix( NULL ); - } -} - -void ProgramController::GlContextCreated() -{ - // reset any potential previous errors - LOG_GL( "GetError()\n" ); - CHECK_GL( mGlAbstraction, mGlAbstraction.GetError() ); - - // find out if program binaries are supported and the format enum as well - Dali::Vector programBinaryFormats; - - CHECK_GL( mGlAbstraction, mGlAbstraction.GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &mNumberOfProgramBinaryFormats ) ); - LOG_GL("GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES) = %d\n", mNumberOfProgramBinaryFormats ); - - if( GL_NO_ERROR == mGlAbstraction.GetError() && 0 < mNumberOfProgramBinaryFormats ) - { - programBinaryFormats.Resize( mNumberOfProgramBinaryFormats ); - CHECK_GL( mGlAbstraction, mGlAbstraction.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( NULL ); - // 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 mGlAbstraction; -} - -Program* ProgramController::GetProgram( size_t shaderHash ) -{ - Program* program = NULL; - const ProgramIterator end = mProgramCache.End(); - for ( ProgramIterator iter = mProgramCache.Begin(); iter != end; ++iter ) - { - size_t hash = (*iter)->GetHash(); - if( shaderHash == hash ) - { - program = (*iter)->GetProgram(); - break; - } - } - return program; -} - -void ProgramController::AddProgram( size_t shaderHash, Program* program ) -{ - // we expect unique hash values so its event thread sides job to guarantee that - // AddProgram is only called after program checks that GetProgram returns NULL - mProgramCache.PushBack( new ProgramPair( program, shaderHash ) ); -} - -Program* ProgramController::GetCurrentProgram() -{ - return mCurrentProgram; -} - -void ProgramController::SetCurrentProgram( Program* program ) -{ - mCurrentProgram = program; -} - -bool ProgramController::IsBinarySupported() -{ - return mNumberOfProgramBinaryFormats > 0; -} - -unsigned int ProgramController::ProgramBinaryFormat() -{ - return mProgramBinaryFormat; -} - -void ProgramController::StoreBinary( Internal::ShaderDataPtr programData ) -{ - DALI_ASSERT_DEBUG( programData->GetBufferSize() > 0 ); - DALI_ASSERT_DEBUG( mShaderSaver && "SetShaderSaver() should have been called during startup." ); - - if( mShaderSaver != NULL ) - { - mShaderSaver->SaveBinary( programData ); - } -} - -void ProgramController::SetShaderSaver( ShaderSaver& shaderSaver ) -{ - mShaderSaver = &shaderSaver; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/shaders/program-controller.h b/dali/internal/render/shaders/program-controller.h deleted file mode 100644 index 9c3945e..0000000 --- a/dali/internal/render/shaders/program-controller.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef __DALI_INTERNAL_PROGRAM_CONTROLLER_H__ -#define __DALI_INTERNAL_PROGRAM_CONTROLLER_H__ - -/* - * Copyright (c) 2014 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 - -namespace Dali -{ - -namespace Internal -{ - -class ShaderSaver; - -/** - * This class is the owner of GL shader programs - */ -class ProgramController : public ProgramCache -{ -public: - - /** - * Wrapper for a program and its hash code - */ - class ProgramPair - { - public: // API - - /** - * Constructor - * @param program - * @param shaderHash - */ - ProgramPair( Program* program, size_t shaderHash ) - : mProgram( program ), mShaderHash( shaderHash ) - { } - - /** - * Destructor, non-virtual as not a base - */ - ~ProgramPair() - { - delete mProgram; - } - - /** - * Inline getter for the program - * @return the program - */ - inline Program* GetProgram() - { - return mProgram; - } - - /** - * Inline getter for the hash - * @return the hash - */ - inline size_t GetHash() - { - return mShaderHash; - } - - private: // Not implemented - ProgramPair( const ProgramPair& ); - ProgramPair& operator=( const ProgramPair& ); - - private: // Data - Program* mProgram; - size_t mShaderHash; - }; - - /** - * Constructor - * @param postProcessDispatcher to send save binary message back to update - */ - ProgramController( Integration::GlAbstraction& glAbstraction ); - - /** - * Destructor, non virtual as not a base class - */ - ~ProgramController(); - -public: // API - - /** - * Resets the program matrices. Must be called at the beginning of every frame - */ - 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. - */ - void SetShaderSaver( ShaderSaver& shaderSaver ); - -private: // From ProgramCache - - /** - * @copydoc ProgramCache::GetGlAbstraction - */ - virtual Integration::GlAbstraction& GetGlAbstraction(); - - /** - * @copydoc ProgramCache::GetProgram - */ - virtual Program* GetProgram( size_t shaderHash ); - - /** - * @copydoc ProgramCache::AddProgram - */ - virtual void AddProgram( size_t shaderHash, Program* program ); - - /** - * @copydoc ProgramCache::GetCurrentProgram - */ - virtual Program* GetCurrentProgram(); - - /** - * @copydoc ProgramCache::SetCurrentProgram - */ - virtual void SetCurrentProgram( Program* program ); - - /** - * @copydoc ProgramCache::IsBinarySupported - */ - virtual bool IsBinarySupported(); - - /** - * @copydoc ProgramCache::ProgramBinaryFormat - */ - virtual GLenum ProgramBinaryFormat(); - - /** - * @copydoc ProgramCache::StoreBinary - */ - virtual void StoreBinary( Internal::ShaderDataPtr programData ); - -private: // not implemented as non-copyable - - ProgramController( const ProgramController& rhs ); - ProgramController& operator=( const ProgramController& rhs ); - -private: // Data - - ShaderSaver* mShaderSaver; - Integration::GlAbstraction& mGlAbstraction; - Program* mCurrentProgram; - - typedef OwnerContainer< ProgramPair* > ProgramContainer; - typedef ProgramContainer::Iterator ProgramIterator; - ProgramContainer mProgramCache; - - GLint mProgramBinaryFormat; - GLint mNumberOfProgramBinaryFormats; - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_PROGRAM_CONTROLLER_H__ - diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp deleted file mode 100644 index 451de0b..0000000 --- a/dali/internal/render/shaders/program.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace -{ -void LogWithLineNumbers( const char * source ) -{ - unsigned int lineNumber = 0u; - const char *prev = source; - const char *ptr = prev; - - while( true ) - { - if(lineNumber > 200u) - { - break; - } - // seek the next end of line or end of text - while( *ptr!='\n' && *ptr != '\0' ) - { - ++ptr; - } - - std::string line( prev, ptr-prev ); - Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%4d %s\n", lineNumber, line.c_str()); - - if( *ptr == '\0' ) - { - break; - } - prev = ++ptr; - ++lineNumber; - } -} - -} //namespace - -namespace Dali -{ - -namespace Internal -{ - -// LOCAL STUFF -namespace -{ - -const char* gStdAttribs[ Program::ATTRIB_TYPE_LAST ] = -{ - "aPosition", // ATTRIB_POSITION - "aTexCoord", // ATTRIB_TEXCOORD -}; - -const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] = -{ - "uMvpMatrix", // UNIFORM_MVP_MATRIX - "uModelView", // UNIFORM_MODELVIEW_MATRIX - "uProjection", // UNIFORM_PROJECTION_MATRIX - "uModelMatrix", // UNIFORM_MODEL_MATRIX, - "uViewMatrix", // UNIFORM_VIEW_MATRIX, - "uNormalMatrix", // UNIFORM_NORMAL_MATRIX - "uColor", // UNIFORM_COLOR - "sTexture", // UNIFORM_SAMPLER - "sTextureRect", // UNIFORM_SAMPLER_RECT - "sEffect", // UNIFORM_EFFECT_SAMPLER - "uSize" // UNIFORM_SIZE -}; - -} // namespace - -// IMPLEMENTATION - -Program* Program::New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) -{ - size_t shaderHash = shaderData->GetHashValue(); - Program* program = cache.GetProgram( shaderHash ); - - if( NULL == program ) - { - // program not found so create it - program = new Program( cache, shaderData, modifiesGeometry ); - program->Load(); - cache.AddProgram( shaderHash, program ); - } - - return program; -} - -void Program::Use() -{ - if ( mLinked ) - { - if ( this != mCache.GetCurrentProgram() ) - { - LOG_GL( "UseProgram(%d)\n", mProgramId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(mProgramId) ); - - mCache.SetCurrentProgram( this ); - } - } -} - -bool Program::IsUsed() -{ - return ( this == mCache.GetCurrentProgram() ); -} - -GLint Program::GetAttribLocation( AttribType type ) -{ - DALI_ASSERT_DEBUG(type != ATTRIB_UNKNOWN); - - return GetCustomAttributeLocation( type ); -} - -unsigned int Program::RegisterCustomAttribute( const std::string& name ) -{ - unsigned int index = 0; - // find the value from cache - for( ;index < mAttributeLocations.size(); ++index ) - { - if( mAttributeLocations[ index ].first == name ) - { - // name found so return index - return index; - } - } - // if we get here, index is one past end so push back the new name - mAttributeLocations.push_back( std::make_pair( name, ATTRIB_UNKNOWN ) ); - return index; -} - -GLint Program::GetCustomAttributeLocation( unsigned int attributeIndex ) -{ - // debug check that index is within name cache - DALI_ASSERT_DEBUG( mAttributeLocations.size() > attributeIndex ); - - // check if we have already queried the location of the attribute - GLint location = mAttributeLocations[ attributeIndex ].second; - - if( location == ATTRIB_UNKNOWN ) - { - location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, mAttributeLocations[ attributeIndex ].first.c_str() ) ); - - mAttributeLocations[ attributeIndex ].second = location; - LOG_GL( "GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[ attributeIndex ].first.c_str(), mAttributeLocations[ attributeIndex ].second ); - } - - return location; -} - - -unsigned int Program::RegisterUniform( const std::string& name ) -{ - unsigned int index = 0; - // find the value from cache - for( ;index < mUniformLocations.size(); ++index ) - { - if( mUniformLocations[ index ].first == name ) - { - // name found so return index - return index; - } - } - // if we get here, index is one past end so push back the new name - mUniformLocations.push_back( std::make_pair( name, UNIFORM_NOT_QUERIED ) ); - return index; -} - -GLint Program::GetUniformLocation( unsigned int uniformIndex ) -{ - // debug check that index is within name cache - DALI_ASSERT_DEBUG( mUniformLocations.size() > uniformIndex ); - - // check if we have already queried the location of the uniform - GLint location = mUniformLocations[ uniformIndex ].second; - - if( location == UNIFORM_NOT_QUERIED ) - { - location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetUniformLocation( mProgramId, mUniformLocations[ uniformIndex ].first.c_str() ) ); - - mUniformLocations[ uniformIndex ].second = location; - LOG_GL( "GetUniformLocation(program=%d,%s) = %d\n", mProgramId, mUniformLocations[ uniformIndex ].first.c_str(), mUniformLocations[ uniformIndex ].second ); - } - - return location; -} - -namespace -{ -/** - * This struct is used to record the position of a uniform declaration - * within the fragment shader source code. - */ -struct LocationPosition -{ - GLint uniformLocation; ///< The location of the uniform (used as an identifier) - int position; ///< the position of the uniform declaration - LocationPosition( GLint uniformLocation, int position ) - : uniformLocation(uniformLocation), position(position) - { - } -}; - -bool sortByPosition( LocationPosition a, LocationPosition b ) -{ - return a.position < b.position; -} -} - -void Program::GetActiveSamplerUniforms() -{ - GLint numberOfActiveUniforms = -1; - GLint uniformMaxNameLength=-1; - - mGlAbstraction.GetProgramiv( mProgramId, GL_ACTIVE_UNIFORMS, &numberOfActiveUniforms ); - mGlAbstraction.GetProgramiv( mProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformMaxNameLength ); - - std::vector samplerNames; - char name[uniformMaxNameLength+1]; // Allow for null terminator - std::vector< LocationPosition > samplerUniformLocations; - - { - int nameLength = -1; - int number = -1; - GLenum type = GL_ZERO; - - for( int i=0; i( i ), uniformMaxNameLength, - &nameLength, &number, &type, name ); - - if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES ) - { - GLuint location = mGlAbstraction.GetUniformLocation( mProgramId, name ); - samplerNames.push_back(name); - samplerUniformLocations.push_back(LocationPosition(location, -1)); - } - } - } - - //Determine declaration order of each sampler - char* fragShader = strdup( mProgramData->GetFragmentShader() ); - char* nextPtr = NULL; - const char* token = strtok_r( fragShader, " ;\n", &nextPtr ); - int samplerPosition = 0; - while( token ) - { - if( ( strncmp( token, "sampler2D", 9u ) == 0 ) || - ( strncmp( token, "samplerCube", 11u ) == 0 ) || - ( strncmp( token, "samplerExternalOES", 18u ) == 0 ) ) - { - bool found( false ); - token = strtok_r( NULL, " ;\n", &nextPtr ); - for( size_t i=0; i 1 ) - { - std::sort( samplerUniformLocations.begin(), samplerUniformLocations.end(), sortByPosition); - } - - mSamplerUniformLocations.resize( samplerUniformCount ); - for( size_t i=0; i= MAX_UNIFORM_CACHE_SIZE ) - { - // not cached, make the gl call - LOG_GL( "Uniform1i(%d,%d)\n", location, value0 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1i( location, value0 ) ); - } - else - { - // check if the value is different from what's already been set - if( value0 != mUniformCacheInt[ location ] ) - { - // make the gl call - LOG_GL( "Uniform1i(%d,%d)\n", location, value0 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1i( location, value0 ) ); - // update cache - mUniformCacheInt[ location ] = value0; - } - } -} - -void Program::SetUniform4i( GLint location, GLint value0, GLint value1, GLint value2, GLint value3 ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // Not caching these as based on current analysis this is not called that often by our shaders - LOG_GL( "Uniform4i(%d,%d,%d,%d,%d)\n", location, value0, value1, value2, value3 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4i( location, value0, value1, value2, value3 ) ); -} - -void Program::SetUniform1f( GLint location, GLfloat value0 ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // check if uniform location fits the cache - if( location >= MAX_UNIFORM_CACHE_SIZE ) - { - // not cached, make the gl call - LOG_GL( "Uniform1f(%d,%f)\n", location, value0 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1f( location, value0 ) ); - } - else - { - // check if the same value has already been set, reset if it is different - if( ( fabsf(value0 - mUniformCacheFloat[ location ]) >= Math::MACHINE_EPSILON_1 ) ) - { - // make the gl call - LOG_GL( "Uniform1f(%d,%f)\n", location, value0 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1f( location, value0 ) ); - - // update cache - mUniformCacheFloat[ location ] = value0; - } - } -} - -void Program::SetUniform2f( GLint location, GLfloat value0, GLfloat value1 ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // check if uniform location fits the cache - if( location >= MAX_UNIFORM_CACHE_SIZE ) - { - // not cached, make the gl call - LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) ); - } - else - { - // check if the same value has already been set, reset if it is different - if( ( fabsf(value0 - mUniformCacheFloat2[ location ][ 0 ]) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value1 - mUniformCacheFloat2[ location ][ 1 ]) >= Math::MACHINE_EPSILON_1 ) ) - { - // make the gl call - LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) ); - - // update cache - mUniformCacheFloat2[ location ][ 0 ] = value0; - mUniformCacheFloat2[ location ][ 1 ] = value1; - } - } -} - -void Program::SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 ) -{ - if( ( fabsf(value0 - mSizeUniformCache.x) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value1 - mSizeUniformCache.y) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value2 - mSizeUniformCache.z) >= Math::MACHINE_EPSILON_1 ) ) - { - mSizeUniformCache.x = value0; - mSizeUniformCache.y = value1; - mSizeUniformCache.z = value2; - SetUniform3f( location, value0, value1, value2 ); - } -} - -void Program::SetUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // Not caching these as based on current analysis this is not called that often by our shaders - LOG_GL( "Uniform3f(%d,%f,%f,%f)\n", location, value0, value1, value2 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform3f( location, value0, value1, value2 ) ); -} - -void Program::SetUniform4f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3 ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // check if uniform location fits the cache - if( location >= MAX_UNIFORM_CACHE_SIZE ) - { - // not cached, make the gl call - LOG_GL( "Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4f( location, value0, value1, value2, value3 ) ); - } - else - { - // check if the same value has already been set, reset if any component is different - // checking index 3 first because we're often animating alpha (rgba) - if( ( fabsf(value3 - mUniformCacheFloat4[ location ][ 3 ]) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value0 - mUniformCacheFloat4[ location ][ 0 ]) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value1 - mUniformCacheFloat4[ location ][ 1 ]) >= Math::MACHINE_EPSILON_1 )|| - ( fabsf(value2 - mUniformCacheFloat4[ location ][ 2 ]) >= Math::MACHINE_EPSILON_1 ) ) - { - // make the gl call - LOG_GL( "Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3 ); - CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4f( location, value0, value1, value2, value3 ) ); - // update cache - mUniformCacheFloat4[ location ][ 0 ] = value0; - mUniformCacheFloat4[ location ][ 1 ] = value1; - mUniformCacheFloat4[ location ][ 2 ] = value2; - mUniformCacheFloat4[ location ][ 3 ] = value3; - } - } -} - -void Program::SetUniformMatrix4fv( GLint location, GLsizei count, const GLfloat* value ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - // Not caching these calls. Based on current analysis this is called very often - // but with different values (we're using this for MVP matrices) - // NOTE! we never want driver or GPU to transpose - LOG_GL( "UniformMatrix4fv(%d,%d,GL_FALSE,%x)\n", location, count, value ); - CHECK_GL( mGlAbstraction, mGlAbstraction.UniformMatrix4fv( location, count, GL_FALSE, value ) ); -} - -void Program::SetUniformMatrix3fv( GLint location, GLsizei count, const GLfloat* value ) -{ - DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used - - if( UNIFORM_UNKNOWN == location ) - { - // From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes - // If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the - // specified uniform variable will not be changed.following opengl silently do nothing - return; - } - - - // Not caching these calls. Based on current analysis this is called very often - // but with different values (we're using this for MVP matrices) - // NOTE! we never want driver or GPU to transpose - LOG_GL( "UniformMatrix3fv(%d,%d,GL_FALSE,%x)\n", location, count, value ); - CHECK_GL( mGlAbstraction, mGlAbstraction.UniformMatrix3fv( location, count, GL_FALSE, value ) ); -} - -void Program::GlContextCreated() -{ -} - -void Program::GlContextDestroyed() -{ - mLinked = false; - mVertexShaderId = 0; - mFragmentShaderId = 0; - mProgramId = 0; - - ResetAttribsUniformCache(); -} - -bool Program::ModifiesGeometry() -{ - return mModifiesGeometry; -} - -Program::Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) -: mCache( cache ), - mGlAbstraction( mCache.GetGlAbstraction() ), - mProjectionMatrix( NULL ), - mViewMatrix( NULL ), - mLinked( false ), - mVertexShaderId( 0 ), - mFragmentShaderId( 0 ), - mProgramId( 0 ), - mProgramData(shaderData), - mModifiesGeometry( modifiesGeometry ) -{ - // reserve space for standard attributes - mAttributeLocations.reserve( ATTRIB_TYPE_LAST ); - for( int i=0; iHasBinary() ) - { - DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - Using Compiled Shader, Size = %d\n", mProgramData->GetBufferSize()); - - CHECK_GL( mGlAbstraction, mGlAbstraction.ProgramBinary(mProgramId, mCache.ProgramBinaryFormat(), mProgramData->GetBufferData(), mProgramData->GetBufferSize()) ); - - CHECK_GL( mGlAbstraction, mGlAbstraction.ValidateProgram(mProgramId) ); - - GLint success; - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_VALIDATE_STATUS, &success ) ); - - DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "ValidateProgram Status = %d\n", success); - - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_LINK_STATUS, &linked ) ); - - if( GL_FALSE == linked ) - { - DALI_LOG_ERROR("Failed to load program binary \n"); - - GLint nLength; - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_INFO_LOG_LENGTH, &nLength) ); - if(nLength > 0) - { - Dali::Vector< char > szLog; - szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramInfoLog( mProgramId, nLength, &nLength, szLog.Begin() ) ); - DALI_LOG_ERROR( "Program Link Error: %s\n", szLog.Begin() ); - } - } - else - { - mLinked = true; - DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Reused binary.\n" ); - } - } - - // Fall back to compiling and linking the vertex and fragment sources - if( GL_FALSE == linked ) - { - DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - Runtime compilation\n"); - if( CompileShader( GL_VERTEX_SHADER, mVertexShaderId, mProgramData->GetVertexShader() ) ) - { - if( CompileShader( GL_FRAGMENT_SHADER, mFragmentShaderId, mProgramData->GetFragmentShader() ) ) - { - Link(); - - if( binariesSupported && mLinked ) - { - GLint binaryLength = 0; - GLenum binaryFormat; - DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Compiled and linked.\n\nVS:\n%s\nFS:\n%s\n", mProgramData->GetVertexShader(), mProgramData->GetFragmentShader() ); - - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength) ); - DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - GL_PROGRAM_BINARY_LENGTH_OES: %d\n", binaryLength); - if( binaryLength > 0 ) - { - // Allocate space for the bytecode in ShaderData - mProgramData->AllocateBuffer(binaryLength); - // Copy the bytecode to ShaderData - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramBinary(mProgramId, binaryLength, NULL, &binaryFormat, mProgramData->GetBufferData()) ); - mCache.StoreBinary( mProgramData ); - DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Saved binary.\n" ); - } - } - } - } - } - - GetActiveSamplerUniforms(); - - // No longer needed - FreeShaders(); -} - -void Program::Unload() -{ - FreeShaders(); - - if( this == mCache.GetCurrentProgram() ) - { - CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(0) ); - - mCache.SetCurrentProgram( NULL ); - } - - if (mProgramId) - { - LOG_GL( "DeleteProgram(%d)\n", mProgramId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteProgram( mProgramId ) ); - mProgramId = 0; - } - - mLinked = false; - -} - -bool Program::CompileShader( GLenum shaderType, GLuint& shaderId, const char* src ) -{ - if (!shaderId) - { - LOG_GL( "CreateShader(%d)\n", shaderType ); - shaderId = CHECK_GL( mGlAbstraction, mGlAbstraction.CreateShader( shaderType ) ); - LOG_GL( "AttachShader(%d,%d)\n", mProgramId, shaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.AttachShader( mProgramId, shaderId ) ); - } - - LOG_GL( "ShaderSource(%d)\n", shaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.ShaderSource(shaderId, 1, &src, NULL ) ); - - LOG_GL( "CompileShader(%d)\n", shaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.CompileShader( shaderId ) ); - - GLint compiled; - LOG_GL( "GetShaderiv(%d)\n", shaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.GetShaderiv( shaderId, GL_COMPILE_STATUS, &compiled ) ); - - if (compiled == GL_FALSE) - { - DALI_LOG_ERROR("Failed to compile shader\n"); - LogWithLineNumbers(src); - - GLint nLength; - mGlAbstraction.GetShaderiv( shaderId, GL_INFO_LOG_LENGTH, &nLength); - if(nLength > 0) - { - Dali::Vector< char > szLog; - szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer - mGlAbstraction.GetShaderInfoLog( shaderId, nLength, &nLength, szLog.Begin() ); - DALI_LOG_ERROR( "Shader Compiler Error: %s\n", szLog.Begin() ); - } - - DALI_ASSERT_ALWAYS( 0 && "Shader compilation failure" ); - } - - return compiled != 0; -} - -void Program::Link() -{ - LOG_GL( "LinkProgram(%d)\n", mProgramId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.LinkProgram( mProgramId ) ); - - GLint linked; - LOG_GL( "GetProgramiv(%d)\n", mProgramId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_LINK_STATUS, &linked ) ); - - if (linked == GL_FALSE) - { - DALI_LOG_ERROR("Shader failed to link \n"); - - GLint nLength; - mGlAbstraction.GetProgramiv( mProgramId, GL_INFO_LOG_LENGTH, &nLength); - if(nLength > 0) - { - Dali::Vector< char > szLog; - szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer - mGlAbstraction.GetProgramInfoLog( mProgramId, nLength, &nLength, szLog.Begin() ); - DALI_LOG_ERROR( "Shader Link Error: %s\n", szLog.Begin() ); - } - - DALI_ASSERT_ALWAYS( 0 && "Shader linking failure" ); - } - - mLinked = linked != GL_FALSE; -} - -void Program::FreeShaders() -{ - if (mVertexShaderId) - { - LOG_GL( "DeleteShader(%d)\n", mVertexShaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.DetachShader( mProgramId, mVertexShaderId ) ); - CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteShader( mVertexShaderId ) ); - mVertexShaderId = 0; - } - - if (mFragmentShaderId) - { - LOG_GL( "DeleteShader(%d)\n", mFragmentShaderId ); - CHECK_GL( mGlAbstraction, mGlAbstraction.DetachShader( mProgramId, mFragmentShaderId ) ); - CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteShader( mFragmentShaderId ) ); - mFragmentShaderId = 0; - } -} - -void Program::ResetAttribsUniformCache() -{ - // reset attribute locations - for( unsigned i = 0; i < mAttributeLocations.size() ; ++i ) - { - mAttributeLocations[ i ].second = ATTRIB_UNKNOWN; - } - - // reset all gl uniform locations - for( unsigned int i = 0; i < mUniformLocations.size(); ++i ) - { - // reset gl program locations and names - mUniformLocations[ i ].second = UNIFORM_NOT_QUERIED; - } - - mSamplerUniformLocations.clear(); - - // reset uniform caches - mSizeUniformCache.x = mSizeUniformCache.y = mSizeUniformCache.z = 0.f; - - for( int i = 0; i < MAX_UNIFORM_CACHE_SIZE; ++i ) - { - // GL initializes uniforms to 0 - mUniformCacheInt[ i ] = 0; - mUniformCacheFloat[ i ] = 0.0f; - mUniformCacheFloat2[ i ][ 0 ] = 0.0f; - mUniformCacheFloat2[ i ][ 1 ] = 0.0f; - mUniformCacheFloat4[ i ][ 0 ] = 0.0f; - mUniformCacheFloat4[ i ][ 1 ] = 0.0f; - mUniformCacheFloat4[ i ][ 2 ] = 0.0f; - mUniformCacheFloat4[ i ][ 3 ] = 0.0f; - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/shaders/program.h b/dali/internal/render/shaders/program.h deleted file mode 100644 index 0d5f416..0000000 --- a/dali/internal/render/shaders/program.h +++ /dev/null @@ -1,399 +0,0 @@ -#ifndef __DALI_INTERNAL_PROGRAM_H__ -#define __DALI_INTERNAL_PROGRAM_H__ - -/* - * Copyright (c) 2016 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. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -class Matrix; - -namespace Integration -{ -class GlAbstraction; -class ShaderData; -} - -namespace Internal -{ - -class ProgramCache; - -/* - * A program contains a vertex & fragment shader. - * - * A program will contain vertex attributes and uniform variables. - * - * uColor is set to the value specified by Actor::SetColor and is - * animatable through the property Actor::COLOR - */ -class Program -{ -public: - - /** - * Size of the uniform cache per program - * GLES specification states that minimum uniform count for fragment shader - * is 16 and for vertex shader 128. We're caching the 16 common ones for now - */ - static const int MAX_UNIFORM_CACHE_SIZE = 16; - - /** - * Constant for uniform / attribute not found - */ - static const int NOT_FOUND = -1; - - /** - * Vertex attributes - */ - enum AttribType - { - ATTRIB_UNKNOWN = -1, - ATTRIB_POSITION, - ATTRIB_TEXCOORD, - ATTRIB_TYPE_LAST - }; - - /** - * Common shader uniform names - */ - enum UniformType - { - UNIFORM_NOT_QUERIED = -2, - UNIFORM_UNKNOWN = -1, - UNIFORM_MVP_MATRIX, - UNIFORM_MODELVIEW_MATRIX, - UNIFORM_PROJECTION_MATRIX, - UNIFORM_MODEL_MATRIX, - UNIFORM_VIEW_MATRIX, - UNIFORM_NORMAL_MATRIX, - UNIFORM_COLOR, - UNIFORM_SAMPLER, - UNIFORM_SAMPLER_RECT, - UNIFORM_EFFECT_SAMPLER, - - UNIFORM_SIZE, - UNIFORM_TYPE_LAST - }; - - /** - * Creates a new program, or returns a copy of an existing program in the program cache - * @param[in] cache where the programs are stored - * @param[in] shaderData A pointer to a data structure containing the program source - * and optionally precompiled binary. If the binary is empty the program bytecode - * is copied into it after compilation and linking) - * @param[in] modifiesGeometry True if the shader modifies geometry - * @return pointer to the program - */ - static Program* New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); - - /** - * Takes this program into use - */ - void Use(); - - /** - * @return true if this program is used currently - */ - bool IsUsed(); - - /** - * @param [in] type of the attribute - * @return the index of the attribute - */ - GLint GetAttribLocation( AttribType type ); - - /** - * Register an attribute name in our local cache - * @param [in] name attribute name - * @return the index of the attribute name in local cache - */ - unsigned int RegisterCustomAttribute( const std::string& name ); - - /** - * Gets the location of a pre-registered attribute. - * @param [in] attributeIndex of the attribute in local cache - * @return the index of the attribute in the GL program - */ - GLint GetCustomAttributeLocation( unsigned int attributeIndex ); - - /** - * Register a uniform name in our local cache - * @param [in] name uniform name - * @return the index of the uniform name in local cache - */ - unsigned int RegisterUniform( const std::string& name ); - - /** - * Gets the location of a pre-registered uniform. - * Uniforms in list UniformType are always registered and in the order of the enumeration - * @param [in] uniformIndex of the uniform in local cache - * @return the index of the uniform in the GL program - */ - GLint GetUniformLocation( unsigned int uniformIndex ); - - /** - * Introspect the newly loaded shader to get the active sampler locations - */ - void GetActiveSamplerUniforms(); - - /** - * Gets the uniform location for a sampler - * @param [in] index The index of the active sampler - * @param [out] location The location of the requested sampler - * @return true if the active sampler was found - */ - bool GetSamplerUniformLocation( unsigned int index, GLint& location ); - - /** - * Get the number of active samplers present in the shader - * @return The number of active samplers - */ - size_t GetActiveSamplerCount() const; - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as int - */ - void SetUniform1i( GLint location, GLint value0 ); - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as int - * @param [in] value1 as int - * @param [in] value2 as int - * @param [in] value3 as int - */ - void SetUniform4i( GLint location, GLint value0, GLint value1, GLint value2, GLint value3 ); - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as float - */ - void SetUniform1f( GLint location, GLfloat value0 ); - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as float - * @param [in] value1 as float - */ - void SetUniform2f( GLint location, GLfloat value0, GLfloat value1 ); - - /** - * Special handling for size as we're using uniform geometry so size is passed on to most programs - * but it rarely changes so we can cache it - * @param [in] location of uniform - * @param [in] value0 as float - * @param [in] value1 as float - * @param [in] value2 as float - */ - void SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 ); - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as float - * @param [in] value1 as float - * @param [in] value2 as float - */ - void SetUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 ); - - /** - * Sets the uniform value - * @param [in] location of uniform - * @param [in] value0 as float - * @param [in] value1 as float - * @param [in] value2 as float - * @param [in] value3 as float - */ - void SetUniform4f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3 ); - - /** - * Sets the uniform value as matrix. NOTE! we never want GPU to transpose - * so make sure your matrix is in correct order for GL. - * @param [in] location Location of uniform - * @param [in] count Count of matrices - * @param [in] value values as float pointers - */ - void SetUniformMatrix4fv( GLint location, GLsizei count, const GLfloat* value ); - - /** - * Sets the uniform value as matrix. NOTE! we never want GPU to transpose - * so make sure your matrix is in correct order for GL. - * @param [in] location Location of uniform - * @param [in] count Count of matrices - * @param [in] value values as float pointers - */ - void SetUniformMatrix3fv( GLint location, GLsizei count, const GLfloat* value ); - - /** - * 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(); - - /** - * Set the projection matrix that has currently been sent - * @param matrix to set - */ - void SetProjectionMatrix( const Matrix* matrix ) - { - mProjectionMatrix = matrix; - } - - /** - * Get the projection matrix that has currently been sent - * @return the matrix that is set - */ - const Matrix* GetProjectionMatrix() - { - return mProjectionMatrix; - } - - /** - * Set the projection matrix that has currently been sent - * @param matrix to set - */ - void SetViewMatrix( const Matrix* matrix ) - { - mViewMatrix = matrix; - } - - /** - * Get the projection matrix that has currently been sent - * @return the matrix that is set - */ - const Matrix* GetViewMatrix() - { - return mViewMatrix; - } - -private: // Implementation - - /** - * Constructor, private so no direct instantiation - * @param[in] cache where the programs are stored - * @param[in] shaderData A smart pointer to a data structure containing the program source and binary - * @param[in] modifiesGeometry True if the vertex shader changes geometry - */ - Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); - -public: - - /** - * Destructor, non virtual as no virtual methods or inheritance - */ - ~Program(); - -private: - - Program(); ///< default constructor, not defined - Program( const Program& ); ///< copy constructor, not defined - Program& operator=( const Program& ); ///< assignment operator, not defined - - /** - * Load the shader, from a precompiled binary if available, else from source code - */ - void Load(); - - /** - * Unload the shader - */ - void Unload(); - - /** - * Compile the shader - * @param shaderType vertex or fragment shader - * @param shaderId of the shader, returned - * @param src of the shader - * @return true if the compilation succeeded - */ - bool CompileShader(GLenum shaderType, GLuint& shaderId, const char* src); - - /** - * Links the shaders together to create program - */ - void Link(); - - /** - * Frees the shader programs - */ - void FreeShaders(); - - /** - * Resets caches - */ - void ResetAttribsUniformCache(); - -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 - bool mLinked; ///< whether the program is linked - GLuint mVertexShaderId; ///< GL identifier for vertex shader - GLuint mFragmentShaderId; ///< GL identifier for fragment shader - GLuint mProgramId; ///< GL identifier for program - Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded) - - // location caches - typedef std::pair< std::string, GLint > NameLocationPair; - typedef std::vector< NameLocationPair > Locations; - - Locations mAttributeLocations; ///< attribute location cache - Locations mUniformLocations; ///< uniform location cache - std::vector mSamplerUniformLocations; ///< sampler uniform location cache - - // uniform value caching - GLint mUniformCacheInt[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single int - GLfloat mUniformCacheFloat[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single float - GLfloat mUniformCacheFloat2[ MAX_UNIFORM_CACHE_SIZE ][2]; ///< Value cache for uniforms of two floats - GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four floats - Vector3 mSizeUniformCache; ///< Cache value for size uniform - bool mModifiesGeometry; ///< True if the program changes geometry - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_PROGRAM_H__ diff --git a/dali/internal/render/shaders/scene-graph-shader.cpp b/dali/internal/render/shaders/scene-graph-shader.cpp deleted file mode 100644 index 00a28e9..0000000 --- a/dali/internal/render/shaders/scene-graph-shader.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include - - -namespace Dali -{ - -namespace Internal -{ - -namespace SceneGraph -{ - -Shader::Shader( Dali::Shader::Hint::Value& hints ) -: mHints( hints ), - mProgram( NULL ), - mConnectionObservers(), - mGfxShader( nullptr ) -{ - AddUniformMapObserver( *this ); -} - -Shader::~Shader() -{ - mConnectionObservers.Destroy( *this ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// The following methods are called during RenderManager::Render() -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Shader::SetProgram( Internal::ShaderDataPtr shaderData, - ProgramCache* programCache, - bool modifiesGeometry ) -{ - DALI_LOG_TRACE_METHOD_FMT( Debug::Filter::gShader, "%d\n", shaderData->GetHashValue() ); - - mProgram = Program::New( *programCache, shaderData, modifiesGeometry ); - // The program cache owns the Program object so we don't need to worry about this raw allocation here. - - mConnectionObservers.ConnectionsChanged(*this); -} - -void Shader::SetGfxObject( const Graphics::API::Accessor& shader ) -{ - mGfxShader = shader; -} - -Graphics::API::Accessor& Shader::GetGfxObject() -{ - return mGfxShader; -} - -Program* Shader::GetProgram() -{ - return mProgram; -} - -void Shader::AddConnectionObserver( ConnectionChangePropagator::Observer& observer ) -{ - mConnectionObservers.Add(observer); -} - -void Shader::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer ) -{ - mConnectionObservers.Remove(observer); -} - -void Shader::UniformMappingsChanged( const UniformMap& mappings ) -{ - // Our uniform map, or that of one of the watched children has changed. - // Inform connected observers. - mConnectionObservers.ConnectedUniformMapChanged(); -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index 260be92..9fb18e3 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace //Unnamed namespace { diff --git a/dali/internal/update/animation/scene-graph-constraint.h b/dali/internal/update/animation/scene-graph-constraint.h index 6e47cac..406883c 100644 --- a/dali/internal/update/animation/scene-graph-constraint.h +++ b/dali/internal/update/animation/scene-graph-constraint.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace Dali { diff --git a/dali/internal/update/common/discard-queue.cpp b/dali/internal/update/common/discard-queue.cpp index 3a0f5b6..ee81a6a 100644 --- a/dali/internal/update/common/discard-queue.cpp +++ b/dali/internal/update/common/discard-queue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,12 +19,9 @@ #include // INTERNAL INCLUDES -#include #include #include -#include -#include -#include +#include #include namespace Dali @@ -36,9 +33,8 @@ namespace Internal namespace SceneGraph { -DiscardQueue::DiscardQueue( RenderQueue& renderQueue ) -: mRenderQueue( renderQueue ), - mNodeQueue(), +DiscardQueue::DiscardQueue() +: mNodeQueue(), mShaderQueue(), mRendererQueue(), mCameraQueue() diff --git a/dali/internal/update/common/discard-queue.h b/dali/internal/update/common/discard-queue.h index e71fe61..b0ef581 100644 --- a/dali/internal/update/common/discard-queue.h +++ b/dali/internal/update/common/discard-queue.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_DISCARD_QUEUE_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -35,7 +35,6 @@ namespace Internal namespace SceneGraph { -class RenderQueue; class Shader; class Camera; @@ -57,9 +56,8 @@ public: /** * Create a new DiscardQueue. - * @param[in] renderQueue Used to send GL clean-up messages for the next Render. */ - DiscardQueue( RenderQueue& renderQueue ); + DiscardQueue(); /** * Non-virtual destructor; DiscardQueue is not suitable as a base class. @@ -117,7 +115,7 @@ private: private: - RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render. + //RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render. // Messages are queued here following the current update buffer number OwnerContainer< Node* > mNodeQueue[2]; diff --git a/dali/internal/update/controllers/render-message-dispatcher.cpp b/dali/internal/update/controllers/render-message-dispatcher.cpp deleted file mode 100644 index 4b5040d..0000000 --- a/dali/internal/update/controllers/render-message-dispatcher.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2017 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace SceneGraph -{ - -RenderMessageDispatcher::RenderMessageDispatcher( RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers ) -: mRenderManager( renderManager ), - mRenderQueue( renderQueue ), - mBuffers( buffers ) -{ -} - -RenderMessageDispatcher::~RenderMessageDispatcher() -{ -} - -void RenderMessageDispatcher::AddRenderer( OwnerPointer< Render::Renderer >& renderer ) -{ - // Message has ownership of renderer while in transit from update -> render - typedef MessageValue1< RenderManager, OwnerPointer< Render::Renderer > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderer, renderer ); -} - -void RenderMessageDispatcher::RemoveRenderer( Render::Renderer& renderer ) -{ - typedef MessageValue1< RenderManager, Render::Renderer* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mRenderManager, &RenderManager::RemoveRenderer, &renderer ); -} - -void RenderMessageDispatcher::AddRenderTracker( Render::RenderTracker& renderTracker ) -{ - typedef MessageValue1< RenderManager, Render::RenderTracker* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderTracker, &renderTracker ); -} - -void RenderMessageDispatcher::RemoveRenderTracker( Render::RenderTracker& renderTracker ) -{ - typedef MessageValue1< RenderManager, Render::RenderTracker* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mRenderManager, &RenderManager::RemoveRenderTracker, &renderTracker ); -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/update/controllers/render-message-dispatcher.h b/dali/internal/update/controllers/render-message-dispatcher.h deleted file mode 100644 index 9fd218b..0000000 --- a/dali/internal/update/controllers/render-message-dispatcher.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_MESSAGE_DISPATCHER_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MESSAGE_DISPATCHER_H__ - -/* - * Copyright (c) 2017 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 - -namespace Dali -{ - -namespace Internal -{ -class MessageBase; - -namespace Render -{ -class RenderTracker; -} -namespace SceneGraph -{ - -class RenderManager; -class RenderQueue; -class PropertyBufferDataProvider; -/** - * A utility class for sending messages to the render-thread. - */ -class RenderMessageDispatcher -{ -public: - - /** - * Constructor - */ - RenderMessageDispatcher( RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers ); - - /** - * Destructor - */ - virtual ~RenderMessageDispatcher(); - - /** - * Add a Renderer. - * @param[in] renderer The renderer to add. - * @post renderer ownership is transferred. - */ - void AddRenderer( OwnerPointer< Render::Renderer >& renderer ); - - /** - * Remove a Renderer. - * @param[in] renderer The renderer to remove. - * @post renderer will be destroyed in the next Render. - */ - void RemoveRenderer( Render::Renderer& renderer ); - - /** - * Add a Render tracker. - * @param[in] renderTracker The render tracker to add. - * @post ownership is transferred - */ - void AddRenderTracker( Render::RenderTracker& renderTracker ); - - /** - * Remove a Render tracker. - * @param[in] renderTracker The render tracker to add. - * @post render tracker will be destroyed in the next Render pass. - */ - void RemoveRenderTracker( Render::RenderTracker& renderTracker ); - -private: - - RenderManager& mRenderManager; - RenderQueue& mRenderQueue; - - const SceneGraphBuffers& mBuffers; -}; - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDERER_DISPATCHER_H__ diff --git a/dali/internal/update/controllers/scene-controller-impl.cpp b/dali/internal/update/controllers/scene-controller-impl.cpp index 718f966..bab9a5f 100644 --- a/dali/internal/update/controllers/scene-controller-impl.cpp +++ b/dali/internal/update/controllers/scene-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -29,12 +29,8 @@ namespace Internal namespace SceneGraph { -SceneControllerImpl::SceneControllerImpl( RenderMessageDispatcher& renderMessageDispatcher, - RenderQueue& renderQueue, - DiscardQueue& discardQueue ) -: mRenderMessageDispatcher( renderMessageDispatcher ), - mRenderQueue( renderQueue ), - mDiscardQueue( discardQueue ) +SceneControllerImpl::SceneControllerImpl( DiscardQueue& discardQueue ) +: mDiscardQueue( discardQueue ) { } diff --git a/dali/internal/update/controllers/scene-controller-impl.h b/dali/internal/update/controllers/scene-controller-impl.h index acef137..20f88e7 100644 --- a/dali/internal/update/controllers/scene-controller-impl.h +++ b/dali/internal/update/controllers/scene-controller-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_IMPL_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -40,13 +40,9 @@ public: /** * Constructor - * @param[in] rendererDispatcher Used for passing ownership of renderers to the render-thread. - * @param[in] renderQueue The renderQueue * @param[in] discardQueue The discardQueue */ - SceneControllerImpl( RenderMessageDispatcher& renderMessageDispatcher, - RenderQueue& renderQueue, - DiscardQueue& discardQueue ); + SceneControllerImpl( DiscardQueue& discardQueue ); /** * Destructor @@ -56,32 +52,15 @@ public: public: // from SceneController /** - * @copydoc SceneController::GetRenderMessageDispatcher() - */ - virtual RenderMessageDispatcher& GetRenderMessageDispatcher() { return mRenderMessageDispatcher; } - - /** - * @copydoc SceneController::GetRenderQueue() - */ - virtual RenderQueue& GetRenderQueue() { return mRenderQueue; } - - /** * @copydoc SceneController::GetDiscardQueue() */ virtual DiscardQueue& GetDiscardQueue() { return mDiscardQueue; } private: - - // Undefined copy constructor. - SceneControllerImpl( const SceneControllerImpl& ); - - // Undefined assignment operator. - SceneControllerImpl& operator=( const SceneControllerImpl& ); + SceneControllerImpl( const SceneControllerImpl& ) = delete; + SceneControllerImpl& operator=( const SceneControllerImpl& ) = delete; private: - - RenderMessageDispatcher& mRenderMessageDispatcher; ///< Used for passing messages to the render-thread - RenderQueue& mRenderQueue; ///< render queue DiscardQueue& mDiscardQueue; ///< discard queue }; diff --git a/dali/internal/update/controllers/scene-controller.h b/dali/internal/update/controllers/scene-controller.h index f810622..127bf18 100644 --- a/dali/internal/update/controllers/scene-controller.h +++ b/dali/internal/update/controllers/scene-controller.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -27,8 +27,6 @@ namespace Internal namespace SceneGraph { -class RenderMessageDispatcher; -class RenderQueue; class DiscardQueue; /** @@ -53,18 +51,6 @@ public: } /** - * Return the render message dispatcher - * @return A reference to the render message dispatcher - */ - virtual RenderMessageDispatcher& GetRenderMessageDispatcher() = 0; - - /** - * Return the render queue - * @return A reference to the render queue - */ - virtual RenderQueue& GetRenderQueue() = 0; - - /** * Return the discard queue * @return A reference to the discard queue */ diff --git a/dali/internal/update/graphics/graphics-algorithms.cpp b/dali/internal/update/graphics/graphics-algorithms.cpp index d63c823..6ebb9af 100644 --- a/dali/internal/update/graphics/graphics-algorithms.cpp +++ b/dali/internal/update/graphics/graphics-algorithms.cpp @@ -17,22 +17,22 @@ // CLASS HEADER #include -#include -#include -#include -#include -#include -// EXTERNAL INCLUDES +// EXTERNAL INCLUDES +#include #include #include #include - // INTERNAL INCLUDES #include -#include -#include +#include +#include +#include +#include +#include +#include +#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" diff --git a/dali/internal/update/graphics/graphics-algorithms.h b/dali/internal/update/graphics/graphics-algorithms.h index 11cfc4d..cebb9ac 100644 --- a/dali/internal/update/graphics/graphics-algorithms.h +++ b/dali/internal/update/graphics/graphics-algorithms.h @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include #include namespace Dali @@ -39,4 +39,4 @@ void SubmitRenderInstructions( Graphics::API::Controller& graphics, } // namespace Internal } // namespace Dali -#endif // DALI_INTERNAL_GRAPHICS_ALGORITHMS_H \ No newline at end of file +#endif // DALI_INTERNAL_GRAPHICS_ALGORITHMS_H diff --git a/dali/internal/update/manager/node-depths.h b/dali/internal/update/manager/node-depths.h new file mode 100644 index 0000000..d9e74f5 --- /dev/null +++ b/dali/internal/update/manager/node-depths.h @@ -0,0 +1,61 @@ +#ifndef DALI_INTERNAL_UPDATE_MANAGER_NODE_DEPTHS_H +#define DALI_INTERNAL_UPDATE_MANAGER_NODE_DEPTHS_H +/* + * Copyright (c) 2018 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 +{ +namespace SceneGraph +{ +class Node; + +struct NodeDepthPair +{ + SceneGraph::Node* node; + uint32_t sortedDepth; + NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth ) + : node(node), + sortedDepth(sortedDepth) + { + } +}; + +struct NodeDepths +{ + NodeDepths() + { + } + + void Add( SceneGraph::Node* node, uint32_t sortedDepth ) + { + nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) ); + } + + std::vector nodeDepths; +}; + + + +} // namespace SceneGraph + +} // namespace Internal + +} // namespace Dali + + +#endif //DALI_INTERNAL_UPDATE_MANAGER_NODE_DEPTHS_H diff --git a/dali/internal/update/manager/render-instruction-processor.cpp b/dali/internal/update/manager/render-instruction-processor.cpp index e64fb71..c3250a0 100644 --- a/dali/internal/update/manager/render-instruction-processor.cpp +++ b/dali/internal/update/manager/render-instruction-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,13 +25,10 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace @@ -186,13 +183,11 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex, if( DALI_LIKELY( renderable.mRenderer ) ) { - item.mRenderer = &renderable.mRenderer->GetRenderer(); item.mTextureSet = renderable.mRenderer->GetTextures(); item.mDepthIndex += renderable.mRenderer->GetDepthIndex(); } else { - item.mRenderer = nullptr; item.mTextureSet = nullptr; } @@ -261,12 +256,9 @@ inline bool TryReuseCachedRenderers( Layer& layer, // Therefore we check a combined sum of all renderer addresses. size_t checkSumNew = 0; size_t checkSumOld = 0; - for( size_t index = 0; index < renderableCount; ++index ) - { - const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer(); - checkSumNew += size_t( &renderer ); - checkSumOld += size_t( &renderList.GetRenderer( index ) ); - } + + // Used to add all renderers to checksum. + if( checkSumNew == checkSumOld ) { // tell list to reuse its existing items @@ -336,11 +328,6 @@ inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex { RenderItem& item = renderList.GetItem( index ); - if( item.mRenderer ) - { - item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] ); - } - // texture set mSortingHelper[ index ].textureSet = item.mTextureSet; @@ -358,12 +345,9 @@ inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex { RenderItem& item = renderList.GetItem( index ); - item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] ); - // texture set mSortingHelper[ index ].textureSet = item.mTextureSet; - mSortingHelper[ index ].zValue = (*sortFunction)( item.mModelViewMatrix.GetTranslation3() ) - item.mDepthIndex; // Keep the RenderItem pointer in the helper so we can quickly reorder items after sort. @@ -385,7 +369,7 @@ inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex for( unsigned int index = 0; index < renderableCount; ++index, ++renderListIter ) { *renderListIter = mSortingHelper[ index ].renderItem; - DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, " sortedList[%d] = %p\n", index, mSortingHelper[ index ].renderItem->mRenderer); + DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, " sortedList[%d]\n", index ); } } diff --git a/dali/internal/update/manager/render-instruction-processor.h b/dali/internal/update/manager/render-instruction-processor.h index 95cc818..8b84cdc 100644 --- a/dali/internal/update/manager/render-instruction-processor.h +++ b/dali/internal/update/manager/render-instruction-processor.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,25 +25,18 @@ namespace Dali { - namespace Internal { -namespace Render -{ -class Geometry; -} - namespace SceneGraph { - +class Geometry; class RenderTracker; struct RenderItem; -class Shader; struct RenderList; class RenderTask; class RenderInstructionContainer; - +class Shader; /** * @brief This class handles the sorting and preparation of Renderers for each layer. @@ -80,7 +73,7 @@ public: RenderItem* renderItem; ///< The render item that is being sorted (includes depth index) const Shader* shader; ///< The shader instance const void* textureSet; ///< The textureSet instance - const Render::Geometry* geometry; ///< The geometry instance + const SceneGraph::Geometry* geometry; ///< The geometry instance float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value) }; diff --git a/dali/internal/update/manager/render-task-processor.cpp b/dali/internal/update/manager/render-task-processor.cpp index 31422ca..be99faf 100644 --- a/dali/internal/update/manager/render-task-processor.cpp +++ b/dali/internal/update/manager/render-task-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -23,11 +23,10 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #if defined(DEBUG_ENABLED) diff --git a/dali/internal/update/manager/update-algorithms.cpp b/dali/internal/update/manager/update-algorithms.cpp index d7f9759..a4f0049 100644 --- a/dali/internal/update/manager/update-algorithms.cpp +++ b/dali/internal/update/manager/update-algorithms.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -105,7 +104,6 @@ inline void UpdateNodeOpacity( Node& node, int nodeDirtyFlags, BufferIndex updat inline int UpdateNodes( Node& node, int parentFlags, BufferIndex updateBufferIndex, - RenderQueue& renderQueue, Layer& currentLayer, int inheritedDrawMode ) { @@ -169,7 +167,6 @@ inline int UpdateNodes( Node& node, cumulativeDirtyFlags |=UpdateNodes( child, nodeDirtyFlags, updateBufferIndex, - renderQueue, *layer, inheritedDrawMode ); } @@ -181,8 +178,7 @@ inline int UpdateNodes( Node& node, * The root node is treated separately; it cannot inherit values since it has no parent */ int UpdateNodeTree( Layer& rootNode, - BufferIndex updateBufferIndex, - RenderQueue& renderQueue ) + BufferIndex updateBufferIndex ) { DALI_ASSERT_DEBUG( rootNode.IsRoot() ); @@ -217,7 +213,6 @@ int UpdateNodeTree( Layer& rootNode, cumulativeDirtyFlags |= UpdateNodes( child, nodeDirtyFlags, updateBufferIndex, - renderQueue, rootNode, drawMode ); } diff --git a/dali/internal/update/manager/update-algorithms.h b/dali/internal/update/manager/update-algorithms.h index 62f2411..41f95ce 100644 --- a/dali/internal/update/manager/update-algorithms.h +++ b/dali/internal/update/manager/update-algorithms.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_ALGORITHMS_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -33,7 +33,6 @@ namespace SceneGraph class Layer; class Node; class PropertyOwner; -class RenderQueue; /** * Constrain the local properties of the PropertyOwner. @@ -50,9 +49,7 @@ void ConstrainPropertyOwner( PropertyOwner& propertyOwner, BufferIndex updateBuf * @param[in] renderQueue Used to query messages for the next Render. * @return The cumulative (ORed) dirty flags for the updated nodes */ -int UpdateNodeTree( Layer& rootNode, - BufferIndex updateBufferIndex, - RenderQueue& renderQueue ); +int UpdateNodeTree( Layer& rootNode, BufferIndex updateBufferIndex ); } // namespace SceneGraph @@ -61,4 +58,3 @@ int UpdateNodeTree( Layer& rootNode, } // namespace Dali #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_ALGORITHMS_H__ - diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 882df7e..6a71316 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -15,10 +15,6 @@ * */ -#define DEBUG_OVERRIDE_VULKAN_SHADER -#ifdef DEBUG_OVERRIDE_VULKAN_SHADER -#include -#endif // CLASS HEADER #include @@ -44,15 +40,10 @@ #include #include #include -#include -#include -#include -#include #include #include #include #include -#include #include #include #include @@ -67,6 +58,8 @@ #include #include #include +#include +#include #include #include @@ -168,53 +161,6 @@ void SortSiblingNodesRecursively( Node& node ) } // unnamed namespace -//@todo: find better place for it -// for now we don't want to spam with new shaders -struct ShaderCache -{ - explicit ShaderCache( Dali::Graphics::API::Controller& _controller ) - : controller( _controller ) - { - - } - struct Item - { - Item() = default; - ~Item() = default; - Dali::Graphics::API::Accessor shader{ nullptr }; - Dali::Graphics::API::ShaderDetails::ShaderSource vertexSource{""}; - Dali::Graphics::API::ShaderDetails::ShaderSource fragmentSource{""}; - }; - - std::vector items; - - Dali::Graphics::API::Accessor GetShader( - const Dali::Graphics::API::ShaderDetails::ShaderSource& vsh, - const Dali::Graphics::API::ShaderDetails::ShaderSource& fsh - ) - { - for( auto&& item : items ) - { - if( item.vertexSource == vsh && item.fragmentSource == fsh ) - { - return item.shader; - } - } - auto shaderRef = - controller.CreateShader( controller.GetShaderFactory() - .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::VERTEX, - Graphics::API::ShaderDetails::Language::SPIRV_1_0, - vsh ) - .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::FRAGMENT, - Graphics::API::ShaderDetails::Language::SPIRV_1_0, - fsh ) - ); - items.emplace_back( Item() = { shaderRef, vsh, fsh } ); - return shaderRef; - } - - Dali::Graphics::API::Controller& controller; -}; /** * Structure to contain UpdateManager internal data @@ -226,28 +172,22 @@ struct UpdateManager::Impl PropertyNotifier& propertyNotifier, DiscardQueue& discardQueue, RenderController& renderController, - RenderManager& renderManager, - RenderQueue& renderQueue, SceneGraphBuffers& sceneGraphBuffers, RenderTaskProcessor& renderTaskProcessor, Integration::Graphics::Graphics& graphics ) - : renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ), - notificationManager( notificationManager ), + : notificationManager( notificationManager ), transformManager(), animationPlaylist( animationPlaylist ), propertyNotifier( propertyNotifier ), - shaderSaver( NULL ), discardQueue( discardQueue ), renderController( renderController ), sceneController( NULL ), - renderManager( renderManager ), - renderQueue( renderQueue ), - renderInstructions( renderManager.GetRenderInstructionContainer() ), + renderInstructions( ), renderTaskProcessor( renderTaskProcessor ), graphics( graphics ), backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), - taskList( renderMessageDispatcher ), - systemLevelTaskList( renderMessageDispatcher ), + taskList( /*renderMessageDispatcher*/ ), + systemLevelTaskList( /*renderMessageDispatcher*/ ), root( NULL ), systemLevelRoot( NULL ), renderers(), @@ -264,7 +204,7 @@ struct UpdateManager::Impl renderersAdded( false ), shaderCache( graphics.GetController() ) { - sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue ); + sceneController = new SceneControllerImpl( discardQueue ); // create first 'dummy' node nodes.PushBack(0u); @@ -316,19 +256,17 @@ struct UpdateManager::Impl } SceneGraphBuffers sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read - RenderMessageDispatcher renderMessageDispatcher; ///< Used for passing messages to the render-thread NotificationManager& notificationManager; ///< Queues notification messages for the event-thread. TransformManager transformManager; ///< Used to update the transformation matrices of the nodes CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified. - ShaderSaver* shaderSaver; ///< Saves shader binaries. + DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph. RenderController& renderController; ///< render controller SceneControllerImpl* sceneController; ///< scene controller - RenderManager& renderManager; ///< This is responsible for rendering the results of each "update" - RenderQueue& renderQueue; ///< Used to queue messages for the next render - RenderInstructionContainer& renderInstructions; ///< Used to prepare the render instructions + RenderInstructionContainer renderInstructions; ///< Used to prepare the render instructions @todo GRAPHICS Remove RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons + Integration::Graphics::Graphics& graphics; ///< Graphics Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame. @@ -353,12 +291,16 @@ struct UpdateManager::Impl OwnerContainer< Renderer* > renderers; ///< A container of owned renderers OwnerContainer< TextureSet* > textureSets; ///< A container of owned texture sets OwnerContainer< Shader* > shaders; ///< A container of owned shaders + + OwnerContainer< SceneGraph::Sampler* > samplerContainer; ///< List of owned samplers + OwnerContainer< SceneGraph::Texture* > textureContainer; ///< List of owned textures + OwnerContainer< SceneGraph::FrameBuffer* > frameBufferContainer; ///< List of owned framebuffers + OwnerContainer< SceneGraph::PropertyBuffer* > propertyBufferContainer; ///< List of owned property buffers + OwnerContainer< SceneGraph::Geometry* > geometryContainer; ///< List of owned Geometries + OwnerPointer< PanGesture > panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager MessageQueue messageQueue; ///< The messages queued from the event-thread - std::vector renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread. - std::vector updateCompiledShaders; ///< Shaders to be sent from Update to Event - Mutex compiledShaderMutex; ///< lock to ensure no corruption on the renderCompiledShaders float keepRenderingSeconds; ///< Set via Dali::Stage::KeepRendering int nodeDirtyFlags; ///< cumulative node dirty flags from previous frame @@ -382,8 +324,6 @@ UpdateManager::UpdateManager( NotificationManager& notificationManag PropertyNotifier& propertyNotifier, DiscardQueue& discardQueue, RenderController& controller, - RenderManager& renderManager, - RenderQueue& renderQueue, RenderTaskProcessor& renderTaskProcessor, Integration::Graphics::Graphics& graphics ) : mImpl( new Impl( notificationManager, @@ -391,8 +331,6 @@ UpdateManager::UpdateManager( NotificationManager& notificationManag propertyNotifier, discardQueue, controller, - renderManager, - renderQueue, mSceneGraphBuffers, renderTaskProcessor, graphics) ) @@ -564,6 +502,7 @@ void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propert void UpdateManager::AddShader( OwnerPointer< Shader >& shader ) { + shader->Initialize( mImpl->graphics, mImpl->shaderCache ); mImpl->shaders.PushBack( shader.Release() ); } @@ -573,63 +512,9 @@ void UpdateManager::RemoveShader( Shader* shader ) EraseUsingDiscardQueue( mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() ); } -void UpdateManager::SetShaderProgram( Shader* shader, - Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) -{ - // TODO: for now we will use hardcoded binary SPIRV shaders which will replace anything - // that is passed by the caller -#ifdef DEBUG_OVERRIDE_VULKAN_SHADER - - auto shaderRef = mImpl->shaderCache.GetShader( Graphics::API::ShaderDetails::ShaderSource( VSH_IMAGE_VISUAL_CODE ), - Graphics::API::ShaderDetails::ShaderSource( FSH_IMAGE_VISUAL_CODE )); - -#else - auto shaderRef = - controller.CreateShader( controller.GetShaderFactory() - .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::VERTEX, - Graphics::API::ShaderDetails::Language::SPIRV_1_0, - Graphics::API::ShaderDetails::ShaderSource( shaderData->GetVertexShader() )) - .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::FRAGMENT, - Graphics::API::ShaderDetails::Language::SPIRV_1_0, - Graphics::API::ShaderDetails::ShaderSource( shaderData->GetFragmentShader() )) - ); -#endif - shader->SetGfxObject( shaderRef ); - -#if 0 - if( shaderData ) - { - - typedef MessageValue3< Shader, Internal::ShaderDataPtr, ProgramCache*, bool> DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( shader, &Shader::SetProgram, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry ); - } -#endif -} - -void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData ) -{ - DALI_ASSERT_DEBUG( shaderData && "No NULL shader data pointers please." ); - DALI_ASSERT_DEBUG( shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save." ); - { - // lock as update might be sending previously compiled shaders to event thread - Mutex::ScopedLock lock( mImpl->compiledShaderMutex ); - mImpl->renderCompiledShaders.push_back( shaderData ); - } -} - -void UpdateManager::SetShaderSaver( ShaderSaver& upstream ) -{ - mImpl->shaderSaver = &upstream; -} - void UpdateManager::AddRenderer( OwnerPointer< Renderer >& renderer ) { - renderer->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() ); + renderer->ConnectToSceneGraph( mSceneGraphBuffers.GetUpdateBufferIndex() ); mImpl->renderers.PushBack( renderer.Release() ); mImpl->renderersAdded = true; } @@ -637,9 +522,9 @@ void UpdateManager::AddRenderer( OwnerPointer< Renderer >& renderer ) void UpdateManager::RemoveRenderer( Renderer* renderer ) { // Find the renderer and destroy it + // @todo Don't need to use discard queue for SceneGraph::Renderer any more ( No dependency from Graphics::RenderCommand ) EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() ); - // Need to remove the render object as well - renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() ); + renderer->DisconnectFromSceneGraph( mSceneGraphBuffers.GetUpdateBufferIndex() ); } void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor ) @@ -831,31 +716,6 @@ void UpdateManager::ProcessPropertyNotifications( BufferIndex bufferIndex ) } } -void UpdateManager::ForwardCompiledShadersToEventThread() -{ - DALI_ASSERT_DEBUG( (mImpl->shaderSaver != 0) && "shaderSaver should be wired-up during startup." ); - if( mImpl->shaderSaver ) - { - // lock and swap the queues - { - // render might be attempting to send us more binaries at the same time - Mutex::ScopedLock lock( mImpl->compiledShaderMutex ); - mImpl->renderCompiledShaders.swap( mImpl->updateCompiledShaders ); - } - - if( mImpl->updateCompiledShaders.size() > 0 ) - { - ShaderSaver& factory = *mImpl->shaderSaver; - for( auto&& shader : mImpl->updateCompiledShaders ) - { - mImpl->notificationManager.QueueMessage( ShaderCompiledMessage( factory, shader ) ); - } - // we don't need them in update anymore - mImpl->updateCompiledShaders.clear(); - } - } -} - void UpdateManager::UpdateRenderers( BufferIndex bufferIndex ) { const unsigned int rendererCount = mImpl->renderers.Count(); @@ -864,7 +724,6 @@ void UpdateManager::UpdateRenderers( BufferIndex bufferIndex ) //Apply constraints ConstrainPropertyOwner( *mImpl->renderers[i], bufferIndex ); - //mImpl->renderers[i]->PrepareRender( bufferIndex ); mImpl->renderers[i]->PrepareRender( mImpl->graphics.GetController(), bufferIndex ); } } @@ -880,15 +739,11 @@ void UpdateManager::UpdateNodes( BufferIndex bufferIndex ) // Prepare resources, update shaders, for each node // And add the renderers to the sorted layers. Start from root, which is also a layer - mImpl->nodeDirtyFlags = UpdateNodeTree( *( mImpl->root ), - bufferIndex, - mImpl->renderQueue ); + mImpl->nodeDirtyFlags = UpdateNodeTree( *( mImpl->root ), bufferIndex ); if ( mImpl->systemLevelRoot ) { - mImpl->nodeDirtyFlags |= UpdateNodeTree( *( mImpl->systemLevelRoot ), - bufferIndex, - mImpl->renderQueue ); + mImpl->nodeDirtyFlags |= UpdateNodeTree( *( mImpl->systemLevelRoot ), bufferIndex ); } } @@ -927,9 +782,6 @@ unsigned int UpdateManager::Update( float elapsedSeconds, // be set again updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex ); - //Forward compiled shader programs to event thread for saving - ForwardCompiledShadersToEventThread(); - // Although the scene-graph may not require an update, we still need to synchronize double-buffered // renderer lists if the scene was updated in the previous frame. // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes @@ -1091,24 +943,12 @@ unsigned int UpdateManager::KeepUpdatingCheck( float elapsedSeconds ) const void UpdateManager::SetBackgroundColor( const Vector4& color ) { - typedef MessageValue1< RenderManager, Vector4 > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetBackgroundColor, color ); + DALI_ASSERT_ALWAYS( true && "GRAPHICS: FIXME" ); } void UpdateManager::SetDefaultSurfaceRect( const Rect& rect ) { - typedef MessageValue1< RenderManager, Rect > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultSurfaceRect, rect ); + DALI_ASSERT_ALWAYS( true && "GRAPHICS: FIXME" ); } void UpdateManager::KeepRendering( float durationSeconds ) @@ -1142,295 +982,86 @@ void UpdateManager::SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths ) SortSiblingNodesRecursively( *( mImpl->root ) ); } -void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler ) -{ - // Message has ownership of Sampler while in transit from update to render - typedef MessageValue1< RenderManager, OwnerPointer< Render::Sampler > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddSampler, sampler ); -} - -void UpdateManager::RemoveSampler( Render::Sampler* sampler ) -{ - typedef MessageValue1< RenderManager, Render::Sampler* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveSampler, sampler ); -} - -void UpdateManager::SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode ) -{ - typedef MessageValue3< RenderManager, Render::Sampler*, unsigned int, unsigned int > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode ); -} - -void UpdateManager::SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) -{ - typedef MessageValue4< RenderManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode ); -} - -void UpdateManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer ) +void UpdateManager::AddSampler( OwnerPointer< SceneGraph::Sampler >& sampler ) { - // Message has ownership of format while in transit from update -> render - typedef MessageValue1< RenderManager, OwnerPointer< Render::PropertyBuffer > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddPropertyBuffer, propertyBuffer ); -} - -void UpdateManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer ) -{ - typedef MessageValue1< RenderManager, Render::PropertyBuffer* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemovePropertyBuffer, propertyBuffer ); + mImpl->samplerContainer.PushBack( sampler.Release() ); } -#if 0 -void UpdateManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ) +void UpdateManager::RemoveSampler( SceneGraph::Sampler* sampler ) { - // Message has ownership of format while in transit from update -> render - typedef MessageValue2< RenderManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetPropertyBufferFormat, propertyBuffer, format ); + mImpl->samplerContainer.EraseObject( sampler ); } -#endif -void UpdateManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ) +void UpdateManager::AddPropertyBuffer( OwnerPointer< SceneGraph::PropertyBuffer >& propertyBuffer ) { - // todo: may not be needed yet - // Message has ownership of format while in transit from update -> render - //auto& controller = GetGraphicsController(); - //controller.CreateBuffer( controller.GetBufferFactory() - //.SetSize( format->size * format->components )) - - // set format directly, on the update thread - propertyBuffer->SetFormat( format.Release() ); + propertyBuffer->Initialize( mImpl->graphics ); + mImpl->propertyBufferContainer.PushBack( propertyBuffer.Release() ); } -#if 0 -void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ) +void UpdateManager::RemovePropertyBuffer( SceneGraph::PropertyBuffer* propertyBuffer ) { - // Message has ownership of format while in transit from update -> render - typedef MessageValue3< RenderManager, Render::PropertyBuffer*, OwnerPointer< Dali::Vector >, size_t > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetPropertyBufferData, propertyBuffer, data, size ); + mImpl->propertyBufferContainer.EraseObject( propertyBuffer ); } -#endif -void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ) +void UpdateManager::AddGeometry( OwnerPointer< SceneGraph::Geometry >& geometry ) { - auto& controller = GetGraphicsController(); - auto buffer = controller.CreateBuffer( controller.GetBufferFactory() - .SetSize( uint32_t(propertyBuffer->GetFormat()->size * size) ) - .SetUsage(Graphics::API::Buffer::UsageHint::ATTRIBUTES )); - propertyBuffer->SetGfxObject( buffer ); - propertyBuffer->SetData( data.Release(), size ); + geometry->Initialize( mImpl->graphics ); + mImpl->geometryContainer.PushBack( geometry.Release() ); } -void UpdateManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry ) +void UpdateManager::RemoveGeometry( SceneGraph::Geometry* geometry ) { - - // Message has ownership of format while in transit from update -> render - typedef MessageValue1< RenderManager, OwnerPointer< Render::Geometry > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddGeometry, geometry ); + mImpl->geometryContainer.EraseObject( geometry ); } -void UpdateManager::RemoveGeometry( Render::Geometry* geometry ) +void UpdateManager::AddTexture( OwnerPointer< SceneGraph::Texture >& texture ) { - typedef MessageValue1< RenderManager, Render::Geometry* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveGeometry, geometry ); + texture->Initialize( mImpl->graphics ); + mImpl->textureContainer.PushBack( texture.Release() ); } -void UpdateManager::SetGeometryType( Render::Geometry* geometry, unsigned int geometryType ) +void UpdateManager::RemoveTexture( SceneGraph::Texture* texture) { - typedef MessageValue2< RenderManager, Render::Geometry*, unsigned int > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); + DALI_ASSERT_DEBUG( NULL != texture ); - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetGeometryType, geometry, geometryType ); -} - -void UpdateManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& indices ) -{ - typedef IndexBufferMessage< RenderManager > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, geometry, indices ); -} - -void UpdateManager::RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ) -{ - /* - typedef MessageValue2< RenderManager, Render::Geometry*, Render::PropertyBuffer* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveVertexBuffer, geometry, propertyBuffer ); - */ - geometry->RemovePropertyBuffer( propertyBuffer ); -} - -void UpdateManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ) -{ - //typedef MessageValue2< RenderManager, Render::Geometry*, Render::PropertyBuffer* > DerivedType; - - // Reserve some memory inside the render queue - //unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - //new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, propertyBuffer ); - - geometry->AddPropertyBuffer( propertyBuffer ); -} - -void UpdateManager::AddTexture( OwnerPointer< Render::Texture >& texture ) -{ - // Message has ownership of Texture while in transit from update -> render - typedef MessageValue1< RenderManager, OwnerPointer< Render::Texture > > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddTexture, texture ); -} - -void UpdateManager::RemoveTexture( Render::Texture* texture) -{ - typedef MessageValue1< RenderManager, Render::Texture* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture ); -} - -void UpdateManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) -{ - typedef MessageValue3< RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > DerivedType; - - // Reserve some memory inside the message queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params ); -} - -void UpdateManager::UploadTextureV2( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) -{ - //fixme: AB: This is temporary solution to create a texture object on the Graphics API side - //fixme: using controller directly in the update thread - auto& controller = mImpl->graphics.GetController(); - - auto tex = controller.CreateTexture( controller.GetTextureFactory() - .SetFormat( Graphics::API::TextureDetails::Format::RGBA8 ) - .SetSize( { pixelData->GetWidth(), pixelData->GetHeight() } ) - .SetType( Graphics::API::TextureDetails::Type::TEXTURE_2D ) - .SetMipMapFlag( Graphics::API::TextureDetails::MipMapFlag::DISABLED ) - .SetData( pixelData->GetBuffer() ) - .SetDataSize( pixelData->GetBufferSize() ) - ); - - // TODO: Render::Texture will be gone, however currently it's still in use - // so it carries the accessor to the texture object - texture->SetGfxObject( tex ); - - texture->SetId( static_cast(tex.GetHandle()) ); -} - -void UpdateManager::GenerateMipmaps( Render::Texture* texture ) -{ - typedef MessageValue1< RenderManager, Render::Texture* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::GenerateMipmaps, texture ); + // Find the texture, use reference to pointer so we can do the erase safely + for ( auto&& iter : mImpl->textureContainer ) + { + if ( iter == texture ) + { + //texture->Destroy(); //@todo Do something in Gfx? + mImpl->textureContainer.Erase( &iter ); // Texture found; now destroy it + return; + } + } } -void UpdateManager::AddFrameBuffer( Render::FrameBuffer* frameBuffer ) +void UpdateManager::AddFrameBuffer( SceneGraph::FrameBuffer* frameBuffer ) { - typedef MessageValue1< RenderManager, Render::FrameBuffer* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddFrameBuffer, frameBuffer ); + mImpl->frameBufferContainer.PushBack( frameBuffer ); + //frameBuffer->Initialize(); @todo Rewrite for Gfx } -void UpdateManager::RemoveFrameBuffer( Render::FrameBuffer* frameBuffer) +void UpdateManager::RemoveFrameBuffer( SceneGraph::FrameBuffer* frameBuffer) { - typedef MessageValue1< RenderManager, Render::FrameBuffer* > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); + DALI_ASSERT_DEBUG( NULL != frameBuffer ); - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer ); + // Find the sampler, use reference so we can safely do the erase + for ( auto&& iter : mImpl->frameBufferContainer ) + { + if ( iter == frameBuffer ) + { + //frameBuffer->Destroy(); @todo Rewrite for Gfx + mImpl->frameBufferContainer.Erase( &iter ); // frameBuffer found; now destroy it + break; + } + } } -void UpdateManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) +void UpdateManager::AttachColorTextureToFrameBuffer( SceneGraph::FrameBuffer* frameBuffer, SceneGraph::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) { - typedef MessageValue4< RenderManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer ); + //frameBuffer->AttachColorTexture( mImpl->context, texture, mipmapLevel, layer ); @todo Rewrite for Gfx + DALI_ASSERT_ALWAYS( true && "GRAPHICS: FIXME" ); } Graphics::API::Controller& UpdateManager::GetGraphicsController() const diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 71c3978..c60f6a0 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -27,20 +27,24 @@ #include #include -#include + #include #include #include -#include -#include // for OwnerPointer< Shader > #include #include #include #include +#include #include #include #include +#include +#include +#include +#include #include // for OwnerPointer< Renderer > +#include // for OwnerPointer< Shader > #include // for OwnerPointer< TextureSet > #include @@ -49,7 +53,6 @@ namespace Dali namespace Integration { -class GlSyncAbstraction; class RenderController; namespace Graphics { @@ -59,17 +62,16 @@ class Graphics; namespace Internal { +namespace SceneGraph +{ +class FrameBuffer; +} class PropertyNotifier; class NotificationManager; class CompleteNotificationInterface; class TouchResampler; -namespace Render -{ -struct Sampler; -class FrameBuffer; -} // value types used by messages template <> struct ParameterType< PropertyNotification::NotifyMode > : public BasicType< PropertyNotification::NotifyMode > {}; @@ -85,31 +87,6 @@ class RenderTaskProcessor; class RenderQueue; class PropertyBuffer; -struct NodeDepthPair -{ - SceneGraph::Node* node; - uint32_t sortedDepth; - NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth ) - : node(node), - sortedDepth(sortedDepth) - { - } -}; - -struct NodeDepths -{ - NodeDepths() - { - } - - void Add( SceneGraph::Node* node, uint32_t sortedDepth ) - { - nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) ); - } - - std::vector nodeDepths; -}; - /** * UpdateManager maintains a scene graph i.e. a tree of nodes as well as @@ -119,7 +96,7 @@ struct NodeDepths * It also maintains the lifecycle of nodes and other property owners that are * disconnected from the scene graph. */ -class UpdateManager : public ShaderSaver +class UpdateManager { public: @@ -130,8 +107,6 @@ public: * @param[in] propertyNotifier The PropertyNotifier * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph. * @param[in] controller After messages are flushed, we request a render from the RenderController. - * @param[in] renderManager This is responsible for rendering the results of each "update". - * @param[in] renderQueue Used to queue messages for the next render. * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons. */ UpdateManager( NotificationManager& notificationManager, @@ -139,8 +114,6 @@ public: PropertyNotifier& propertyNotifier, DiscardQueue& discardQueue, Integration::RenderController& controller, - RenderManager& renderManager, - RenderQueue& renderQueue, RenderTaskProcessor& renderTaskProcessor, Dali::Integration::Graphics::Graphics& graphics); @@ -286,27 +259,6 @@ public: */ void RemoveShader( Shader* shader ); - /** - * Set the shader program for a Shader object - * @param[in] shader The shader to modify - * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program - * @param[in] modifiesGeometry True if the vertex shader modifies geometry - */ - void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); - - /** - * @brief Accept compiled shaders passed back on render thread for saving. - * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved. - */ - virtual void SaveBinary( Internal::ShaderDataPtr shaderData ); - - /** - * @brief Set the destination for compiled shader binaries to be passed on to. - * The dispatcher passed in will be called from the update thread. - * @param[in] upstream A sink for ShaderDatas to be passed into. - */ - void SetShaderSaver( ShaderSaver& upstream ); - // Renderers /** @@ -399,31 +351,14 @@ public: * @post Sends a message to RenderManager to add the sampler. * The sampler will be owned by RenderManager */ - void AddSampler( OwnerPointer< Render::Sampler >& sampler ); + void AddSampler( OwnerPointer< SceneGraph::Sampler >& sampler ); /** * Removes an existing sampler from RenderManager * @param[in] sampler The sampler to remove * @post The sampler will be destroyed in the render thread */ - void RemoveSampler( Render::Sampler* sampler ); - - /** - * Sets the filter modes for an existing sampler - * @param[in] sampler The sampler - * @param[in] minFilterMode The filter to use under minification - * @param[in] magFilterMode The filter to use under magnification - */ - void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode ); - - /** - * Sets the wrap mode for an existing sampler - * @param[in] sampler The sampler - * @param[in] rWrapMode Wrapping mode in z direction - * @param[in] sWrapMode Wrapping mode in x direction - * @param[in] tWrapMode Wrapping mode in y direction - */ - void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ); + void RemoveSampler( SceneGraph::Sampler* sampler ); /** * Add a new property buffer to RenderManager @@ -431,14 +366,14 @@ public: * @post Sends a message to RenderManager to add the property buffer. * The property buffer will be owned by RenderManager */ - void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer ); + void AddPropertyBuffer( OwnerPointer< SceneGraph::PropertyBuffer >& propertyBuffer ); /** * Removes an existing PropertyBuffer from RenderManager * @param[in] propertryBuffer The property buffer to remove * @post The property buffer will be destroyed in the render thread */ - void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer ); + void RemovePropertyBuffer( SceneGraph::PropertyBuffer* propertryBuffer ); /** * Sets the format of an existing property buffer @@ -446,7 +381,7 @@ public: * @param[in] format The new format of the buffer * @post Sends a message to RenderManager to set the new format to the property buffer. */ - void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ); + void SetPropertyBufferFormat( SceneGraph::PropertyBuffer* propertyBuffer, OwnerPointer< SceneGraph::PropertyBuffer::Format>& format ); /** * Sets the data of an existing property buffer @@ -455,7 +390,7 @@ public: * @param[in] size The new size of the buffer * @post Sends a message to RenderManager to set the new data to the property buffer. */ - void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ); + void SetPropertyBufferData( SceneGraph::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ); /** * Adds a geometry to the RenderManager @@ -463,86 +398,70 @@ public: * @post Sends a message to RenderManager to add the Geometry * The geometry will be owned by RenderManager */ - void AddGeometry( OwnerPointer< Render::Geometry >& geometry ); + void AddGeometry( OwnerPointer< SceneGraph::Geometry >& geometry ); /** * Removes an existing Geometry from RenderManager * @param[in] geometry The geometry to remove * @post The geometry will be destroyed in the render thread */ - void RemoveGeometry( Render::Geometry* geometry ); + void RemoveGeometry( SceneGraph::Geometry* geometry ); /** * Sets the geometry type of an existing Geometry * @param[in] geometry The geometry * @param[in] geometryType The type of the geometry */ - void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType ); + void SetGeometryType( SceneGraph::Geometry* geometry, unsigned int geometryType ); /** * Sets the index buffer to be used by a geometry * @param[in] geometry The geometry * @param[in] indices A vector containing the indices for the geometry */ - void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& indices ); + void SetIndexBuffer( SceneGraph::Geometry* geometry, Dali::Vector& indices ); /** * Adds a vertex buffer to a geometry * @param[in] geometry The geometry * @param[in] propertyBuffer The property buffer */ - void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); + void AttachVertexBuffer( SceneGraph::Geometry* geometry, SceneGraph::PropertyBuffer* propertyBuffer ); /** * Removes a vertex buffer from a geometry * @param[in] geometry The geometry * @param[in] propertyBuffer The property buffer */ - void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); + void RemoveVertexBuffer( SceneGraph::Geometry* geometry, SceneGraph::PropertyBuffer* propertyBuffer ); /** * Adds a texture to the render manager * @param[in] texture The texture to add * The texture will be owned by RenderManager */ - void AddTexture( OwnerPointer< Render::Texture >& texture ); + void AddTexture( OwnerPointer< SceneGraph::Texture >& texture ); /** * Removes a texture from the render manager * @param[in] texture The texture to remove * @post The texture will be destroyed in the render thread */ - void RemoveTexture( Render::Texture* texture ); - - /** - * Uploads data to a texture owned by the RenderManager - * @param[in] texture The texture - * @param[in] pixelData The pixel data object - * @param[in] params The parameters for the upload - */ - void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ); - - void UploadTextureV2( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ); - - /** - * Generates mipmaps for a texture owned by the RenderManager - * @param[in] texture The texture - */ - void GenerateMipmaps( Render::Texture* texture ); + void RemoveTexture( SceneGraph::Texture* texture ); /** * Adds a framebuffer to the render manager * @param[in] frameBuffer The framebuffer to add * The framebuffer will be owned by RenderManager */ - void AddFrameBuffer( Render::FrameBuffer* frameBuffer ); + void AddFrameBuffer( SceneGraph::FrameBuffer* frameBuffer ); /** * Removes a FrameBuffer from the render manager * @param[in] frameBuffer The FrameBuffer to remove * @post The FrameBuffer will be destroyed in the render thread */ - void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer ); + void RemoveFrameBuffer( SceneGraph::FrameBuffer* frameBuffer ); /** * Attach a texture as color output to an existing FrameBuffer @@ -551,7 +470,7 @@ public: * @param[in] mipmapLevel The mipmap of the texture to be attached * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures */ - void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face ); + void AttachColorTextureToFrameBuffer( SceneGraph::FrameBuffer* frameBuffer, SceneGraph::Texture* texture, unsigned int mipmapLevel, unsigned int face ); Graphics::API::Controller& GetGraphicsController() const; @@ -910,20 +829,6 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader ); } -inline void SetShaderProgramMessage( UpdateManager& manager, - Shader& shader, - Internal::ShaderDataPtr shaderData, - bool modifiesGeometry ) -{ - typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry ); -} - inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color ) { typedef MessageValue1< UpdateManager, Vector4 > LocalType; @@ -1018,10 +923,10 @@ inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& texture new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet ); } -inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler ) +inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Sampler >& sampler ) { // Message has ownership of Sampler while in transit from event -> update - typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Sampler > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1030,9 +935,9 @@ inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sam new (slot) LocalType( &manager, &UpdateManager::AddSampler, sampler ); } -inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler ) +inline void RemoveSamplerMessage( UpdateManager& manager, SceneGraph::Sampler& sampler ) { - typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::Sampler* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1041,32 +946,10 @@ inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampl new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler ); } -inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode ) -{ - typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode ); -} - -inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) -{ - typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode ); -} - -inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer ) +inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< SceneGraph::PropertyBuffer >& propertyBuffer ) { // Message has ownership of propertyBuffer while in transit from event -> update - typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::PropertyBuffer > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1075,9 +958,9 @@ inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::Pro new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer ); } -inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer ) +inline void RemovePropertyBuffer( UpdateManager& manager, SceneGraph::PropertyBuffer& propertyBuffer ) { - typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::PropertyBuffer* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1086,34 +969,10 @@ inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer ); } -inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ) -{ - // Message has ownership of PropertyBuffer::Format while in transit from event -> update - typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format ); -} - -inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector >& data, size_t size ) -{ - // Message has ownership of PropertyBuffer data while in transit from event -> update - typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector >, size_t > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size ); -} - -inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry ) +inline void AddGeometry( UpdateManager& manager, OwnerPointer< SceneGraph::Geometry >& geometry ) { // Message has ownership of Geometry while in transit from event -> update - typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Geometry > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1122,9 +981,9 @@ inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry new (slot) LocalType( &manager, &UpdateManager::AddGeometry, geometry ); } -inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry ) +inline void RemoveGeometry( UpdateManager& manager, SceneGraph::Geometry& geometry ) { - typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::Geometry* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1133,94 +992,10 @@ inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry ) new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry ); } -inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) -{ - typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast(&vertexBuffer) ); -} - -inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) -{ - typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast(&vertexBuffer) ); -} - -// Custom message type for SetIndexBuffer() used to move data with Vector::Swap() -template< typename T > -class IndexBufferMessage : public MessageBase -{ -public: - - /** - * Constructor which does a Vector::Swap() - */ - IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector& indices ) - : MessageBase(), - mManager( manager ), - mRenderGeometry( geometry ) - { - mIndices.Swap( indices ); - } - - /** - * Virtual destructor - */ - virtual ~IndexBufferMessage() - { - } - - /** - * @copydoc MessageBase::Process - */ - virtual void Process( BufferIndex /*bufferIndex*/ ) - { - DALI_ASSERT_DEBUG( mManager && "Message does not have an object" ); - mManager->SetIndexBuffer( mRenderGeometry, mIndices ); - } - -private: - - T* mManager; - Render::Geometry* mRenderGeometry; - Dali::Vector mIndices; -}; - -inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector& indices ) -{ - typedef IndexBufferMessage< UpdateManager > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &geometry, indices ); -} - -inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType ) -{ - typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType ); -} - -inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture ) +inline void AddTextureMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Texture >& texture ) { // Message has ownership of Texture while in transit from event -> update - typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Texture > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1229,9 +1004,9 @@ inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& new (slot) LocalType( &manager, &UpdateManager::AddTexture, texture ); } -inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture ) +inline void RemoveTextureMessage( UpdateManager& manager, SceneGraph::Texture& texture ) { - typedef MessageValue1< UpdateManager, Render::Texture* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::Texture* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1240,43 +1015,10 @@ inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture ) new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture ); } -inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) -{ - typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params ); -} - -inline void UploadTextureMessageV2( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) -{ - typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::UploadTextureV2, &texture, pixelData, params ); -} - -inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture ) -{ - typedef MessageValue1< UpdateManager, Render::Texture* > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture ); -} - -inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) +inline void AddFrameBuffer( UpdateManager& manager, SceneGraph::FrameBuffer& frameBuffer ) { - typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::FrameBuffer* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1285,9 +1027,9 @@ inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBu new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer ); } -inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) +inline void RemoveFrameBuffer( UpdateManager& manager, SceneGraph::FrameBuffer& frameBuffer ) { - typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType; + typedef MessageValue1< UpdateManager, SceneGraph::FrameBuffer* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1296,9 +1038,9 @@ inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& fram new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer ); } -inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) +inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, SceneGraph::FrameBuffer& frameBuffer, SceneGraph::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) { - typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > LocalType; + typedef MessageValue4< UpdateManager, SceneGraph::FrameBuffer*, SceneGraph::Texture*, unsigned int, unsigned int > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index 93e6a3f..dca0d49 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_NODE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -36,7 +35,10 @@ #include #include #include -#include +#include + +//#include + namespace Dali { @@ -56,6 +58,10 @@ class DiscardQueue; class Layer; class RenderTask; class UpdateManager; +class Renderer; + +using RendererContainer = Dali::Vector; + /** * Flag whether property has changed, during the Update phase. diff --git a/dali/internal/update/queue/update-message-queue.cpp b/dali/internal/update/queue/update-message-queue.cpp index 59ad4f1..c8fab1e 100644 --- a/dali/internal/update/queue/update-message-queue.cpp +++ b/dali/internal/update/queue/update-message-queue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -24,7 +24,7 @@ #include #include #include -#include +#include using std::vector; diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp index 93fec3c..069b73c 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -30,9 +30,9 @@ namespace Internal namespace SceneGraph { -RenderTaskList::RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher ) -: mNotificationObject( NULL ), - mRenderMessageDispatcher( renderMessageDispatcher ) +RenderTaskList::RenderTaskList( /*RenderMessageDispatcher& renderMessageDispatcher*/ ) +: mNotificationObject( NULL ) + //,mRenderMessageDispatcher( renderMessageDispatcher ) { } @@ -44,7 +44,7 @@ void RenderTaskList::AddTask( OwnerPointer< RenderTask >& newTask ) { DALI_ASSERT_DEBUG( newTask != NULL && "SceneGraph RenderTask is null"); - newTask->Initialize( mRenderMessageDispatcher ); + newTask->Initialize( /*mRenderMessageDispatcher*/ ); // mRenderTasks container takes ownership mRenderTasks.PushBack( newTask.Release() ); } diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-list.h b/dali/internal/update/render-tasks/scene-graph-render-task-list.h index 6f1c320..b950a4e 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-list.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task-list.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -33,7 +33,7 @@ class CompleteNotificationInterface; namespace SceneGraph { -class RenderMessageDispatcher; + class RenderTask; /** @@ -49,7 +49,7 @@ public: * Constructor * @param renderMessageDispatcher to send messages */ - RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher ); + RenderTaskList( /*RenderMessageDispatcher& renderMessageDispatcher*/ ); /** * Destructor @@ -102,9 +102,7 @@ private: private: CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification - RenderMessageDispatcher& mRenderMessageDispatcher; ///< for sending messages to render thread RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks - }; // Messages for RenderTaskList diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.cpp b/dali/internal/update/render-tasks/scene-graph-render-task.cpp index 007d341..213ca33 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -20,10 +20,10 @@ // INTERNAL INCLUDES #include -#include + #include -#include -#include +#include +#include #include @@ -50,15 +50,11 @@ RenderTask::~RenderTask() mSourceNode->SetExclusiveRenderTask( NULL ); } } - if( mRenderSyncTracker ) - { - mRenderMessageDispatcher->RemoveRenderTracker( *mRenderSyncTracker ); - } + // @todo remove any hard sync object } -void RenderTask::Initialize( RenderMessageDispatcher& renderMessageDispatcher ) +void RenderTask::Initialize() { - mRenderMessageDispatcher = &renderMessageDispatcher; } void RenderTask::SetSourceNode( Node* node ) @@ -111,12 +107,12 @@ void RenderTask::SetCamera( Node* cameraNode, Camera* camera ) mCamera = camera; } -void RenderTask::SetFrameBuffer( Render::FrameBuffer* frameBuffer ) +void RenderTask::SetFrameBuffer( SceneGraph::FrameBuffer* frameBuffer ) { mFrameBuffer = frameBuffer; } -Render::FrameBuffer* RenderTask::GetFrameBuffer() +SceneGraph::FrameBuffer* RenderTask::GetFrameBuffer() { return mFrameBuffer; } @@ -293,7 +289,7 @@ void RenderTask::UpdateState() mNotifyTrigger = false; if( mFrameBuffer ) { - if( !mRenderSyncTracker || (mRenderSyncTracker && mRenderSyncTracker->IsSynced() )) + // @todo If hard sync exists, check if it has completed before cleaning up { mWaitingToRender = false; mNotifyTrigger = true; @@ -378,18 +374,7 @@ void RenderTask::PrepareRenderInstruction( RenderInstruction& instruction, Buffe if( mRequiresSync && mRefreshRate == Dali::RenderTask::REFRESH_ONCE ) { - // create tracker if one doesn't yet exist. - if( !mRenderSyncTracker ) - { - mRenderSyncTracker = new Render::RenderTracker(); - mRenderMessageDispatcher->AddRenderTracker( *mRenderSyncTracker ); - } - instruction.mRenderTracker = mRenderSyncTracker; - } - else - { - // no sync needed, texture FBOs are "ready" the same frame they are rendered to - instruction.mRenderTracker = NULL; + // Perform a hard synchronization after render instruction has executed. } } @@ -463,8 +448,7 @@ RenderTask::RenderTask() : mViewportPosition( Vector2::ZERO), mViewportSize( Vector2::ZERO), mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ), - mRenderMessageDispatcher( NULL ), - mRenderSyncTracker( NULL ), + //mRenderSyncTracker( NULL ), mSourceNode( NULL ), mCameraNode( NULL ), mCamera( NULL ), diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.h b/dali/internal/update/render-tasks/scene-graph-render-task.h index 0797dd3..fb42243 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -26,25 +26,18 @@ #include #include #include -#include +#include namespace Dali { - namespace Internal { - -namespace Render -{ -class RenderTracker; -} - namespace SceneGraph { class Node; class Camera; class RenderInstruction; -class RenderMessageDispatcher; + /** * RenderTasks describe how the Dali scene should be rendered. @@ -73,9 +66,8 @@ public: /** * Initialize the render task. Called in update thread - * @param[in] renderMessageDispatcher to send messages to render thread */ - void Initialize( RenderMessageDispatcher& renderMessageDispatcher ); + void Initialize(); /** * Set the nodes to be rendered. @@ -112,13 +104,13 @@ public: * Set the frame-buffer used as a render target. * @param[in] frameBuffer The framebuffer */ - void SetFrameBuffer( Render::FrameBuffer* frameBuffer ); + void SetFrameBuffer( SceneGraph::FrameBuffer* frameBuffer ); /** * Retrieve the resource ID of the frame-buffer. * @return The resource ID, or zero if not rendering off-screen. */ - Render::FrameBuffer* GetFrameBuffer(); + SceneGraph::FrameBuffer* GetFrameBuffer(); /** * Set the value of property viewportPosition @@ -349,12 +341,10 @@ public: // Animatable Properties AnimatableProperty< Vector4 > mClearColor; ///< clearColor private: - RenderMessageDispatcher* mRenderMessageDispatcher; - Render::RenderTracker* mRenderSyncTracker; Node* mSourceNode; Node* mCameraNode; SceneGraph::Camera* mCamera; - Render::FrameBuffer* mFrameBuffer; + SceneGraph::FrameBuffer* mFrameBuffer; bool mWaitingToRender:1; ///< True when an render once to FBO is waiting bool mNotifyTrigger:1; ///< True if a render once render task has finished renderering @@ -372,9 +362,9 @@ private: }; // Messages for RenderTask -inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, RenderTask& task, Render::FrameBuffer* frameBuffer ) +inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, RenderTask& task, SceneGraph::FrameBuffer* frameBuffer ) { - typedef MessageValue1< RenderTask, Render::FrameBuffer*> LocalType; + typedef MessageValue1< RenderTask, SceneGraph::FrameBuffer*> LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); diff --git a/dali/internal/render/data-providers/node-data-provider.h b/dali/internal/update/rendering/data-providers/node-data-provider.h similarity index 93% rename from dali/internal/render/data-providers/node-data-provider.h rename to dali/internal/update/rendering/data-providers/node-data-provider.h index 0a40075..5eef50d 100644 --- a/dali/internal/render/data-providers/node-data-provider.h +++ b/dali/internal/update/rendering/data-providers/node-data-provider.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -18,7 +18,7 @@ * */ -#include +#include namespace Dali { diff --git a/dali/internal/render/data-providers/property-buffer-data-provider.h b/dali/internal/update/rendering/data-providers/property-buffer-data-provider.h similarity index 98% rename from dali/internal/render/data-providers/property-buffer-data-provider.h rename to dali/internal/update/rendering/data-providers/property-buffer-data-provider.h index 51c8f64..57dfe42 100644 --- a/dali/internal/render/data-providers/property-buffer-data-provider.h +++ b/dali/internal/update/rendering/data-providers/property-buffer-data-provider.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BUFFER_DATA_PROVIDER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. diff --git a/dali/internal/render/data-providers/render-data-provider.cpp b/dali/internal/update/rendering/data-providers/render-data-provider.cpp similarity index 86% rename from dali/internal/render/data-providers/render-data-provider.cpp rename to dali/internal/update/rendering/data-providers/render-data-provider.cpp index 037e9c7..a4efc26 100644 --- a/dali/internal/render/data-providers/render-data-provider.cpp +++ b/dali/internal/update/rendering/data-providers/render-data-provider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -15,7 +15,7 @@ * */ -#include "render-data-provider.h" +#include namespace Dali { @@ -59,7 +59,7 @@ RenderDataProvider::Samplers& RenderDataProvider::GetSamplers() return mSamplers; } -std::vector& RenderDataProvider::GetTextures() +std::vector& RenderDataProvider::GetTextures() { return mTextures; } diff --git a/dali/internal/render/data-providers/render-data-provider.h b/dali/internal/update/rendering/data-providers/render-data-provider.h similarity index 77% rename from dali/internal/render/data-providers/render-data-provider.h rename to dali/internal/update/rendering/data-providers/render-data-provider.h index 2289282..8f862be 100644 --- a/dali/internal/render/data-providers/render-data-provider.h +++ b/dali/internal/update/rendering/data-providers/render-data-provider.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -20,11 +20,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Dali { @@ -33,6 +33,7 @@ namespace Internal struct BlendingOptions; + namespace SceneGraph { class PropertyBuffer; @@ -48,8 +49,8 @@ class Shader; class RenderDataProvider { public: - - typedef std::vector< Render::Sampler* > Samplers; + typedef Dali::Vector< const PropertyBufferDataProvider* > VertexBuffers; + typedef std::vector< SceneGraph::Sampler* > Samplers; /** * Constructor. @@ -86,7 +87,7 @@ public: * Returns the shader * @return The shader */ - Dali::Internal::SceneGraph::Shader& GetShader() const; + Shader& GetShader() const; /** * Returns the list of samplers @@ -98,13 +99,13 @@ public: * Returns the list of Textures * @return The list of Textures */ - std::vector& GetTextures(); + std::vector& GetTextures(); private: const UniformMapDataProvider* mUniformMapDataProvider; - Dali::Internal::SceneGraph::Shader* mShader; - std::vector mTextures; + Shader* mShader; + std::vector mTextures; Samplers mSamplers; // Give Renderer access to our private data to reduce copying vectors on construction. diff --git a/dali/internal/render/data-providers/uniform-map-data-provider.h b/dali/internal/update/rendering/data-providers/uniform-map-data-provider.h similarity index 97% rename from dali/internal/render/data-providers/uniform-map-data-provider.h rename to dali/internal/update/rendering/data-providers/uniform-map-data-provider.h index 7d7e120..58f0e71 100644 --- a/dali/internal/render/data-providers/uniform-map-data-provider.h +++ b/dali/internal/update/rendering/data-providers/uniform-map-data-provider.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_DATA_PROVIDER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. diff --git a/dali/internal/render/common/render-instruction-container.cpp b/dali/internal/update/rendering/render-instruction-container.cpp similarity index 92% rename from dali/internal/render/common/render-instruction-container.cpp rename to dali/internal/update/rendering/render-instruction-container.cpp index 3cbff8a..1c0b3fa 100644 --- a/dali/internal/render/common/render-instruction-container.cpp +++ b/dali/internal/update/rendering/render-instruction-container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -16,10 +16,10 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali/internal/render/common/render-instruction-container.h b/dali/internal/update/rendering/render-instruction-container.h similarity index 97% rename from dali/internal/render/common/render-instruction-container.h rename to dali/internal/update/rendering/render-instruction-container.h index 1bcff8b..8563e85 100644 --- a/dali/internal/render/common/render-instruction-container.h +++ b/dali/internal/update/rendering/render-instruction-container.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_CONTAINER_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. diff --git a/dali/internal/render/common/render-instruction.cpp b/dali/internal/update/rendering/render-instruction.cpp similarity index 88% rename from dali/internal/render/common/render-instruction.cpp rename to dali/internal/update/rendering/render-instruction.cpp index 4eb7a40..c4ecaaa 100644 --- a/dali/internal/render/common/render-instruction.cpp +++ b/dali/internal/update/rendering/render-instruction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -16,11 +16,11 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include // for Color::BLACK -#include +#include #include namespace Dali @@ -33,8 +33,7 @@ namespace SceneGraph { RenderInstruction::RenderInstruction() -: mRenderTracker( NULL ), - mClearColor(), +: mClearColor(), mIsViewportSet( false ), mIsClearColorSet( false ), mIgnoreRenderToFbo( false ), @@ -105,17 +104,16 @@ const RenderList* RenderInstruction::GetRenderList( RenderListContainer::SizeTyp return mRenderLists[ index ]; } -void RenderInstruction::Reset( Camera* camera, - Render::FrameBuffer* frameBuffer, - const Viewport* viewport, - const Vector4* clearColor ) +void RenderInstruction::Reset( Camera* camera, + SceneGraph::FrameBuffer* frameBuffer, + const Viewport* viewport, + const Vector4* clearColor ) { mCamera = camera; mViewport = viewport ? *viewport : Viewport(); mIsViewportSet = NULL != viewport; mClearColor = clearColor ? *clearColor : Color::BLACK; mIsClearColorSet = NULL != clearColor; - mRenderTracker = NULL; mNextFreeRenderList = 0; mFrameBuffer = frameBuffer; diff --git a/dali/internal/render/common/render-instruction.h b/dali/internal/update/rendering/render-instruction.h similarity index 91% rename from dali/internal/render/common/render-instruction.h rename to dali/internal/update/rendering/render-instruction.h index 3157f85..4ca1385 100644 --- a/dali/internal/render/common/render-instruction.h +++ b/dali/internal/update/rendering/render-instruction.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -22,20 +22,13 @@ #include #include #include -#include -#include +#include +#include namespace Dali { - namespace Internal { - -namespace Render -{ -class RenderTracker; -} - namespace SceneGraph { @@ -98,7 +91,7 @@ public: * @param[in] clearColor A pointer to a color to clear with, or NULL if no clear is required. */ void Reset( Camera* camera, - Render::FrameBuffer* frameBuffer, + SceneGraph::FrameBuffer* frameBuffer, const Viewport* viewport, const Vector4* clearColor ); @@ -133,15 +126,13 @@ private: public: // Data - Render::RenderTracker* mRenderTracker; ///< Pointer to an optional tracker object (not owned) - Viewport mViewport; ///< Optional viewport Vector4 mClearColor; ///< Optional color to clear with bool mIsViewportSet:1; ///< Flag to determine whether the viewport is set bool mIsClearColorSet:1; ///< Flag to determine whether the clearColor is set bool mIgnoreRenderToFbo:1; ///< Whether to ignore the render to FBO option (used to measure the performance above 60 fps) - Render::FrameBuffer* mFrameBuffer; + SceneGraph::FrameBuffer* mFrameBuffer; private: // Data diff --git a/dali/internal/render/common/render-item.cpp b/dali/internal/update/rendering/render-item.cpp similarity index 96% rename from dali/internal/render/common/render-item.cpp rename to dali/internal/update/rendering/render-item.cpp index ad024e8..2da5e01 100644 --- a/dali/internal/render/common/render-item.cpp +++ b/dali/internal/update/rendering/render-item.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -16,11 +16,10 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include -#include #include namespace @@ -46,7 +45,7 @@ RenderItem::RenderItem() : mModelMatrix( false ), mModelViewMatrix( false ), mSize(), - mRenderer( NULL ), + //mRenderer( NULL ), mNode( NULL ), mTextureSet( NULL ), mDepthIndex( 0 ), diff --git a/dali/internal/render/common/render-item.h b/dali/internal/update/rendering/render-item.h similarity index 96% rename from dali/internal/render/common/render-item.h rename to dali/internal/update/rendering/render-item.h index 7dbd3fb..1c1fbd3 100644 --- a/dali/internal/render/common/render-item.h +++ b/dali/internal/update/rendering/render-item.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_ITEM_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -30,11 +30,6 @@ namespace Dali namespace Internal { -namespace Render -{ -class Renderer; -} - namespace SceneGraph { @@ -79,7 +74,6 @@ struct RenderItem Matrix mModelMatrix; Matrix mModelViewMatrix; Vector3 mSize; - Render::Renderer* mRenderer; Node* mNode; const void* mTextureSet; //< Used for sorting only int mDepthIndex; diff --git a/dali/internal/render/common/render-list.h b/dali/internal/update/rendering/render-list.h similarity index 93% rename from dali/internal/render/common/render-list.h rename to dali/internal/update/rendering/render-list.h index 1aef561..d26e54e 100644 --- a/dali/internal/render/common/render-list.h +++ b/dali/internal/update/rendering/render-list.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { @@ -31,11 +31,6 @@ typedef Rect ClippingBox; namespace Internal { -namespace Render -{ -class Renderer; -} - namespace SceneGraph { @@ -129,15 +124,6 @@ public: } /** - * Get renderer from an item in the list - */ - const Render::Renderer& GetRenderer( RenderItemContainer::SizeType index ) const - { - DALI_ASSERT_DEBUG( index < GetCachedItemCount() ); - return *mItems[ index ]->mRenderer; - } - - /** * Get the number of real items * Because of caching, the actual size may be bit more * @return The number of items diff --git a/dali/internal/render/common/render-tracker.h b/dali/internal/update/rendering/render-tracker.h similarity index 74% rename from dali/internal/render/common/render-tracker.h rename to dali/internal/update/rendering/render-tracker.h index 307e101..6fbafcb 100644 --- a/dali/internal/render/common/render-tracker.h +++ b/dali/internal/update/rendering/render-tracker.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_RENDER_RENDER_TRACKER_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -18,7 +18,6 @@ * */ -#include #include namespace Dali @@ -48,11 +47,11 @@ public: /** * Creates a sync object for this tracker. Will delete any existing sync object. */ - void CreateSyncObject( Integration::GlSyncAbstraction& glSyncAbstraction ); + void CreateSyncObject(); /** - * Check the GL Sync objects. This is called from Render Thread. - * If the GlSyncObject has been triggered, then atomically set the sync trigger + * Check the Sync objects. + * If the SyncObject has been triggered, then atomically set the sync trigger */ void PollSyncObject(); @@ -74,10 +73,10 @@ public: void SetSyncFlag(); private: - - Integration::GlSyncAbstraction* mGlSyncAbstraction; // The sync abstraction - Integration::GlSyncAbstraction::SyncObject* mSyncObject; // Associated sync object - volatile int mSyncTrigger; // Trigger that update thread can read + /** + * @todo Need a new sync mechanism from Graphics API + */ + volatile int mSyncTrigger; // Trigger that update thread can read }; diff --git a/dali/internal/update/rendering/scene-graph-frame-buffer.cpp b/dali/internal/update/rendering/scene-graph-frame-buffer.cpp new file mode 100644 index 0000000..1be69e8 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-frame-buffer.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018 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 + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments ) +: mWidth( width ), + mHeight( height ) +{ +} + +FrameBuffer::~FrameBuffer() +{ +} + +void FrameBuffer::AttachColorTexture( SceneGraph::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) +{ +} + +unsigned int FrameBuffer::GetWidth() const +{ + return mWidth; +} + +unsigned int FrameBuffer::GetHeight() const +{ + return mHeight; +} + + +} //Render + +} //Internal + +} //Dali diff --git a/dali/internal/render/renderers/render-frame-buffer.h b/dali/internal/update/rendering/scene-graph-frame-buffer.h similarity index 62% rename from dali/internal/render/renderers/render-frame-buffer.h rename to dali/internal/update/rendering/scene-graph-frame-buffer.h index 942e5b3..11f66df 100644 --- a/dali/internal/render/renderers/render-frame-buffer.h +++ b/dali/internal/update/rendering/scene-graph-frame-buffer.h @@ -1,8 +1,8 @@ -#ifndef DALI_INTERNAL_RENDER_FRAME_BUFFER_H -#define DALI_INTERNAL_RENDER_FRAME_BUFFER_H +#ifndef DALI_INTERNAL_SCENE_GRAPH_FRAME_BUFFER_H +#define DALI_INTERNAL_SCENE_GRAPH_FRAME_BUFFER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,17 +19,15 @@ // INTERNAL INCLUDES #include -#include -#include -#include +#include namespace Dali { namespace Internal { -namespace Render + +namespace SceneGraph { -class Texture; class FrameBuffer { @@ -49,36 +47,13 @@ public: ~FrameBuffer(); /** - * Creates a FrameBuffer object in the GPU. - * @param[in] context The GL context - */ - void Initialize(Context& context); - - /** - * Deletes the framebuffer object from the GPU - * @param[in] context The GL context - */ - void Destroy( Context& context ); - - /** - * Called by RenderManager to inform the framebuffer that the context has been destroyed - */ - void GlContextDestroyed(); - - /** * @brief Attach a texture for color rendering. Valid only for Framebuffers with COLOR attachments. * param[in] context The GL context * @param[in] texture The texture that will be used as output when rendering * @param[in] mipmapLevel The mipmap of the texture to be attached * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures */ - void AttachColorTexture( Context& context, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ); - - /** - * @brief Bind the framebuffer - * @param[in] context The GL context - */ - void Bind( Context& context ); + void AttachColorTexture( SceneGraph::Texture* texture, unsigned int mipmapLevel, unsigned int layer ); /** * @brief Get the width of the FrameBuffer @@ -94,19 +69,16 @@ public: private: - GLuint mId; - GLuint mDepthBuffer; - GLuint mStencilBuffer; unsigned int mWidth; unsigned int mHeight; }; -} // namespace Render +} // namespace SceneGraph } // namespace Internal } // namespace Dali -#endif // DALI_INTERNAL_RENDER_FRAME_BUFFER_H +#endif // DALI_INTERNAL_SCENE_GRAPH_FRAME_BUFFER_H diff --git a/dali/internal/update/rendering/scene-graph-geometry.cpp b/dali/internal/update/rendering/scene-graph-geometry.cpp new file mode 100644 index 0000000..ecc9533 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-geometry.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018 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 + +// INTERNAL HEADERS +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +Geometry::Geometry() +: mIndices(), + mGeometryType( Dali::Geometry::TRIANGLES ), + mIndicesChanged(false), + mHasBeenUpdated(false), + mAttributesChanged(true) +{ +} + +Geometry::~Geometry() +{ +} + +void Geometry::Initialize( Integration::Graphics::Graphics& graphics ) +{ + mGraphics = &graphics; +} + +void Geometry::AddPropertyBuffer( SceneGraph::PropertyBuffer* propertyBuffer ) +{ + mVertexBuffers.PushBack( propertyBuffer ); + mAttributesChanged = true; +} + +void Geometry::SetIndexBuffer( Dali::Vector& indices ) +{ + mIndices.Swap( indices ); + mIndicesChanged = true; +} + +void Geometry::RemovePropertyBuffer( const SceneGraph::PropertyBuffer* propertyBuffer ) +{ + size_t bufferCount = mVertexBuffers.Size(); + for( size_t i(0); i +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ +class PropertyBuffer; + +/** + * This class encapsulates vertex data and index data used to describe a mesh. + */ +class Geometry +{ +public: + typedef Dali::Geometry::Type Type; + + Geometry(); + + /** + * Destructor + */ + ~Geometry(); + + /** + * Initialize the geometry object with the Graphics API when added to UpdateManager + * + * @param[in] graphics The Graphics API + */ + void Initialize( Integration::Graphics::Graphics& graphics ); + + /** + * Adds a property buffer to the geometry + * @param[in] dataProvider The PropertyBuffer data provider + */ + void AddPropertyBuffer( SceneGraph::PropertyBuffer* propertyBuffer ); + + /** + * Set the data for the index buffer to be used by the geometry + * @param[in] indices A vector containing the indices + */ + void SetIndexBuffer( Dali::Vector& indices ); + + /** + * Removes a PropertyBuffer from the geometry + * @param[in] propertyBuffer The property buffer to be removed + */ + void RemovePropertyBuffer( const SceneGraph::PropertyBuffer* propertyBuffer ); + + /** + * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers + * @param[out] attributeLocation The vector where the attributes locations will be stored + * @param[in] program The program + * @param[in] bufferIndex The current buffer index + */ + + /** + * Chack if the attributes for the geometry have changed + * @return True if vertex buffers have been added or removed since last frame, false otherwise + */ + bool AttributesChanged() const + { + return mAttributesChanged; + } + + /** + * Sets the geometry type + * @param[in] type The new geometry type + */ + void SetType( Type type ) + { + mGeometryType = type; + } + + /** + * Upload the geometry if it has changed, set up the attributes and perform + * the Draw call corresponding to the geometry type + * @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 + */ + void UploadAndDraw( Graphics::API::Controller& controller, + BufferIndex bufferIndex, + Vector& attributeLocation, + size_t elementBufferOffset, + size_t elementBufferCount ); + + /** + * @return + */ + const Vector< SceneGraph::PropertyBuffer* >& GetVertexBuffers() const + { + return mVertexBuffers; + } + + const Dali::Vector< unsigned short>& GetIndices() const + { + return mIndices; + } + +private: + Integration::Graphics::Graphics* mGraphics; ///< Graphics interface object + + // PropertyBuffers + Vector< SceneGraph::PropertyBuffer* > mVertexBuffers; + Dali::Vector< unsigned short> mIndices; + + Type mGeometryType; + + // Booleans + bool mIndicesChanged : 1; + bool mHasBeenUpdated : 1; + bool mAttributesChanged : 1; +}; + +} // SceneGraph + +// Enums can be passed via message by templating a suitable ParameterType. +template <> struct ParameterType< Dali::Geometry::Type > : public BasicType< Dali::Geometry::Type > {}; + +namespace SceneGraph +{ + +// Custom message type for SetIndexBuffer() used to move data with Vector::Swap() +class IndexBufferMessage : public MessageBase +{ +public: + + /** + * Constructor which does a Vector::Swap() + */ + IndexBufferMessage( SceneGraph::Geometry* geometry, Dali::Vector& indices ) + : MessageBase(), + mGeometry( geometry ) + { + mIndices.Swap( indices ); + } + + /** + * Virtual destructor + */ + virtual ~IndexBufferMessage() + { + } + + /** + * @copydoc MessageBase::Process + */ + virtual void Process( BufferIndex /*bufferIndex*/ ) + { + DALI_ASSERT_DEBUG( mGeometry && "Message does not have an object" ); + mGeometry->SetIndexBuffer( mIndices ); + } + +private: + SceneGraph::Geometry* mGeometry; + Dali::Vector mIndices; +}; + +inline void SetIndexBufferMessage( EventThreadServices& eventThreadServices, SceneGraph::Geometry& geometry, Dali::Vector& indices ) +{ + typedef IndexBufferMessage LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &geometry, indices ); +} + +inline void AttachVertexBufferMessage( EventThreadServices& eventThreadServices, SceneGraph::Geometry& geometry, const SceneGraph::PropertyBuffer& vertexBuffer ) +{ + typedef MessageValue1< SceneGraph::Geometry, SceneGraph::PropertyBuffer* > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &geometry, &Geometry::AddPropertyBuffer, const_cast(&vertexBuffer) ); +} + +inline void RemoveVertexBufferMessage( EventThreadServices& eventThreadServices, SceneGraph::Geometry& geometry, const SceneGraph::PropertyBuffer& vertexBuffer ) +{ + typedef MessageValue1< SceneGraph::Geometry, const SceneGraph::PropertyBuffer* > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &geometry, &Geometry::RemovePropertyBuffer, &vertexBuffer ); +} + +inline void SetGeometryTypeMessage( EventThreadServices& eventThreadServices, SceneGraph::Geometry& geometry, Dali::Geometry::Type geometryType ) +{ + typedef MessageValue1< Geometry, Dali::Geometry::Type > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &geometry, &Geometry::SetType, geometryType ); +} + +} // namespace SceneGraph +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_H diff --git a/dali/internal/update/rendering/scene-graph-property-buffer.cpp b/dali/internal/update/rendering/scene-graph-property-buffer.cpp new file mode 100644 index 0000000..708e17e --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-property-buffer.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2018 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 + +// INTERNAL HEADERS +#include // Dali::Internal::PropertyBuffer +#include +#include + + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +PropertyBuffer::PropertyBuffer() +: mGraphics( nullptr ), + mFormat( nullptr ), + mData( nullptr ), + mSize(0), + mDataChanged(true), + mGraphicsBuffer{ nullptr }, + mGraphicsBufferUsage{ Graphics::API::Buffer::UsageHint::ATTRIBUTES } +{ +} + +PropertyBuffer::~PropertyBuffer() +{ +} + +void PropertyBuffer::Initialize( Integration::Graphics::Graphics& graphics ) +{ + mGraphics = &graphics; +} + +void PropertyBuffer::SetUsage( Graphics::API::Buffer::UsageHint usage ) +{ + mGraphicsBufferUsage = usage; +} + +void PropertyBuffer::SetFormat( OwnerPointer< PropertyBuffer::Format >& format ) +{ + mFormat.Swap( format ); + mDataChanged = true; +} + +void PropertyBuffer::SetData( OwnerPointer< Dali::Vector >& data, size_t size ) +{ + mData.Swap( data ); + mSize = size; + mDataChanged = true; + + if( mGraphics ) + { + auto& controller = mGraphics->GetController(); + mGraphicsBuffer = controller.CreateBuffer( controller.GetBufferFactory() + .SetSize( uint32_t( mFormat->size * size) ) + .SetUsage(Graphics::API::Buffer::UsageHint::ATTRIBUTES )); + + } +} + +bool PropertyBuffer::Update( Dali::Graphics::API::Controller& controller ) +{ + if( !mData || !mFormat || !mSize ) + { + return false; + } + + if( mDataChanged || !mGraphicsBuffer ) + { + if( !mGraphicsBuffer ) + { + mGraphicsBuffer = controller.CreateBuffer( controller.GetBufferFactory() + .SetUsage( mGraphicsBufferUsage ) + .SetSize( mSize ) ); + } + + // schedule deferred write + mGraphicsBuffer.Get().Write( mData.Get()->begin(), GetDataSize(), 0u ); + + mDataChanged = false; + } + + return true; +} + +} //Render +} //Internal +} //Dali diff --git a/dali/internal/render/renderers/render-property-buffer.h b/dali/internal/update/rendering/scene-graph-property-buffer.h similarity index 61% rename from dali/internal/render/renderers/render-property-buffer.h rename to dali/internal/update/rendering/scene-graph-property-buffer.h index 655bfc4..5028a76 100644 --- a/dali/internal/render/renderers/render-property-buffer.h +++ b/dali/internal/update/rendering/scene-graph-property-buffer.h @@ -1,8 +1,8 @@ -#ifndef DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H -#define DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H +#ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BUFFER_H +#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BUFFER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,11 +19,13 @@ #include #include #include -#include -#include -#include #include #include +#include +#include +#include +#include +#include namespace Dali { @@ -37,7 +39,7 @@ class Controller; namespace Internal { -namespace Render +namespace SceneGraph { class PropertyBuffer @@ -72,13 +74,21 @@ public: ~PropertyBuffer(); /** + * Initialize the shader object with the Graphics API when added to UpdateManager + * + * @param[in] graphics The Graphics API + */ + void Initialize( Integration::Graphics::Graphics& graphics ); + + /** * @brief Set the format of the buffer * * This function takes ownership of the pointer * * @param[in] format The format for the PropertyBuffer */ - void SetFormat( PropertyBuffer::Format* format ); + void SetFormat( OwnerPointer& format ); + /** * @brief Set the data of the PropertyBuffer @@ -87,7 +97,7 @@ public: * @param[in] data The new data of the PropertyBuffer * @param[in] size The new size of the buffer */ - void SetData( Dali::Vector* data, size_t size ); + void SetData( OwnerPointer< Dali::Vector >& data, size_t size ); /** * @brief Set the number of elements @@ -96,36 +106,13 @@ public: void SetSize( unsigned int size ); /** - * @brief Bind the property buffer - * @param[in] target The binding point - */ - void BindBuffer(GpuBuffer::Target target); - -#if 0 - /** - * Perform the upload of the buffer only when requiered - * @param[in] context The GL context - */ - bool Update( Context& context ); -#endif - - /** * Perform the upload of the buffer only when required - * @param controller + * @param[in] controller * @return */ bool Update( Dali::Graphics::API::Controller& controller ); /** - * Enable the vertex attributes for each vertex buffer from the corresponding - * shader program. - * @param[in] context The GL context - * @param[in] vAttributeLocation Vector containing attributes location for current program - * @param[in] locationBase Index in vAttributeLocation corresponding to the first attribute defined by this buffer - */ - unsigned int EnableVertexAttributes( Context& context, Vector& vAttributeLocation, unsigned int locationBase ); - - /** * Get the number of attributes present in the buffer * @return The number of attributes stored in this buffer */ @@ -175,62 +162,60 @@ public: return mSize; } - /** - * Retrieve reference to the data storage vector - * @return Reference to the data storage - */ - inline const Dali::Vector< char >& GetData() const - { - return *mData.Get(); - } - - /** - * Retrieve data writeable pointer ( direct access to the buffer data ) - * @return Pointer to data converted to requested type - */ - template - inline T* GetDataTypedPtr() - { - Dali::Vector< char >* data = mData.Release(); - mData = data; - return reinterpret_cast( &data->operator[]( 0 ) ); - } - inline const PropertyBuffer::Format* GetFormat() const { return mFormat.Get(); } - - inline void SetGfxObject( Graphics::API::Accessor gfxObject ) - { - mGfxBuffer = gfxObject; - } - inline Graphics::API::Accessor GetGfxObject() const { - return mGfxBuffer; + return mGraphicsBuffer; } void SetUsage( Graphics::API::Buffer::UsageHint usage ); private: + Integration::Graphics::Graphics* mGraphics; ///< Graphics interface object OwnerPointer< PropertyBuffer::Format > mFormat; ///< Format of the buffer OwnerPointer< Dali::Vector< char > > mData; ///< Data - OwnerPointer< GpuBuffer > mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderPropertyBuffer size_t mSize; ///< Number of Elements in the buffer bool mDataChanged; ///< Flag to know if data has changed in a frame // GRAPHICS - Graphics::API::Accessor mGfxBuffer; - Graphics::API::Buffer::UsageHint mGfxBufferUsage; + Graphics::API::Accessor mGraphicsBuffer; + Graphics::API::Buffer::UsageHint mGraphicsBufferUsage; }; -} // namespace Render + +inline void SetPropertyBufferFormatMessage( EventThreadServices& eventThreadServices, SceneGraph::PropertyBuffer& propertyBuffer, OwnerPointer< SceneGraph::PropertyBuffer::Format>& format ) +{ + // Message has ownership of PropertyBuffer::Format while in transit from event -> update + typedef MessageValue1< SceneGraph::PropertyBuffer, OwnerPointer< SceneGraph::PropertyBuffer::Format> > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &propertyBuffer, &PropertyBuffer::SetFormat, format ); +} + +inline void SetPropertyBufferDataMessage( EventThreadServices& eventThreadServices, SceneGraph::PropertyBuffer& propertyBuffer, OwnerPointer< Vector >& data, size_t size ) +{ + // Message has ownership of PropertyBuffer data while in transit from event -> update + typedef MessageValue2< SceneGraph::PropertyBuffer, OwnerPointer< Vector >, size_t > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &propertyBuffer, &PropertyBuffer::SetData, data, size ); +} + +} // namespace SceneGraph } // namespace Internal } // namespace Dali -#endif // DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H +#endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BUFFER_H diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index 7fbced7..f0ef54a 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,15 +25,12 @@ // INTERNAL INCLUDES #include #include -#include -#include #include +#include +#include +#include #include -#include -#include -#include -#include -#include +#include #include #include @@ -161,8 +158,7 @@ Renderer* Renderer::New() } Renderer::Renderer() -: mSceneController( 0 ), - mRenderer( NULL ), +: mRenderDataProvider(), mTextureSet( NULL ), mGeometry( NULL ), mShader( NULL ), @@ -253,8 +249,6 @@ void Renderer::PrepareRender( Graphics::API::Controller& controller, BufferIndex } } - - /** * REGENERATE UNIFORM MAP */ @@ -292,9 +286,6 @@ void Renderer::PrepareRender( Graphics::API::Controller& controller, BufferIndex mRegenerateUniformMap--; } - - - auto& shader = mShader->GetGfxObject().Get(); auto uboCount = shader.GetUniformBlockCount(); @@ -478,141 +469,7 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex ) if( mResendFlag != 0 ) { - if( mResendFlag & RESEND_DATA_PROVIDER ) - { - OwnerPointer dataProvider = NewRenderDataProvider(); - - typedef MessageValue1< Render::Renderer, OwnerPointer > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderDataProvider, dataProvider ); - } - - if( mResendFlag & RESEND_GEOMETRY ) - { - typedef MessageValue1< Render::Renderer, Render::Geometry* > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetGeometry, mGeometry ); - } - - if( mResendFlag & RESEND_FACE_CULLING_MODE ) - { - typedef MessageValue1< Render::Renderer, FaceCullingMode::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetFaceCullingMode, mFaceCullingMode ); - } - - if( mResendFlag & RESEND_BLEND_BIT_MASK ) - { - typedef MessageValue1< Render::Renderer, unsigned int > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendingBitMask, mBlendBitmask ); - } - - if( mResendFlag & RESEND_BLEND_COLOR ) - { - typedef MessageValue1< Render::Renderer, Vector4 > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendColor, GetBlendColor() ); - } - - if( mResendFlag & RESEND_PREMULTIPLIED_ALPHA ) - { - typedef MessageValue1< Render::Renderer, bool > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::EnablePreMultipliedAlpha, mPremultipledAlphaEnabled ); - } - - if( mResendFlag & RESEND_INDEXED_DRAW_FIRST_ELEMENT ) - { - typedef MessageValue1< Render::Renderer, size_t > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetIndexedDrawFirstElement, mIndexedDrawFirstElement ); - } - - if( mResendFlag & RESEND_INDEXED_DRAW_ELEMENTS_COUNT ) - { - typedef MessageValue1< Render::Renderer, size_t > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetIndexedDrawElementsCount, mIndexedDrawElementsCount ); - } - - if( mResendFlag & RESEND_DEPTH_WRITE_MODE ) - { - typedef MessageValue1< Render::Renderer, DepthWriteMode::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthWriteMode, mDepthWriteMode ); - } - - if( mResendFlag & RESEND_DEPTH_TEST_MODE ) - { - typedef MessageValue1< Render::Renderer, DepthTestMode::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthTestMode, mDepthTestMode ); - } - - if( mResendFlag & RESEND_DEPTH_FUNCTION ) - { - typedef MessageValue1< Render::Renderer, DepthFunction::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction ); - } - - if( mResendFlag & RESEND_RENDER_MODE ) - { - typedef MessageValue1< Render::Renderer, RenderMode::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode ); - } - - if( mResendFlag & RESEND_STENCIL_FUNCTION ) - { - typedef MessageValue1< Render::Renderer, StencilFunction::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunction, mStencilParameters.stencilFunction ); - } - - if( mResendFlag & RESEND_STENCIL_FUNCTION_MASK ) - { - typedef MessageValue1< Render::Renderer, int > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunctionMask, mStencilParameters.stencilFunctionMask ); - } - - if( mResendFlag & RESEND_STENCIL_FUNCTION_REFERENCE ) - { - typedef MessageValue1< Render::Renderer, int > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunctionReference, mStencilParameters.stencilFunctionReference ); - } - - if( mResendFlag & RESEND_STENCIL_MASK ) - { - typedef MessageValue1< Render::Renderer, int > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilMask, mStencilParameters.stencilMask ); - } - - if( mResendFlag & RESEND_STENCIL_OPERATION_ON_FAIL ) - { - typedef MessageValue1< Render::Renderer, StencilOperation::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnFail, mStencilParameters.stencilOperationOnFail ); - } - - if( mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_FAIL ) - { - typedef MessageValue1< Render::Renderer, StencilOperation::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZFail, mStencilParameters.stencilOperationOnZFail ); - } - - if( mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_PASS ) - { - typedef MessageValue1< Render::Renderer, StencilOperation::Type > DerivedType; - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZPass, mStencilParameters.stencilOperationOnZPass ); - } - + // This used to send messages to obsolete Render::Renderer at this point mResendFlag = 0; } } @@ -647,15 +504,10 @@ void Renderer::SetShader( Shader* shader ) mResendFlag |= RESEND_DATA_PROVIDER; } -void Renderer::SetGeometry( Render::Geometry* geometry ) +void Renderer::SetGeometry( SceneGraph::Geometry* geometry ) { DALI_ASSERT_DEBUG( geometry != NULL && "Geometry pointer is NULL"); mGeometry = geometry; - - if( mRenderer ) - { - mResendFlag |= RESEND_GEOMETRY; - } } void Renderer::SetDepthIndex( int depthIndex ) @@ -789,51 +641,31 @@ void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperati } //Called when SceneGraph::Renderer is added to update manager ( that happens when an "event-thread renderer" is created ) -void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex ) +void Renderer::ConnectToSceneGraph( BufferIndex bufferIndex ) { mRegenerateUniformMap = REGENERATE_UNIFORM_MAP; - mSceneController = &sceneController; - RenderDataProvider* dataProvider = NewRenderDataProvider(); - - mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast< FaceCullingMode::Type >( mFaceCullingMode ), - mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters ); - - OwnerPointer< Render::Renderer > transferOwnership( mRenderer ); - mSceneController->GetRenderMessageDispatcher().AddRenderer( transferOwnership ); -} - -//Called just before destroying the scene-graph renderer ( when the "event-thread renderer" is no longer referenced ) -void Renderer::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex ) -{ - //Remove renderer from RenderManager - if( mRenderer ) - { - mSceneController->GetRenderMessageDispatcher().RemoveRenderer( *mRenderer ); - mRenderer = NULL; - } - mSceneController = NULL; -} -RenderDataProvider* Renderer::NewRenderDataProvider() -{ - RenderDataProvider* dataProvider = new RenderDataProvider(); + mRenderDataProvider = std::make_unique< RenderDataProvider >(); - dataProvider->mUniformMapDataProvider = this; - dataProvider->mShader = mShader; + mRenderDataProvider->mUniformMapDataProvider = this; + mRenderDataProvider->mShader = mShader; if( mTextureSet ) { size_t textureCount = mTextureSet->GetTextureCount(); - dataProvider->mTextures.resize( textureCount ); - dataProvider->mSamplers.resize( textureCount ); + mRenderDataProvider->mTextures.resize( textureCount ); + mRenderDataProvider->mSamplers.resize( textureCount ); for( unsigned int i(0); imTextures[i] = mTextureSet->GetTexture(i); - dataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i); + mRenderDataProvider->mTextures[i] = mTextureSet->GetTexture(i); + mRenderDataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i); } } +} - return dataProvider; +//Called just before destroying the scene-graph renderer ( when the "event-thread renderer" is no longer referenced ) +void Renderer::DisconnectFromSceneGraph( BufferIndex bufferIndex ) +{ } const Vector4& Renderer::GetBlendColor() const @@ -845,11 +677,6 @@ const Vector4& Renderer::GetBlendColor() const return Color::TRANSPARENT; } -Render::Renderer& Renderer::GetRenderer() -{ - return *mRenderer; -} - const CollectedUniformMap& Renderer::GetUniformMap( BufferIndex bufferIndex ) const { return mCollectedUniformMap[bufferIndex]; @@ -942,4 +769,4 @@ void Renderer::ObservedObjectDestroyed(PropertyOwner& owner) } // namespace Internal } // namespace Dali -#pragma GCC diagnostic pop \ No newline at end of file +#pragma GCC diagnostic pop diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index cc8abd9..ddb8ae1 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -25,8 +25,10 @@ #include #include #include -#include -#include +#include +#include +#include +#include namespace Dali { @@ -34,28 +36,24 @@ namespace Dali namespace Internal { -namespace Render -{ -class Renderer; -class Geometry; -} + namespace SceneGraph { +class Geometry; class SceneController; +class TextureSet; class Renderer; typedef Dali::Vector< Renderer* > RendererContainer; typedef RendererContainer::Iterator RendererIter; typedef RendererContainer::ConstIterator RendererConstIter; -class TextureSet; -class Geometry; -class Renderer : public PropertyOwner, - public UniformMapDataProvider, - public UniformMap::Observer, - public ConnectionChangePropagator::Observer +class Renderer : public PropertyOwner, + public UniformMapDataProvider, + public UniformMap::Observer, + public ConnectionChangePropagator::Observer { public: @@ -116,9 +114,13 @@ public: * Set the geometry for the renderer * @param[in] geometry The geometry this renderer will use */ - void SetGeometry( Render::Geometry* geometry ); + void SetGeometry( SceneGraph::Geometry* geometry ); - Render::Geometry* GetGeometry() const + /** + * Get the geometry for the renderer + * @return The geometry this renderer will use + */ + SceneGraph::Geometry* GetGeometry() const { return mGeometry; } @@ -258,13 +260,7 @@ public: * @param controller * @param updateBufferIndex */ - void PrepareRender( class Graphics::API::Controller& controller, BufferIndex updateBufferIndex ); - - /* - * Retrieve the Render thread renderer - * @return The associated render thread renderer - */ - Render::Renderer& GetRenderer(); + void PrepareRender( Graphics::API::Controller& controller, BufferIndex updateBufferIndex ); Graphics::API::RenderCommand& GetGfxRenderCommand() { @@ -300,17 +296,15 @@ public: /** * Connect the object to the scene graph * - * @param[in] sceneController The scene controller - used for sending messages to render thread * @param[in] bufferIndex The current buffer index - used for sending messages to render thread */ - void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex ); + void ConnectToSceneGraph( BufferIndex bufferIndex ); /** * Disconnect the object from the scene graph - * @param[in] sceneController The scene controller - used for sending messages to render thread * @param[in] bufferIndex The current buffer index - used for sending messages to render thread */ - void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex ); + void DisconnectFromSceneGraph( BufferIndex bufferIndex ); public: // Implementation of ConnectionChangePropagator /** @@ -387,14 +381,13 @@ private: private: CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer - SceneController* mSceneController; ///< Used for initializing renderers - Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager) + std::unique_ptr mRenderDataProvider; ///< Contains data for graphics renderer @todo Refactor TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned) - Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned) + SceneGraph::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned) Shader* mShader; ///< The shader this renderer uses. (Not owned) OwnerPointer< Vector4 > mBlendColor; ///< The blend color for blending operation - Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options + StencilParameters mStencilParameters; ///< Struct containing all stencil related options size_t mIndexedDrawFirstElement; ///< first element index to be drawn using indexed draw size_t mIndexedDrawElementsCount; ///< number of elements to be drawn using indexed draw @@ -411,12 +404,11 @@ private: bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required - std::vector> mUboMemory; ///< Transient memory allocated for each UBO - std::unique_ptr mGfxRenderCommand; -public: + std::vector> mUboMemory; ///< Transient memory allocated for each UBO + std::unique_ptr mGfxRenderCommand; +public: int mDepthIndex; ///< Used only in PrepareRenderInstructions - }; @@ -432,15 +424,15 @@ inline void SetTexturesMessage( EventThreadServices& eventThreadServices, const new (slot) LocalType( &renderer, &Renderer::SetTextures, const_cast(&textureSet) ); } -inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry ) +inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const SceneGraph::Geometry& geometry ) { - typedef MessageValue1< Renderer, Render::Geometry* > LocalType; + typedef MessageValue1< Renderer, SceneGraph::Geometry* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast(&geometry) ); + new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast(&geometry) ); } inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Shader& shader ) diff --git a/dali/internal/update/rendering/scene-graph-sampler.h b/dali/internal/update/rendering/scene-graph-sampler.h new file mode 100644 index 0000000..de72672 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-sampler.h @@ -0,0 +1,133 @@ +#ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H +#define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H + +/* + * Copyright (c) 2018 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. + */ + +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +struct Sampler +{ + + typedef Dali::FilterMode::Type FilterMode; + typedef Dali::WrapMode::Type WrapMode; + + /** + * Constructor + */ + Sampler() + :mMinificationFilter(FilterMode::DEFAULT), + mMagnificationFilter(FilterMode::DEFAULT), + mSWrapMode(WrapMode::DEFAULT), + mTWrapMode(WrapMode::DEFAULT), + mRWrapMode(WrapMode::DEFAULT) + {} + + /** + * Destructor + */ + ~Sampler() + {} + + + /** + * Sets the filter modes for an existing sampler + * @param[in] sampler The sampler + * @param[in] minFilterMode The filter to use under minification + * @param[in] magFilterMode The filter to use under magnification + */ + void SetFilterMode( unsigned int minFilterMode, unsigned int magFilterMode ) + { + mMinificationFilter = static_cast(minFilterMode); + mMagnificationFilter = static_cast(magFilterMode ); + } + + /** + * Sets the wrap mode for an existing sampler + * @param[in] sampler The sampler + * @param[in] rWrapMode Wrapping mode in z direction + * @param[in] sWrapMode Wrapping mode in x direction + * @param[in] tWrapMode Wrapping mode in y direction + */ + void SetWrapMode( unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) + { + mRWrapMode = static_cast(rWrapMode); + mSWrapMode = static_cast(sWrapMode); + mTWrapMode = static_cast(tWrapMode); + } + + bool operator==(const Sampler& rhs) const + { + return ( ( mMinificationFilter == rhs.mMinificationFilter ) && + ( mMagnificationFilter == rhs.mMagnificationFilter ) && + ( mSWrapMode == rhs.mSWrapMode ) && + ( mTWrapMode == rhs.mTWrapMode ) && + ( mRWrapMode == rhs.mRWrapMode ) ); + } + + bool operator!=(const Sampler& rhs) const + { + return !(*this == rhs); + } + + FilterMode mMinificationFilter : 4; ///< The minify filter + FilterMode mMagnificationFilter : 4; ///< The magnify filter + WrapMode mSWrapMode : 4; ///< The horizontal wrap mode + WrapMode mTWrapMode : 4; ///< The vertical wrap mode + WrapMode mRWrapMode : 4; ///< The vertical wrap mode +}; + + +inline void SetFilterModeMessage( EventThreadServices& eventThreadServices, SceneGraph::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode ) +{ + typedef MessageValue2< SceneGraph::Sampler, unsigned int, unsigned int > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &sampler, &Sampler::SetFilterMode, minFilterMode, magFilterMode ); +} + +inline void SetWrapModeMessage( EventThreadServices& eventThreadServices, SceneGraph::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) +{ + typedef MessageValue3< SceneGraph::Sampler, unsigned int, unsigned int, unsigned int > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &sampler, &Sampler::SetWrapMode, rWrapMode, sWrapMode, tWrapMode ); +} + +} // namespace SceneGraph + +} // namespace Internal + +} // namespace Dali + + +#endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H diff --git a/dali/internal/update/rendering/scene-graph-shader.cpp b/dali/internal/update/rendering/scene-graph-shader.cpp new file mode 100644 index 0000000..e9f1a5a --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-shader.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018 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 + +// INTERNAL INCLUDES +#define DEBUG_OVERRIDE_VULKAN_SHADER +#ifdef DEBUG_OVERRIDE_VULKAN_SHADER +#include +#endif + +namespace Dali +{ + +namespace Internal +{ + +namespace SceneGraph +{ + +Shader::Shader( Dali::Shader::Hint::Value& hints ) +: mGraphics( nullptr ), + mGraphicsShader( nullptr ), + mShaderCache( nullptr ), + mHints( hints ), + mConnectionObservers() +{ + AddUniformMapObserver( *this ); +} + +Shader::~Shader() +{ + mConnectionObservers.Destroy( *this ); +} + +void Shader::Initialize( Integration::Graphics::Graphics& graphics, ShaderCache& shaderCache ) +{ + mGraphics = &graphics; + mShaderCache = &shaderCache; +} + +Graphics::API::Accessor& Shader::GetGfxObject() +{ + return mGraphicsShader; +} + +void Shader::AddConnectionObserver( ConnectionChangePropagator::Observer& observer ) +{ + mConnectionObservers.Add(observer); +} + +void Shader::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer ) +{ + mConnectionObservers.Remove(observer); +} + +void Shader::UniformMappingsChanged( const UniformMap& mappings ) +{ + // Our uniform map, or that of one of the watched children has changed. + // Inform connected observers. + mConnectionObservers.ConnectedUniformMapChanged(); +} + +void Shader::SetShaderProgram( Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) +{ + // TODO: for now we will use hardcoded binary SPIRV shaders which will replace anything + // that is passed by the caller +#ifdef DEBUG_OVERRIDE_VULKAN_SHADER + + mGraphicsShader = mShaderCache->GetShader( Graphics::API::ShaderDetails::ShaderSource( VSH_IMAGE_VISUAL_CODE ), + Graphics::API::ShaderDetails::ShaderSource( FSH_IMAGE_VISUAL_CODE )); + +#else + auto& controller = mGraphics->GetController(); + + mGraphicsShader = controller.CreateShader( + controller.GetShaderFactory() + .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::VERTEX, + Graphics::API::ShaderDetails::Language::SPIRV_1_0, + Graphics::API::ShaderDetails::ShaderSource( shaderData->GetVertexShader() )) + .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::FRAGMENT, + Graphics::API::ShaderDetails::Language::SPIRV_1_0, + Graphics::API::ShaderDetails::ShaderSource( shaderData->GetFragmentShader() )) ); +#endif +} + + +} // namespace SceneGraph + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/render/shaders/scene-graph-shader.h b/dali/internal/update/rendering/scene-graph-shader.h similarity index 54% rename from dali/internal/render/shaders/scene-graph-shader.h rename to dali/internal/update/rendering/scene-graph-shader.h index 3bfd542..0c4d09a 100644 --- a/dali/internal/render/shaders/scene-graph-shader.h +++ b/dali/internal/update/rendering/scene-graph-shader.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SCENE_GRAPH_SHADER_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,27 +19,33 @@ */ // INTERNAL INCLUDES +#include +#include +#include + +#include + +#include #include +#include #include #include -#include -#include +#include namespace Dali { namespace Internal { -class Program; -class ProgramCache; - namespace SceneGraph { class ConnectionObserver; class SceneController; + /** - * A holder class for Program; also enables sharing of uniform properties + * Owner of Graphics Shader; also enables sharing of uniform properties. + * Owned by UpdateManager. */ class Shader : public PropertyOwner, public UniformMap::Observer { @@ -56,9 +62,13 @@ public: */ virtual ~Shader(); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // The following methods are called during Update - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * Initialize the shader object with the Graphics API when added to UpdateManager + * + * @param[in] graphics The Graphics API + * @param[in] shaderCache A cache + */ + void Initialize( Integration::Graphics::Graphics& graphics, ShaderCache& shaderCache ); /** * Query whether a shader hint is set. @@ -72,22 +82,6 @@ public: } /** - * @return True if the fragment shader outputs only 1.0 on the alpha channel - * - * @note Shaders that can output any value on the alpha channel - * including 1.0 should return false for this. - */ - bool IsOutputOpaque(); - - /** - * @return True if the fragment shader can output any value but 1.0 on the alpha channel - * - * @note Shaders that can output any value on the alpha channel - * including 1.0 should return false for this - */ - bool IsOutputTransparent(); - - /** * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties */ virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) @@ -95,30 +89,20 @@ public: // no default properties } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // The following methods are called during Render - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * @brief Set the program for this shader. - * @param[in] shaderData The program's vertex/fragment source and optionally precompiled shader binary. - * @param[in] programCache Owner of the Programs. - * @param[in] modifiesGeometry True if the vertex shader changes the positions of vertexes such that - * they might exceed the bounding box of vertexes passing through the default transformation. + * Get the graphics shader object + * @return the graphics shader object */ - void SetProgram( Internal::ShaderDataPtr shaderData, - ProgramCache* programCache, - bool modifiesGeometry ); - - void SetGfxObject( const Graphics::API::Accessor& shader ); - Graphics::API::Accessor& GetGfxObject(); +public: // Messages /** - * Get the program built for this shader - * @return The program built from the shader sources. + * Set the shader data into the graphics API. + * + * @param[in] shaderData The shader source or binary. + * @param[in] modifiesGeometry Hint to say if the shader modifies geometry. (useful for culling) */ - Program* GetProgram(); + void SetShaderProgram( Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); public: // Implementation of ConnectionChangePropagator @@ -138,16 +122,31 @@ public: // UniformMap::Observer */ virtual void UniformMappingsChanged( const UniformMap& mappings ); + private: // Data + Integration::Graphics::Graphics* mGraphics; ///< Graphics interface object + Graphics::API::Accessor mGraphicsShader; ///< The graphics object + ShaderCache* mShaderCache; + Dali::Shader::Hint::Value mHints; ///< Hints for the shader + ConnectionChangePropagator mConnectionObservers; ///< Watch for connection changes +}; - Dali::Shader::Hint::Value mHints; - Program* mProgram; +inline void SetShaderProgramMessage( EventThreadServices& eventThreadServices, + Shader& shader, + Internal::ShaderDataPtr shaderData, + bool modifiesGeometry ) +{ + typedef MessageValue2< Shader, Internal::ShaderDataPtr, bool > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &shader, &Shader::SetShaderProgram, shaderData, modifiesGeometry ); +} - ConnectionChangePropagator mConnectionObservers; - Graphics::API::Accessor mGfxShader; -}; } // namespace SceneGraph diff --git a/dali/internal/update/rendering/scene-graph-texture-set.cpp b/dali/internal/update/rendering/scene-graph-texture-set.cpp index a5e7df8..c9d614b 100644 --- a/dali/internal/update/rendering/scene-graph-texture-set.cpp +++ b/dali/internal/update/rendering/scene-graph-texture-set.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -63,7 +63,7 @@ void TextureSet::operator delete( void* ptr ) gTextureSetMemoryPool.FreeThreadSafe( static_cast( ptr ) ); } -void TextureSet::SetSampler( size_t index, Render::Sampler* sampler ) +void TextureSet::SetSampler( size_t index, SceneGraph::Sampler* sampler ) { size_t samplerCount( mSamplers.Size() ); if( samplerCount < index + 1 ) @@ -79,7 +79,7 @@ void TextureSet::SetSampler( size_t index, Render::Sampler* sampler ) NotifyChangeToRenderers(); } -void TextureSet::SetTexture( size_t index, Render::Texture* texture ) +void TextureSet::SetTexture( size_t index, SceneGraph::Texture* texture ) { const size_t textureCount( mTextures.Size() ); if( textureCount < index + 1 ) diff --git a/dali/internal/update/rendering/scene-graph-texture-set.h b/dali/internal/update/rendering/scene-graph-texture-set.h index fdb52a5..96445f0 100644 --- a/dali/internal/update/rendering/scene-graph-texture-set.h +++ b/dali/internal/update/rendering/scene-graph-texture-set.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -27,15 +27,12 @@ namespace Dali { namespace Internal { - -namespace Render -{ -struct Sampler; -class Texture; -} namespace SceneGraph { + class Renderer; +class Sampler; +class Texture; class TextureSet { @@ -62,14 +59,14 @@ public: * @param[in] index The index of the texture * @param[in] sampler The sampler to be used by the texture */ - void SetSampler( size_t index, Render::Sampler* sampler ); + void SetSampler( size_t index, SceneGraph::Sampler* sampler ); /** * Set the texture at position "index" * @param[in] index The index of the texture * @param[in] texture The texture */ - void SetTexture( size_t index, Render::Texture* texture ); + void SetTexture( size_t index, SceneGraph::Texture* texture ); /** * Return whether any texture in the texture set has an alpha channel @@ -97,7 +94,7 @@ public: * @param[in] index The index of the texture in the textures array * @return the sampler used by the texture */ - Render::Sampler* GetTextureSampler( size_t index ) + SceneGraph::Sampler* GetTextureSampler( size_t index ) { return mSamplers[index]; } @@ -116,7 +113,7 @@ public: * @param[in] index The index of the texture in the textures array * @return the pointer to the Texture in that position */ - Render::Texture* GetTexture( size_t index ) + SceneGraph::Texture* GetTexture( size_t index ) { return mTextures[index]; } @@ -136,15 +133,15 @@ private: private: // Data - Vector< Render::Sampler* > mSamplers; ///< List of samplers used by each texture. Not owned - Vector< Render::Texture* > mTextures; ///< List of Textures. Not owned - Vector mRenderers; ///< List of renderers using the TextureSet - bool mHasAlpha; ///< if any of the textures has an alpha channel + Vector< SceneGraph::Sampler* > mSamplers; ///< List of samplers used by each texture. Not owned + Vector< SceneGraph::Texture* > mTextures; ///< List of Textures. Not owned + Vector mRenderers; ///< List of renderers using the TextureSet + bool mHasAlpha; ///< if any of the textures has an alpha channel }; -inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, Render::Texture* texture ) +inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, SceneGraph::Texture* texture ) { - typedef MessageValue2< TextureSet, size_t, Render::Texture* > LocalType; + typedef MessageValue2< TextureSet, size_t, SceneGraph::Texture* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); @@ -153,9 +150,9 @@ inline void SetTextureMessage( EventThreadServices& eventThreadServices, const T new (slot) LocalType( &textureSet, &TextureSet::SetTexture, index, texture ); } -inline void SetSamplerMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, Render::Sampler* sampler ) +inline void SetSamplerMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, SceneGraph::Sampler* sampler ) { - typedef MessageValue2< TextureSet, size_t, Render::Sampler* > LocalType; + typedef MessageValue2< TextureSet, size_t, SceneGraph::Sampler* > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); diff --git a/dali/internal/update/rendering/scene-graph-texture.cpp b/dali/internal/update/rendering/scene-graph-texture.cpp new file mode 100644 index 0000000..2d48974 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-texture.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2018 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 + +// INTERNAL INCLUDES +#include // Dali::ImageDimensions +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +namespace +{ + +/** + * @brief Whether specified pixel format is compressed. + * + * @param [in] pixelformat Pixel format + * @return true if format is compressed, false otherwise + */ +bool IsCompressedFormat(Pixel::Format pixelFormat) +{ + switch (pixelFormat) + { + case Pixel::L8: + case Pixel::A8: + case Pixel::LA88: + case Pixel::RGB565: + case Pixel::RGBA4444: + case Pixel::RGBA5551: + case Pixel::BGR565: + case Pixel::BGRA4444: + case Pixel::BGRA5551: + case Pixel::RGB888: + case Pixel::RGB8888: + case Pixel::BGR8888: + case Pixel::RGBA8888: + case Pixel::BGRA8888: + case Pixel::RGB16F: + case Pixel::RGB32F: + case Pixel::INVALID: + { + return false; + } + + case Pixel::COMPRESSED_R11_EAC: + case Pixel::COMPRESSED_SIGNED_R11_EAC: + case Pixel::COMPRESSED_RG11_EAC: + case Pixel::COMPRESSED_SIGNED_RG11_EAC: + case Pixel::COMPRESSED_RGB8_ETC2: + case Pixel::COMPRESSED_SRGB8_ETC2: + case Pixel::COMPRESSED_RGB8_ETC1: + case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1: + case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case Pixel::COMPRESSED_RGBA8_ETC2_EAC: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR: + case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + { + return true; + } + } + + return false; +} +} //Unnamed namespace + + +Texture::Texture( Type type, Pixel::Format format, ImageDimensions size ) +: mGraphics( nullptr ), + mGraphicsTexture( nullptr ), + mNativeImage(), + mSampler(), + mId( 0 ), + mWidth( size.GetWidth() ), + mHeight( size.GetHeight() ), + mMaxMipMapLevel( 0 ), + mType( type ), + mHasAlpha( HasAlpha( format ) ), + mIsCompressed( IsCompressedFormat( format ) ) +{ +} + +Texture::Texture( NativeImageInterfacePtr nativeImageInterface ) +: mGraphics( nullptr ), + mGraphicsTexture( nullptr ), + mNativeImage( nativeImageInterface ), + mSampler(), + mId( 0 ), + mWidth( nativeImageInterface->GetWidth() ), + mHeight( nativeImageInterface->GetHeight() ), + mMaxMipMapLevel( 0 ), + mType( TextureType::TEXTURE_2D ), + mHasAlpha( nativeImageInterface->RequiresBlending() ), + mIsCompressed( false ) +{ +} + +Texture::~Texture() +{} + +void Texture::Initialize( Integration::Graphics::Graphics& graphics ) +{ + mGraphics = &graphics; +} + +const Graphics::API::Accessor& Texture::GetGfxObject() const +{ + return mGraphicsTexture; +} + +void Texture::UploadTexture( PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ) +{ + if( mGraphics ) + { + auto& controller = mGraphics->GetController(); + + mGraphicsTexture = controller.CreateTexture( controller.GetTextureFactory() + .SetFormat( Graphics::API::TextureDetails::Format::RGBA8 ) + .SetSize( { pixelData->GetWidth(), pixelData->GetHeight() } ) + .SetType( Graphics::API::TextureDetails::Type::TEXTURE_2D ) + .SetMipMapFlag( Graphics::API::TextureDetails::MipMapFlag::DISABLED ) + .SetData( pixelData->GetBuffer() ) + .SetDataSize( pixelData->GetBufferSize() ) + ); + + mId = static_cast< uint32_t >( mGraphicsTexture.GetHandle() ); + } +} + +bool Texture::HasAlphaChannel() +{ + return mHasAlpha; +} + +void Texture::GenerateMipmaps() +{ + mMaxMipMapLevel = 0; + DALI_LOG_ERROR( "FIXME: GRAPHICS\n"); + //@todo Implement with GraphicsAPI +} + + +} // namespace SceneGraph +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/update/rendering/scene-graph-texture.h b/dali/internal/update/rendering/scene-graph-texture.h new file mode 100644 index 0000000..39ec7f3 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-texture.h @@ -0,0 +1,173 @@ +#ifndef DALI_INTERNAL_SCENE_GRAPH_TEXTURE_H +#define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_H + +/* + * Copyright (c) 2018 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. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include // Dali::ImageDimensions +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +/** + * The SceneGraph::Texture object wraps the Graphics texture object, and is owned + * by the UpdateManager. It is used by SceneGraphRenderer to set up RenderCommands. + */ +class Texture +{ +public: + typedef Dali::TextureType::Type Type; + + /** + * Constructor + * @param[in] type The type of the texture + * @param[in] format The format of the pixel data + * @param[in] size The size of the texture + */ + Texture( Type type, Pixel::Format format, ImageDimensions size ); + + /** + * Constructor from native image + * @param[in] nativeImageInterface The native image + */ + Texture( NativeImageInterfacePtr nativeImageInterface ); + + /** + * Destructor + */ + ~Texture(); + + /** + * Initialize the texture object with the Graphics API when added to UpdateManager + * + * @param[in] graphics The Graphics API + */ + void Initialize( Integration::Graphics::Graphics& graphics ); + + /** + * Retrieve wheter the texture has an alpha channel + * @return True if the texture has alpha channel, false otherwise + */ + bool HasAlphaChannel(); + + /** + * Get the type of the texture + * @return Type of the texture + */ + Type GetType() const + { + return mType; + } + + /** + * Check if the texture is a native image + * @return if the texture is a native image + */ + bool IsNativeImage() const + { + return mNativeImage; + } + + /** + * Get the Graphics object associated with this texture + * @return The graphics object. + */ + const Graphics::API::Accessor& GetGfxObject() const; + + /** + * Get the texture id associated with the graphics texture + */ + uint32_t GetId() + { + return mId; + } + +public: // From messages + /** + * Uploads data to Graphics + * @param[in] pixelData The pixel data object + * @param[in] params The parameters for the upload + */ + void UploadTexture( PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ); + + /** + * Generates mipmaps + */ + void GenerateMipmaps(); + + +private: + Integration::Graphics::Graphics* mGraphics; ///< Graphics interface object + Graphics::API::Accessor mGraphicsTexture; ///< Graphics texture + + NativeImageInterfacePtr mNativeImage; ///< Pointer to native image + SceneGraph::Sampler mSampler; ///< The current sampler state + uint32_t mId; ///< The Graphics texture handle + uint16_t mWidth; ///< Width of the texture + uint16_t mHeight; ///< Height of the texture + uint16_t mMaxMipMapLevel; ///< Maximum mipmap level + Type mType:2; ///< Type of the texture + bool mHasAlpha : 1; ///< Whether the format has an alpha channel + bool mIsCompressed : 1; ///< Whether the format is compressed +}; + + +inline void UploadTextureMessage( EventThreadServices& eventThreadServices, SceneGraph::Texture& texture, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ) +{ + typedef MessageValue2< SceneGraph::Texture, PixelDataPtr, Internal::Texture::UploadParams > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &texture, &SceneGraph::Texture::UploadTexture, pixelData, params ); +} + +inline void GenerateMipmapsMessage( EventThreadServices& eventThreadServices, SceneGraph::Texture& texture ) +{ + typedef Message< SceneGraph::Texture > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &texture, &SceneGraph::Texture::GenerateMipmaps ); +} + +} // namespace SceneGraph + +} // namespace Internal + +} // namespace Dali + + +#endif // DALI_INTERNAL_SCENE_GRAPH_TEXTURE_H diff --git a/dali/internal/update/rendering/shader-cache.cpp b/dali/internal/update/rendering/shader-cache.cpp new file mode 100644 index 0000000..bf7f66b --- /dev/null +++ b/dali/internal/update/rendering/shader-cache.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 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. + */ + +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +ShaderCache::ShaderCache( Dali::Graphics::API::Controller& controller ) +: mController( controller ) +{ +} + +Dali::Graphics::API::Accessor ShaderCache::GetShader( + const Dali::Graphics::API::ShaderDetails::ShaderSource& vsh, + const Dali::Graphics::API::ShaderDetails::ShaderSource& fsh ) +{ + for( auto&& item : mItems ) + { + if( item.vertexSource == vsh && item.fragmentSource == fsh ) + { + return item.shader; + } + } + auto shaderRef = + mController.CreateShader( mController.GetShaderFactory() + .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::VERTEX, + Graphics::API::ShaderDetails::Language::SPIRV_1_0, + vsh ) + .SetShaderModule( Graphics::API::ShaderDetails::PipelineStage::FRAGMENT, + Graphics::API::ShaderDetails::Language::SPIRV_1_0, + fsh ) ); + mItems.emplace_back( Item() = { shaderRef, vsh, fsh } ); + return shaderRef; +} + +} // namespace SceneGraph +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/update/rendering/shader-cache.h b/dali/internal/update/rendering/shader-cache.h new file mode 100644 index 0000000..ae204fc --- /dev/null +++ b/dali/internal/update/rendering/shader-cache.h @@ -0,0 +1,69 @@ +#ifndef DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_H +#define DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_H + +/* + * Copyright (c) 2018 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. + */ + +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +/** + * Caches graphics shaders as they are created by SceneGraph::Shader. + */ +struct ShaderCache +{ + struct Item + { + Item() = default; + ~Item() = default; + Dali::Graphics::API::Accessor shader{ nullptr }; + Dali::Graphics::API::ShaderDetails::ShaderSource vertexSource{""}; + Dali::Graphics::API::ShaderDetails::ShaderSource fragmentSource{""}; + }; + + /** + * Constructor + * + * @param[in] controller The graphics controller + */ + explicit ShaderCache( Dali::Graphics::API::Controller& controller ); + + /** + * Get a shader from it's source code + */ + Dali::Graphics::API::Accessor GetShader( + const Dali::Graphics::API::ShaderDetails::ShaderSource& vsh, + const Dali::Graphics::API::ShaderDetails::ShaderSource& fsh ); + +private: + std::vector mItems; + Dali::Graphics::API::Controller& mController; +}; + +} // namespace SceneGraph +} // namespace Internal +} // namespace Dali + +#endif //DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_H diff --git a/dali/internal/update/rendering/stencil-parameters.h b/dali/internal/update/rendering/stencil-parameters.h new file mode 100644 index 0000000..122188b --- /dev/null +++ b/dali/internal/update/rendering/stencil-parameters.h @@ -0,0 +1,64 @@ +#ifndef DALI_INTERNAL_UPDATE_RENDERING_STENCIL_PARAMETERS_H +#define DALI_INTERNAL_UPDATE_RENDERING_STENCIL_PARAMETERS_H +/* + * Copyright (c) 2018 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. + */ + +#include + +namespace Dali +{ +namespace Internal +{ +namespace SceneGraph +{ + +/** + * @brief Struct to encapsulate stencil parameters required for control of the stencil buffer. + */ +struct StencilParameters +{ + StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask, + int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail, + StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass ) + : stencilFunctionMask ( stencilFunctionMask ), + stencilFunctionReference ( stencilFunctionReference ), + stencilMask ( stencilMask ), + renderMode ( renderMode ), + stencilFunction ( stencilFunction ), + stencilOperationOnFail ( stencilOperationOnFail ), + stencilOperationOnZFail ( stencilOperationOnZFail ), + stencilOperationOnZPass ( stencilOperationOnZPass ) + { + } + + int stencilFunctionMask; ///< The stencil function mask + int stencilFunctionReference; ///< The stencil function reference + int stencilMask; ///< The stencil mask + RenderMode::Type renderMode:3; ///< The render mode + StencilFunction::Type stencilFunction:3; ///< The stencil function + StencilOperation::Type stencilOperationOnFail:3; ///< The stencil operation for stencil test fail + StencilOperation::Type stencilOperationOnZFail:3; ///< The stencil operation for depth test fail + StencilOperation::Type stencilOperationOnZPass:3; ///< The stencil operation for depth test pass +}; + + +} // namespace SceneGraph + +} // namespace Interanl + +} // namespace Dali + +#endif //DALI_INTERNAL_UPDATE_RENDERING_STENCIL_PARAMETERS_H diff --git a/dali/public-api/math/matrix.cpp b/dali/public-api/math/matrix.cpp index 67ade79..4719a1d 100644 --- a/dali/public-api/math/matrix.cpp +++ b/dali/public-api/math/matrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace { diff --git a/dali/public-api/math/quaternion.cpp b/dali/public-api/math/quaternion.cpp index 93db036..46cd4b2 100644 --- a/dali/public-api/math/quaternion.cpp +++ b/dali/public-api/math/quaternion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -27,7 +27,7 @@ #include #include #include -#include +#include namespace Dali { diff --git a/dali/public-api/math/vector2.cpp b/dali/public-api/math/vector2.cpp index 6e4b07a..0e0a162 100644 --- a/dali/public-api/math/vector2.cpp +++ b/dali/public-api/math/vector2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace Dali { diff --git a/dali/public-api/math/vector3.cpp b/dali/public-api/math/vector3.cpp index 2b410d0..6caeb3b 100644 --- a/dali/public-api/math/vector3.cpp +++ b/dali/public-api/math/vector3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace Dali { diff --git a/dali/public-api/math/vector4.cpp b/dali/public-api/math/vector4.cpp index 15815d4..df27600 100644 --- a/dali/public-api/math/vector4.cpp +++ b/dali/public-api/math/vector4.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -27,7 +27,7 @@ #include #include #include -#include +#include namespace Dali { -- 2.7.4