1 #ifndef DALI_GRAPHICS_GLES_PROGRAM_H
2 #define DALI_GRAPHICS_GLES_PROGRAM_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.
21 #include <dali/graphics-api/graphics-program-create-info.h>
22 #include <dali/graphics-api/graphics-program.h>
25 #include "gles-graphics-resource.h"
27 namespace Dali::Graphics::GLES
32 * @brief Program implementation
34 * Program implementation is owned only by the PipelineCache
36 * Like pipeline, it's created and managed by the PipelineCache
44 * @param[in] createInfo Valid create info structure
45 * @param[in] controller Valid reference to the controller object
47 ProgramImpl(const Graphics::ProgramCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
55 * @brief Destroys GL resources associated with the Program
57 * @return True on success
62 * @brief Creates GL resource for this Program
64 * @return True on success
69 * @brief Returns GL program id
71 * @return GL program id
73 [[nodiscard]] uint32_t GetGlProgram() const;
76 * @brief Increases ref count
78 * @return new refcount
83 * @brief Decreases ref count
85 * @return New refcount
90 * @brief Returns reflection
92 * @return Valid reflection associated with the Program
94 [[nodiscard]] const GLES::Reflection& GetReflection() const;
97 * @brief Returns controller
99 * @return Valid Controller object
101 [[nodiscard]] EglGraphicsController& GetController() const;
104 * @brief Returns create info structure
106 * @return Reference to valid create info structure
108 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
111 * @brief Returns parameter value specified by parameterId
113 * This function can be used as a backdoor into the implementation
114 * used to retrieve internal data.
116 * @param[in] parameterId Integer parameter id
117 * @param[out] out Pointer to write to
119 * @return True on success
121 bool GetParameter(uint32_t parameterId, void* out);
124 * @brief Updates standalone uniforms
126 * Updates standalone uniforms (issues the GL calls) and
127 * updates internal uniform cache
129 * @param[in] ptr Valid pointer to the uniform block memory
131 void UpdateStandaloneUniformBlock(const char* ptr);
134 * @brief Builds standalone uniform cache
136 * This function allocates cache memory and
137 * gathers a list of GL functions per uniform type.
139 void BuildStandaloneUniformCache();
142 friend class Program;
145 std::unique_ptr<Impl> mImpl;
148 ///////////////////////////////////////////////////////////////
151 * @brief Wrapper for the pipeline implementation
153 * This object is returned back to the client-side
155 class Program : public Graphics::Program
161 * @param[in] impl Pointer to valid implementation
163 explicit Program(ProgramImpl* impl)
175 * @brief Returns reference to the Reflection object
179 [[nodiscard]] const GLES::Reflection& GetReflection() const;
182 * @brief Retrieves internal program implementation
184 * @return Valid pointer to the ProgramImpl object
186 [[nodiscard]] ProgramImpl* GetImplementation() const
192 * @brief Returns controller
196 [[nodiscard]] EglGraphicsController& GetController() const;
199 * @brief Returns create info structure
201 * @return create info structure
203 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
205 bool operator==(const GLES::Program& program) const
207 return (program.mProgram == mProgram);
210 bool operator==(const GLES::ProgramImpl* programImpl) const
212 return (programImpl == mProgram);
215 bool operator!=(const GLES::Program& program) const
217 return (program.mProgram != mProgram);
221 * @brief Run by UniquePtr to discard resource
223 void DiscardResource();
226 * @brief Destroying GL resources
228 * This function is kept for compatibility with Resource<> class
229 * so can the object can be use with templated functions.
231 void DestroyResource()
233 // nothing to do here
237 ProgramImpl* mProgram{nullptr};
239 } // namespace Dali::Graphics::GLES
241 #endif //DALI_GRAPHICS_GLES_PROGRAM_H