• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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_PIPELINE_STATE_OBJECT_GLES_H
17 #define GLES_PIPELINE_STATE_OBJECT_GLES_H
18 
19 #include <base/containers/unique_ptr.h>
20 #include <base/containers/unordered_map.h>
21 #include <render/device/pipeline_layout_desc.h>
22 #include <render/namespace.h>
23 
24 #include "device/pipeline_state_object.h"
25 
26 RENDER_BEGIN_NAMESPACE()
27 class Device;
28 class DeviceGLES;
29 class GpuShaderProgram;
30 class GpuComputeProgram;
31 class GpuComputeProgramGLES;
32 class GpuShaderProgramGLES;
33 struct OES_Bind;
34 
35 struct PipelineStateObjectPlatformDataGL final {
36     const GpuComputeProgramGLES* computeShader;
37     const GpuShaderProgramGLES* graphicsShader;
38     GraphicsState graphicsState;
39     PipelineLayout pipelineLayout;
40     VertexInputDeclarationData vertexInputDeclaration;
41     RenderPassDesc renderPassDesc;
42     DynamicStateFlags dynamicStateFlags;
43     uint32_t vao;
44 };
45 
46 class GraphicsPipelineStateObjectGLES final : public GraphicsPipelineStateObject {
47 public:
48     GraphicsPipelineStateObjectGLES(Device& device, const GpuShaderProgram& gpuShaderProgram,
49         const GraphicsState& graphicsState, const PipelineLayout& pipelineLayout,
50         const VertexInputDeclarationView& vertexInputDeclaration,
51         const ShaderSpecializationConstantDataView& specializationConstants, const DynamicStateFlags dynamicStateFlags,
52         const RenderPassDesc& renderPassDesc,
53         const BASE_NS::array_view<const RenderPassSubpassDesc>& renderPassSubpassDescs, const uint32_t subpassIndex);
54 
55     ~GraphicsPipelineStateObjectGLES();
56 
57     const PipelineStateObjectPlatformDataGL& GetPlatformData() const;
58 
59     GpuShaderProgramGLES* GetOESProgram(const BASE_NS::vector<OES_Bind>& oes_binds) const;
60 
61 private:
62     void MakeVAO() noexcept;
63     DeviceGLES& device_;
64 
65     PipelineStateObjectPlatformDataGL plat_ {};
66     BASE_NS::unique_ptr<GpuShaderProgramGLES> specialized_;
67 
68     mutable BASE_NS::unordered_map<BASE_NS::string, BASE_NS::unique_ptr<GpuShaderProgramGLES>>
69         oesPrograms_; // generated dynamically.
70 };
71 
72 class ComputePipelineStateObjectGLES final : public ComputePipelineStateObject {
73 public:
74     ComputePipelineStateObjectGLES(Device& device, const GpuComputeProgram& gpuComputeProgram,
75         const PipelineLayout& pipelineLayout, const ShaderSpecializationConstantDataView& specializationConstants);
76     ~ComputePipelineStateObjectGLES();
77 
78     const PipelineStateObjectPlatformDataGL& GetPlatformData() const;
79 
80 private:
81     DeviceGLES& device_;
82 
83     PipelineStateObjectPlatformDataGL plat_ {};
84     GpuComputeProgramGLES* specialized_ { nullptr };
85 };
86 RENDER_END_NAMESPACE()
87 
88 #endif // GLES_PIPELINE_STATE_OBJECT_GLES_H
89