/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #ifdef XR_USE_PLATFORM_ANDROID #include #endif #include "utils/handle.h" #include #include #include #include namespace xr { class session; class swapchain : public utils::handle { public: struct image { vk::Image image{}; vk::raii::ImageView view = nullptr; }; private: int32_t width_; int32_t height_; int sample_count_; vk::Format format_; std::vector images_; public: swapchain() = default; swapchain(session &, vk::raii::Device& device, vk::Format format, int32_t width, int32_t height, int sample_count = 1); swapchain(swapchain &&) = default; swapchain(const swapchain &) = delete; swapchain & operator=(swapchain &&) = default; swapchain & operator=(const swapchain &) = delete; ~swapchain(); int32_t width() const { return width_; } int32_t height() const { return height_; } XrExtent2Di extent() const { return { width_, height_ }; } int sample_count() const { return sample_count_; } const std::vector & images() const { return images_; } std::vector & images() { return images_; } vk::Format format() const { return format_; } int acquire(); bool wait(XrDuration timeout = XR_INFINITE_DURATION); void release(); }; } // namespace xr