X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fegl-graphics-controller.cpp;h=8717f7f9fb2b30400a0698fd1378e167e02e8e2f;hb=ffee1abdac31e9756f02edfbded64f6d9b3d30b1;hp=eec74afd8fff7544ab93184715c24be9fc024187;hpb=9c36a5902b28db99a5c5fcb61ec8045943242f12;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index eec74af..8717f7f 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.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. @@ -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 @@ -105,7 +109,21 @@ const uint32_t TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB = 1; } // namespace -EglGraphicsController::~EglGraphicsController() = default; +EglGraphicsController::EglGraphicsController() +: mTextureDependencyChecker(*this), + mSyncPool(*this) +{ +} + +EglGraphicsController::~EglGraphicsController() +{ + while(!mPresentationCommandBuffers.empty()) + { + auto presentCommandBuffer = const_cast(mPresentationCommandBuffers.front()); + delete presentCommandBuffer; + mPresentationCommandBuffers.pop(); + } +} void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction) { @@ -178,6 +196,12 @@ void EglGraphicsController::ResolvePresentRenderTarget(GLES::RenderTarget* rende } } +void EglGraphicsController::PostRender() +{ + mTextureDependencyChecker.Reset(); + mSyncPool.AgeSyncObjects(); +} + Integration::GlAbstraction& EglGraphicsController::GetGlAbstraction() { DALI_ASSERT_DEBUG(mGlAbstraction && "Graphics controller not initialized"); @@ -300,6 +324,15 @@ void EglGraphicsController::ActivateResourceContext() { mCurrentContext = mContext.get(); mCurrentContext->GlContextCreated(); + + if(!mSharedContext) + { + auto eglGraphics = dynamic_cast(mGraphics); + if(eglGraphics) + { + mSharedContext = eglGraphics->GetEglImplementation().GetContext(); + } + } } void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) @@ -347,6 +380,12 @@ void EglGraphicsController::ProcessDiscardQueues() // Process Framebuffers ProcessDiscardQueue(mDiscardFramebufferQueue); + // Process RenderPass + ProcessDiscardQueue(mDiscardRenderPassQueue); + + // Process RenderTarget + ProcessDiscardQueue(mDiscardRenderTargetQueue); + // Process pipelines ProcessDiscardQueue(mDiscardPipelineQueue); @@ -424,17 +463,17 @@ void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& comm } case GLES::CommandType::DRAW: { - mCurrentContext->Flush(false, cmd.draw); + mCurrentContext->Flush(false, cmd.draw, mTextureDependencyChecker); break; } case GLES::CommandType::DRAW_INDEXED: { - mCurrentContext->Flush(false, cmd.draw); + mCurrentContext->Flush(false, cmd.draw, mTextureDependencyChecker); break; } case GLES::CommandType::DRAW_INDEXED_INDIRECT: { - mCurrentContext->Flush(false, cmd.draw); + mCurrentContext->Flush(false, cmd.draw, mTextureDependencyChecker); break; } case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here? @@ -530,12 +569,15 @@ void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& comm } mCurrentContext->BeginRenderPass(cmd.beginRenderPass); + break; } case GLES::CommandType::END_RENDERPASS: { - mCurrentContext->EndRenderPass(); + mCurrentContext->EndRenderPass(mTextureDependencyChecker); + // This sync object is to enable cpu to wait for rendering to complete, not gpu. + // It's only needed for reading the framebuffer texture in the client. auto syncObject = const_cast(static_cast(cmd.endRenderPass.syncObject)); if(syncObject) { @@ -569,6 +611,23 @@ void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& comm } break; } + case GLES::CommandType::DRAW_NATIVE: + { + auto* info = &cmd.drawNative.drawNativeInfo; + + mCurrentContext->PrepareForNativeRendering(); + + if(info->glesNativeInfo.eglSharedContextStoragePointer) + { + auto* anyContext = reinterpret_cast(info->glesNativeInfo.eglSharedContextStoragePointer); + *anyContext = mSharedContext; + } + + CallbackBase::ExecuteReturn(*info->callback, info->userData); + + mCurrentContext->RestoreFromNativeRendering(); + break; + } } } } @@ -615,14 +674,19 @@ void EglGraphicsController::ProcessTextureUpdateQueue() info.srcExtent2D.height != (createInfo.size.height / (1 << info.level))); auto* sourceBuffer = reinterpret_cast(source.memorySource.memory); + auto sourceStride = info.srcStride; std::vector tempBuffer; + if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage)) { // Convert RGB to RGBA if necessary. - texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer); - sourceBuffer = &tempBuffer[0]; - srcFormat = destFormat; - srcType = GLES::GLTextureFormatType(createInfo.format).type; + if(texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcStride, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer)) + { + sourceBuffer = &tempBuffer[0]; + sourceStride = 0u; // Converted buffer compacted. make stride as 0. + srcFormat = destFormat; + srcType = GLES::GLTextureFormatType(createInfo.format).type; + } } // Calculate the maximum mipmap level for the texture @@ -638,6 +702,8 @@ void EglGraphicsController::ProcessTextureUpdateQueue() } mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1); + mGlAbstraction->PixelStorei(GL_UNPACK_ROW_LENGTH, sourceStride); + mCurrentContext->BindTexture(bindTarget, texture->GetTextureTypeId(), texture->GetGLTexture()); if(!isSubImage) @@ -724,10 +790,11 @@ void EglGraphicsController::UpdateTextures(const std::vector& // TODO: using PBO with GLES3, this is just naive // oldschool way - char* stagingBuffer = reinterpret_cast(malloc(info.srcSize)); - std::copy(&reinterpret_cast(source.memorySource.memory)[info.srcOffset], - reinterpret_cast(source.memorySource.memory) + info.srcSize, - stagingBuffer); + uint8_t* stagingBuffer = reinterpret_cast(malloc(info.srcSize)); + + uint8_t* srcMemory = &reinterpret_cast(source.memorySource.memory)[info.srcOffset]; + + std::copy(srcMemory, srcMemory + info.srcSize, stagingBuffer); mTextureUploadTotalCPUMemoryUsed += info.srcSize; @@ -749,7 +816,7 @@ void EglGraphicsController::UpdateTextures(const std::vector& } // If upload buffer exceeds maximum size, flush. - if(mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB * 1024) + if(mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB * 1024 * 1024) { Flush(); mTextureUploadTotalCPUMemoryUsed = 0;