/* * 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 #include "vk/allocation.h" #include #include #include #include #include #include #include #include struct image_loader { image_allocation image; vk::raii::ImageView image_view = nullptr; vk::Format format; vk::Extent3D extent; vk::ImageType image_type; vk::ImageViewType image_view_type; uint32_t num_mipmaps; buffer_allocation staging_buffer; // Load a PNG/JPEG file image_loader(vk::raii::Device & device, vk::raii::CommandBuffer & cb, std::span bytes, bool srgb); // Load raw pixel data image_loader(vk::raii::Device & device, vk::raii::CommandBuffer & cb, const void * pixels, vk::Extent3D extent, vk::Format format); template image_loader(vk::raii::Device & device, vk::raii::CommandBuffer & cb, std::span pixels, vk::Extent3D extent, vk::Format format) : image_loader(device, cb, pixels.data(), extent, format) {} template image_loader(vk::raii::Device & device, vk::raii::CommandBuffer & cb, const std::array & pixels, vk::Extent3D extent, vk::Format format) : image_loader(device, cb, pixels.data(), extent, format) {} private: void do_load(vk::raii::Device & device, vk::raii::CommandBuffer & cb, const void * pixels, vk::Extent3D extent, vk::Format format); };