• 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 VULKAN_SWAPCHAIN_VK_H
17 #define VULKAN_SWAPCHAIN_VK_H
18 
19 #include <cstdint>
20 #include <vulkan/vulkan_core.h>
21 
22 #include <base/containers/vector.h>
23 #include <render/device/gpu_resource_desc.h>
24 #include <render/namespace.h>
25 
26 #include "device/swapchain.h"
27 
28 RENDER_BEGIN_NAMESPACE()
29 class Device;
30 struct SwapchainCreateInfo;
31 
32 struct SwapchainImagesVk {
33     BASE_NS::vector<VkImage> images;
34     BASE_NS::vector<VkImageView> imageViews;
35 
36     uint32_t width { 0 };
37     uint32_t height { 0 };
38 
39     VkSemaphore semaphore { VK_NULL_HANDLE };
40 };
41 
42 struct SwapchainPlatformDataVk final {
43     VkSwapchainKHR swapchain { VK_NULL_HANDLE };
44     SwapchainImagesVk swapchainImages;
45 };
46 
47 class SwapchainVk final : public Swapchain {
48 public:
49     SwapchainVk(Device& device, const SwapchainCreateInfo& swapchainCreateInfo);
50     ~SwapchainVk();
51 
52     const SwapchainPlatformDataVk& GetPlatformData() const;
53     const GpuImageDesc& GetDesc() const override;
54     const GpuImageDesc& GetDescDepthBuffer() const override;
55 
56     uint32_t GetFlags() const override;
57 
58 private:
59     Device& device_;
60 
61     GpuImageDesc desc_;
62     GpuImageDesc descDepthBuffer_;
63     SwapchainPlatformDataVk plat_;
64     uint32_t flags_ { 0u };
65 };
66 RENDER_END_NAMESPACE()
67 
68 #endif // VULKAN_SWAPCHAIN_VK_H
69