Drop support for XR_FB_FOVEATION
This commit is contained in:
@@ -1243,10 +1243,6 @@ void application::initialize()
|
||||
XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME,
|
||||
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
|
||||
XR_FB_FACE_TRACKING2_EXTENSION_NAME,
|
||||
// Disable foveation, doesn't seem useful
|
||||
// XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME,
|
||||
// XR_FB_FOVEATION_EXTENSION_NAME,
|
||||
// XR_FB_FOVEATION_VULKAN_EXTENSION_NAME,
|
||||
XR_FB_PASSTHROUGH_EXTENSION_NAME,
|
||||
XR_FB_SWAPCHAIN_UPDATE_STATE_EXTENSION_NAME,
|
||||
|
||||
|
||||
@@ -845,7 +845,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
application::haptic_start(haptic_output, XR_NULL_PATH, 10'000'000, 1000, 1);
|
||||
}
|
||||
|
||||
vk::Image destination = swapchain.images()[image_index].image;
|
||||
vk::Image destination = swapchain.images()[image_index];
|
||||
|
||||
ImGui::SetCurrentContext(context);
|
||||
ImPlot::SetCurrentContext(plot_context);
|
||||
|
||||
@@ -340,7 +340,7 @@ scene_renderer::renderpass & scene_renderer::get_renderpass(const renderpass_inf
|
||||
|
||||
scene_renderer::renderpass scene_renderer::create_renderpass(const renderpass_info & info_)
|
||||
{
|
||||
vk::StructureChain<vk::RenderPassCreateInfo, vk::RenderPassFragmentDensityMapCreateInfoEXT, vk::RenderPassMultiviewCreateInfo> info;
|
||||
vk::StructureChain<vk::RenderPassCreateInfo, vk::RenderPassMultiviewCreateInfo> info;
|
||||
scene_renderer::renderpass rp;
|
||||
|
||||
std::vector<vk::AttachmentDescription> attachments;
|
||||
@@ -392,29 +392,6 @@ scene_renderer::renderpass scene_renderer::create_renderpass(const renderpass_in
|
||||
});
|
||||
}
|
||||
|
||||
if (info_.fragment_density_map)
|
||||
{
|
||||
vk::RenderPassFragmentDensityMapCreateInfoEXT & fragment_density_info = info.get<vk::RenderPassFragmentDensityMapCreateInfoEXT>();
|
||||
rp.fragment_density_attachment = {
|
||||
.attachment = (uint32_t)attachments.size(),
|
||||
.layout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
|
||||
};
|
||||
fragment_density_info.fragmentDensityMapAttachment = {
|
||||
.attachment = (uint32_t)attachments.size(),
|
||||
.layout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
|
||||
};
|
||||
attachments.push_back(vk::AttachmentDescription{
|
||||
.format = vk::Format::eR8G8Unorm,
|
||||
.samples = vk::SampleCountFlagBits::e1,
|
||||
.loadOp = vk::AttachmentLoadOp::eLoad,
|
||||
.storeOp = vk::AttachmentStoreOp::eDontCare,
|
||||
.initialLayout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
|
||||
.finalLayout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
|
||||
});
|
||||
}
|
||||
else
|
||||
info.unlink<vk::RenderPassFragmentDensityMapCreateInfoEXT>();
|
||||
|
||||
info.get().setAttachments(attachments);
|
||||
|
||||
vk::SubpassDescription subpasses{
|
||||
@@ -573,27 +550,6 @@ scene_renderer::output_image scene_renderer::create_output_image_data(const outp
|
||||
});
|
||||
}
|
||||
|
||||
if (info.renderpass.fragment_density_map)
|
||||
{
|
||||
assert(info.foveation != VK_NULL_HANDLE);
|
||||
|
||||
out.foveation_view = vk::raii::ImageView(
|
||||
device,
|
||||
vk::ImageViewCreateInfo{
|
||||
.image = info.foveation,
|
||||
.viewType = vk::ImageViewType::e2DArray,
|
||||
.format = vk::Format::eR8G8Unorm,
|
||||
.components{},
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = 1,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = info.renderpass.multiview_count,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
vk::FramebufferCreateInfo fb_info{
|
||||
.renderPass = *get_renderpass(info.renderpass).renderpass,
|
||||
.width = info.output_size.width,
|
||||
@@ -618,9 +574,6 @@ scene_renderer::output_image scene_renderer::create_output_image_data(const outp
|
||||
|
||||
attachments[rp.depth_attachment.attachment] = vk::ImageView{*out.depth_view};
|
||||
|
||||
if (rp.fragment_density_attachment)
|
||||
attachments[rp.fragment_density_attachment->attachment] = vk::ImageView{*out.foveation_view};
|
||||
|
||||
fb_info.setAttachments(attachments);
|
||||
out.framebuffer = vk::raii::Framebuffer(device, fb_info);
|
||||
return out;
|
||||
@@ -911,7 +864,6 @@ void scene_renderer::render(
|
||||
vk::Format depth_format,
|
||||
vk::Image color_buffer,
|
||||
vk::Image depth_buffer,
|
||||
vk::Image foveation_image,
|
||||
std::span<frame_info> frames,
|
||||
bool render_debug_draws)
|
||||
{
|
||||
@@ -964,7 +916,6 @@ void scene_renderer::render(
|
||||
.keep_depth_buffer = depth_buffer != vk::Image{},
|
||||
.msaa_samples = vk::SampleCountFlagBits::e1,
|
||||
// .msaa_samples = vk::SampleCountFlagBits::e4, // FIXME: MSAA does not work
|
||||
.fragment_density_map = foveation_image != vk::Image{},
|
||||
.multiview_count = (uint32_t)frames.size(),
|
||||
};
|
||||
vk::raii::RenderPass & renderpass = get_renderpass(rp_info).renderpass;
|
||||
@@ -1060,7 +1011,6 @@ void scene_renderer::render(
|
||||
.output_size = output_size,
|
||||
.color = color_buffer,
|
||||
.depth = depth_buffer,
|
||||
.foveation = foveation_image,
|
||||
});
|
||||
|
||||
vk::DeviceSize frame_ubo_offset = resources.uniform_buffer_offset;
|
||||
|
||||
@@ -44,7 +44,6 @@ struct renderpass_info
|
||||
vk::Format depth_format;
|
||||
bool keep_depth_buffer;
|
||||
vk::SampleCountFlagBits msaa_samples = vk::SampleCountFlagBits::e1;
|
||||
bool fragment_density_map;
|
||||
uint32_t multiview_count;
|
||||
|
||||
bool operator==(const renderpass_info & other) const noexcept = default;
|
||||
@@ -81,7 +80,6 @@ struct output_image_info
|
||||
vk::Extent2D output_size;
|
||||
VkImage color;
|
||||
VkImage depth;
|
||||
VkImage foveation;
|
||||
|
||||
bool operator==(const output_image_info & other) const noexcept = default;
|
||||
};
|
||||
@@ -127,8 +125,6 @@ class scene_renderer
|
||||
|
||||
image_allocation multisample_image;
|
||||
vk::raii::ImageView multisample_view = nullptr;
|
||||
|
||||
vk::raii::ImageView foveation_view = nullptr;
|
||||
};
|
||||
|
||||
struct renderpass
|
||||
@@ -279,7 +275,6 @@ public:
|
||||
vk::Format depth_format,
|
||||
vk::Image color_buffer,
|
||||
vk::Image depth_buffer,
|
||||
vk::Image foveation_image,
|
||||
std::span<frame_info> info,
|
||||
bool render_debug_draws = false);
|
||||
void end_frame();
|
||||
|
||||
+7
-51
@@ -155,7 +155,6 @@ void scene::render_world(
|
||||
bool keep_depth_buffer,
|
||||
uint32_t layer_mask,
|
||||
XrColor4f clear_color,
|
||||
const std::optional<xr::foveation_profile> & foveation,
|
||||
bool render_debug_draws)
|
||||
{
|
||||
assert(views.size() <= layer::max_views);
|
||||
@@ -163,14 +162,13 @@ void scene::render_world(
|
||||
beman::inplace_vector::inplace_vector<XrCompositionLayerProjectionView, layer::max_views> composition_layer_color;
|
||||
beman::inplace_vector::inplace_vector<XrCompositionLayerDepthInfoKHR, layer::max_views> composition_layer_depth;
|
||||
|
||||
auto [color_swapchain, color_image, foveation_image] = [&]() -> std::tuple<XrSwapchain, vk::Image, vk::Image> {
|
||||
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size(), foveation);
|
||||
auto [color_swapchain, color_image] = [&]() -> std::tuple<XrSwapchain, vk::Image> {
|
||||
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size());
|
||||
|
||||
int color_image_index = color_swapchain.acquire();
|
||||
vk::Image color_image = color_swapchain.images()[color_image_index].image;
|
||||
vk::Image foveation_image = color_swapchain.images()[color_image_index].foveation;
|
||||
vk::Image color_image = color_swapchain.images()[color_image_index];
|
||||
color_swapchain.wait();
|
||||
return {color_swapchain, color_image, foveation_image};
|
||||
return {color_swapchain, color_image};
|
||||
}();
|
||||
|
||||
auto [depth_swapchain, depth_image] = [&]() -> std::pair<XrSwapchain, vk::Image> {
|
||||
@@ -179,7 +177,7 @@ void scene::render_world(
|
||||
xr::swapchain & depth_swapchain = get_swapchain(depth_format, width, height, 1, views.size());
|
||||
|
||||
int depth_image_index = depth_swapchain.acquire();
|
||||
vk::Image depth_image = depth_swapchain.images()[depth_image_index].image;
|
||||
vk::Image depth_image = depth_swapchain.images()[depth_image_index];
|
||||
depth_swapchain.wait();
|
||||
return {depth_swapchain, depth_image};
|
||||
}
|
||||
@@ -240,7 +238,6 @@ void scene::render_world(
|
||||
depth_format,
|
||||
color_image,
|
||||
depth_image,
|
||||
foveation_image,
|
||||
frames,
|
||||
render_debug_draws);
|
||||
|
||||
@@ -251,41 +248,10 @@ void scene::render_world(
|
||||
composition_layer_depth);
|
||||
}
|
||||
|
||||
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size, const std::optional<xr::foveation_profile> & foveation)
|
||||
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size)
|
||||
{
|
||||
XrFoveationProfileFB foveation_profile = XR_NULL_HANDLE;
|
||||
XrFoveationLevelFB foveation_level = XR_FOVEATION_LEVEL_NONE_FB;
|
||||
float foveation_vertical_offset_degrees = 0;
|
||||
bool foveation_dynamic = false;
|
||||
|
||||
if (foveation)
|
||||
{
|
||||
foveation_profile = *foveation;
|
||||
foveation_level = foveation->level();
|
||||
foveation_vertical_offset_degrees = foveation->vertical_offset_degrees();
|
||||
foveation_dynamic = foveation->dynamic();
|
||||
}
|
||||
|
||||
// Look for an exact match
|
||||
for (swapchain_entry & entry: swapchains)
|
||||
{
|
||||
if (not entry.used and
|
||||
entry.format == format and
|
||||
entry.width == width and
|
||||
entry.height == height and
|
||||
entry.sample_count == sample_count and
|
||||
entry.array_size == array_size and
|
||||
entry.foveation_level == foveation_level and
|
||||
entry.foveation_vertical_offset_degrees == foveation_vertical_offset_degrees and
|
||||
entry.foveation_dynamic == foveation_dynamic)
|
||||
{
|
||||
entry.used = true;
|
||||
return entry.swapchain;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for a swapchain with a different foveation profile
|
||||
for (swapchain_entry & entry: swapchains)
|
||||
{
|
||||
if (not entry.used and
|
||||
entry.format == format and
|
||||
@@ -294,13 +260,7 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
|
||||
entry.sample_count == sample_count and
|
||||
entry.array_size == array_size)
|
||||
{
|
||||
spdlog::info("Updating swapchain foveation profile to {}, {:.1f} deg", magic_enum::enum_name(foveation_level), foveation_vertical_offset_degrees);
|
||||
entry.foveation_level = foveation_level;
|
||||
entry.foveation_vertical_offset_degrees = foveation_vertical_offset_degrees;
|
||||
entry.foveation_dynamic = foveation_dynamic;
|
||||
|
||||
entry.used = true;
|
||||
entry.swapchain.update_foveation(*foveation);
|
||||
return entry.swapchain;
|
||||
}
|
||||
}
|
||||
@@ -312,9 +272,6 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
|
||||
.height = height,
|
||||
.sample_count = sample_count,
|
||||
.array_size = array_size,
|
||||
.foveation_level = foveation_level,
|
||||
.foveation_vertical_offset_degrees = foveation_vertical_offset_degrees,
|
||||
.foveation_dynamic = foveation_dynamic,
|
||||
.used = true,
|
||||
.swapchain = xr::swapchain(
|
||||
instance,
|
||||
@@ -324,8 +281,7 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
|
||||
width,
|
||||
height,
|
||||
sample_count,
|
||||
array_size,
|
||||
foveation_profile)};
|
||||
array_size)};
|
||||
spdlog::info("Created swapchain");
|
||||
|
||||
return swapchains.emplace_back(std::move(new_swapchain)).swapchain;
|
||||
|
||||
+1
-7
@@ -24,7 +24,6 @@
|
||||
#include "render/scene_renderer.h"
|
||||
#include "utils/cache.h"
|
||||
#include "xr/actionset.h"
|
||||
#include "xr/foveation_profile.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/swapchain.h"
|
||||
@@ -156,17 +155,13 @@ protected:
|
||||
int sample_count;
|
||||
uint32_t array_size;
|
||||
|
||||
XrFoveationLevelFB foveation_level;
|
||||
float foveation_vertical_offset_degrees;
|
||||
bool foveation_dynamic;
|
||||
|
||||
bool used;
|
||||
xr::swapchain swapchain;
|
||||
};
|
||||
std::vector<swapchain_entry> swapchains;
|
||||
|
||||
// The returned reference is valid until the next call to get_swapchain
|
||||
xr::swapchain & get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size, const std::optional<xr::foveation_profile> & foveation = std::nullopt);
|
||||
xr::swapchain & get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size);
|
||||
void clear_swapchains();
|
||||
|
||||
void render_start(bool passthrough, XrTime predicted_display_time);
|
||||
@@ -194,7 +189,6 @@ protected:
|
||||
bool keep_depth_buffer,
|
||||
uint32_t layer_mask,
|
||||
XrColor4f clear_color,
|
||||
const std::optional<xr::foveation_profile> & foveation = std::nullopt,
|
||||
bool render_debug_draws = false);
|
||||
|
||||
void set_color_scale_bias(XrColor4f scale, XrColor4f bias);
|
||||
|
||||
+1
-12
@@ -157,15 +157,6 @@ scenes::lobby::lobby() :
|
||||
else
|
||||
spdlog::info("Composition layer color scale/bias NOT supported");
|
||||
|
||||
if (instance.has_extension(XR_FB_FOVEATION_VULKAN_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME))
|
||||
{
|
||||
spdlog::info("Foveation image supported");
|
||||
foveation = xr::foveation_profile(instance, session, XR_FOVEATION_LEVEL_NONE_FB, -10, false);
|
||||
}
|
||||
else
|
||||
spdlog::info("Foveation image NOT supported");
|
||||
|
||||
if (std::getenv("WIVRN_AUTOCONNECT"))
|
||||
force_autoconnect = true;
|
||||
|
||||
@@ -1069,7 +1060,6 @@ void scenes::lobby::render(const XrFrameState & frame_state)
|
||||
composition_layer_depth_test_supported,
|
||||
composition_layer_depth_test_supported ? layer_lobby | layer_controllers : layer_lobby,
|
||||
clear_color,
|
||||
foveation,
|
||||
true);
|
||||
|
||||
if (composition_layer_depth_test_supported)
|
||||
@@ -1100,8 +1090,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
|
||||
height,
|
||||
composition_layer_depth_test_supported,
|
||||
composition_layer_depth_test_supported ? layer_rays : layer_rays | layer_controllers,
|
||||
{0, 0, 0, 0},
|
||||
foveation);
|
||||
{0, 0, 0, 0});
|
||||
|
||||
if (composition_layer_depth_test_supported)
|
||||
set_depth_test(true, XR_COMPARE_OP_LESS_OR_EQUAL_FB);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_discover.h"
|
||||
#include "xr/face_tracker.h"
|
||||
#include "xr/foveation_profile.h"
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -79,8 +78,6 @@ class lobby : public scene_impl<lobby>
|
||||
|
||||
xr::face_tracker face_tracker;
|
||||
|
||||
std::optional<xr::foveation_profile> foveation;
|
||||
|
||||
std::string selected_item;
|
||||
std::unique_ptr<utils::mapped_file> license;
|
||||
|
||||
|
||||
@@ -663,31 +663,6 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
}
|
||||
|
||||
if (foveation)
|
||||
{
|
||||
std::array<const char *, 4> foveation_levels = {
|
||||
gettext_noop_context("Foveation level", "None"),
|
||||
gettext_noop_context("Foveation level", "Low"),
|
||||
gettext_noop_context("Foveation level", "Medium"),
|
||||
gettext_noop_context("Foveation level", "High"),
|
||||
};
|
||||
|
||||
if (ImGui::BeginCombo(_S("Foveation level"), _cS("Foveation level", foveation_levels[(int)foveation->level()])))
|
||||
{
|
||||
for (int level = 0; level < foveation_levels.size(); level++)
|
||||
{
|
||||
if (ImGui::Selectable(_cS("Foveation level", foveation_levels[level]), (int)foveation->level() == level))
|
||||
{
|
||||
foveation = xr::foveation_profile{instance, session, (XrFoveationLevelFB)level, -10, false};
|
||||
// TODO save in configuration
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
|
||||
// Render resolution
|
||||
{
|
||||
const auto current = config.resolution_scale;
|
||||
|
||||
@@ -283,7 +283,6 @@ void scenes::lobby::update_file_picker()
|
||||
vk::Format::eD32Sfloat, // Depth format
|
||||
output, // Output image
|
||||
vk::Image{}, // Depth image
|
||||
vk::Image{}, // Foveation image
|
||||
{&frame, 1}, // View info
|
||||
false);
|
||||
local_renderer.end_frame();
|
||||
|
||||
@@ -1175,14 +1175,11 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
|
||||
|
||||
spdlog::info("Initializing reprojector");
|
||||
vk::Extent2D extent = {(uint32_t)swapchain.width(), (uint32_t)swapchain.height()};
|
||||
std::vector<vk::Image> swapchain_images;
|
||||
for (auto & image: swapchain.images())
|
||||
swapchain_images.push_back(image.image);
|
||||
|
||||
defoveator.emplace(
|
||||
device,
|
||||
physical_device,
|
||||
swapchain_images,
|
||||
swapchain.images(),
|
||||
extent,
|
||||
swapchain.format());
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "foveation_profile.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
|
||||
xr::foveation_profile::foveation_profile(instance & inst, session & s, XrFoveationLevelFB level, float vertical_offset_degrees, bool dynamic) :
|
||||
handle(inst.get_proc<PFN_xrDestroyFoveationProfileFB>("xrDestroyFoveationProfileFB")),
|
||||
level_(level),
|
||||
vertical_offset_degrees_(vertical_offset_degrees),
|
||||
dynamic_(dynamic)
|
||||
{
|
||||
auto create = inst.get_proc<PFN_xrCreateFoveationProfileFB>("xrCreateFoveationProfileFB");
|
||||
XrFoveationLevelProfileCreateInfoFB level_info{
|
||||
.type = XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB,
|
||||
.level = level,
|
||||
.verticalOffset = vertical_offset_degrees,
|
||||
.dynamic = dynamic ? XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_FB : XR_FOVEATION_DYNAMIC_DISABLED_FB,
|
||||
};
|
||||
XrFoveationProfileCreateInfoFB info{
|
||||
.type = XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB,
|
||||
.next = &level_info,
|
||||
};
|
||||
create(s, &info, &id);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
class instance;
|
||||
class session;
|
||||
class foveation_profile : public utils::handle<XrFoveationProfileFB>
|
||||
{
|
||||
XrFoveationLevelFB level_;
|
||||
float vertical_offset_degrees_;
|
||||
bool dynamic_;
|
||||
|
||||
public:
|
||||
foveation_profile(instance & inst, session & s, XrFoveationLevelFB level, float vertical_offset_degrees, bool dynamic);
|
||||
|
||||
bool operator==(const foveation_profile & other) const
|
||||
{
|
||||
return level_ == other.level_ and vertical_offset_degrees_ == other.vertical_offset_degrees_ and dynamic_ == other.dynamic_;
|
||||
}
|
||||
|
||||
XrFoveationLevelFB level() const
|
||||
{
|
||||
return level_;
|
||||
}
|
||||
|
||||
float vertical_offset_degrees() const
|
||||
{
|
||||
return vertical_offset_degrees_;
|
||||
}
|
||||
|
||||
bool dynamic() const
|
||||
{
|
||||
return dynamic_;
|
||||
}
|
||||
};
|
||||
} // namespace xr
|
||||
+5
-41
@@ -30,16 +30,13 @@ xr::swapchain::swapchain(
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int sample_count,
|
||||
uint32_t array_size,
|
||||
XrFoveationProfileFB foveated) :
|
||||
uint32_t array_size) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
sample_count_(sample_count),
|
||||
format_(format)
|
||||
{
|
||||
assert(sample_count == 1);
|
||||
if (foveated)
|
||||
update = inst.get_proc<PFN_xrUpdateSwapchainFB>("xrUpdateSwapchainFB");
|
||||
|
||||
XrSwapchainUsageFlags usage_flags;
|
||||
|
||||
@@ -58,14 +55,8 @@ xr::swapchain::swapchain(
|
||||
break;
|
||||
}
|
||||
|
||||
XrSwapchainCreateInfoFoveationFB foveation_info{
|
||||
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO_FOVEATION_FB,
|
||||
.flags = XR_SWAPCHAIN_CREATE_FOVEATION_FRAGMENT_DENSITY_MAP_BIT_FB,
|
||||
};
|
||||
|
||||
XrSwapchainCreateInfo create_info{
|
||||
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO,
|
||||
.next = foveated ? &foveation_info : nullptr,
|
||||
.createFlags = 0,
|
||||
.usageFlags = usage_flags,
|
||||
.format = static_cast<VkFormat>(format),
|
||||
@@ -79,29 +70,11 @@ xr::swapchain::swapchain(
|
||||
|
||||
CHECK_XR(xrCreateSwapchain(s, &create_info, &id));
|
||||
|
||||
std::tuple<std::vector<XrSwapchainImageVulkanKHR>, std::vector<XrSwapchainImageFoveationVulkanFB>> array;
|
||||
auto & images = std::get<0>(array);
|
||||
auto & foveation = std::get<1>(array);
|
||||
if (foveated)
|
||||
{
|
||||
update_foveation(foveated);
|
||||
details::enumerate2(xrEnumerateSwapchainImages, array, id);
|
||||
assert(images.size() == foveation.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
details::enumerate(xrEnumerateSwapchainImages, images, id);
|
||||
}
|
||||
auto images = details::enumerate<XrSwapchainImageVulkanKHR>(xrEnumerateSwapchainImages, id);
|
||||
|
||||
images_.resize(images.size());
|
||||
for (uint32_t i = 0; i < images.size(); i++)
|
||||
{
|
||||
images_[i].image = images[i].image;
|
||||
if (foveated)
|
||||
{
|
||||
images_[i].foveation = foveation[i].image;
|
||||
}
|
||||
}
|
||||
images_.reserve(images.size());
|
||||
for (auto & image: images)
|
||||
images_.push_back(image.image);
|
||||
}
|
||||
|
||||
int xr::swapchain::acquire()
|
||||
@@ -139,12 +112,3 @@ void xr::swapchain::release()
|
||||
auto lock = application::get_queue().lock();
|
||||
CHECK_XR(xrReleaseSwapchainImage(id, &release_info));
|
||||
}
|
||||
|
||||
void xr::swapchain::update_foveation(XrFoveationProfileFB foveation)
|
||||
{
|
||||
XrSwapchainStateFoveationFB update_info{
|
||||
.type = XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB,
|
||||
.profile = foveation,
|
||||
};
|
||||
CHECK_XR(update(id, (XrSwapchainStateBaseHeaderFB *)&update_info));
|
||||
}
|
||||
|
||||
+3
-18
@@ -35,21 +35,13 @@ class session;
|
||||
|
||||
class swapchain : public utils::handle<XrSwapchain, xrDestroySwapchain>
|
||||
{
|
||||
public:
|
||||
struct image
|
||||
{
|
||||
vk::Image image{};
|
||||
vk::Image foveation{};
|
||||
};
|
||||
|
||||
private:
|
||||
PFN_xrUpdateSwapchainFB update;
|
||||
int32_t width_;
|
||||
int32_t height_;
|
||||
int sample_count_;
|
||||
vk::Format format_;
|
||||
|
||||
std::vector<image> images_;
|
||||
std::vector<vk::Image> images_;
|
||||
|
||||
public:
|
||||
swapchain() = default;
|
||||
@@ -61,8 +53,7 @@ public:
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int sample_count = 1,
|
||||
uint32_t array_size = 1,
|
||||
XrFoveationProfileFB foveation = XR_NULL_HANDLE);
|
||||
uint32_t array_size = 1);
|
||||
|
||||
int32_t width() const
|
||||
{
|
||||
@@ -80,11 +71,7 @@ public:
|
||||
{
|
||||
return sample_count_;
|
||||
}
|
||||
const std::vector<image> & images() const
|
||||
{
|
||||
return images_;
|
||||
}
|
||||
std::vector<image> & images()
|
||||
const std::vector<vk::Image> & images() const
|
||||
{
|
||||
return images_;
|
||||
}
|
||||
@@ -96,7 +83,5 @@ public:
|
||||
int acquire();
|
||||
bool wait(XrDuration timeout = XR_INFINITE_DURATION);
|
||||
void release();
|
||||
|
||||
void update_foveation(XrFoveationProfileFB foveation);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
Reference in New Issue
Block a user