1 #ifndef DALI_GRAPHICS_GLES_PIPELINE_CACHE_H
2 #define DALI_GRAPHICS_GLES_PIPELINE_CACHE_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/graphics-api/graphics-pipeline-create-info.h>
23 #include <dali/graphics-api/graphics-pipeline.h>
24 #include <dali/graphics-api/graphics-program-create-info.h>
25 #include <dali/graphics-api/graphics-program.h>
26 #include <dali/graphics-api/graphics-shader-create-info.h>
27 #include <dali/graphics-api/graphics-shader.h>
30 #include "gles-graphics-resource.h"
32 namespace Dali::Graphics
34 class EglGraphicsController;
45 * @brief PipelineCache manages pipeline and program
46 * objects so there are no duplicates created.
54 explicit PipelineCache(EglGraphicsController& controller);
62 * @brief Retrieves pipeline matching the spec
64 * Function returns either existing pipeline if one is found
65 * in the cache or creates new one.
67 * @param[in] pipelineCreateInfo Valid PipelineCreateInfo structure
68 * @param[in] oldPipeline previous pipeline object
69 * @return Pipeline object
71 Graphics::UniquePtr<Graphics::Pipeline> GetPipeline(const PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline);
74 * @brief Retrieves program matching the spec
76 * Function returns either existing program if one is found
77 * in the cache or creates new one.
79 * @param[in] programCreateInfo Valid ProgramCreateInfo structure
80 * @param[in] oldProgram previous program object
81 * @return Program object
83 Graphics::UniquePtr<Graphics::Program> GetProgram(const ProgramCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Program>&& oldProgram);
86 * @brief Retrieves shader matching the spec
88 * Function returns either existing shader if one is found
89 * in the cache or creates new one.
91 * @param[in] shaderCreateInfo Valid ShaderCreateInfo structure
92 * @param[in] oldShader previous shader object
93 * @return Shader object
95 Graphics::UniquePtr<Graphics::Shader> GetShader(const ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader);
98 * @brief Flushes pipeline and program cache
100 * Removes cached items when they are no longer needed. This function
101 * should be called at the very end of Controller render loop iteration.
106 * @brief Set true if we can flush cached pipeline / program / shader.
107 * If we make it false, we can keep shader / program instance during app running.
108 * But it might have sightly panalty for memory.
111 * @param enabled True if we can flush the caches. False when we don't want to flush caches.
113 void EnableCacheFlush(bool enabled);
116 * @brief Notify that we need to flush pipeline cache next FlushCache API.
118 void MarkPipelineCacheFlushRequired();
121 * @brief Notify that we need to flush program cache next FlushCache API.
123 void MarkProgramCacheFlushRequired();
126 * @brief Notify that we need to flush shader cache next FlushCache API.
128 void MarkShaderCacheFlushRequired();
132 * @brief Finds pipeline implementation based on the spec
133 * @param[in] info Valid create info structure
134 * @return Returns pointer to pipeline or nullptr
136 PipelineImpl* FindPipelineImpl(const PipelineCreateInfo& info);
139 * @brief Finds program implementation based on the spec
140 * @param[in] info Valid create info structure
141 * @return Returns pointer to program or nullptr
143 ProgramImpl* FindProgramImpl(const ProgramCreateInfo& info);
146 * @brief Finds shader implementation based on create info
148 * @param[in] shadercreateinfo Valid create info structure
149 * @return Returns pointer to shader or nullptr
151 ShaderImpl* FindShaderImpl(const ShaderCreateInfo& shaderCreateInfo);
155 std::unique_ptr<Impl> mImpl;
158 } // namespace Dali::Graphics