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();
291 mCurrentContext->GlContextCreated();
294 void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface)
296 if(surface && mGraphics->IsResourceContextSupported())
298 auto iter = std::find_if(mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) {
299 return (iter.first == surface);
302 if(iter != mSurfaceContexts.end())
304 mCurrentContext = iter->second.get();
305 mCurrentContext->GlContextCreated();
310 void EglGraphicsController::AddTexture(GLES::Texture& texture)
312 // Assuming we are on the correct context
313 mCreateTextureQueue.push(&texture);
316 void EglGraphicsController::AddBuffer(GLES::Buffer& buffer)
318 // Assuming we are on the correct context
319 mCreateBufferQueue.push(&buffer);
322 void EglGraphicsController::AddFramebuffer(GLES::Framebuffer& framebuffer)
324 // Assuming we are on the correct context
325 mCreateFramebufferQueue.push(&framebuffer);
328 void EglGraphicsController::ProcessDiscardQueues()
331 ProcessDiscardQueue<GLES::Texture>(mDiscardTextureQueue);
334 ProcessDiscardQueue<GLES::Buffer>(mDiscardBufferQueue);
336 // Process Framebuffers
337 ProcessDiscardQueue<GLES::Framebuffer>(mDiscardFramebufferQueue);
340 ProcessDiscardQueue(mDiscardPipelineQueue);
343 ProcessDiscardQueue<GLES::Program>(mDiscardProgramQueue);
346 ProcessDiscardQueue<GLES::Shader>(mDiscardShaderQueue);
349 ProcessDiscardQueue<GLES::Sampler>(mDiscardSamplerQueue);
351 // Process command buffers
352 ProcessDiscardQueue<GLES::CommandBuffer>(mDiscardCommandBufferQueue);
355 void EglGraphicsController::ProcessCreateQueues()
358 ProcessCreateQueue(mCreateTextureQueue);
361 ProcessCreateQueue(mCreateBufferQueue);
363 // Process framebuffers
364 ProcessCreateQueue(mCreateFramebufferQueue);
367 void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer)
369 for(auto& cmd : commandBuffer.GetCommands())
374 case GLES::CommandType::FLUSH:
376 // Nothing to do here
379 case GLES::CommandType::BIND_TEXTURES:
381 mCurrentContext->BindTextures(cmd.bindTextures.textureBindings);
384 case GLES::CommandType::BIND_VERTEX_BUFFERS:
386 auto& bindings = cmd.bindVertexBuffers.vertexBufferBindings;
387 mCurrentContext->BindVertexBuffers(bindings);
390 case GLES::CommandType::BIND_UNIFORM_BUFFER:
392 auto& bindings = cmd.bindUniformBuffers;
393 mCurrentContext->BindUniformBuffers(bindings.uniformBufferBindings, bindings.standaloneUniformsBufferBinding);
396 case GLES::CommandType::BIND_INDEX_BUFFER:
398 mCurrentContext->BindIndexBuffer(cmd.bindIndexBuffer);
401 case GLES::CommandType::BIND_SAMPLERS:
405 case GLES::CommandType::BIND_PIPELINE:
407 auto pipeline = static_cast<const GLES::Pipeline*>(cmd.bindPipeline.pipeline);
408 mCurrentContext->BindPipeline(pipeline);
411 case GLES::CommandType::DRAW:
413 mCurrentContext->Flush(false, cmd.draw);
416 case GLES::CommandType::DRAW_INDEXED:
418 mCurrentContext->Flush(false, cmd.draw);
421 case GLES::CommandType::DRAW_INDEXED_INDIRECT:
423 mCurrentContext->Flush(false, cmd.draw);
426 case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here?
428 mGlAbstraction->Scissor(cmd.scissor.region.x, cmd.scissor.region.y, cmd.scissor.region.width, cmd.scissor.region.height);
431 case GLES::CommandType::SET_SCISSOR_TEST:
433 mCurrentContext->SetScissorTestEnabled(cmd.scissorTest.enable);
436 case GLES::CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
438 mGlAbstraction->Viewport(cmd.viewport.region.x, cmd.viewport.region.y, cmd.viewport.region.width, cmd.viewport.region.height);
442 case GLES::CommandType::SET_COLOR_MASK:
444 mCurrentContext->ColorMask(cmd.colorMask.enabled);
447 case GLES::CommandType::CLEAR_STENCIL_BUFFER:
449 mCurrentContext->ClearStencilBuffer();
452 case GLES::CommandType::CLEAR_DEPTH_BUFFER:
454 mCurrentContext->ClearDepthBuffer();
458 case GLES::CommandType::SET_STENCIL_TEST_ENABLE:
460 mCurrentContext->SetStencilTestEnable(cmd.stencilTest.enabled);
464 case GLES::CommandType::SET_STENCIL_FUNC:
466 mCurrentContext->StencilFunc(cmd.stencilFunc.compareOp,
467 cmd.stencilFunc.reference,
468 cmd.stencilFunc.compareMask);
472 case GLES::CommandType::SET_STENCIL_WRITE_MASK:
474 mCurrentContext->StencilMask(cmd.stencilWriteMask.mask);
478 case GLES::CommandType::SET_STENCIL_OP:
480 mCurrentContext->StencilOp(cmd.stencilOp.failOp,
481 cmd.stencilOp.depthFailOp,
482 cmd.stencilOp.passOp);
486 case GLES::CommandType::SET_DEPTH_COMPARE_OP:
488 mCurrentContext->SetDepthCompareOp(cmd.depth.compareOp);
491 case GLES::CommandType::SET_DEPTH_TEST_ENABLE:
493 mCurrentContext->SetDepthTestEnable(cmd.depth.testEnabled);
496 case GLES::CommandType::SET_DEPTH_WRITE_ENABLE:
498 mCurrentContext->SetDepthWriteEnable(cmd.depth.writeEnabled);
502 case GLES::CommandType::BEGIN_RENDERPASS:
504 auto& renderTarget = *cmd.beginRenderPass.renderTarget;
505 const auto& targetInfo = renderTarget.GetCreateInfo();
507 if(targetInfo.surface)
509 // switch to surface context
510 mGraphics->ActivateSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(targetInfo.surface));
512 else if(targetInfo.framebuffer)
514 // switch to resource context
515 mGraphics->ActivateResourceContext();
518 mCurrentContext->BeginRenderPass(cmd.beginRenderPass);
521 case GLES::CommandType::END_RENDERPASS:
523 mCurrentContext->EndRenderPass();
525 auto syncObject = const_cast<GLES::SyncObject*>(static_cast<const GLES::SyncObject*>(cmd.endRenderPass.syncObject));
528 syncObject->InitializeResource();
532 case GLES::CommandType::PRESENT_RENDER_TARGET:
534 ResolvePresentRenderTarget(cmd.presentRenderTarget.targetToPresent);
536 // push this command buffer to the discard queue
537 mDiscardCommandBufferQueue.push(const_cast<GLES::CommandBuffer*>(&commandBuffer));
540 case GLES::CommandType::EXECUTE_COMMAND_BUFFERS:
542 // Process secondary command buffers
543 // todo: check validity of the secondaries
544 // there are operations which are illigal to be done
545 // within secondaries.
546 for(auto& buf : cmd.executeCommandBuffers.buffers)
548 ProcessCommandBuffer(*static_cast<const GLES::CommandBuffer*>(buf));
556 void EglGraphicsController::ProcessCommandQueues()
558 // TODO: command queue per context, sync between queues should be
560 currentFramebuffer = nullptr;
564 while(!mCommandQueue.empty())
566 auto cmdBuf = mCommandQueue.front();
568 DUMP_FRAME_COMMAND_BUFFER(cmdBuf);
569 ProcessCommandBuffer(*cmdBuf);
575 void EglGraphicsController::ProcessTextureUpdateQueue()
577 while(!mTextureUpdateRequests.empty())
579 TextureUpdateRequest& request = mTextureUpdateRequests.front();
581 auto& info = request.first;
582 auto& source = request.second;
584 if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
586 // GPU memory must be already allocated.
588 // Check if it needs conversion
589 auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
590 const auto& createInfo = texture->GetCreateInfo();
591 auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
592 auto srcType = GLES::GLTextureFormatType(info.srcFormat).type;
593 auto destInternalFormat = GLES::GLTextureFormatType(createInfo.format).internalFormat;
594 auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
596 // From render-texture.cpp
597 const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
598 info.srcExtent2D.width != (createInfo.size.width / (1 << info.level)) ||
599 info.srcExtent2D.height != (createInfo.size.height / (1 << info.level)));
601 auto* sourceBuffer = reinterpret_cast<uint8_t*>(source.memorySource.memory);
602 std::vector<uint8_t> tempBuffer;
603 if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage))
605 // Convert RGB to RGBA if necessary.
606 texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
607 sourceBuffer = &tempBuffer[0];
608 srcFormat = destFormat;
609 srcType = GLES::GLTextureFormatType(createInfo.format).type;
612 // Calculate the maximum mipmap level for the texture
613 texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
615 GLenum bindTarget{GL_TEXTURE_2D};
616 GLenum target{GL_TEXTURE_2D};
618 if(createInfo.textureType == Graphics::TextureType::TEXTURE_CUBEMAP)
620 bindTarget = GL_TEXTURE_CUBE_MAP;
621 target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer;
624 mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
625 mCurrentContext->BindTexture(bindTarget, texture->GetTextureTypeId(), texture->GetGLTexture());
629 if(!texture->IsCompressed())
631 mGlAbstraction->TexImage2D(target,
634 info.srcExtent2D.width,
635 info.srcExtent2D.height,
643 mGlAbstraction->CompressedTexImage2D(target,
646 info.srcExtent2D.width,
647 info.srcExtent2D.height,
655 if(!texture->IsCompressed())
657 mGlAbstraction->TexSubImage2D(target,
661 info.srcExtent2D.width,
662 info.srcExtent2D.height,
669 mGlAbstraction->CompressedTexSubImage2D(target,
673 info.srcExtent2D.width,
674 info.srcExtent2D.height,
680 // free staging memory
681 free(source.memorySource.memory);
685 // TODO: other sources
688 mTextureUpdateRequests.pop();
692 void EglGraphicsController::UpdateTextures(const std::vector<TextureUpdateInfo>& updateInfoList,
693 const std::vector<TextureUpdateSourceInfo>& sourceList)
696 for(auto& info : updateInfoList)
698 mTextureUpdateRequests.push(std::make_pair(info, sourceList[info.srcReference]));
699 auto& pair = mTextureUpdateRequests.back();
700 switch(pair.second.sourceType)
702 case Graphics::TextureUpdateSourceInfo::Type::MEMORY:
704 auto& info = pair.first;
705 auto& source = pair.second;
707 // allocate staging memory and copy the data
708 // TODO: using PBO with GLES3, this is just naive
711 char* stagingBuffer = reinterpret_cast<char*>(malloc(info.srcSize));
712 std::copy(&reinterpret_cast<char*>(source.memorySource.memory)[info.srcOffset],
713 reinterpret_cast<char*>(source.memorySource.memory) + info.srcSize,
716 mTextureUploadTotalCPUMemoryUsed += info.srcSize;
718 // store staging buffer
719 source.memorySource.memory = stagingBuffer;
722 case Graphics::TextureUpdateSourceInfo::Type::BUFFER:
724 // TODO, with PBO support
727 case Graphics::TextureUpdateSourceInfo::Type::TEXTURE:
729 // TODO texture 2 texture in-GPU copy
735 // If upload buffer exceeds maximum size, flush.
736 if(mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB * 1024)
739 mTextureUploadTotalCPUMemoryUsed = 0;
743 void EglGraphicsController::ProcessTextureMipmapGenerationQueue()
745 while(!mTextureMipmapGenerationRequests.empty())
747 auto* texture = mTextureMipmapGenerationRequests.front();
749 mCurrentContext->BindTexture(texture->GetGlTarget(), texture->GetTextureTypeId(), texture->GetGLTexture());
750 mCurrentContext->GenerateMipmap(texture->GetGlTarget());
752 mTextureMipmapGenerationRequests.pop();
756 void EglGraphicsController::GenerateTextureMipmaps(const Graphics::Texture& texture)
758 mTextureMipmapGenerationRequests.push(static_cast<const GLES::Texture*>(&texture));
761 Graphics::UniquePtr<Memory> EglGraphicsController::MapBufferRange(const MapBufferInfo& mapInfo)
763 mGraphics->ActivateResourceContext();
765 // Mapping buffer requires the object to be created NOW
766 // Workaround - flush now, otherwise there will be given a staging buffer
767 // in case when the buffer is not there yet
768 ProcessCreateQueues();
770 if(GetGLESVersion() < GLES::GLESVersion::GLES_30)
772 return Graphics::UniquePtr<Memory>(new GLES::Memory2(mapInfo, *this));
776 return Graphics::UniquePtr<Memory>(new GLES::Memory3(mapInfo, *this));
780 bool EglGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData)
782 return static_cast<GLES::Program*>(&program)->GetImplementation()->GetParameter(parameterId, outData);
785 GLES::PipelineCache& EglGraphicsController::GetPipelineCache() const
787 return *mPipelineCache;
790 } // namespace Dali::Graphics