clang-format

This commit is contained in:
Guillaume Meunier
2024-03-30 17:00:34 +01:00
parent bb660cfb3f
commit 9cceaac648
122 changed files with 2904 additions and 2783 deletions
+1 -1
View File
@@ -19,8 +19,8 @@
#pragma once
#include <openxr/openxr.h>
#include <system_error>
#include <openxr/openxr.h>
namespace xr
{
+1 -1
View File
@@ -17,8 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "xr/check.h"
#include "xr.h"
#include "xr/check.h"
#include <system_error>
namespace
+14 -15
View File
@@ -19,34 +19,33 @@
#include "hand_tracker.h"
std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::hand_tracker::locate(XrSpace space, XrTime time)
{
if (!id || !xrLocateHandJointsEXT)
return std::nullopt;
XrHandJointsLocateInfoEXT info{
.type = XR_TYPE_HAND_JOINTS_LOCATE_INFO_EXT,
.next = nullptr,
.baseSpace = space,
.time = time,
.type = XR_TYPE_HAND_JOINTS_LOCATE_INFO_EXT,
.next = nullptr,
.baseSpace = space,
.time = time,
};
std::array<XrHandJointLocationEXT, XR_HAND_JOINT_COUNT_EXT> joints_pos;
std::array<XrHandJointVelocityEXT, XR_HAND_JOINT_COUNT_EXT> joints_vel;
XrHandJointVelocitiesEXT velocities{
.type = XR_TYPE_HAND_JOINT_VELOCITIES_EXT,
.next = nullptr,
.jointCount = joints_vel.size(),
.jointVelocities = joints_vel.data(),
.type = XR_TYPE_HAND_JOINT_VELOCITIES_EXT,
.next = nullptr,
.jointCount = joints_vel.size(),
.jointVelocities = joints_vel.data(),
};
XrHandJointLocationsEXT locations{
.type = XR_TYPE_HAND_JOINT_LOCATIONS_EXT,
.next = &velocities,
.jointCount = joints_pos.size(),
.jointLocations = joints_pos.data(),
.type = XR_TYPE_HAND_JOINT_LOCATIONS_EXT,
.next = &velocities,
.jointCount = joints_pos.size(),
.jointLocations = joints_pos.data(),
};
CHECK_XR(xrLocateHandJointsEXT(id, &info, &locations));
@@ -55,9 +54,9 @@ std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::
return std::nullopt;
std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> joints;
for(int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
joints[i] = { joints_pos[i], joints_vel[i] };
joints[i] = {joints_pos[i], joints_vel[i]};
}
return joints;
+2 -2
View File
@@ -20,10 +20,10 @@
#pragma once
#include "utils/handle.h"
#include <openxr/openxr.h>
#include <array>
#include <utility>
#include <optional>
#include <utility>
#include <openxr/openxr.h>
#include "instance.h"
+14 -13
View File
@@ -24,7 +24,6 @@
#include <cassert>
#include <cstring>
#include <spdlog/spdlog.h>
#include <utility>
#include <vulkan/vulkan.h>
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
@@ -66,15 +65,15 @@ xr::instance::instance(std::string_view application_name, std::vector<const char
// This must be called before the instance is created
PFN_xrInitializeLoaderKHR initializeLoader = nullptr;
if (XR_SUCCEEDED(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)(&initializeLoader))))
if (XR_SUCCEEDED(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction *)(&initializeLoader))))
{
XrLoaderInitInfoAndroidKHR loaderInitInfoAndroid = {
.type = XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR,
.applicationVM = applicationVM,
.applicationContext = applicationActivity,
.type = XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR,
.applicationVM = applicationVM,
.applicationContext = applicationActivity,
};
initializeLoader((const XrLoaderInitInfoBaseHeaderKHR*)&loaderInitInfoAndroid);
}
initializeLoader((const XrLoaderInitInfoBaseHeaderKHR *)&loaderInitInfoAndroid);
}
#endif
std::vector<const char *> layers;
@@ -111,7 +110,7 @@ xr::instance::instance(std::string_view application_name, std::vector<const char
for (auto & i: extensions)
{
uint32_t version = 0;
for(auto & j: all_extensions)
for (auto & j: all_extensions)
{
if (!strcmp(j.extensionName, i))
version = j.extensionVersion;
@@ -205,11 +204,13 @@ bool xr::instance::poll_event(xr::event & buffer)
void xr::instance::suggest_bindings(const std::string & interaction_profile,
std::vector<XrActionSuggestedBinding> & bindings)
{
XrInteractionProfileSuggestedBinding suggested_binding{};
suggested_binding.type = XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING;
suggested_binding.interactionProfile = string_to_path(interaction_profile);
suggested_binding.countSuggestedBindings = bindings.size();
suggested_binding.suggestedBindings = bindings.data();
XrInteractionProfileSuggestedBinding suggested_binding{
.type = XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING,
.interactionProfile = string_to_path(interaction_profile),
.countSuggestedBindings = (uint32_t)bindings.size(),
.suggestedBindings = bindings.data(),
};
CHECK_XR(xrSuggestInteractionProfileBindings(id, &suggested_binding));
}
+22 -24
View File
@@ -18,10 +18,10 @@
*/
#include "passthrough.h"
#include "session.h"
#include "openxr/openxr.h"
#include "session.h"
xr::passthrough_layer_fb::passthrough_layer_fb(instance& inst, session& s, const XrPassthroughLayerCreateInfoFB& info)
xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, const XrPassthroughLayerCreateInfoFB & info)
{
xrDestroyPassthroughLayerFB = inst.get_proc<PFN_xrDestroyPassthroughLayerFB>("xrDestroyPassthroughLayerFB");
@@ -35,7 +35,6 @@ xr::passthrough_layer_fb::~passthrough_layer_fb()
xrDestroyPassthroughLayerFB(id);
}
xr::passthrough_fb::passthrough_fb(instance & inst, session & s)
{
PFN_xrCreatePassthroughFB xrCreatePassthroughFB = inst.get_proc<PFN_xrCreatePassthroughFB>("xrCreatePassthroughFB");
@@ -47,26 +46,26 @@ xr::passthrough_fb::passthrough_fb(instance & inst, session & s)
xrPassthroughLayerResumeFB = inst.get_proc<PFN_xrPassthroughLayerResumeFB>("xrPassthroughLayerResumeFB");
XrPassthroughCreateInfoFB info{
.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_FB,
.flags = 0
.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_FB,
.flags = 0,
};
CHECK_XR(xrCreatePassthroughFB(s, &info, &id));
XrPassthroughLayerCreateInfoFB layer_info{
.type = XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB,
.passthrough = id,
.flags = 0,
.purpose = XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB
.type = XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB,
.passthrough = id,
.flags = 0,
.purpose = XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB,
};
passthrough_layer.emplace(inst, s, layer_info);
composition_layer = XrCompositionLayerPassthroughFB{
.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB,
.flags = 0,
.space = XR_NULL_HANDLE,
.layerHandle = *passthrough_layer
.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB,
.flags = 0,
.space = XR_NULL_HANDLE,
.layerHandle = *passthrough_layer,
};
}
@@ -95,21 +94,21 @@ xr::passthrough_htc::passthrough_htc(instance & inst, session & s)
xrDestroyPassthroughHTC = inst.get_proc<PFN_xrDestroyPassthroughHTC>("xrDestroyPassthroughHTC");
XrPassthroughCreateInfoHTC info{
.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
.form = XR_PASSTHROUGH_FORM_PLANAR_HTC
.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
.form = XR_PASSTHROUGH_FORM_PLANAR_HTC,
};
CHECK_XR(xrCreatePassthroughHTC(s, &info, &id));
composition_layer = XrCompositionLayerPassthroughHTC{
.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_HTC,
.layerFlags = 0,
.space = XR_NULL_HANDLE,
.passthrough = id,
.color = {
.type = XR_TYPE_PASSTHROUGH_COLOR_HTC,
.alpha = 1
}
.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_HTC,
.layerFlags = 0,
.space = XR_NULL_HANDLE,
.passthrough = id,
.color = {
.type = XR_TYPE_PASSTHROUGH_COLOR_HTC,
.alpha = 1,
},
};
}
@@ -118,4 +117,3 @@ xr::passthrough_htc::~passthrough_htc()
if (id != XR_NULL_HANDLE && xrDestroyPassthroughHTC)
xrDestroyPassthroughHTC(id);
}
+13 -6
View File
@@ -31,11 +31,12 @@ class session;
class passthrough_layer_fb : public utils::handle<XrPassthroughLayerFB>
{
PFN_xrDestroyPassthroughLayerFB xrDestroyPassthroughLayerFB{};
public:
passthrough_layer_fb() = default;
passthrough_layer_fb(instance&, session&, const XrPassthroughLayerCreateInfoFB&);
passthrough_layer_fb(passthrough_layer_fb&&) = delete;
passthrough_layer_fb& operator=(passthrough_layer_fb&&) = delete;
passthrough_layer_fb(instance &, session &, const XrPassthroughLayerCreateInfoFB &);
passthrough_layer_fb(passthrough_layer_fb &&) = delete;
passthrough_layer_fb & operator=(passthrough_layer_fb &&) = delete;
~passthrough_layer_fb();
};
@@ -61,15 +62,18 @@ public:
void start();
void pause();
XrCompositionLayerBaseHeader * layer() { return (XrCompositionLayerBaseHeader*)&composition_layer; }
XrCompositionLayerBaseHeader * layer()
{
return (XrCompositionLayerBaseHeader *)&composition_layer;
}
};
class passthrough_htc : public utils::handle<XrPassthroughHTC>
{
PFN_xrDestroyPassthroughHTC xrDestroyPassthroughHTC{};
XrCompositionLayerPassthroughHTC composition_layer;
public:
passthrough_htc() = default;
passthrough_htc(instance &, session &);
@@ -81,7 +85,10 @@ public:
void start() {}
void pause() {}
XrCompositionLayerBaseHeader * layer() { return (XrCompositionLayerBaseHeader*)&composition_layer; }
XrCompositionLayerBaseHeader * layer()
{
return (XrCompositionLayerBaseHeader *)&composition_layer;
}
};
using passthrough = std::variant<passthrough_fb, passthrough_htc>;
+71 -58
View File
@@ -20,27 +20,30 @@
#include "session.h"
#include "details/enumerate.h"
#include "utils/ranges.h"
#include "xr.h"
#include <vulkan/vulkan.h>
#include <openxr/openxr_platform.h>
#include "utils/ranges.h"
xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance& vk_inst, vk::raii::PhysicalDevice& pdev, vk::raii::Device& dev, int queue_family_index) :
xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance & vk_inst, vk::raii::PhysicalDevice & pdev, vk::raii::Device & dev, int queue_family_index) :
inst(&inst)
{
XrGraphicsBindingVulkan2KHR vulkan_binding{};
vulkan_binding.type = XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR;
XrGraphicsBindingVulkan2KHR vulkan_binding{
.type = XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR,
vulkan_binding.instance = *vk_inst;
vulkan_binding.physicalDevice = *pdev;
vulkan_binding.device = *dev;
vulkan_binding.queueFamilyIndex = queue_family_index;
vulkan_binding.queueIndex = 0;
.instance = *vk_inst,
.physicalDevice = *pdev,
.device = *dev,
.queueFamilyIndex = (uint32_t)queue_family_index,
.queueIndex = 0,
};
XrSessionCreateInfo session_info{
.type = XR_TYPE_SESSION_CREATE_INFO,
.next = &vulkan_binding,
.systemId = sys,
};
XrSessionCreateInfo session_info{};
session_info.type = XR_TYPE_SESSION_CREATE_INFO;
session_info.next = &vulkan_binding;
session_info.systemId = sys;
CHECK_XR(xrCreateSession(inst, &session_info, &id));
}
@@ -51,10 +54,11 @@ std::vector<XrReferenceSpaceType> xr::session::get_reference_spaces() const
xr::space xr::session::create_reference_space(XrReferenceSpaceType ref, const XrPosef & pose)
{
XrReferenceSpaceCreateInfo create_info{};
create_info.type = XR_TYPE_REFERENCE_SPACE_CREATE_INFO;
create_info.referenceSpaceType = ref;
create_info.poseInReferenceSpace = pose;
XrReferenceSpaceCreateInfo create_info{
.type = XR_TYPE_REFERENCE_SPACE_CREATE_INFO,
.referenceSpaceType = ref,
.poseInReferenceSpace = pose,
};
XrSpace s;
CHECK_XR(xrCreateReferenceSpace(id, &create_info, &s));
@@ -64,11 +68,12 @@ xr::space xr::session::create_reference_space(XrReferenceSpaceType ref, const Xr
xr::space xr::session::create_action_space(XrAction action, const XrPosef & pose)
{
XrActionSpaceCreateInfo create_info{};
create_info.type = XR_TYPE_ACTION_SPACE_CREATE_INFO;
create_info.action = action;
create_info.poseInActionSpace = pose;
create_info.subactionPath = XR_NULL_PATH;
XrActionSpaceCreateInfo create_info{
.type = XR_TYPE_ACTION_SPACE_CREATE_INFO,
.action = action,
.subactionPath = XR_NULL_PATH,
.poseInActionSpace = pose,
};
XrSpace s;
CHECK_XR(xrCreateActionSpace(id, &create_info, &s));
@@ -76,15 +81,13 @@ xr::space xr::session::create_action_space(XrAction action, const XrPosef & pose
return s;
}
xr::hand_tracker xr::session::create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set)
{
XrHandTrackerCreateInfoEXT create_info
{
.type = XR_TYPE_HAND_TRACKER_CREATE_INFO_EXT,
.next = nullptr,
.hand = hand,
.handJointSet = hand_joint_set,
XrHandTrackerCreateInfoEXT create_info{
.type = XR_TYPE_HAND_TRACKER_CREATE_INFO_EXT,
.next = nullptr,
.hand = hand,
.handJointSet = hand_joint_set,
};
XrHandTrackerEXT ht;
@@ -106,11 +109,13 @@ std::vector<vk::Format> xr::session::get_swapchain_formats() const
XrFrameState xr::session::wait_frame()
{
XrFrameWaitInfo wait_info{};
wait_info.type = XR_TYPE_FRAME_WAIT_INFO;
XrFrameWaitInfo wait_info{
.type = XR_TYPE_FRAME_WAIT_INFO,
};
XrFrameState state{};
state.type = XR_TYPE_FRAME_STATE;
XrFrameState state{
.type = XR_TYPE_FRAME_STATE,
};
CHECK_XR(xrWaitFrame(id, &wait_info, &state));
@@ -119,29 +124,32 @@ XrFrameState xr::session::wait_frame()
void xr::session::begin_frame()
{
XrFrameBeginInfo begin_info{};
begin_info.type = XR_TYPE_FRAME_BEGIN_INFO;
XrFrameBeginInfo begin_info{
.type = XR_TYPE_FRAME_BEGIN_INFO,
};
CHECK_XR(xrBeginFrame(id, &begin_info));
}
void xr::session::end_frame(XrTime display_time, const std::vector<XrCompositionLayerBaseHeader *> & layers, XrEnvironmentBlendMode blend_mode)
{
XrFrameEndInfo end_info{};
end_info.type = XR_TYPE_FRAME_END_INFO;
end_info.displayTime = display_time;
end_info.environmentBlendMode = blend_mode;
end_info.layerCount = layers.size();
end_info.layers = layers.data();
XrFrameEndInfo end_info{
.type = XR_TYPE_FRAME_END_INFO,
.displayTime = display_time,
.environmentBlendMode = blend_mode,
.layerCount = (uint32_t)layers.size(),
.layers = layers.data(),
};
CHECK_XR(xrEndFrame(id, &end_info));
}
void xr::session::begin_session(XrViewConfigurationType view_config)
{
XrSessionBeginInfo begin_info{};
begin_info.type = XR_TYPE_SESSION_BEGIN_INFO;
begin_info.primaryViewConfigurationType = view_config;
XrSessionBeginInfo begin_info{
.type = XR_TYPE_SESSION_BEGIN_INFO,
.primaryViewConfigurationType = view_config,
};
CHECK_XR(xrBeginSession(id, &begin_info));
}
@@ -155,14 +163,16 @@ std::pair<XrViewStateFlags, std::vector<XrView>> xr::session::locate_views(XrVie
XrTime display_time,
XrSpace space)
{
XrViewLocateInfo view_locate_info{};
view_locate_info.type = XR_TYPE_VIEW_LOCATE_INFO;
view_locate_info.viewConfigurationType = view_config_type;
view_locate_info.displayTime = display_time;
view_locate_info.space = space;
XrViewLocateInfo view_locate_info{
.type = XR_TYPE_VIEW_LOCATE_INFO,
.viewConfigurationType = view_config_type,
.displayTime = display_time,
.space = space,
};
XrViewState view_state{};
view_state.type = XR_TYPE_VIEW_STATE;
XrViewState view_state{
.type = XR_TYPE_VIEW_STATE,
};
auto views = details::enumerate<XrView>(xrLocateViews, id, &view_locate_info, &view_state);
@@ -171,8 +181,10 @@ std::pair<XrViewStateFlags, std::vector<XrView>> xr::session::locate_views(XrVie
std::string xr::session::get_current_interaction_profile(const std::string & path)
{
XrInteractionProfileState state{};
state.type = XR_TYPE_INTERACTION_PROFILE_STATE;
XrInteractionProfileState state{
.type = XR_TYPE_INTERACTION_PROFILE_STATE,
};
CHECK_XR(xrGetCurrentInteractionProfile(id, inst->string_to_path(path), &state));
return inst->path_to_string(state.interactionProfile);
@@ -180,10 +192,11 @@ std::string xr::session::get_current_interaction_profile(const std::string & pat
void xr::session::attach_actionsets(const std::vector<XrActionSet> & actionsets)
{
XrSessionActionSetsAttachInfo attach_info{};
attach_info.type = XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO;
attach_info.countActionSets = actionsets.size();
attach_info.actionSets = actionsets.data();
XrSessionActionSetsAttachInfo attach_info{
.type = XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO,
.countActionSets = (uint32_t)actionsets.size(),
.actionSets = actionsets.data(),
};
CHECK_XR(xrAttachSessionActionSets(id, &attach_info));
}
@@ -265,7 +278,7 @@ void xr::session::sync_actions(std::span<XrActionSet> action_sets)
{
std::vector<XrActiveActionSet> active_action_sets(action_sets.size());
for(auto&& [i, j]: utils::zip(active_action_sets, action_sets))
for (auto && [i, j]: utils::zip(active_action_sets, action_sets))
{
i.actionSet = j;
i.subactionPath = XR_NULL_PATH;
+6 -4
View File
@@ -20,14 +20,14 @@
#pragma once
#include "utils/handle.h"
#include <span>
#include <string>
#include <vector>
#include <span>
#include <vulkan/vulkan_raii.hpp>
#include <openxr/openxr.h>
#include "space.h"
#include "hand_tracker.h"
#include "space.h"
namespace xr
{
@@ -40,7 +40,7 @@ class session : public utils::handle<XrSession>
public:
session() = default;
session(instance &, system &, vk::raii::Instance&, vk::raii::PhysicalDevice&, vk::raii::Device&, int queue_family_index);
session(instance &, system &, vk::raii::Instance &, vk::raii::PhysicalDevice &, vk::raii::Device &, int queue_family_index);
session(session &&) = default;
session & operator=(session &&) = default;
@@ -67,7 +67,9 @@ public:
std::string get_current_interaction_profile(const std::string & path);
void attach_actionsets(const std::vector<XrActionSet> & actionsets);
std::vector<std::string> sources_for_action(XrAction a);
std::vector<std::string> localized_sources_for_action(XrAction action, XrInputSourceLocalizedNameFlags components = XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT | XR_INPUT_SOURCE_LOCALIZED_NAME_INTERACTION_PROFILE_BIT | XR_INPUT_SOURCE_LOCALIZED_NAME_COMPONENT_BIT);
std::vector<std::string> localized_sources_for_action(
XrAction action,
XrInputSourceLocalizedNameFlags components = XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT | XR_INPUT_SOURCE_LOCALIZED_NAME_INTERACTION_PROFILE_BIT | XR_INPUT_SOURCE_LOCALIZED_NAME_COMPONENT_BIT);
float get_current_refresh_rate();
std::vector<float> get_refresh_rates();
+34 -31
View File
@@ -21,21 +21,22 @@
#include "details/enumerate.h"
#include "session.h"
xr::swapchain::swapchain(xr::session & s, vk::raii::Device& device, vk::Format format, int32_t width, int32_t height, int sample_count)
xr::swapchain::swapchain(xr::session & s, vk::raii::Device & device, vk::Format format, int32_t width, int32_t height, int sample_count)
{
assert(sample_count == 1);
XrSwapchainCreateInfo create_info{};
create_info.type = XR_TYPE_SWAPCHAIN_CREATE_INFO;
create_info.createFlags = 0;
create_info.usageFlags = XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT;
create_info.format = static_cast<VkFormat>(format);
create_info.sampleCount = sample_count;
create_info.width = width;
create_info.height = height;
create_info.faceCount = 1;
create_info.arraySize = 1;
create_info.mipCount = 1;
XrSwapchainCreateInfo create_info{
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO,
.createFlags = 0,
.usageFlags = XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT,
.format = static_cast<VkFormat>(format),
.sampleCount = (uint32_t)sample_count,
.width = (uint32_t)width,
.height = (uint32_t)height,
.faceCount = 1,
.arraySize = 1,
.mipCount = 1,
};
width_ = width;
height_ = height;
@@ -53,18 +54,17 @@ xr::swapchain::swapchain(xr::session & s, vk::raii::Device& device, vk::Format f
images_[i].image = array[i].image;
vk::ImageViewCreateInfo iv_create_info{
.image = array[i].image,
.viewType = vk::ImageViewType::e2D,
.format = format,
.components = {},
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
}
};
.image = array[i].image,
.viewType = vk::ImageViewType::e2D,
.format = format,
.components = {},
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
}};
images_[i].view = vk::raii::ImageView(device, iv_create_info);
}
@@ -80,8 +80,9 @@ int xr::swapchain::acquire()
{
uint32_t index;
XrSwapchainImageAcquireInfo acquire_info{};
acquire_info.type = XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO;
XrSwapchainImageAcquireInfo acquire_info{
.type = XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO,
};
CHECK_XR(xrAcquireSwapchainImage(id, &acquire_info, &index));
@@ -90,9 +91,10 @@ int xr::swapchain::acquire()
bool xr::swapchain::wait(XrDuration timeout)
{
XrSwapchainImageWaitInfo wait_info{};
wait_info.type = XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO;
wait_info.timeout = timeout;
XrSwapchainImageWaitInfo wait_info{
.type = XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO,
.timeout = timeout,
};
XrResult result = xrWaitSwapchainImage(id, &wait_info);
CHECK_XR(result, "xrWaitSwapchainImage");
@@ -101,8 +103,9 @@ bool xr::swapchain::wait(XrDuration timeout)
void xr::swapchain::release()
{
XrSwapchainImageReleaseInfo release_info{};
release_info.type = XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO;
XrSwapchainImageReleaseInfo release_info{
.type = XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO,
};
CHECK_XR(xrReleaseSwapchainImage(id, &release_info));
}
+2 -2
View File
@@ -52,7 +52,7 @@ private:
public:
swapchain() = default;
swapchain(session &, vk::raii::Device& device, vk::Format format, int32_t width, int32_t height, int sample_count = 1);
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;
@@ -69,7 +69,7 @@ public:
}
XrExtent2Di extent() const
{
return { width_, height_ };
return {width_, height_};
}
int sample_count() const
{
+34 -31
View File
@@ -48,8 +48,9 @@ XrGraphicsRequirementsVulkan2KHR xr::system::graphics_requirements() const
auto xrGetVulkanGraphicsRequirements2KHR =
inst->get_proc<PFN_xrGetVulkanGraphicsRequirements2KHR>("xrGetVulkanGraphicsRequirements2KHR");
XrGraphicsRequirementsVulkan2KHR requirements{};
requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR;
XrGraphicsRequirementsVulkan2KHR requirements{
.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR,
};
CHECK_XR(xrGetVulkanGraphicsRequirements2KHR(*inst, id, &requirements));
return requirements;
@@ -60,7 +61,9 @@ XrSystemProperties xr::system::properties() const
if (!id)
throw std::invalid_argument("this");
XrSystemProperties prop{.type = XR_TYPE_SYSTEM_PROPERTIES};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
return prop;
@@ -71,14 +74,13 @@ XrSystemHandTrackingPropertiesEXT xr::system::hand_tracking_properties() const
if (!id)
throw std::invalid_argument("this");
XrSystemHandTrackingPropertiesEXT hand_tracking_prop
{
.type = XR_TYPE_SYSTEM_HAND_TRACKING_PROPERTIES_EXT,
XrSystemHandTrackingPropertiesEXT hand_tracking_prop{
.type = XR_TYPE_SYSTEM_HAND_TRACKING_PROPERTIES_EXT,
};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &hand_tracking_prop,
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &hand_tracking_prop,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
@@ -87,25 +89,24 @@ XrSystemHandTrackingPropertiesEXT xr::system::hand_tracking_properties() const
xr::system::passthrough_type xr::system::passthrough_supported() const
{
const std::vector<std::string>& xr_extensions = application::get_xr_extensions();
const std::vector<std::string> & xr_extensions = application::get_xr_extensions();
if (utils::contains(xr_extensions, XR_HTC_PASSTHROUGH_EXTENSION_NAME))
return passthrough_type::color;
if (utils::contains(xr_extensions, XR_FB_PASSTHROUGH_EXTENSION_NAME))
{
XrSystemPassthroughProperties2FB passthrough_prop2{
.type = XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB,
.type = XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB,
};
XrSystemPassthroughPropertiesFB passthrough_prop
{
.type = XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB,
.next = &passthrough_prop2,
XrSystemPassthroughPropertiesFB passthrough_prop{
.type = XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB,
.next = &passthrough_prop2,
};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &passthrough_prop,
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &passthrough_prop,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
@@ -124,15 +125,16 @@ xr::system::passthrough_type xr::system::passthrough_supported() const
return passthrough_type::no_passthrough;
}
vk::raii::PhysicalDevice xr::system::physical_device(vk::raii::Instance& vulkan) const
vk::raii::PhysicalDevice xr::system::physical_device(vk::raii::Instance & vulkan) const
{
auto xrGetVulkanGraphicsDevice2KHR =
inst->get_proc<PFN_xrGetVulkanGraphicsDevice2KHR>("xrGetVulkanGraphicsDevice2KHR");
XrVulkanGraphicsDeviceGetInfoKHR get_info{};
get_info.type = XR_TYPE_VULKAN_GRAPHICS_DEVICE_GET_INFO_KHR;
get_info.systemId = id;
get_info.vulkanInstance = *vulkan;
XrVulkanGraphicsDeviceGetInfoKHR get_info{
.type = XR_TYPE_VULKAN_GRAPHICS_DEVICE_GET_INFO_KHR,
.systemId = id,
.vulkanInstance = *vulkan,
};
VkPhysicalDevice dev;
CHECK_XR(xrGetVulkanGraphicsDevice2KHR(*inst, &get_info, &dev));
@@ -140,15 +142,15 @@ vk::raii::PhysicalDevice xr::system::physical_device(vk::raii::Instance& vulkan)
return vk::raii::PhysicalDevice{vulkan, dev};
}
vk::raii::Device xr::system::create_device(vk::raii::PhysicalDevice& pdev, vk::DeviceCreateInfo & create_info) const
vk::raii::Device xr::system::create_device(vk::raii::PhysicalDevice & pdev, vk::DeviceCreateInfo & create_info) const
{
XrVulkanDeviceCreateInfoKHR xr_create_info{};
xr_create_info.type = XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR;
xr_create_info.pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
xr_create_info.systemId = id;
xr_create_info.vulkanPhysicalDevice = *pdev;
xr_create_info.vulkanCreateInfo = &(VkDeviceCreateInfo&)create_info;
XrVulkanDeviceCreateInfoKHR xr_create_info{
.type = XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR,
.systemId = id,
.pfnGetInstanceProcAddr = vkGetInstanceProcAddr,
.vulkanPhysicalDevice = *pdev,
.vulkanCreateInfo = &(VkDeviceCreateInfo &)create_info,
};
VkDevice dev;
VkResult vresult;
@@ -167,8 +169,9 @@ std::vector<XrViewConfigurationType> xr::system::view_configurations() const
XrViewConfigurationProperties xr::system::view_configuration_properties(XrViewConfigurationType type) const
{
XrViewConfigurationProperties prop{};
prop.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES;
XrViewConfigurationProperties prop{
.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES,
};
CHECK_XR(xrGetViewConfigurationProperties(*inst, id, type, &prop));
return prop;
+2 -2
View File
@@ -65,8 +65,8 @@ public:
passthrough_type passthrough_supported() const;
XrGraphicsRequirementsVulkan2KHR graphics_requirements() const;
vk::raii::PhysicalDevice physical_device(vk::raii::Instance& vulkan) const;
vk::raii::Device create_device(vk::raii::PhysicalDevice& pdev, vk::DeviceCreateInfo & create_info) const;
vk::raii::PhysicalDevice physical_device(vk::raii::Instance & vulkan) const;
vk::raii::Device create_device(vk::raii::PhysicalDevice & pdev, vk::DeviceCreateInfo & create_info) const;
std::vector<XrViewConfigurationType> view_configurations() const;
XrViewConfigurationProperties view_configuration_properties(XrViewConfigurationType) const;