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 VULKAN_PIPELINE_STATE_OBJECT_VK_H
17 #define VULKAN_PIPELINE_STATE_OBJECT_VK_H
18 
19 #include <cstdint>
20 #include <vulkan/vulkan_core.h>
21 
22 #include <render/device/pipeline_state_desc.h>
23 #include <render/namespace.h>
24 
25 #include "device/pipeline_state_object.h"
26 
27 RENDER_BEGIN_NAMESPACE()
28 class Device;
29 class GpuComputeProgram;
30 class GpuShaderProgram;
31 struct PipelineLayout;
32 struct LowLevelRenderPassData;
33 struct LowLevelPipelineLayoutData;
34 
35 struct PipelineStateObjectPlatformDataVk final {
36     VkPipeline pipeline { VK_NULL_HANDLE };
37     VkPipelineLayout pipelineLayout { VK_NULL_HANDLE };
38 };
39 
40 class GraphicsPipelineStateObjectVk final : public GraphicsPipelineStateObject {
41 public:
42     GraphicsPipelineStateObjectVk(Device& device, const GpuShaderProgram& gpuShaderProgram,
43         const GraphicsState& graphicsState, const PipelineLayout& pipelineLayout,
44         const VertexInputDeclarationView& vertexInputDeclaration,
45         const ShaderSpecializationConstantDataView& specializationConstants,
46         const BASE_NS::array_view<const DynamicStateEnum> dynamicStates, const RenderPassDesc& renderPassDesc,
47         const BASE_NS::array_view<const RenderPassSubpassDesc>& renderPassSubpassDescs, const uint32_t subpassIndex,
48         const LowLevelRenderPassData& renderPassData, const LowLevelPipelineLayoutData& pipelineLayoutData);
49     ~GraphicsPipelineStateObjectVk();
50 
51     const PipelineStateObjectPlatformDataVk& GetPlatformData() const;
52 
53 private:
54     Device& device_;
55 
56     PipelineStateObjectPlatformDataVk plat_;
57 };
58 
59 class ComputePipelineStateObjectVk final : public ComputePipelineStateObject {
60 public:
61     ComputePipelineStateObjectVk(Device& device, const GpuComputeProgram& gpuComputeProgram,
62         const PipelineLayout& pipelineLayout, const ShaderSpecializationConstantDataView& specializationConstants,
63         const LowLevelPipelineLayoutData& pipelineLayoutData);
64     ~ComputePipelineStateObjectVk();
65 
66     const PipelineStateObjectPlatformDataVk& GetPlatformData() const;
67 
68 private:
69     Device& device_;
70 
71     PipelineStateObjectPlatformDataVk plat_;
72 };
73 RENDER_END_NAMESPACE()
74 
75 #endif // VULKAN_PIPELINE_STATE_OBJECT_VK_H
76