Merge remote-tracking branch 'origin/monado-update'

This commit is contained in:
Guillaume Meunier
2023-07-29 11:42:29 +02:00
9 changed files with 56 additions and 38 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20)
project(WiVRn VERSION 1.0 LANGUAGES C CXX)
project(WiVRn VERSION 1.0.0 LANGUAGES C CXX)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
@@ -78,7 +78,7 @@ FetchContent_Declare(tinygltf URL https://github.com/syoyo/tinygltf/archive/refs
FetchContent_Declare(boostpfr URL https://github.com/boostorg/pfr/archive/refs/tags/2.0.3.tar.gz)
FetchContent_Declare(monado
GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado
GIT_TAG e9475b13137db2cca8571576b5381a70fb8180a5
GIT_TAG e39e0ee5ffc6b961dd51a556c83fe5e7f76822d8
)
+21 -19
View File
@@ -1,23 +1,25 @@
set(XRT_BUILD_DRIVER_ARDUINO OFF)
set(XRT_BUILD_DRIVER_DAYDREAM OFF)
set(XRT_BUILD_DRIVER_EUROC OFF)
set(XRT_BUILD_DRIVER_HDK OFF)
set(XRT_BUILD_DRIVER_HYDRA OFF)
set(XRT_BUILD_DRIVER_NS OFF)
set(XRT_BUILD_DRIVER_OHMD OFF)
set(XRT_BUILD_DRIVER_OPENGLOVES OFF)
set(XRT_BUILD_DRIVER_PSMV OFF)
set(XRT_BUILD_DRIVER_PSVR OFF)
set(XRT_BUILD_DRIVER_QWERTY OFF)
set(XRT_BUILD_DRIVER_REMOTE OFF)
set(XRT_BUILD_DRIVER_RIFT_S OFF)
set(XRT_BUILD_DRIVER_SIMULATED ON)
set(XRT_BUILD_DRIVER_TWRAP OFF)
set(XRT_BUILD_DRIVER_VF OFF)
set(XRT_BUILD_DRIVER_VIVE OFF)
set(XRT_BUILD_DRIVER_WMR OFF)
set(XRT_BUILD_SAMPLES OFF)
set(XRT_BUILD_DRIVER_ARDUINO OFF)
set(XRT_BUILD_DRIVER_DAYDREAM OFF)
set(XRT_BUILD_DRIVER_EUROC OFF)
set(XRT_BUILD_DRIVER_HDK OFF)
set(XRT_BUILD_DRIVER_HYDRA OFF)
set(XRT_BUILD_DRIVER_NS OFF)
set(XRT_BUILD_DRIVER_OHMD OFF)
set(XRT_BUILD_DRIVER_OPENGLOVES OFF)
set(XRT_BUILD_DRIVER_PSMV OFF)
set(XRT_BUILD_DRIVER_PSSENSE OFF)
set(XRT_BUILD_DRIVER_PSVR OFF)
set(XRT_BUILD_DRIVER_QWERTY OFF)
set(XRT_BUILD_DRIVER_REMOTE OFF)
set(XRT_BUILD_DRIVER_RIFT_S OFF)
set(XRT_BUILD_DRIVER_SIMULATED ON)
set(XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE OFF)
set(XRT_BUILD_DRIVER_TWRAP OFF)
set(XRT_BUILD_DRIVER_VF OFF)
set(XRT_BUILD_DRIVER_VIVE OFF)
set(XRT_BUILD_DRIVER_WMR OFF)
set(XRT_BUILD_SAMPLES OFF)
set(XRT_FEATURE_COMPOSITOR_NULL OFF)
set(XRT_FEATURE_SERVICE ON)
+2 -1
View File
@@ -40,6 +40,7 @@ namespace xrt::drivers::wivrn
std::unique_ptr<VideoEncoder> VideoEncoder::Create(
vk_bundle * vk,
vk_cmd_pool & pool,
encoder_settings & settings,
uint8_t stream_idx,
int input_width,
@@ -51,7 +52,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
#ifdef WIVRN_HAVE_X264
if (settings.encoder_name == encoder_x264)
{
res = std::make_unique<VideoEncoderX264>(vk, settings, input_width, input_height, fps);
res = std::make_unique<VideoEncoderX264>(vk, pool, settings, input_width, input_height, fps);
}
#endif
#ifdef WIVRN_HAVE_CUDA
+4
View File
@@ -19,6 +19,7 @@
#pragma once
#include "vk/vk_cmd_pool.h"
#include "vk/vk_helpers.h"
#include <chrono>
#include <memory>
@@ -40,8 +41,10 @@ inline const char * encoder_x264 = "x264";
class VideoEncoder
{
std::mutex mutex;
protected:
uint8_t stream_idx;
private:
uint64_t frame_idx;
@@ -52,6 +55,7 @@ private:
public:
static std::unique_ptr<VideoEncoder> Create(vk_bundle * vk,
vk_cmd_pool & pool,
encoder_settings & settings,
uint8_t stream_idx,
int input_width,
+2
View File
@@ -82,6 +82,7 @@ void VideoEncoderX264::InsertInPendingNal(pending_nal && nal)
VideoEncoderX264::VideoEncoderX264(
vk_bundle * vk,
vk_cmd_pool & pool,
encoder_settings & settings,
int input_width,
int input_height,
@@ -100,6 +101,7 @@ VideoEncoderX264::VideoEncoderX264(
converter = std::make_unique<YuvConverter>(
vk,
pool,
VkExtent3D{uint32_t(settings.video_width), uint32_t(settings.video_height), 1},
settings.offset_x,
settings.offset_y,
+1 -1
View File
@@ -51,7 +51,7 @@ class VideoEncoderX264 : public VideoEncoder
std::list<pending_nal> pending_nals;
public:
VideoEncoderX264(vk_bundle * vk, encoder_settings & settings, int input_width, int input_height, float fps);
VideoEncoderX264(vk_bundle * vk, vk_cmd_pool & pool, encoder_settings & settings, int input_width, int input_height, float fps);
void SetImages(int width,
int height,
+17 -10
View File
@@ -22,6 +22,8 @@
#include "math/m_space.h"
#include "util/u_pacing.h"
#include "video_encoder.h"
#include "vk/vk_cmd.h"
#include "vk/vk_cmd_pool.h"
#include "xrt/xrt_config_have.h"
#include "xrt_cast.h"
#include <atomic>
@@ -53,6 +55,8 @@ struct wivrn_comp_target : public comp_target
//! Compositor frame pacing helper
struct u_pacing_compositor * upc{};
vk_cmd_pool pool;
float fps;
int64_t current_frame_id;
@@ -116,7 +120,7 @@ static void destroy_images(struct wivrn_comp_target * cn)
vk->vkDestroyImageView(vk->device, cn->images[i].view, NULL);
vk->vkDestroyImage(vk->device, cn->images[i].handle, NULL);
vk->vkFreeMemory(vk->device, cn->psc.images[i].memory, NULL);
vk->vkFreeCommandBuffers(vk->device, vk->cmd_pool, 1, &cn->psc.images[i].present_cmd);
vk->vkFreeCommandBuffers(vk->device, cn->pool.pool, 1, &cn->psc.images[i].present_cmd);
}
free(cn->images);
@@ -154,7 +158,7 @@ static void create_encoders(wivrn_comp_target * cn, std::vector<encoder_settings
{
uint8_t stream_index = cn->encoders.size();
auto & encoder = cn->encoders.emplace_back(
VideoEncoder::Create(vk, settings, stream_index, desc.width, desc.height, desc.fps));
VideoEncoder::Create(vk, cn->pool, settings, stream_index, desc.width, desc.height, desc.fps));
desc.items.push_back(settings);
std::vector<VkImage> images(cn->image_count);
@@ -304,11 +308,10 @@ static VkResult create_images(struct wivrn_comp_target * cn, VkImageUsageFlags f
createinfo.flags = 0;
res = vk->vkCreateFence(vk->device, &createinfo, NULL, &cn->psc.images[i].fence);
vk_check_error("vkCreateFence", res, res);
res = vk_cmd_buffer_create_and_begin(vk, &cn->psc.images[i].present_cmd);
vk_check_error("vk_cmd_buffer_create_and_begin", res, res);
res = vk_cmd_pool_create_and_begin_cmd_buffer(vk, &cn->pool, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, &cn->psc.images[i].present_cmd);
vk_check_error("vk_cmd_pool_create_and_begin_cmd_buffer", res, res);
VkImageSubresourceRange first_color_level_subresource_range{
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
@@ -333,7 +336,10 @@ static bool comp_wivrn_init_pre_vulkan(struct comp_target * ct)
static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t preferred_width, uint32_t preferred_height)
{
return true;
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
auto res = vk_cmd_pool_init(get_vk(cn), &cn->pool, 0);
return not vk_has_error(res, "vk_cmd_pool_init", __FILE__, __LINE__);
}
static bool comp_wivrn_check_ready(struct comp_target * ct)
@@ -456,7 +462,7 @@ static VkResult comp_wivrn_acquire(struct comp_target * ct, uint32_t * out_index
submit.signalSemaphoreCount = 1;
submit.pSignalSemaphores = &cn->semaphores.present_complete;
VkResult res = vk_locked_submit(vk, vk->queue, 1, &submit, VK_NULL_HANDLE);
VkResult res = vk_cmd_pool_submit(vk, &cn->pool, 1, &submit, VK_NULL_HANDLE);
vk_check_error("vk_locked_submit", res, res);
res = VK_ERROR_OUT_OF_HOST_MEMORY;
@@ -523,7 +529,8 @@ static void * comp_wivrn_present_thread(void * void_param)
}
VkResult res = vk->vkWaitForFences(vk->device, nb_fences, fences.data(), VK_TRUE, UINT64_MAX);
if (nb_fences > 1) {
if (nb_fences > 1)
{
U_LOG_I("Encoder group %d dropped %d frames", param->thread->index, nb_fences - 1);
}
vk_check_error("vkWaitForFences", res, NULL);
@@ -601,7 +608,7 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
std::lock_guard lock(cn->psc.mutex);
VkResult res = vk->vkResetFences(vk->device, 1, &cn->psc.images[index].fence);
vk_check_error("vkResetFences", res, res);
res = vk_locked_submit(vk, vk->queue, 1, &submit, cn->psc.images[index].fence);
res = vk_cmd_pool_submit(vk, &cn->pool, 1, &submit, cn->psc.images[index].fence);
vk_check_error("vk_locked_submit", res, res);
assert(cn->psc.images[index].status == image_acquired);
@@ -734,7 +741,7 @@ static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, uint6
*
*/
comp_target * comp_target_wivrn_create(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor* c, float fps)
comp_target * comp_target_wivrn_create(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps)
{
wivrn_comp_target * cn = new wivrn_comp_target{};
+4 -4
View File
@@ -128,8 +128,8 @@ static void destroy_all(YuvConverter * ptr)
throw std::runtime_error(fun "failed"); \
} while (0)
YuvConverter::YuvConverter(vk_bundle * vk, VkExtent3D extent, int offset_x, int offset_y, int input_width, int input_height) :
vk(*vk)
YuvConverter::YuvConverter(vk_bundle * vk, vk_cmd_pool & pool, VkExtent3D extent, int offset_x, int offset_y, int input_width, int input_height) :
vk(*vk), pool(pool)
{
std::unique_ptr<YuvConverter, decltype(&destroy_all)> deleter(this, destroy_all);
@@ -365,8 +365,8 @@ void YuvConverter::SetImages(int num_images, VkImage * images, VkImageView * vie
vk.vkUpdateDescriptorSets(vk.device, 1, &descriptorWrite, 0, nullptr);
VkCommandBuffer cmdBuffer;
res = vk_cmd_buffer_create_and_begin(&vk, &cmdBuffer);
vk_check_throw("vk_cmd_buffer_create_and_begin", res);
res = vk_cmd_pool_create_and_begin_cmd_buffer(&vk, &pool, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, &cmdBuffer);
vk_check_throw("vk_cmd_pool_create_and_begin_cmd_buffer", res);
for (auto & comp: {y, uv})
{
+3 -1
View File
@@ -19,6 +19,7 @@
#pragma once
#include "vk/vk_cmd_pool.h"
#include "vk/vk_helpers.h"
#include <vector>
#include <vulkan/vulkan_core.h>
@@ -42,6 +43,7 @@ public:
int stride;
};
vk_bundle & vk;
vk_cmd_pool & pool;
image_bundle y;
image_bundle uv;
VkSampler sampler = VK_NULL_HANDLE;
@@ -55,7 +57,7 @@ public:
std::vector<VkCommandBuffer> command_buffers;
std::vector<VkDescriptorSet> descriptor_sets;
YuvConverter(vk_bundle * vk, VkExtent3D extent, int offset_x, int offset_y, int input_width, int input_height);
YuvConverter(vk_bundle * vk, vk_cmd_pool & pool, VkExtent3D extent, int offset_x, int offset_y, int input_width, int input_height);
~YuvConverter();
void SetImages(int num_images, VkImage * images, VkImageView * views);