Skip to content
Snippets Groups Projects
Commit 4c45bb13 authored by Jens Koenen's avatar Jens Koenen
Browse files

Merge remote-tracking branch 'remotes/origin/develop' into feature/remote-controllers

parents 8ab32c6b 93d92eb1
No related branches found
No related tags found
No related merge requests found
......@@ -51,3 +51,6 @@
[submodule "ext/asio"]
path = ext/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "ext/openxr"]
path = ext/openxr
url = https://github.com/KhronosGroup/OpenXR-SDK.git
......@@ -28,6 +28,9 @@ message("> module")
# Enable Vulkan Beta Extension needed for Vulkan Video
add_compile_definitions(VK_ENABLE_BETA_EXTENSIONS)
# Use OpenXR together with Vulkan
add_compile_definitions(XR_USE_GRAPHICS_API_VULKAN)
set(LIBLAVA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/liblava)
set(LIBLAVA_EXT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext)
set(LIBLAVA_RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/res)
......@@ -384,6 +387,13 @@ endif ()
message("<<< openvr")
add_subdirectory(${LIBLAVA_EXT_DIR}/openxr openxr)
message(">>> openxr")
message("<<< openxr")
message(">>> assimp")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
......@@ -682,7 +692,8 @@ message("=======================================================================
#Headset
${SRC_DIR}/headset/headset.hpp ${SRC_DIR}/headset/headset.cpp
${SRC_DIR}/headset/emulated_headset.hpp ${SRC_DIR}/headset/emulated_headset.cpp
${SRC_DIR}/headset/local_headset.hpp ${SRC_DIR}/headset/local_headset.cpp
${SRC_DIR}/headset/openvr_headset.hpp ${SRC_DIR}/headset/openvr_headset.cpp
${SRC_DIR}/headset/openxr_headset.hpp ${SRC_DIR}/headset/openxr_headset.cpp
${SRC_DIR}/headset/remote_headset.hpp ${SRC_DIR}/headset/remote_headset.cpp
#Strategy
......@@ -761,6 +772,7 @@ message("=======================================================================
else ()
target_link_libraries(${NAME} lava::app openvr_api)
endif ()
target_link_libraries(${NAME} lava::app openxr_loader)
target_link_libraries(${NAME} lava::app assimp::assimp)
target_include_directories(${NAME} PUBLIC ${OPENVR_HEADER_DIR})
target_link_libraries(${NAME} "${CMAKE_SOURCE_DIR}/ext/openvr/lib/win64/openvr_api.lib")
......
Subproject commit 1ca7bec6b531185530c9b4f1e7a50e1fd55e7641
#include "headset.hpp"
#include "emulated_headset.hpp"
#include "local_headset.hpp"
#include "openvr_headset.hpp"
#include "openxr_headset.hpp"
#include "remote_headset.hpp"
void Headset::set_application(VRApplication* application)
......@@ -42,8 +43,11 @@ Headset::Ptr make_headset(VRApplication* application, HeadsetType headset_type)
case HEADSET_TYPE_EMULATED:
headset = std::make_shared<EmulatedHeadset>();
break;
case HEADSET_TYPE_LOCAL:
headset = std::make_shared<LocalHeadset>();
case HEADSET_TYPE_OPEN_VR:
headset = std::make_shared<OpenVRHeadset>();
break;
case HEADSET_TYPE_OPEN_XR:
headset = std::make_shared<OpenXRHeadset>();
break;
case HEADSET_TYPE_REMOTE:
headset = std::make_shared<RemoteHeadset>();
......
......@@ -32,7 +32,8 @@ enum Eye
enum HeadsetType
{
HEADSET_TYPE_EMULATED,
HEADSET_TYPE_LOCAL,
HEADSET_TYPE_OPEN_VR,
HEADSET_TYPE_OPEN_XR,
HEADSET_TYPE_REMOTE
};
......
#include "local_headset.hpp"
#include "openvr_headset.hpp"
#include "vr_application.hpp"
#include <iostream>
......@@ -6,7 +6,7 @@
#include <glm/gtx/matrix_operation.hpp>
#include <imgui.h>
bool LocalHeadset::on_setup_instance(lava::frame_config& config)
bool OpenVRHeadset::on_setup_instance(lava::frame_config& config)
{
vr::EVRInitError error;
this->system = VR_Init(&error, vr::EVRApplicationType::VRApplication_Scene);
......@@ -34,7 +34,7 @@ bool LocalHeadset::on_setup_instance(lava::frame_config& config)
return true;
}
bool LocalHeadset::on_setup_device(lava::device::create_param& parameters)
bool OpenVRHeadset::on_setup_device(lava::device::create_param& parameters)
{
uint32_t extension_count = vr::VRCompositor()->GetVulkanDeviceExtensionsRequired(parameters.physical_device->get(), nullptr, 0);
std::string extension_string(extension_count, '\0');
......@@ -50,7 +50,7 @@ bool LocalHeadset::on_setup_device(lava::device::create_param& parameters)
return true;
}
bool LocalHeadset::on_create()
bool OpenVRHeadset::on_create()
{
this->system->GetRecommendedRenderTargetSize(&this->resolution.x, &this->resolution.y);
......@@ -70,7 +70,7 @@ bool LocalHeadset::on_create()
return true;
}
void LocalHeadset::on_destroy()
void OpenVRHeadset::on_destroy()
{
this->destroy_framebuffer(EYE_LEFT);
this->destroy_framebuffer(EYE_RIGHT);
......@@ -78,7 +78,7 @@ void LocalHeadset::on_destroy()
vr::VR_Shutdown();
}
bool LocalHeadset::on_interface()
bool OpenVRHeadset::on_interface()
{
if (ImGui::DragFloat("Near Plane", &this->near_plane))
{
......@@ -95,7 +95,7 @@ bool LocalHeadset::on_interface()
return true;
}
bool LocalHeadset::on_update(lava::delta delta_time)
bool OpenVRHeadset::on_update(lava::delta delta_time)
{
vr::VREvent_t event;
......@@ -126,7 +126,7 @@ bool LocalHeadset::on_update(lava::delta delta_time)
return true;
}
void LocalHeadset::submit_frame(VkCommandBuffer command_buffer, VkImageLayout frame_layout, FrameId frame_id)
void OpenVRHeadset::submit_frame(VkCommandBuffer command_buffer, VkImageLayout frame_layout, FrameId frame_id)
{
lava::image::ptr frame_image = this->get_framebuffer(frame_id);
......@@ -167,42 +167,42 @@ void LocalHeadset::submit_frame(VkCommandBuffer command_buffer, VkImageLayout fr
}
}
VkFormat LocalHeadset::get_format() const
VkFormat OpenVRHeadset::get_format() const
{
return VK_FORMAT_R8G8B8A8_SRGB;
}
const glm::uvec2& LocalHeadset::get_resolution() const
const glm::uvec2& OpenVRHeadset::get_resolution() const
{
return this->resolution;
}
const glm::mat4& LocalHeadset::get_view_matrix() const
const glm::mat4& OpenVRHeadset::get_view_matrix() const
{
return this->view_matrix;
}
const glm::mat4& LocalHeadset::get_head_to_eye_matrix(Eye eye) const
const glm::mat4& OpenVRHeadset::get_head_to_eye_matrix(Eye eye) const
{
return this->head_to_eye_matrices[eye];
}
const glm::mat4& LocalHeadset::get_projection_matrix(Eye eye) const
const glm::mat4& OpenVRHeadset::get_projection_matrix(Eye eye) const
{
return this->projection_matrices[eye];
}
lava::image::ptr LocalHeadset::get_framebuffer(FrameId frame_id) const
lava::image::ptr OpenVRHeadset::get_framebuffer(FrameId frame_id) const
{
return this->framebuffers[frame_id];
}
const char* LocalHeadset::get_name() const
const char* OpenVRHeadset::get_name() const
{
return "Local Headset";
return "OpenVR Headset";
}
bool LocalHeadset::create_framebuffer(Eye eye)
bool OpenVRHeadset::create_framebuffer(Eye eye)
{
lava::image::ptr framebuffer = lava::make_image(this->get_format());
framebuffer->set_usage(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT);
......@@ -217,13 +217,13 @@ bool LocalHeadset::create_framebuffer(Eye eye)
return true;
}
void LocalHeadset::destroy_framebuffer(Eye eye)
void OpenVRHeadset::destroy_framebuffer(Eye eye)
{
this->framebuffers[eye]->destroy();
this->framebuffers[eye] = nullptr;
}
void LocalHeadset::compute_matrices(Eye eye)
void OpenVRHeadset::compute_matrices(Eye eye)
{
vr::HmdMatrix44_t projection_matrix = this->system->GetProjectionMatrix((vr::EVREye)eye, this->near_plane, this->far_plane);
vr::HmdMatrix34_t eye_to_head_matrix = this->system->GetEyeToHeadTransform((vr::EVREye)eye);
......@@ -232,7 +232,7 @@ void LocalHeadset::compute_matrices(Eye eye)
this->head_to_eye_matrices[eye] = glm::mat4(glm::transpose(glm::make_mat3x4(&eye_to_head_matrix.m[0][0])));
}
std::vector<std::string> LocalHeadset::split_string(std::string string, char delimiter)
std::vector<std::string> OpenVRHeadset::split_string(std::string string, char delimiter)
{
std::vector<std::string> strings;
......
......@@ -9,13 +9,13 @@
#include "headset.hpp"
class LocalHeadset : public Headset
class OpenVRHeadset : public Headset
{
public:
typedef std::shared_ptr<LocalHeadset> Ptr;
typedef std::shared_ptr<OpenVRHeadset> Ptr;
public:
LocalHeadset() = default;
OpenVRHeadset() = default;
bool on_setup_instance(lava::frame_config& config) override;
bool on_setup_device(lava::device::create_param& parameters) override;
......
This diff is collapsed.
#pragma once
#include <liblava/lava.hpp>
#include <glm/glm.hpp>
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#include <memory>
#include <vector>
#include <array>
#include "headset.hpp"
class OpenXRHeadset : public Headset
{
public:
typedef std::shared_ptr<OpenXRHeadset> Ptr;
public:
OpenXRHeadset();
bool on_setup_instance(lava::frame_config& config) override;
bool on_setup_device(lava::device::create_param& parameters) override;
bool on_create() override;
void on_destroy() override;
bool on_interface() override;
bool on_update(lava::delta delta_time) override;
void submit_frame(VkCommandBuffer command_buffer, VkImageLayout frame_layout, FrameId frame_id) override;
VkFormat get_format() const override;
const glm::uvec2& get_resolution() const override;
const glm::mat4& get_view_matrix() const override;
const glm::mat4& get_head_to_eye_matrix(Eye eye) const override;
const glm::mat4& get_projection_matrix(Eye eye) const override;
lava::image::ptr get_framebuffer(FrameId frame_id) const override;
const char* get_name() const override;
private:
bool create_framebuffers();
void destroy_framebuffers();
bool create_swapchains();
void destroy_swapchains();
bool poll_events();
bool process_event(const XrEventDataBuffer& event);
bool begin_frame();
bool update_views();
bool acquire_image(FrameId frame_id);
bool release_image(FrameId frame_id);
bool end_frame();
bool check_result(XrResult result) const;
bool check_layer_support(const std::vector<const char*>& required_layers) const;
bool check_extension_support(const std::vector<const char*>& required_extensions) const;
bool check_blend_mode_support(XrEnvironmentBlendMode required_mode) const;
bool check_view_type_support(XrViewConfigurationType required_type) const;
bool check_swapchain_format_support(int64_t required_format) const;
static std::vector<std::string> split_string(std::string string, char delimiter = ' ');
private:
XrInstance instance = XR_NULL_HANDLE;
XrSystemId system = XR_NULL_SYSTEM_ID;
XrSession session = XR_NULL_HANDLE;
XrSpace space = XR_NULL_HANDLE;
XrFrameState frame_state;
std::vector<XrSwapchain> swapchains;
std::vector<XrView> views;
std::array<uint32_t, 2> swapchain_indices;
std::array<std::vector<VkImage>, 2> swapchain_images;
std::array<lava::image::ptr, 2> framebuffers;
std::vector<std::string> instance_extensions;
std::vector<std::string> device_extensions;
bool active = false;
uint32_t submit_count = 0;
float near_plane = 10.0f;
float far_plane = 10000.0f;
glm::uvec2 resolution;
glm::mat4 view_matrix;
std::array<glm::mat4, 2> head_to_eye_matrices;
std::array<glm::mat4, 2> projection_matrices;
};
\ No newline at end of file
......@@ -246,7 +246,7 @@ void CommandParser::show_help()
std::cout << " --benchmark Play animation once and close program after completion." << std::endl;
std::cout << " If not set, the application runs indefinitely and the interface is enabled." << std::endl;
std::cout << " --headset={headset} The headset that should be used." << std::endl;
std::cout << " Options: emulated (default), local, remote" << std::endl;
std::cout << " Options: emulated (default), openvr, openxr, remote" << std::endl;
std::cout << " --stereo-strategy={strategy} The stereo strategy that should be used." << std::endl;
std::cout << " Options: native_forward (default), native_deferred, dpr" << std::endl;
std::cout << " --animation={animation_name} The name of the animation that should be played." << std::endl;
......@@ -273,9 +273,14 @@ bool CommandParser::set_headset(const std::string& name)
this->headset = HEADSET_TYPE_EMULATED;
}
else if (name == "local")
else if (name == "openvr")
{
this->headset = HEADSET_TYPE_LOCAL;
this->headset = HEADSET_TYPE_OPEN_VR;
}
else if (name == "openxr")
{
this->headset = HEADSET_TYPE_OPEN_XR;
}
else if (name == "remote")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment