18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci 168bf80f4bSopenharmony_ci#ifndef VULKAN_SWAPCHAIN_VK_H 178bf80f4bSopenharmony_ci#define VULKAN_SWAPCHAIN_VK_H 188bf80f4bSopenharmony_ci 198bf80f4bSopenharmony_ci#include <cstdint> 208bf80f4bSopenharmony_ci#include <vulkan/vulkan_core.h> 218bf80f4bSopenharmony_ci 228bf80f4bSopenharmony_ci#include <base/containers/vector.h> 238bf80f4bSopenharmony_ci#include <render/device/gpu_resource_desc.h> 248bf80f4bSopenharmony_ci#include <render/namespace.h> 258bf80f4bSopenharmony_ci 268bf80f4bSopenharmony_ci#include "device/swapchain.h" 278bf80f4bSopenharmony_ci 288bf80f4bSopenharmony_ciRENDER_BEGIN_NAMESPACE() 298bf80f4bSopenharmony_ciclass Device; 308bf80f4bSopenharmony_cistruct SwapchainCreateInfo; 318bf80f4bSopenharmony_ci 328bf80f4bSopenharmony_cistruct SwapchainImagesVk { 338bf80f4bSopenharmony_ci BASE_NS::vector<VkImage> images; 348bf80f4bSopenharmony_ci BASE_NS::vector<VkImageView> imageViews; 358bf80f4bSopenharmony_ci 368bf80f4bSopenharmony_ci uint32_t width { 0 }; 378bf80f4bSopenharmony_ci uint32_t height { 0 }; 388bf80f4bSopenharmony_ci 398bf80f4bSopenharmony_ci BASE_NS::vector<VkSemaphore> semaphores; 408bf80f4bSopenharmony_ci}; 418bf80f4bSopenharmony_ci 428bf80f4bSopenharmony_cistruct SwapchainPlatformDataVk final { 438bf80f4bSopenharmony_ci VkSwapchainKHR swapchain { VK_NULL_HANDLE }; 448bf80f4bSopenharmony_ci SwapchainImagesVk swapchainImages; 458bf80f4bSopenharmony_ci}; 468bf80f4bSopenharmony_ci 478bf80f4bSopenharmony_ciclass SwapchainVk final : public Swapchain { 488bf80f4bSopenharmony_cipublic: 498bf80f4bSopenharmony_ci SwapchainVk(Device& device, const SwapchainCreateInfo& swapchainCreateInfo); 508bf80f4bSopenharmony_ci ~SwapchainVk(); 518bf80f4bSopenharmony_ci 528bf80f4bSopenharmony_ci const SwapchainPlatformDataVk& GetPlatformData() const; 538bf80f4bSopenharmony_ci const GpuImageDesc& GetDesc() const override; 548bf80f4bSopenharmony_ci const GpuImageDesc& GetDescDepthBuffer() const override; 558bf80f4bSopenharmony_ci 568bf80f4bSopenharmony_ci uint32_t GetFlags() const override; 578bf80f4bSopenharmony_ci SurfaceTransformFlags GetSurfaceTransformFlags() const override; 588bf80f4bSopenharmony_ci uint64_t GetSurfaceHandle() const override; 598bf80f4bSopenharmony_ci 608bf80f4bSopenharmony_ci // only for locked backend usage to get always the next semaphore index in image acquire 618bf80f4bSopenharmony_ci uint32_t GetNextAcquireSwapchainSemaphoreIndex() const; 628bf80f4bSopenharmony_ci 638bf80f4bSopenharmony_ciprivate: 648bf80f4bSopenharmony_ci Device& device_; 658bf80f4bSopenharmony_ci 668bf80f4bSopenharmony_ci VkSurfaceKHR surface_ {}; 678bf80f4bSopenharmony_ci bool ownsSurface_ { false }; 688bf80f4bSopenharmony_ci 698bf80f4bSopenharmony_ci GpuImageDesc desc_; 708bf80f4bSopenharmony_ci GpuImageDesc descDepthBuffer_; 718bf80f4bSopenharmony_ci SwapchainPlatformDataVk plat_; 728bf80f4bSopenharmony_ci uint32_t flags_ { 0u }; 738bf80f4bSopenharmony_ci SurfaceTransformFlags surfaceTransformFlags_ { 0u }; 748bf80f4bSopenharmony_ci 758bf80f4bSopenharmony_ci // mutable object for locked backend usage only 768bf80f4bSopenharmony_ci mutable uint32_t currSemaphoreIdx_ { 0U }; 778bf80f4bSopenharmony_ci}; 788bf80f4bSopenharmony_ciRENDER_END_NAMESPACE() 798bf80f4bSopenharmony_ci 808bf80f4bSopenharmony_ci#endif // VULKAN_SWAPCHAIN_VK_H 81