1 #ifndef DALI_INTERNAL_SHADER_CACHE_H
2 #define DALI_INTERNAL_SHADER_CACHE_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.
20 #include <dali/graphics-api/graphics-controller.h>
21 #include <dali/graphics-api/graphics-shader-create-info.h>
22 #include <dali/graphics-api/graphics-shader.h>
32 * Caches graphics shaders as they are created by SceneGraph::Shader.
39 Item(const Item&) = delete;
40 Item(Item&&) = default;
42 Item(Graphics::UniquePtr<Dali::Graphics::Shader> shader,
43 const std::vector<char>& shaderCode,
44 Graphics::PipelineStage stage,
45 Graphics::ShaderSourceMode type)
46 : shader(std::move(shader)),
47 shaderCode(shaderCode),
55 Graphics::UniquePtr<Dali::Graphics::Shader> shader{nullptr};
56 std::vector<char> shaderCode;
57 Graphics::PipelineStage stage;
58 Graphics::ShaderSourceMode type;
64 * @param[in] controller The graphics controller
66 explicit ShaderCache(Dali::Graphics::Controller& controller);
69 * Get a shader from it's source code
71 * @param[in] shaderCode The shader code
72 * @param[in] stage The pipeline stage (e.g. VERTEX_SHADER or FRAGMENT_SHADER etc.)
73 * @param[in] type The type of the shader (i.e. text or binary)
74 * @return the graphics shader
76 Dali::Graphics::Shader& GetShader(const std::vector<char>& shaderCode, Graphics::PipelineStage stage, Graphics::ShaderSourceMode type);
79 std::vector<Item> mItems;
80 Dali::Graphics::Controller& mController;
84 } // namespace Internal
87 #endif //DALI_INTERNAL_SHADER_CACHE_H