/* * WiVRn VR streaming * Copyright (C) 2025 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 "decoder.h" #include "vk/allocation.h" #include namespace wivrn { class raw_decoder : public decoder { private: static const int image_count = 5; struct image { image_allocation image; vk::raii::ImageView view_full = nullptr; vk::ImageLayout current_layout = vk::ImageLayout::eUndefined; std::atomic_bool free = true; vk::raii::Semaphore semaphore = nullptr; uint64_t semaphore_val = 0; }; vk::raii::Device & device; vk::raii::SamplerYcbcrConversion ycbcr_conversion; vk::raii::Sampler sampler_; vk::raii::CommandPool command_pool; vk::CommandBuffer cmd; vk::raii::Fence fence; std::array image_pool; std::weak_ptr weak_scene; uint64_t current_frame = 0; std::array input; uint8_t * input_pos; from_headset::feedback feedback; to_headset::video_stream_data_shard::view_info_t view_info; public: raw_decoder(vk::raii::Device & device, vk::raii::PhysicalDevice & physical_device, uint32_t vk_queue_family_index, const wivrn::to_headset::video_stream_description::item & description, uint8_t stream_index, std::weak_ptr scene); void push_data(std::span> data, uint64_t frame_index, bool partial) override; void frame_completed( const wivrn::from_headset::feedback & feedback, const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info) override; vk::Sampler sampler() override { return *sampler_; } vk::Extent2D image_size() { return { description.width, description.height, }; } static std::vector supported_codecs(); private: image * get_free(); }; } // namespace wivrn