From: Adam Bialogonski Date: Fri, 17 Jun 2022 09:31:04 +0000 (+0100) Subject: Direct Rendering X-Git-Tag: dali_2.1.30~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F276534%2F7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Direct Rendering - Added passing the shared context to the callback - The context created by the draw call now can share the GL resources Change-Id: I20933ec4fbc7812b6589124bcd452ee7a7e317a6 --- diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp index 6a8eab4..fc176e5 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp @@ -32,6 +32,8 @@ #include #include +#include + namespace Dali { std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo) @@ -696,6 +698,13 @@ void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& com case CommandType::DRAW_NATIVE: { auto info = &cmd.data.draw.drawNative.drawNativeInfo; + + if(info->glesNativeInfo.eglSharedContextStoragePointer) + { + auto* anyContext = reinterpret_cast(info->glesNativeInfo.eglSharedContextStoragePointer); + *anyContext = reinterpret_cast(0x12345678u); + } + CallbackBase::ExecuteReturn(*info->callback, info->userData); break; } diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index 0a22d9c..d7b8d33 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp @@ -37,6 +37,10 @@ #include #include +#include + +#include + // Uncomment the following define to turn on frame dumping //#define ENABLE_COMMAND_BUFFER_FRAME_DUMP 1 #include @@ -308,6 +312,12 @@ void EglGraphicsController::ActivateResourceContext() { mCurrentContext = mContext.get(); mCurrentContext->GlContextCreated(); + + if(!mSharedContext) + { + auto eglGraphics = dynamic_cast(mGraphics); + mSharedContext = eglGraphics->GetEglImplementation().GetContext(); + } } void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) @@ -589,6 +599,12 @@ void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& comm mCurrentContext->PrepareForNativeRendering(); + if(info->glesNativeInfo.eglSharedContextStoragePointer) + { + auto* anyContext = reinterpret_cast(info->glesNativeInfo.eglSharedContextStoragePointer); + *anyContext = mSharedContext; + } + CallbackBase::ExecuteReturn(*info->callback, info->userData); mCurrentContext->RestoreFromNativeRendering(); diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.h b/dali/internal/graphics/gles-impl/egl-graphics-controller.h index 6af7383..fd944d3 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.h +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.h @@ -2,7 +2,7 @@ #define DALI_EGL_GRAPHICS_CONTROLLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -756,6 +756,16 @@ public: return mCurrentContext; } + /** + * @brief Returns EGL shared context + * + * @return valid EGL shared context + */ + void* GetSharedContext() const + { + return mSharedContext; + } + private: Integration::GlAbstraction* mGlAbstraction{nullptr}; Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr}; @@ -799,6 +809,8 @@ private: bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down std::queue mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine + + void* mSharedContext{nullptr}; ///< Shared EGL context }; } // namespace Graphics diff --git a/dali/internal/graphics/gles-impl/gles-context.cpp b/dali/internal/graphics/gles-impl/gles-context.cpp index f38ed4a..06de56a 100644 --- a/dali/internal/graphics/gles-impl/gles-context.cpp +++ b/dali/internal/graphics/gles-impl/gles-context.cpp @@ -32,7 +32,6 @@ #include #include - namespace Dali::Graphics::GLES { struct Context::Impl @@ -593,11 +592,23 @@ void Context::ResolveUniformBuffers() void Context::ResolveStandaloneUniforms() { // Find reflection for program - const auto program = static_cast(mImpl->mNewPipeline->GetCreateInfo().programState->program); - const auto ptr = reinterpret_cast(mImpl->mCurrentStandaloneUBOBinding.buffer->GetCPUAllocatedAddress()) + mImpl->mCurrentStandaloneUBOBinding.offset; + const GLES::Program* program{nullptr}; - // Update program uniforms - program->GetImplementation()->UpdateStandaloneUniformBlock(ptr); + if(mImpl->mNewPipeline) + { + program = static_cast(mImpl->mNewPipeline->GetCreateInfo().programState->program); + } + else if(mImpl->mCurrentPipeline) + { + program = static_cast(mImpl->mCurrentPipeline->GetCreateInfo().programState->program); + } + + if(program) + { + const auto ptr = reinterpret_cast(mImpl->mCurrentStandaloneUBOBinding.buffer->GetCPUAllocatedAddress()) + mImpl->mCurrentStandaloneUBOBinding.offset; + // Update program uniforms + program->GetImplementation()->UpdateStandaloneUniformBlock(ptr); + } } void Context::BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin) @@ -1008,7 +1019,7 @@ void Context::PrepareForNativeRendering() attribs.push_back(version % 10); attribs.push_back(EGL_NONE); - mImpl->mNativeDrawContext = eglCreateContext(display, configs[configId], EGL_NO_CONTEXT, attribs.data()); + mImpl->mNativeDrawContext = eglCreateContext(display, configs[configId], mImpl->mController.GetSharedContext(), attribs.data()); } eglMakeCurrent(display, drawSurface, readSurface, mImpl->mNativeDrawContext); diff --git a/dali/internal/window-system/common/gl-window-render-thread.cpp b/dali/internal/window-system/common/gl-window-render-thread.cpp index 9ed0a54..532d61d 100644 --- a/dali/internal/window-system/common/gl-window-render-thread.cpp +++ b/dali/internal/window-system/common/gl-window-render-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -117,8 +117,8 @@ void GlWindowRenderThread::Stop() } void GlWindowRenderThread::RegisterGlCallbacks(CallbackBase* initCallback, - CallbackBase* renderFrameCallback, - CallbackBase* terminateCallback) + CallbackBase* renderFrameCallback, + CallbackBase* terminateCallback) { mGLInitCallback = std::unique_ptr(initCallback); mGLRenderFrameCallback = std::unique_ptr(renderFrameCallback); diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp index 770072a..52fe66d 100644 --- a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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,46 +65,22 @@ NativeImageSurfaceEcoreWl::NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueu bool NativeImageSurfaceEcoreWl::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) { - bool featureFlag = false; - int error = SYSTEM_INFO_ERROR_NONE; - - if(version == 30) - { - error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.3_0", &featureFlag); - } - else if(version == 20) + // Setup the configuration + // The GLES version support is done by the caller + mDepth = depth; + mStencil = stencil; + if(mMSAA == 0) { - error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.2_0", &featureFlag); + //EGL_DONT_CARE is -1 + mMSAA = -1; } else { - DALI_LOG_ERROR("version is not valid"); - return false; - } - - if(error != SYSTEM_INFO_ERROR_NONE) - { - DALI_LOG_ERROR("Can't check platform feature.\n"); - return false; - } - - if(featureFlag) - { - mDepth = depth; - mStencil = stencil; - if(mMSAA == 0) - { - //EGL_DONT_CARE is -1 - mMSAA = -1; - } - else - { - mMSAA = msaa; - } - mGLESVersion = version; + mMSAA = msaa; } + mGLESVersion = version; - return featureFlag; + return true; } Any NativeImageSurfaceEcoreWl::GetNativeRenderable()