1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef GLES_NODE_CONTEXT_DESCRIPTOR_SET_MANAGER_GLES_H
17 #define GLES_NODE_CONTEXT_DESCRIPTOR_SET_MANAGER_GLES_H
18 
19 #include <base/containers/array_view.h>
20 #include <base/containers/vector.h>
21 #include <render/device/pipeline_layout_desc.h>
22 #include <render/namespace.h>
23 #include <render/render_data_structures.h>
24 
25 #include "nodecontext/node_context_descriptor_set_manager.h"
26 
27 RENDER_BEGIN_NAMESPACE()
28 struct RenderPassBeginInfo;
29 class GpuResourceManager;
30 
31 class NodeContextDescriptorSetManagerGLES final : public NodeContextDescriptorSetManager {
32 public:
33     explicit NodeContextDescriptorSetManagerGLES(Device& device);
34     ~NodeContextDescriptorSetManagerGLES();
35 
36     void ResetAndReserve(const DescriptorCounts& descriptorCounts) override;
37     void BeginFrame() override;
38 
39     RenderHandle CreateDescriptorSet(
40         const BASE_NS::array_view<const DescriptorSetLayoutBinding> descriptorSetLayoutBindings) override;
41     RenderHandle CreateOneFrameDescriptorSet(
42         const BASE_NS::array_view<const DescriptorSetLayoutBinding> descriptorSetLayoutBindings) override;
43 
44     void UpdateDescriptorSetGpuHandle(const RenderHandle handle) override;
45     void UpdateCpuDescriptorSetPlatform(const DescriptorSetLayoutBindingResources& bindingResources) override;
46 
47 private:
48     Device& device_;
49 
50     uint32_t oneFrameDescSetGeneration_ { 0u };
51 #if (RENDER_VALIDATION_ENABLED == 1)
52     static constexpr uint32_t MAX_ONE_FRAME_GENERATION_IDX { 16u };
53 #endif
54 };
55 RENDER_END_NAMESPACE()
56 
57 #endif // GLES_NODE_CONTEXT_DESCRIPTOR_SET_MANAGER_GLES_H
58