1 #ifndef DALI_INTERNAL_RENDER_PIPELINE_CACHE_H
2 #define DALI_INTERNAL_RENDER_PIPELINE_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.
21 #include <dali/internal/common/blending-options.h>
22 #include <dali/graphics-api/graphics-types.h>
23 #include <dali/graphics-api/graphics-controller.h>
24 #include <dali/graphics-api/graphics-pipeline.h>
29 namespace Dali::Internal
38 * Cache Level 2 : Last level of cache, stores actual pipeline
40 struct PipelineCacheL2
43 Graphics::ColorBlendState colorBlendState;
44 Graphics::UniquePtr<Graphics::Pipeline> pipeline;
48 * Cache Level 1 : Stores rasterization and input assembly states
50 struct PipelineCacheL1
53 PipelineCacheL2 *GetPipelineCacheL2(bool blend, bool premul, BlendingOptions &blendingOptions);
55 uint32_t hashCode{}; // 1byte cull, 1byte poly, 1byte frontface
56 Graphics::RasterizationState rs{};
57 Graphics::InputAssemblyState ia{};
59 PipelineCacheL2 noBlend; // special case
60 std::vector<PipelineCacheL2> level2nodes;
64 * Cache Level 0 : Stores geometry, program amd vertex input state
66 struct PipelineCacheL0 // L0 cache
68 PipelineCacheL1 *GetPipelineCacheL1(Render::Renderer *renderer, bool usingReflection);
72 Graphics::VertexInputState inputState;
74 std::vector<PipelineCacheL1> level1nodes;
77 struct PipelineCacheQueryInfo
84 bool cameraUsingReflection;
88 bool alphaPremultiplied;
89 BlendingOptions *blendingOptions;
94 * Result of PipelineCache::GetPipeline() call
98 Graphics::Pipeline* pipeline;
100 PipelineCacheL0* level0;
101 PipelineCacheL1* level1;
102 PipelineCacheL2* level2;
113 * @param[in] controller Graphics controller
115 explicit PipelineCache(Graphics::Controller& controller);
118 * Retrieves next cache level
120 PipelineCacheL0* GetPipelineCacheL0( Program *program, Render::Geometry *geometry);
123 * Retrieves pipeline matching queryInfo struct
125 * May retrieve existing pipeline or create one or return nullptr.
127 PipelineResult GetPipeline( const PipelineCacheQueryInfo& queryInfo, bool createNewIfNotFound );
131 Graphics::Controller* graphicsController{nullptr};
132 std::vector<PipelineCacheL0> level0nodes;
138 #endif // DALI_INTERNAL_RENDER_PIPELINE_CACHE_H