1 #ifndef DALI_GRAPHICS_GLES_PIPELINE_H
2 #define DALI_GRAPHICS_GLES_PIPELINE_H
5 * Copyright (c) 2021 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>
27 #include "gles-graphics-reflection.h"
28 #include "gles-graphics-resource.h"
30 namespace Dali::Graphics::GLES
36 * @brief PipelineImpl is the implementation of Pipeline
38 * PipelineImpl is owned by the pipeline cache. The client-side
39 * will receive Graphics::Pipeline objects which are only
40 * wrappers for this implementation. The lifecycle of
41 * PipelineImpl is managed by the PipelineCache.
48 * @param[in] createInfo valid TextureCreateInfo structure
49 * @param[in] controller Reference to the Controller
50 * @param[in] pipelineCache Reference to valid pipeline cache
52 PipelineImpl(const Graphics::PipelineCreateInfo& createInfo, Graphics::EglGraphicsController& controller, PipelineCache& pipelineCache);
60 * @brief Binds pipeline
62 * Binds Pipeline by binding GL program and flushing state.
64 * @param[in] glProgram The GL program to be bound
66 void Bind(const uint32_t glProgram) const;
69 * @brief Increases ref count
74 * @brief Decreases ref count
79 * @brief Retrieves ref count
80 * @return Refcount value
82 [[nodiscard]] uint32_t GetRefCount() const;
85 * @brief Returns PipelineCreateInfo structure
87 * @return PipelineCreateInfo structure
89 [[nodiscard]] const PipelineCreateInfo& GetCreateInfo() const;
92 * @brief Returns controller
94 * @return Reference to the Controller
96 [[nodiscard]] auto& GetController() const;
100 * @brief Helper function. Copies state if pointer is set
103 void CopyStateIfSet(const T* sourceState, T& copyState, T** destState)
105 *destState = nullptr;
108 copyState = *sourceState;
109 *destState = ©State;
114 * @brief Helper function. Copies const state if pointer is set
117 void CopyStateIfSet(const T* sourceState, T& copyState, const T** destState)
119 *destState = nullptr;
122 copyState = *sourceState;
123 *destState = ©State;
127 // Pipeline state is store locally so any assigned pointers on a
128 // client-side may go safely out of scope.
129 struct PipelineState;
130 std::unique_ptr<PipelineState> mPipelineState;
132 EglGraphicsController& mController;
133 PipelineCreateInfo mCreateInfo;
135 uint32_t mRefCount{0u};
139 * @brief Pipeline class wraps the PipelineImpl
141 class Pipeline : public Graphics::Pipeline
148 * @param pipeline Pipeline implementation
150 explicit Pipeline(GLES::PipelineImpl& pipeline)
151 : mPipeline(pipeline)
160 ~Pipeline() override;
163 * @brief Returns pipeline implementation
165 * @return Valid pipeline implementation
167 [[nodiscard]] auto& GetPipeline() const
173 * @brief Returns create info structure
175 * @return Valid create info structure
177 [[nodiscard]] const PipelineCreateInfo& GetCreateInfo() const;
180 * @brief Returns controller
182 * @return reference to Controller
184 [[nodiscard]] EglGraphicsController& GetController() const;
186 bool operator==(const PipelineImpl* impl) const
188 return &mPipeline == impl;
192 * @brief Run by UniquePtr to discard resource
194 void DiscardResource();
197 * @brief Destroy resource
199 * Despite this class doesn't inherit Resource it must provide
200 * (so it won't duplicate same data) same set of functions
201 * so it can work with resource management functions of Controller.
203 void DestroyResource()
205 // Nothing to do here
209 GLES::PipelineImpl& mPipeline;
212 } // namespace Dali::Graphics::GLES