2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
21 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/integration-api/gl-abstraction.h>
24 #include <dali/integration-api/gl-defines.h>
25 #include <dali/integration-api/graphics-sync-abstraction.h>
26 #include <dali/internal/graphics/gles-impl/egl-sync-object.h>
27 #include <dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h>
28 #include <dali/internal/graphics/gles-impl/gles-graphics-pipeline.h>
29 #include <dali/internal/graphics/gles-impl/gles-graphics-program.h>
30 #include <dali/internal/graphics/gles-impl/gles-graphics-render-pass.h>
31 #include <dali/internal/graphics/gles-impl/gles-graphics-render-target.h>
32 #include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
33 #include <dali/internal/graphics/gles-impl/gles-graphics-texture.h>
34 #include <dali/internal/graphics/gles-impl/gles-graphics-types.h>
35 #include <dali/internal/graphics/gles-impl/gles-sync-object.h>
36 #include <dali/internal/graphics/gles-impl/gles3-graphics-memory.h>
37 #include <dali/internal/graphics/gles/egl-sync-implementation.h>
38 #include <dali/public-api/common/dali-common.h>
40 // Uncomment the following define to turn on frame dumping
41 //#define ENABLE_COMMAND_BUFFER_FRAME_DUMP 1
42 #include <dali/internal/graphics/gles-impl/egl-graphics-controller-debug.h>
45 namespace Dali::Graphics
50 * @brief Custom deleter for all Graphics objects created
51 * with use of the Controller.
53 * When Graphics object dies the unique pointer (Graphics::UniquePtr)
54 * doesn't destroy it directly but passes the ownership back
55 * to the Controller. The GLESDeleter is responsible for passing
56 * the object to the discard queue (by calling Resource::DiscardResource()).
61 GLESDeleter() = default;
63 void operator()(T* object)
65 // Discard resource (add it to discard queue)
66 object->DiscardResource();
71 * @brief Helper function allocating graphics object
73 * @param[in] info Create info structure
74 * @param[in] controller Controller object
75 * @param[out] out Unique pointer to the return object
77 template<class GLESType, class GfxCreateInfo, class T>
78 auto NewObject(const GfxCreateInfo& info, EglGraphicsController& controller, T&& oldObject)
81 using Type = typename T::element_type;
82 using UPtr = Graphics::UniquePtr<Type>;
83 if(info.allocationCallbacks)
85 auto* memory = info.allocationCallbacks->allocCallback(
88 info.allocationCallbacks->userData);
89 return UPtr(new(memory) GLESType(info, controller), GLESDeleter<GLESType>());
91 else // Use standard allocator
93 return UPtr(new GLESType(info, controller), GLESDeleter<GLESType>());
97 template<class T0, class T1>
98 T0* CastObject(T1* apiObject)
100 return static_cast<T0*>(apiObject);
103 // Maximum size of texture upload buffer.
104 const uint32_t TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB = 1;
108 EglGraphicsController::~EglGraphicsController() = default;
110 void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction)
112 DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #1\n");
113 mGlAbstraction = &glAbstraction;
114 mContext = std::make_unique<GLES::Context>(*this);
115 mCurrentContext = mContext.get();
118 void EglGraphicsController::Initialize(Integration::GraphicsSyncAbstraction& syncImplementation,
119 Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
120 Internal::Adaptor::GraphicsInterface& graphicsInterface)
122 DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #2\n");
123 auto* syncImplPtr = static_cast<Internal::Adaptor::EglSyncImplementation*>(&syncImplementation);
125 mEglSyncImplementation = syncImplPtr;
126 mGlContextHelperAbstraction = &glContextHelperAbstraction;
127 mGraphics = &graphicsInterface;
130 void EglGraphicsController::SubmitCommandBuffers(const SubmitInfo& submitInfo)
132 for(auto& cmdbuf : submitInfo.cmdBuffer)
134 // Push command buffers
135 mCommandQueue.push(static_cast<GLES::CommandBuffer*>(cmdbuf));
138 // If flush bit set, flush all pending tasks
139 if(submitInfo.flags & (0 | SubmitFlagBits::FLUSH))
145 void EglGraphicsController::PresentRenderTarget(RenderTarget* renderTarget)
147 // Use command buffer to execute presentation (we should pool it)
148 CommandBufferCreateInfo info;
149 info.SetLevel(CommandBufferLevel::PRIMARY);
150 info.fixedCapacity = 1; // only one command
151 auto presentCommandBuffer = new GLES::CommandBuffer(info, *this);
152 presentCommandBuffer->PresentRenderTarget(static_cast<GLES::RenderTarget*>(renderTarget));
153 SubmitInfo submitInfo;
154 submitInfo.cmdBuffer = {presentCommandBuffer};
155 submitInfo.flags = 0 | SubmitFlagBits::FLUSH;
156 SubmitCommandBuffers(submitInfo);
159 void EglGraphicsController::ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget)
161 auto* rt = static_cast<GLES::RenderTarget*>(renderTarget);
162 if(rt->GetCreateInfo().surface)
164 auto* surfaceInterface = reinterpret_cast<Dali::RenderSurfaceInterface*>(rt->GetCreateInfo().surface);
165 surfaceInterface->MakeContextCurrent();
166 surfaceInterface->PostRender();
170 Integration::GlAbstraction& EglGraphicsController::GetGlAbstraction()
172 DALI_ASSERT_DEBUG(mGlAbstraction && "Graphics controller not initialized");
173 return *mGlAbstraction;
176 Integration::GlContextHelperAbstraction& EglGraphicsController::GetGlContextHelperAbstraction()
178 DALI_ASSERT_DEBUG(mGlContextHelperAbstraction && "Graphics controller not initialized");
179 return *mGlContextHelperAbstraction;
182 Internal::Adaptor::EglSyncImplementation& EglGraphicsController::GetEglSyncImplementation()
184 DALI_ASSERT_DEBUG(mEglSyncImplementation && "Sync implementation not initialized");
185 return *mEglSyncImplementation;
188 Graphics::UniquePtr<CommandBuffer> EglGraphicsController::CreateCommandBuffer(
189 const CommandBufferCreateInfo& commandBufferCreateInfo,
190 Graphics::UniquePtr<CommandBuffer>&& oldCommandBuffer)
192 return NewObject<GLES::CommandBuffer>(commandBufferCreateInfo, *this, std::move(oldCommandBuffer));
195 Graphics::UniquePtr<RenderPass> EglGraphicsController::CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<RenderPass>&& oldRenderPass)
197 return NewObject<GLES::RenderPass>(renderPassCreateInfo, *this, std::move(oldRenderPass));
200 Graphics::UniquePtr<Texture>
201 EglGraphicsController::CreateTexture(const TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Texture>&& oldTexture)
203 return NewObject<GLES::Texture>(textureCreateInfo, *this, std::move(oldTexture));
206 Graphics::UniquePtr<Buffer> EglGraphicsController::CreateBuffer(
207 const BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr<Buffer>&& oldBuffer)
209 return NewObject<GLES::Buffer>(bufferCreateInfo, *this, std::move(oldBuffer));
212 Graphics::UniquePtr<Framebuffer> EglGraphicsController::CreateFramebuffer(
213 const FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Framebuffer>&& oldFramebuffer)
215 return NewObject<GLES::Framebuffer>(framebufferCreateInfo, *this, std::move(oldFramebuffer));
218 Graphics::UniquePtr<Pipeline> EglGraphicsController::CreatePipeline(
219 const PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
221 // Create pipeline cache if needed
224 mPipelineCache = std::make_unique<GLES::PipelineCache>(*this);
227 return mPipelineCache->GetPipeline(pipelineCreateInfo, std::move(oldPipeline));
230 Graphics::UniquePtr<Program> EglGraphicsController::CreateProgram(
231 const ProgramCreateInfo& programCreateInfo, UniquePtr<Program>&& oldProgram)
233 // Create program cache if needed
236 mPipelineCache = std::make_unique<GLES::PipelineCache>(*this);
239 return mPipelineCache->GetProgram(programCreateInfo, std::move(oldProgram));
242 Graphics::UniquePtr<Shader> EglGraphicsController::CreateShader(const ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Shader>&& oldShader)
244 return NewObject<GLES::Shader>(shaderCreateInfo, *this, std::move(oldShader));
247 Graphics::UniquePtr<Sampler> EglGraphicsController::CreateSampler(const SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Sampler>&& oldSampler)
249 return NewObject<GLES::Sampler>(samplerCreateInfo, *this, std::move(oldSampler));
252 Graphics::UniquePtr<RenderTarget> EglGraphicsController::CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<RenderTarget>&& oldRenderTarget)
254 return NewObject<GLES::RenderTarget>(renderTargetCreateInfo, *this, std::move(oldRenderTarget));
257 Graphics::UniquePtr<SyncObject> EglGraphicsController::CreateSyncObject(const SyncObjectCreateInfo& syncObjectCreateInfo,
258 UniquePtr<SyncObject>&& oldSyncObject)
260 if(GetGLESVersion() < GLES::GLESVersion::GLES_30)
262 return NewObject<EGL::SyncObject>(syncObjectCreateInfo, *this, std::move(oldSyncObject));
266 return NewObject<GLES::SyncObject>(syncObjectCreateInfo, *this, std::move(oldSyncObject));
270 const Graphics::Reflection& EglGraphicsController::GetProgramReflection(const Graphics::Program& program)
272 return static_cast<const Graphics::GLES::Program*>(&program)->GetReflection();
275 void EglGraphicsController::CreateSurfaceContext(Dali::RenderSurfaceInterface* surface)
277 std::unique_ptr<GLES::Context> context = std::make_unique<GLES::Context>(*this);
278 mSurfaceContexts.push_back(std::move(std::make_pair(surface, std::move(context))));
281 void EglGraphicsController::DeleteSurfaceContext(Dali::RenderSurfaceInterface* surface)
283 mSurfaceContexts.erase(std::remove_if(
284 mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) { return surface == iter.first; }),
285 mSurfaceContexts.end());
288 void EglGraphicsController::ActivateResourceContext()
290 mCurrentContext = mContext.get();
293 void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface)
295 if(surface && mGraphics->IsResourceContextSupported())
297 auto iter = std::find_if(mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) {
298 return (iter.first == surface);
301 if(iter != mSurfaceContexts.end())
303 mCurrentContext = iter->second.get();
308 void EglGraphicsController::AddTexture(GLES::Texture& texture)
310 // Assuming we are on the correct context
311 mCreateTextureQueue.push(&texture);
314 void EglGraphicsController::AddBuffer(GLES::Buffer& buffer)
316 // Assuming we are on the correct context
317 mCreateBufferQueue.push(&buffer);
320 void EglGraphicsController::AddFramebuffer(GLES::Framebuffer& framebuffer)
322 // Assuming we are on the correct context
323 mCreateFramebufferQueue.push(&framebuffer);
326 void EglGraphicsController::ProcessDiscardQueues()
329 ProcessDiscardQueue<GLES::Texture>(mDiscardTextureQueue);
332 ProcessDiscardQueue<GLES::Buffer>(mDiscardBufferQueue);
334 // Process Framebuffers
335 ProcessDiscardQueue<GLES::Framebuffer>(mDiscardFramebufferQueue);
338 ProcessDiscardQueue<GLES::Pipeline>(mDiscardPipelineQueue);
341 ProcessDiscardQueue<GLES::Program>(mDiscardProgramQueue);
344 ProcessDiscardQueue<GLES::Shader>(mDiscardShaderQueue);
347 ProcessDiscardQueue<GLES::Sampler>(mDiscardSamplerQueue);
349 // Process command buffers
350 ProcessDiscardQueue<GLES::CommandBuffer>(mDiscardCommandBufferQueue);
353 void EglGraphicsController::ProcessCreateQueues()
356 ProcessCreateQueue(mCreateTextureQueue);
359 ProcessCreateQueue(mCreateBufferQueue);
361 // Process framebuffers
362 ProcessCreateQueue(mCreateFramebufferQueue);
365 void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer)
367 for(auto& cmd : commandBuffer.GetCommands())
372 case GLES::CommandType::FLUSH:
374 // Nothing to do here
377 case GLES::CommandType::BIND_TEXTURES:
379 mCurrentContext->BindTextures(cmd.bindTextures.textureBindings);
382 case GLES::CommandType::BIND_VERTEX_BUFFERS:
384 auto& bindings = cmd.bindVertexBuffers.vertexBufferBindings;
385 mCurrentContext->BindVertexBuffers(bindings);
388 case GLES::CommandType::BIND_UNIFORM_BUFFER:
390 auto& bindings = cmd.bindUniformBuffers;
391 mCurrentContext->BindUniformBuffers(bindings.uniformBufferBindings, bindings.standaloneUniformsBufferBinding);
394 case GLES::CommandType::BIND_INDEX_BUFFER:
396 mCurrentContext->BindIndexBuffer(cmd.bindIndexBuffer);
399 case GLES::CommandType::BIND_SAMPLERS:
403 case GLES::CommandType::BIND_PIPELINE:
405 auto pipeline = static_cast<const GLES::Pipeline*>(cmd.bindPipeline.pipeline);
406 mCurrentContext->BindPipeline(pipeline);
409 case GLES::CommandType::DRAW:
411 mCurrentContext->Flush(false, cmd.draw);
414 case GLES::CommandType::DRAW_INDEXED:
416 mCurrentContext->Flush(false, cmd.draw);
419 case GLES::CommandType::DRAW_INDEXED_INDIRECT:
421 mCurrentContext->Flush(false, cmd.draw);
424 case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here?
426 mGlAbstraction->Scissor(cmd.scissor.region.x, cmd.scissor.region.y, cmd.scissor.region.width, cmd.scissor.region.height);
429 case GLES::CommandType::SET_SCISSOR_TEST:
431 if(cmd.scissorTest.enable)
433 mGlAbstraction->Enable(GL_SCISSOR_TEST);
437 mGlAbstraction->Disable(GL_SCISSOR_TEST);
441 case GLES::CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
443 mGlAbstraction->Viewport(cmd.viewport.region.x, cmd.viewport.region.y, cmd.viewport.region.width, cmd.viewport.region.height);
447 case GLES::CommandType::SET_COLOR_MASK:
449 mCurrentContext->ColorMask(cmd.colorMask.enabled);
452 case GLES::CommandType::CLEAR_STENCIL_BUFFER:
454 mCurrentContext->ClearStencilBuffer();
457 case GLES::CommandType::CLEAR_DEPTH_BUFFER:
459 mCurrentContext->ClearDepthBuffer();
463 case GLES::CommandType::SET_STENCIL_TEST_ENABLE:
465 mCurrentContext->SetStencilTestEnable(cmd.stencilTest.enabled);
469 case GLES::CommandType::SET_STENCIL_FUNC:
471 mCurrentContext->StencilFunc(cmd.stencilFunc.compareOp,
472 cmd.stencilFunc.reference,
473 cmd.stencilFunc.compareMask);
477 case GLES::CommandType::SET_STENCIL_WRITE_MASK:
479 mCurrentContext->StencilMask(cmd.stencilWriteMask.mask);
483 case GLES::CommandType::SET_STENCIL_OP:
485 mCurrentContext->StencilOp(cmd.stencilOp.failOp,
486 cmd.stencilOp.depthFailOp,
487 cmd.stencilOp.passOp);
491 case GLES::CommandType::SET_DEPTH_COMPARE_OP:
493 mCurrentContext->SetDepthCompareOp(cmd.depth.compareOp);
496 case GLES::CommandType::SET_DEPTH_TEST_ENABLE:
498 mCurrentContext->SetDepthTestEnable(cmd.depth.testEnabled);
501 case GLES::CommandType::SET_DEPTH_WRITE_ENABLE:
503 mCurrentContext->SetDepthWriteEnable(cmd.depth.writeEnabled);
507 case GLES::CommandType::BEGIN_RENDERPASS:
509 auto& renderTarget = *cmd.beginRenderPass.renderTarget;
510 const auto& targetInfo = renderTarget.GetCreateInfo();
512 if(targetInfo.surface)
514 // switch to surface context
515 mGraphics->ActivateSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(targetInfo.surface));
517 else if(targetInfo.framebuffer)
519 // switch to resource context
520 mGraphics->ActivateResourceContext();
523 mCurrentContext->BeginRenderPass(cmd.beginRenderPass);
526 case GLES::CommandType::END_RENDERPASS:
528 mCurrentContext->EndRenderPass();
530 auto syncObject = const_cast<GLES::SyncObject*>(static_cast<const GLES::SyncObject*>(cmd.endRenderPass.syncObject));
533 syncObject->InitializeResource();
537 case GLES::CommandType::PRESENT_RENDER_TARGET:
539 ResolvePresentRenderTarget(cmd.presentRenderTarget.targetToPresent);
541 // push this command buffer to the discard queue
542 mDiscardCommandBufferQueue.push(const_cast<GLES::CommandBuffer*>(&commandBuffer));
545 case GLES::CommandType::EXECUTE_COMMAND_BUFFERS:
547 // Process secondary command buffers
548 // todo: check validity of the secondaries
549 // there are operations which are illigal to be done
550 // within secondaries.
551 for(auto& buf : cmd.executeCommandBuffers.buffers)
553 ProcessCommandBuffer(*static_cast<const GLES::CommandBuffer*>(buf));
561 void EglGraphicsController::ProcessCommandQueues()
563 // TODO: command queue per context, sync between queues should be
565 currentFramebuffer = nullptr;
569 while(!mCommandQueue.empty())
571 auto cmdBuf = mCommandQueue.front();
573 DUMP_FRAME_COMMAND_BUFFER(cmdBuf);
574 ProcessCommandBuffer(*cmdBuf);
580 void EglGraphicsController::ProcessTextureUpdateQueue()
582 while(!mTextureUpdateRequests.empty())
584 TextureUpdateRequest& request = mTextureUpdateRequests.front();
586 auto& info = request.first;
587 auto& source = request.second;
589 if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
591 // GPU memory must be already allocated.
593 // Check if it needs conversion
594 auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
595 const auto& createInfo = texture->GetCreateInfo();
596 auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
597 auto srcType = GLES::GLTextureFormatType(info.srcFormat).type;
598 auto destInternalFormat = GLES::GLTextureFormatType(createInfo.format).internalFormat;
599 auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
601 // From render-texture.cpp
602 const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
603 info.srcExtent2D.width != (createInfo.size.width / (1 << info.level)) ||
604 info.srcExtent2D.height != (createInfo.size.height / (1 << info.level)));
606 auto* sourceBuffer = reinterpret_cast<uint8_t*>(source.memorySource.memory);
607 std::vector<uint8_t> tempBuffer;
608 if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage))
610 // Convert RGB to RGBA if necessary.
611 texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
612 sourceBuffer = &tempBuffer[0];
613 srcFormat = destFormat;
614 srcType = GLES::GLTextureFormatType(createInfo.format).type;
617 // Calculate the maximum mipmap level for the texture
618 texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
620 GLenum bindTarget{GL_TEXTURE_2D};
621 GLenum target{GL_TEXTURE_2D};
623 if(createInfo.textureType == Graphics::TextureType::TEXTURE_CUBEMAP)
625 bindTarget = GL_TEXTURE_CUBE_MAP;
626 target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer;
629 mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
630 mGlAbstraction->BindTexture(bindTarget, texture->GetGLTexture());
634 if(!texture->IsCompressed())
636 mGlAbstraction->TexImage2D(target,
639 info.srcExtent2D.width,
640 info.srcExtent2D.height,
648 mGlAbstraction->CompressedTexImage2D(target,
651 info.srcExtent2D.width,
652 info.srcExtent2D.height,
660 if(!texture->IsCompressed())
662 mGlAbstraction->TexSubImage2D(target,
666 info.srcExtent2D.width,
667 info.srcExtent2D.height,
674 mGlAbstraction->CompressedTexSubImage2D(target,
678 info.srcExtent2D.width,
679 info.srcExtent2D.height,
685 // free staging memory
686 free(source.memorySource.memory);
690 // TODO: other sources
693 mTextureUpdateRequests.pop();
697 void EglGraphicsController::UpdateTextures(const std::vector<TextureUpdateInfo>& updateInfoList,
698 const std::vector<TextureUpdateSourceInfo>& sourceList)
701 for(auto& info : updateInfoList)
703 mTextureUpdateRequests.push(std::make_pair(info, sourceList[info.srcReference]));
704 auto& pair = mTextureUpdateRequests.back();
705 switch(pair.second.sourceType)
707 case Graphics::TextureUpdateSourceInfo::Type::MEMORY:
709 auto& info = pair.first;
710 auto& source = pair.second;
712 // allocate staging memory and copy the data
713 // TODO: using PBO with GLES3, this is just naive
716 char* stagingBuffer = reinterpret_cast<char*>(malloc(info.srcSize));
717 std::copy(&reinterpret_cast<char*>(source.memorySource.memory)[info.srcOffset],
718 reinterpret_cast<char*>(source.memorySource.memory) + info.srcSize,
721 mTextureUploadTotalCPUMemoryUsed += info.srcSize;
723 // store staging buffer
724 source.memorySource.memory = stagingBuffer;
727 case Graphics::TextureUpdateSourceInfo::Type::BUFFER:
729 // TODO, with PBO support
732 case Graphics::TextureUpdateSourceInfo::Type::TEXTURE:
734 // TODO texture 2 texture in-GPU copy
740 // If upload buffer exceeds maximum size, flush.
741 if(mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB * 1024)
744 mTextureUploadTotalCPUMemoryUsed = 0;
748 void EglGraphicsController::ProcessTextureMipmapGenerationQueue()
750 while(!mTextureMipmapGenerationRequests.empty())
752 auto* texture = mTextureMipmapGenerationRequests.front();
754 mGlAbstraction->BindTexture(texture->GetGlTarget(), texture->GetGLTexture());
755 mGlAbstraction->GenerateMipmap(texture->GetGlTarget());
757 mTextureMipmapGenerationRequests.pop();
761 void EglGraphicsController::GenerateTextureMipmaps(const Graphics::Texture& texture)
763 mTextureMipmapGenerationRequests.push(static_cast<const GLES::Texture*>(&texture));
766 Graphics::UniquePtr<Memory> EglGraphicsController::MapBufferRange(const MapBufferInfo& mapInfo)
768 mGraphics->ActivateResourceContext();
770 // Mapping buffer requires the object to be created NOW
771 // Workaround - flush now, otherwise there will be given a staging buffer
772 // in case when the buffer is not there yet
773 ProcessCreateQueues();
775 if(GetGLESVersion() < GLES::GLESVersion::GLES_30)
777 return Graphics::UniquePtr<Memory>(new GLES::Memory2(mapInfo, *this));
781 return Graphics::UniquePtr<Memory>(new GLES::Memory3(mapInfo, *this));
785 bool EglGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData)
787 return static_cast<GLES::Program*>(&program)->GetImplementation()->GetParameter(parameterId, outData);
790 GLES::PipelineCache& EglGraphicsController::GetPipelineCache() const
792 return *mPipelineCache;
795 } // namespace Dali::Graphics