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/gles-graphics-command-buffer.h>
27 #include <dali/internal/graphics/gles-impl/gles-graphics-pipeline.h>
28 #include <dali/internal/graphics/gles-impl/gles-graphics-program.h>
29 #include <dali/internal/graphics/gles-impl/gles-graphics-render-pass.h>
30 #include <dali/internal/graphics/gles-impl/gles-graphics-render-target.h>
31 #include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
32 #include <dali/internal/graphics/gles-impl/gles-graphics-texture.h>
33 #include <dali/internal/graphics/gles-impl/gles-graphics-types.h>
34 #include <dali/internal/graphics/gles-impl/gles-sync-object.h>
35 #include <dali/internal/graphics/gles-impl/gles3-graphics-memory.h>
36 #include <dali/internal/graphics/gles/egl-sync-implementation.h>
37 #include <dali/public-api/common/dali-common.h>
39 // Uncomment the following define to turn on frame dumping
40 //#define ENABLE_COMMAND_BUFFER_FRAME_DUMP 1
41 #include <dali/internal/graphics/gles-impl/egl-graphics-controller-debug.h>
44 namespace Dali::Graphics
49 * @brief Custom deleter for all Graphics objects created
50 * with use of the Controller.
52 * When Graphics object dies the unique pointer (Graphics::UniquePtr)
53 * doesn't destroy it directly but passes the ownership back
54 * to the Controller. The GLESDeleter is responsible for passing
55 * the object to the discard queue (by calling Resource::DiscardResource()).
60 GLESDeleter() = default;
62 void operator()(T* object)
64 // Discard resource (add it to discard queue)
65 object->DiscardResource();
70 * @brief Helper function allocating graphics object
72 * @param[in] info Create info structure
73 * @param[in] controller Controller object
74 * @param[out] out Unique pointer to the return object
76 template<class GLESType, class GfxCreateInfo, class T>
77 auto NewObject(const GfxCreateInfo& info, EglGraphicsController& controller, T&& oldObject)
80 using Type = typename T::element_type;
81 using UPtr = Graphics::UniquePtr<Type>;
82 if(info.allocationCallbacks)
84 auto* memory = info.allocationCallbacks->allocCallback(
87 info.allocationCallbacks->userData);
88 return UPtr(new(memory) GLESType(info, controller), GLESDeleter<GLESType>());
90 else // Use standard allocator
92 return UPtr(new GLESType(info, controller), GLESDeleter<GLESType>());
96 template<class T0, class T1>
97 T0* CastObject(T1* apiObject)
99 return static_cast<T0*>(apiObject);
102 // Maximum size of texture upload buffer.
103 const uint32_t TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB = 1;
107 EglGraphicsController::~EglGraphicsController() = default;
109 void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction)
111 DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #1\n");
112 mGlAbstraction = &glAbstraction;
113 mContext = std::make_unique<GLES::Context>(*this);
114 mCurrentContext = mContext.get();
117 void EglGraphicsController::Initialize(Integration::GraphicsSyncAbstraction& syncImplementation,
118 Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
119 Internal::Adaptor::GraphicsInterface& graphicsInterface)
121 DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #2\n");
122 auto* syncImplPtr = static_cast<Internal::Adaptor::EglSyncImplementation*>(&syncImplementation);
124 mEglSyncImplementation = syncImplPtr;
125 mGlContextHelperAbstraction = &glContextHelperAbstraction;
126 mGraphics = &graphicsInterface;
129 void EglGraphicsController::SubmitCommandBuffers(const SubmitInfo& submitInfo)
131 for(auto& cmdbuf : submitInfo.cmdBuffer)
133 // Push command buffers
134 mCommandQueue.push(static_cast<GLES::CommandBuffer*>(cmdbuf));
137 // If flush bit set, flush all pending tasks
138 if(submitInfo.flags & (0 | SubmitFlagBits::FLUSH))
144 void EglGraphicsController::PresentRenderTarget(RenderTarget* renderTarget)
146 // Use command buffer to execute presentation (we should pool it)
147 CommandBufferCreateInfo info;
148 info.SetLevel(CommandBufferLevel::PRIMARY);
149 info.fixedCapacity = 1; // only one command
150 auto presentCommandBuffer = new GLES::CommandBuffer(info, *this);
151 presentCommandBuffer->PresentRenderTarget(static_cast<GLES::RenderTarget*>(renderTarget));
152 SubmitInfo submitInfo;
153 submitInfo.cmdBuffer = {presentCommandBuffer};
154 submitInfo.flags = 0 | SubmitFlagBits::FLUSH;
155 SubmitCommandBuffers(submitInfo);
158 void EglGraphicsController::ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget)
160 auto* rt = static_cast<GLES::RenderTarget*>(renderTarget);
161 if(rt->GetCreateInfo().surface)
163 auto* surfaceInterface = reinterpret_cast<Dali::RenderSurfaceInterface*>(rt->GetCreateInfo().surface);
164 surfaceInterface->MakeContextCurrent();
165 surfaceInterface->PostRender();
169 Integration::GlAbstraction& EglGraphicsController::GetGlAbstraction()
171 DALI_ASSERT_DEBUG(mGlAbstraction && "Graphics controller not initialized");
172 return *mGlAbstraction;
175 Integration::GlContextHelperAbstraction& EglGraphicsController::GetGlContextHelperAbstraction()
177 DALI_ASSERT_DEBUG(mGlContextHelperAbstraction && "Graphics controller not initialized");
178 return *mGlContextHelperAbstraction;
181 Internal::Adaptor::EglSyncImplementation& EglGraphicsController::GetEglSyncImplementation()
183 DALI_ASSERT_DEBUG(mEglSyncImplementation && "Sync implementation not initialized");
184 return *mEglSyncImplementation;
187 Graphics::UniquePtr<CommandBuffer> EglGraphicsController::CreateCommandBuffer(
188 const CommandBufferCreateInfo& commandBufferCreateInfo,
189 Graphics::UniquePtr<CommandBuffer>&& oldCommandBuffer)
191 return NewObject<GLES::CommandBuffer>(commandBufferCreateInfo, *this, std::move(oldCommandBuffer));
194 Graphics::UniquePtr<RenderPass> EglGraphicsController::CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<RenderPass>&& oldRenderPass)
196 return NewObject<GLES::RenderPass>(renderPassCreateInfo, *this, std::move(oldRenderPass));
199 Graphics::UniquePtr<Texture>
200 EglGraphicsController::CreateTexture(const TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Texture>&& oldTexture)
202 return NewObject<GLES::Texture>(textureCreateInfo, *this, std::move(oldTexture));
205 Graphics::UniquePtr<Buffer> EglGraphicsController::CreateBuffer(
206 const BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr<Buffer>&& oldBuffer)
208 return NewObject<GLES::Buffer>(bufferCreateInfo, *this, std::move(oldBuffer));
211 Graphics::UniquePtr<Framebuffer> EglGraphicsController::CreateFramebuffer(
212 const FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Framebuffer>&& oldFramebuffer)
214 return NewObject<GLES::Framebuffer>(framebufferCreateInfo, *this, std::move(oldFramebuffer));
217 Graphics::UniquePtr<Pipeline> EglGraphicsController::CreatePipeline(
218 const PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
220 // Create pipeline cache if needed
223 mPipelineCache = std::make_unique<GLES::PipelineCache>(*this);
226 return mPipelineCache->GetPipeline(pipelineCreateInfo, std::move(oldPipeline));
229 Graphics::UniquePtr<Program> EglGraphicsController::CreateProgram(
230 const ProgramCreateInfo& programCreateInfo, UniquePtr<Program>&& oldProgram)
232 // Create program cache if needed
235 mPipelineCache = std::make_unique<GLES::PipelineCache>(*this);
238 return mPipelineCache->GetProgram(programCreateInfo, std::move(oldProgram));
241 Graphics::UniquePtr<Shader> EglGraphicsController::CreateShader(const ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Shader>&& oldShader)
243 return NewObject<GLES::Shader>(shaderCreateInfo, *this, std::move(oldShader));
246 Graphics::UniquePtr<Sampler> EglGraphicsController::CreateSampler(const SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Sampler>&& oldSampler)
248 return NewObject<GLES::Sampler>(samplerCreateInfo, *this, std::move(oldSampler));
251 Graphics::UniquePtr<RenderTarget> EglGraphicsController::CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<RenderTarget>&& oldRenderTarget)
253 return NewObject<GLES::RenderTarget>(renderTargetCreateInfo, *this, std::move(oldRenderTarget));
256 Graphics::UniquePtr<SyncObject> EglGraphicsController::CreateSyncObject(const SyncObjectCreateInfo& syncObjectCreateInfo,
257 UniquePtr<SyncObject>&& oldSyncObject)
259 return NewObject<GLES::SyncObject>(syncObjectCreateInfo, *this, std::move(oldSyncObject));
262 const Graphics::Reflection& EglGraphicsController::GetProgramReflection(const Graphics::Program& program)
264 return static_cast<const Graphics::GLES::Program*>(&program)->GetReflection();
267 void EglGraphicsController::CreateSurfaceContext(Dali::RenderSurfaceInterface* surface)
269 std::unique_ptr<GLES::Context> context = std::make_unique<GLES::Context>(*this);
270 mSurfaceContexts.push_back(std::move(std::make_pair(surface, std::move(context))));
273 void EglGraphicsController::DeleteSurfaceContext(Dali::RenderSurfaceInterface* surface)
275 mSurfaceContexts.erase(std::remove_if(
276 mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) { return surface == iter.first; }),
277 mSurfaceContexts.end());
280 void EglGraphicsController::ActivateResourceContext()
282 mCurrentContext = mContext.get();
285 void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface)
287 if(surface && mGraphics->IsResourceContextSupported())
289 auto iter = std::find_if(mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) {
290 return (iter.first == surface);
293 if(iter != mSurfaceContexts.end())
295 mCurrentContext = iter->second.get();
300 void EglGraphicsController::AddTexture(GLES::Texture& texture)
302 // Assuming we are on the correct context
303 mCreateTextureQueue.push(&texture);
306 void EglGraphicsController::AddBuffer(GLES::Buffer& buffer)
308 // Assuming we are on the correct context
309 mCreateBufferQueue.push(&buffer);
312 void EglGraphicsController::AddFramebuffer(GLES::Framebuffer& framebuffer)
314 // Assuming we are on the correct context
315 mCreateFramebufferQueue.push(&framebuffer);
318 void EglGraphicsController::ProcessDiscardQueues()
321 ProcessDiscardQueue<GLES::Texture>(mDiscardTextureQueue);
324 ProcessDiscardQueue<GLES::Buffer>(mDiscardBufferQueue);
326 // Process Framebuffers
327 ProcessDiscardQueue<GLES::Framebuffer>(mDiscardFramebufferQueue);
330 ProcessDiscardQueue<GLES::Pipeline>(mDiscardPipelineQueue);
333 ProcessDiscardQueue<GLES::Program>(mDiscardProgramQueue);
336 ProcessDiscardQueue<GLES::Shader>(mDiscardShaderQueue);
339 ProcessDiscardQueue<GLES::Sampler>(mDiscardSamplerQueue);
341 // Process command buffers
342 ProcessDiscardQueue<GLES::CommandBuffer>(mDiscardCommandBufferQueue);
345 void EglGraphicsController::ProcessCreateQueues()
348 ProcessCreateQueue(mCreateTextureQueue);
351 ProcessCreateQueue(mCreateBufferQueue);
353 // Process framebuffers
354 ProcessCreateQueue(mCreateFramebufferQueue);
357 void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer)
359 for(auto& cmd : commandBuffer.GetCommands())
364 case GLES::CommandType::FLUSH:
366 // Nothing to do here
369 case GLES::CommandType::BIND_TEXTURES:
371 mCurrentContext->BindTextures(cmd.bindTextures.textureBindings);
374 case GLES::CommandType::BIND_VERTEX_BUFFERS:
376 auto& bindings = cmd.bindVertexBuffers.vertexBufferBindings;
377 mCurrentContext->BindVertexBuffers(bindings);
380 case GLES::CommandType::BIND_UNIFORM_BUFFER:
382 auto& bindings = cmd.bindUniformBuffers;
383 mCurrentContext->BindUniformBuffers(bindings.uniformBufferBindings, bindings.standaloneUniformsBufferBinding);
386 case GLES::CommandType::BIND_INDEX_BUFFER:
388 mCurrentContext->BindIndexBuffer(cmd.bindIndexBuffer);
391 case GLES::CommandType::BIND_SAMPLERS:
395 case GLES::CommandType::BIND_PIPELINE:
397 auto pipeline = static_cast<const GLES::Pipeline*>(cmd.bindPipeline.pipeline);
398 mCurrentContext->BindPipeline(pipeline);
401 case GLES::CommandType::DRAW:
403 mCurrentContext->Flush(false, cmd.draw);
406 case GLES::CommandType::DRAW_INDEXED:
408 mCurrentContext->Flush(false, cmd.draw);
411 case GLES::CommandType::DRAW_INDEXED_INDIRECT:
413 mCurrentContext->Flush(false, cmd.draw);
416 case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here?
418 mGlAbstraction->Scissor(cmd.scissor.region.x, cmd.scissor.region.y, cmd.scissor.region.width, cmd.scissor.region.height);
421 case GLES::CommandType::SET_SCISSOR_TEST:
423 if(cmd.scissorTest.enable)
425 mGlAbstraction->Enable(GL_SCISSOR_TEST);
429 mGlAbstraction->Disable(GL_SCISSOR_TEST);
433 case GLES::CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
435 mGlAbstraction->Viewport(cmd.viewport.region.x, cmd.viewport.region.y, cmd.viewport.region.width, cmd.viewport.region.height);
439 case GLES::CommandType::SET_COLOR_MASK:
441 mCurrentContext->ColorMask(cmd.colorMask.enabled);
444 case GLES::CommandType::CLEAR_STENCIL_BUFFER:
446 mCurrentContext->ClearStencilBuffer();
449 case GLES::CommandType::CLEAR_DEPTH_BUFFER:
451 mCurrentContext->ClearDepthBuffer();
455 case GLES::CommandType::SET_STENCIL_TEST_ENABLE:
457 mCurrentContext->SetStencilTestEnable(cmd.stencilTest.enabled);
461 case GLES::CommandType::SET_STENCIL_FUNC:
463 mCurrentContext->StencilFunc(cmd.stencilFunc.compareOp,
464 cmd.stencilFunc.reference,
465 cmd.stencilFunc.compareMask);
469 case GLES::CommandType::SET_STENCIL_WRITE_MASK:
471 mCurrentContext->StencilMask(cmd.stencilWriteMask.mask);
475 case GLES::CommandType::SET_STENCIL_OP:
477 mCurrentContext->StencilOp(cmd.stencilOp.failOp,
478 cmd.stencilOp.depthFailOp,
479 cmd.stencilOp.passOp);
483 case GLES::CommandType::SET_DEPTH_COMPARE_OP:
485 mCurrentContext->SetDepthCompareOp(cmd.depth.compareOp);
488 case GLES::CommandType::SET_DEPTH_TEST_ENABLE:
490 mCurrentContext->SetDepthTestEnable(cmd.depth.testEnabled);
493 case GLES::CommandType::SET_DEPTH_WRITE_ENABLE:
495 mCurrentContext->SetDepthWriteEnable(cmd.depth.writeEnabled);
499 case GLES::CommandType::BEGIN_RENDERPASS:
501 auto& renderTarget = *cmd.beginRenderPass.renderTarget;
502 const auto& targetInfo = renderTarget.GetCreateInfo();
504 if(targetInfo.surface)
506 // switch to surface context
507 mGraphics->ActivateSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(targetInfo.surface));
509 else if(targetInfo.framebuffer)
511 // switch to resource context
512 mGraphics->ActivateResourceContext();
515 mCurrentContext->BeginRenderPass(cmd.beginRenderPass);
518 case GLES::CommandType::END_RENDERPASS:
520 mCurrentContext->EndRenderPass();
522 auto syncObject = const_cast<GLES::SyncObject*>(static_cast<const GLES::SyncObject*>(cmd.endRenderPass.syncObject));
525 syncObject->InitializeResource();
529 case GLES::CommandType::PRESENT_RENDER_TARGET:
531 ResolvePresentRenderTarget(cmd.presentRenderTarget.targetToPresent);
533 // push this command buffer to the discard queue
534 mDiscardCommandBufferQueue.push(const_cast<GLES::CommandBuffer*>(&commandBuffer));
537 case GLES::CommandType::EXECUTE_COMMAND_BUFFERS:
539 // Process secondary command buffers
540 // todo: check validity of the secondaries
541 // there are operations which are illigal to be done
542 // within secondaries.
543 for(auto& buf : cmd.executeCommandBuffers.buffers)
545 ProcessCommandBuffer(*static_cast<const GLES::CommandBuffer*>(buf));
553 void EglGraphicsController::ProcessCommandQueues()
555 // TODO: command queue per context, sync between queues should be
557 currentFramebuffer = nullptr;
561 while(!mCommandQueue.empty())
563 auto cmdBuf = mCommandQueue.front();
565 DUMP_FRAME_COMMAND_BUFFER(cmdBuf);
566 ProcessCommandBuffer(*cmdBuf);
572 void EglGraphicsController::ProcessTextureUpdateQueue()
574 while(!mTextureUpdateRequests.empty())
576 TextureUpdateRequest& request = mTextureUpdateRequests.front();
578 auto& info = request.first;
579 auto& source = request.second;
581 if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
583 // GPU memory must be already allocated.
585 // Check if it needs conversion
586 auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
587 const auto& createInfo = texture->GetCreateInfo();
588 auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
589 auto srcType = GLES::GLTextureFormatType(info.srcFormat).type;
590 auto destInternalFormat = GLES::GLTextureFormatType(createInfo.format).internalFormat;
591 auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
593 // From render-texture.cpp
594 const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
595 info.srcExtent2D.width != (createInfo.size.width / (1 << info.level)) ||
596 info.srcExtent2D.height != (createInfo.size.height / (1 << info.level)));
598 auto* sourceBuffer = reinterpret_cast<uint8_t*>(source.memorySource.memory);
599 std::vector<uint8_t> tempBuffer;
600 if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage))
602 // Convert RGB to RGBA if necessary.
603 texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
604 sourceBuffer = &tempBuffer[0];
605 srcFormat = destFormat;
606 srcType = GLES::GLTextureFormatType(createInfo.format).type;
609 // Calculate the maximum mipmap level for the texture
610 texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
612 GLenum bindTarget{GL_TEXTURE_2D};
613 GLenum target{GL_TEXTURE_2D};
615 if(createInfo.textureType == Graphics::TextureType::TEXTURE_CUBEMAP)
617 bindTarget = GL_TEXTURE_CUBE_MAP;
618 target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer;
621 mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
622 mGlAbstraction->BindTexture(bindTarget, texture->GetGLTexture());
626 if(!texture->IsCompressed())
628 mGlAbstraction->TexImage2D(target,
631 info.srcExtent2D.width,
632 info.srcExtent2D.height,
640 mGlAbstraction->CompressedTexImage2D(target,
643 info.srcExtent2D.width,
644 info.srcExtent2D.height,
652 if(!texture->IsCompressed())
654 mGlAbstraction->TexSubImage2D(target,
658 info.srcExtent2D.width,
659 info.srcExtent2D.height,
666 mGlAbstraction->CompressedTexSubImage2D(target,
670 info.srcExtent2D.width,
671 info.srcExtent2D.height,
677 // free staging memory
678 free(source.memorySource.memory);
682 // TODO: other sources
685 mTextureUpdateRequests.pop();
689 void EglGraphicsController::UpdateTextures(const std::vector<TextureUpdateInfo>& updateInfoList,
690 const std::vector<TextureUpdateSourceInfo>& sourceList)
693 for(auto& info : updateInfoList)
695 mTextureUpdateRequests.push(std::make_pair(info, sourceList[info.srcReference]));
696 auto& pair = mTextureUpdateRequests.back();
697 switch(pair.second.sourceType)
699 case Graphics::TextureUpdateSourceInfo::Type::MEMORY:
701 auto& info = pair.first;
702 auto& source = pair.second;
704 // allocate staging memory and copy the data
705 // TODO: using PBO with GLES3, this is just naive
708 char* stagingBuffer = reinterpret_cast<char*>(malloc(info.srcSize));
709 std::copy(&reinterpret_cast<char*>(source.memorySource.memory)[info.srcOffset],
710 reinterpret_cast<char*>(source.memorySource.memory) + info.srcSize,
713 mTextureUploadTotalCPUMemoryUsed += info.srcSize;
715 // store staging buffer
716 source.memorySource.memory = stagingBuffer;
719 case Graphics::TextureUpdateSourceInfo::Type::BUFFER:
721 // TODO, with PBO support
724 case Graphics::TextureUpdateSourceInfo::Type::TEXTURE:
726 // TODO texture 2 texture in-GPU copy
732 // If upload buffer exceeds maximum size, flush.
733 if(mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB * 1024)
736 mTextureUploadTotalCPUMemoryUsed = 0;
740 void EglGraphicsController::ProcessTextureMipmapGenerationQueue()
742 while(!mTextureMipmapGenerationRequests.empty())
744 auto* texture = mTextureMipmapGenerationRequests.front();
746 mGlAbstraction->BindTexture(texture->GetGlTarget(), texture->GetGLTexture());
747 mGlAbstraction->GenerateMipmap(texture->GetGlTarget());
749 mTextureMipmapGenerationRequests.pop();
753 void EglGraphicsController::GenerateTextureMipmaps(const Graphics::Texture& texture)
755 mTextureMipmapGenerationRequests.push(static_cast<const GLES::Texture*>(&texture));
758 Graphics::UniquePtr<Memory> EglGraphicsController::MapBufferRange(const MapBufferInfo& mapInfo)
760 mGraphics->ActivateResourceContext();
762 // Mapping buffer requires the object to be created NOW
763 // Workaround - flush now, otherwise there will be given a staging buffer
764 // in case when the buffer is not there yet
765 ProcessCreateQueues();
767 if(GetGLESVersion() < GLES::GLESVersion::GLES_30)
769 return Graphics::UniquePtr<Memory>(new GLES::Memory2(mapInfo, *this));
773 return Graphics::UniquePtr<Memory>(new GLES::Memory3(mapInfo, *this));
777 bool EglGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData)
779 return static_cast<GLES::Program*>(&program)->GetImplementation()->GetParameter(parameterId, outData);
782 GLES::PipelineCache& EglGraphicsController::GetPipelineCache() const
784 return *mPipelineCache;
787 } // namespace Dali::Graphics