1 #ifndef DALI_GRAPHICS_GLES_PROGRAM_H
2 #define DALI_GRAPHICS_GLES_PROGRAM_H
5 * Copyright (c) 2024 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 Preprocesses shaders
74 * @brief Returns GL program id
76 * @return GL program id
78 [[nodiscard]] uint32_t GetGlProgram() const;
81 * @brief Increases ref count
83 * @return new refcount
88 * @brief Decreases ref count
90 * @return New refcount
95 * @brief Retrieves ref count
96 * @return Refcount value
98 [[nodiscard]] uint32_t GetRefCount() const;
101 * @brief Returns reflection
103 * @return Valid reflection associated with the Program
105 [[nodiscard]] const GLES::Reflection& GetReflection() const;
108 * @brief Returns controller
110 * @return Valid Controller object
112 [[nodiscard]] EglGraphicsController& GetController() const;
115 * @brief Returns create info structure
117 * @return Reference to valid create info structure
119 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
122 * @brief Returns parameter value specified by parameterId
124 * This function can be used as a backdoor into the implementation
125 * used to retrieve internal data.
127 * @param[in] parameterId Integer parameter id
128 * @param[out] out Pointer to write to
130 * @return True on success
132 bool GetParameter(uint32_t parameterId, void* out);
135 * @brief Updates standalone uniforms
137 * Updates standalone uniforms (issues the GL calls) and
138 * updates internal uniform cache
140 * @param[in] ptr Valid pointer to the uniform block memory
142 void UpdateStandaloneUniformBlock(const char* ptr);
145 * @brief Builds standalone uniform cache
147 * This function allocates cache memory and
148 * gathers a list of GL functions per uniform type.
150 void BuildStandaloneUniformCache();
153 friend class Program;
156 std::unique_ptr<Impl> mImpl;
159 ///////////////////////////////////////////////////////////////
162 * @brief Wrapper for the program implementation
164 * This object is returned back to the client-side
166 class Program : public Graphics::Program
172 * @param[in] impl Pointer to valid implementation
174 explicit Program(ProgramImpl* impl)
186 * @brief Returns reference to the Reflection object
190 [[nodiscard]] const GLES::Reflection& GetReflection() const;
193 * @brief Retrieves internal program implementation
195 * @return Valid pointer to the ProgramImpl object
197 [[nodiscard]] ProgramImpl* GetImplementation() const
203 * @brief Returns controller
207 [[nodiscard]] EglGraphicsController& GetController() const;
210 * @brief Returns create info structure
212 * @return create info structure
214 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
216 bool operator==(const GLES::Program& program) const
218 return (program.mProgram == mProgram);
221 bool operator==(const GLES::ProgramImpl* programImpl) const
223 return (programImpl == mProgram);
226 bool operator!=(const GLES::Program& program) const
228 return (program.mProgram != mProgram);
232 * @brief Run by UniquePtr to discard resource
234 void DiscardResource();
237 * @brief Destroying GL resources
239 * This function is kept for compatibility with Resource<> class
240 * so can the object can be use with templated functions.
242 void DestroyResource()
244 // nothing to do here
248 ProgramImpl* mProgram{nullptr};
250 } // namespace Dali::Graphics::GLES
252 #endif //DALI_GRAPHICS_GLES_PROGRAM_H