Use the fragment density map in the lobby

This commit is contained in:
Guillaume Meunier
2025-10-25 10:25:53 +02:00
parent b8c08f1feb
commit 17ac7ab7d9
10 changed files with 301 additions and 98 deletions
+140 -77
View File
@@ -19,7 +19,6 @@
#include "render/scene_renderer.h"
#include "application.h"
#include "render/growable_descriptor_pool.h"
#include "render/image_loader.h"
#include "render/scene_components.h"
#include "utils/alignment.h"
@@ -39,7 +38,9 @@
#include <ranges>
#include <spdlog/spdlog.h>
#include <vk_mem_alloc.h>
#include <vulkan/vulkan.hpp>
#include <vulkan/vulkan_enums.hpp>
#include <vulkan/vulkan_handles.hpp>
#include <vulkan/vulkan_structs.hpp>
// TODO move in lobby?
@@ -260,7 +261,7 @@ void scene_renderer::wait_idle()
throw std::runtime_error("vkWaitForfences: " + vk::to_string(result));
}
vk::raii::RenderPass & scene_renderer::get_renderpass(const renderpass_info & info)
scene_renderer::renderpass & scene_renderer::get_renderpass(const renderpass_info & info)
{
auto it = renderpasses.find(info);
if (it != renderpasses.end())
@@ -269,78 +270,96 @@ vk::raii::RenderPass & scene_renderer::get_renderpass(const renderpass_info & in
return renderpasses.emplace(info, create_renderpass(info)).first->second;
}
vk::raii::RenderPass scene_renderer::create_renderpass(const renderpass_info & info_)
scene_renderer::renderpass scene_renderer::create_renderpass(const renderpass_info & info_)
{
vk::RenderPassCreateInfo info;
vk::StructureChain<vk::RenderPassCreateInfo, vk::RenderPassFragmentDensityMapCreateInfoEXT> info;
scene_renderer::renderpass rp;
std::array attachments = {
vk::AttachmentDescription{
.format = info_.color_format,
.samples = info_.msaa_samples,
.loadOp = vk::AttachmentLoadOp::eClear,
.storeOp = vk::AttachmentStoreOp::eStore,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eColorAttachmentOptimal,
},
vk::AttachmentDescription{
.format = info_.depth_format,
.samples = info_.msaa_samples,
.loadOp = vk::AttachmentLoadOp::eClear,
.storeOp = info_.keep_depth_buffer ? vk::AttachmentStoreOp::eStore : vk::AttachmentStoreOp::eDontCare,
.stencilLoadOp = vk::AttachmentLoadOp::eClear,
.stencilStoreOp = vk::AttachmentStoreOp::eDontCare,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal,
},
vk::AttachmentDescription{
.format = info_.color_format,
.samples = vk::SampleCountFlagBits::e1,
.loadOp = vk::AttachmentLoadOp::eDontCare,
.storeOp = vk::AttachmentStoreOp::eStore,
.stencilLoadOp = vk::AttachmentLoadOp::eClear,
.stencilStoreOp = vk::AttachmentStoreOp::eDontCare,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eColorAttachmentOptimal,
std::vector<vk::AttachmentDescription> attachments;
}};
if (info_.msaa_samples != vk::SampleCountFlagBits::e1)
{
info.setAttachments(attachments);
}
else
{
info.setPAttachments(attachments.data());
info.setAttachmentCount(2);
}
vk::AttachmentReference color_attachment{
.attachment = 0,
rp.color_attachment = {
.attachment = (uint32_t)attachments.size(),
.layout = vk::ImageLayout::eColorAttachmentOptimal,
};
attachments.push_back(vk::AttachmentDescription{
.format = info_.color_format,
.samples = info_.msaa_samples,
.loadOp = vk::AttachmentLoadOp::eClear,
.storeOp = vk::AttachmentStoreOp::eStore,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eColorAttachmentOptimal,
});
vk::AttachmentReference depth_attachment{
.attachment = 1,
rp.depth_attachment = {
.attachment = (uint32_t)attachments.size(),
.layout = vk::ImageLayout::eDepthStencilAttachmentOptimal,
};
attachments.push_back(vk::AttachmentDescription{
.format = info_.depth_format,
.samples = info_.msaa_samples,
.loadOp = vk::AttachmentLoadOp::eClear,
.storeOp = info_.keep_depth_buffer ? vk::AttachmentStoreOp::eStore : vk::AttachmentStoreOp::eDontCare,
.stencilLoadOp = vk::AttachmentLoadOp::eClear,
.stencilStoreOp = vk::AttachmentStoreOp::eDontCare,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal,
});
// Only used if MSAA is enabled
vk::AttachmentReference resolve_attachment{
.attachment = 2,
.layout = vk::ImageLayout::eColorAttachmentOptimal,
};
if (info_.msaa_samples != vk::SampleCountFlagBits::e1)
{
rp.resolve_attachment = {
.attachment = (uint32_t)attachments.size(),
.layout = vk::ImageLayout::eColorAttachmentOptimal,
};
attachments.push_back(vk::AttachmentDescription{
.format = info_.color_format,
.samples = vk::SampleCountFlagBits::e1,
.loadOp = vk::AttachmentLoadOp::eDontCare,
.storeOp = vk::AttachmentStoreOp::eStore,
.stencilLoadOp = vk::AttachmentLoadOp::eClear,
.stencilStoreOp = vk::AttachmentStoreOp::eDontCare,
.initialLayout = vk::ImageLayout::eUndefined,
.finalLayout = vk::ImageLayout::eColorAttachmentOptimal,
});
}
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{
.pipelineBindPoint = vk::PipelineBindPoint::eGraphics,
.colorAttachmentCount = 1,
.pColorAttachments = &color_attachment,
.pDepthStencilAttachment = &depth_attachment,
.pColorAttachments = &rp.color_attachment,
.pDepthStencilAttachment = &rp.depth_attachment,
};
if (info_.msaa_samples != vk::SampleCountFlagBits::e1)
subpasses.pResolveAttachments = &resolve_attachment;
subpasses.pResolveAttachments = &*rp.resolve_attachment;
info.setSubpasses(subpasses);
info.get().setSubpasses(subpasses);
std::array dependencies{
vk::SubpassDependency{
@@ -359,9 +378,11 @@ vk::raii::RenderPass scene_renderer::create_renderpass(const renderpass_info & i
.srcAccessMask{},
.dstAccessMask = vk::AccessFlagBits::eDepthStencilAttachmentWrite,
}};
info.setDependencies(dependencies);
info.get().setDependencies(dependencies);
return vk::raii::RenderPass(device, info);
rp.attachment_count = (uint32_t)attachments.size();
rp.renderpass = vk::raii::RenderPass(device, info.get());
return rp;
}
scene_renderer::output_image & scene_renderer::get_output_image_data(const output_image_info & info)
@@ -475,13 +496,58 @@ 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::e2D,
.format = vk::Format::eR8G8Unorm,
.components{},
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = info.base_array_layer,
.layerCount = 1,
},
});
}
vk::FramebufferCreateInfo fb_info{
.renderPass = *get_renderpass(info.renderpass),
.renderPass = *get_renderpass(info.renderpass).renderpass,
.width = info.output_size.width,
.height = info.output_size.height,
.layers = 1,
};
std::vector<vk::ImageView> attachments;
auto & rp = get_renderpass(info.renderpass);
attachments.resize(rp.attachment_count);
if (rp.resolve_attachment)
{
attachments[rp.color_attachment.attachment] = vk::ImageView{*out.multisample_view};
attachments[rp.resolve_attachment->attachment] = vk::ImageView{*out.image_view};
}
else
{
attachments[rp.color_attachment.attachment] = vk::ImageView{*out.image_view};
}
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;
if (info.renderpass.msaa_samples != vk::SampleCountFlagBits::e1)
{
std::array attachments{
@@ -604,7 +670,7 @@ vk::raii::Pipeline scene_renderer::create_pipeline(const pipeline_info & info)
vk::DynamicState::eScissor,
},
.layout = *pipeline_layout,
.renderPass = *get_renderpass(info.renderpass),
.renderPass = *get_renderpass(info.renderpass).renderpass,
.subpass = 0,
}};
}
@@ -768,6 +834,7 @@ 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)
{
per_frame_resources & resources = current_frame();
@@ -811,19 +878,24 @@ void scene_renderer::render(
// print_scene_hierarchy(scene);
renderpass_info rp_info{
.color_format = color_format,
.depth_format = depth_format,
.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{},
};
vk::raii::RenderPass & renderpass = get_renderpass(rp_info).renderpass;
for (const auto && [frame_index, frame]: utils::enumerate(frames))
{
scene_renderer::output_image & output = get_output_image_data(output_image_info{
.renderpass = {
.color_format = color_format,
.depth_format = depth_format,
.keep_depth_buffer = depth_buffer != vk::Image{},
.msaa_samples = vk::SampleCountFlagBits::e1,
// .msaa_samples = vk::SampleCountFlagBits::e4, // FIXME: MSAA does not work
},
.renderpass = rp_info,
.output_size = output_size,
.color = color_buffer,
.depth = depth_buffer,
.foveation = foveation_image,
.base_array_layer = (uint32_t)frame_index,
});
glm::mat4 viewproj = frame.projection * frame.view;
@@ -845,12 +917,6 @@ void scene_renderer::render(
frame_ubo.proj = frame.projection;
frame_ubo.view = frame.view;
vk::raii::RenderPass & renderpass = get_renderpass(renderpass_info{
.color_format = color_format,
.depth_format = depth_format,
.keep_depth_buffer = depth_buffer != vk::Image{},
});
cb.beginRenderPass(
vk::RenderPassBeginInfo{
.renderPass = *renderpass,
@@ -933,10 +999,7 @@ void scene_renderer::render(
// Get the pipeline
pipeline_info info{
.renderpass = {
.color_format = color_format,
.depth_format = depth_format,
.keep_depth_buffer = depth_buffer != vk::Image{}},
.renderpass = rp_info,
.shader_name = material->shader_name,
.cull_mode = primitive.cull_mode,
.front_face = primitive.front_face,
+18 -3
View File
@@ -41,6 +41,7 @@ struct renderpass_info
vk::Format depth_format;
bool keep_depth_buffer;
vk::SampleCountFlagBits msaa_samples = vk::SampleCountFlagBits::e1;
bool fragment_density_map;
bool operator==(const renderpass_info & other) const noexcept = default;
};
@@ -74,6 +75,7 @@ struct output_image_info
vk::Extent2D output_size;
VkImage color;
VkImage depth;
VkImage foveation;
uint32_t base_array_layer;
bool operator==(const output_image_info & other) const noexcept = default;
@@ -116,11 +118,23 @@ class scene_renderer
image_allocation multisample_image;
vk::raii::ImageView multisample_view = nullptr;
vk::raii::ImageView foveation_view = nullptr;
};
struct renderpass
{
vk::raii::RenderPass renderpass = nullptr;
vk::AttachmentReference color_attachment;
vk::AttachmentReference depth_attachment;
std::optional<vk::AttachmentReference> resolve_attachment; // Only used if MSAA is enabled
std::optional<vk::AttachmentReference> fragment_density_attachment; // Only used if fragment density map is enabled
int attachment_count;
};
// Initialization functions
output_image create_output_image_data(const output_image_info & info);
vk::raii::RenderPass create_renderpass(const renderpass_info & info);
renderpass create_renderpass(const renderpass_info & info);
vk::raii::PipelineLayout create_pipeline_layout(std::span<vk::DescriptorSetLayout> layouts);
vk::raii::Pipeline create_pipeline(const pipeline_info & info);
@@ -129,13 +143,13 @@ class scene_renderer
vk::raii::DescriptorSetLayout create_descriptor_set_layout(std::span<vk::DescriptorSetLayoutBinding> bindings, vk::DescriptorSetLayoutCreateFlags flags = {});
// Caches
std::unordered_map<renderpass_info, vk::raii::RenderPass> renderpasses;
std::unordered_map<renderpass_info, renderpass> renderpasses;
std::unordered_map<output_image_info, output_image> output_images;
std::unordered_map<pipeline_info, vk::raii::Pipeline> pipelines;
output_image & get_output_image_data(const output_image_info & info);
vk::raii::Pipeline & get_pipeline(const pipeline_info & info);
vk::raii::RenderPass & get_renderpass(const renderpass_info & info);
renderpass & get_renderpass(const renderpass_info & info);
vk::raii::DescriptorSetLayout layout_0; // Descriptor set 0: per-frame/view data (UBO), per-instance data (UBO + SSBO), per-material data (5 combined image samplers and 1 uniform buffer)
@@ -234,6 +248,7 @@ public:
vk::Format depth_format,
vk::Image color_buffer,
vk::Image depth_buffer,
vk::Image foveation_image,
std::span<frame_info> info);
void end_frame();
+59 -9
View File
@@ -24,10 +24,8 @@
#include "utils/i18n.h"
#include "utils/overloaded.h"
#include "utils/ranges.h"
#include <chrono>
#include <entt/core/fwd.hpp>
#include <magic_enum.hpp>
#include <spdlog/fmt/chrono.h>
#include <spdlog/spdlog.h>
#include <vulkan/vulkan_raii.hpp>
#include <openxr/openxr.h>
@@ -156,7 +154,8 @@ void scene::render_world(
uint32_t height,
bool keep_depth_buffer,
uint32_t layer_mask,
XrColor4f clear_color)
XrColor4f clear_color,
const std::optional<xr::foveation_profile> & foveation)
{
std::vector<scene_renderer::frame_info> frames;
frames.reserve(views.size());
@@ -169,13 +168,14 @@ void scene::render_world(
if (keep_depth_buffer)
composition_layer_depth.reserve(views.size());
auto [color_swapchain, color_image] = [&]() -> std::pair<XrSwapchain, vk::Image> {
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size());
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);
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;
color_swapchain.wait();
return {color_swapchain, color_image};
return {color_swapchain, color_image, foveation_image};
}();
auto [depth_swapchain, depth_image] = [&]() -> std::pair<XrSwapchain, vk::Image> {
@@ -244,6 +244,7 @@ void scene::render_world(
depth_format,
color_image,
depth_image,
foveation_image,
frames);
add_projection_layer(
@@ -253,8 +254,40 @@ void scene::render_world(
std::move(composition_layer_depth));
}
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size)
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)
{
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
@@ -264,7 +297,13 @@ 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;
}
}
@@ -276,9 +315,20 @@ 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, session, device, format, width, height, sample_count, array_size),
};
.swapchain = xr::swapchain(
instance,
session,
device,
format,
width,
height,
sample_count,
array_size,
foveation_profile)};
spdlog::info("Created swapchain");
return swapchains.emplace_back(std::move(new_swapchain)).swapchain;
+8 -2
View File
@@ -25,6 +25,7 @@
#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"
@@ -154,13 +155,17 @@ 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);
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);
void clear_swapchains();
void render_start(bool passthrough, XrTime predicted_display_time);
@@ -187,7 +192,8 @@ protected:
uint32_t height,
bool keep_depth_buffer,
uint32_t layer_mask,
XrColor4f clear_color);
XrColor4f clear_color,
const std::optional<xr::foveation_profile> & foveation = std::nullopt);
void set_color_scale_bias(XrColor4f scale, XrColor4f bias);
void set_depth_test(bool write, XrCompareOpFB op);
+15 -3
View File
@@ -28,6 +28,7 @@
#include "protocol_version.h"
#include "render/animation.h"
#include "stream.h"
#include "utils/contains.h"
#include "utils/i18n.h"
#include "wivrn_client.h"
#include "wivrn_discover.h"
@@ -110,7 +111,7 @@ scenes::lobby::lobby() :
scene_impl<lobby>(supported_color_formats, supported_depth_formats)
{
spdlog::info("Using formats {} and {}", vk::to_string(swapchain_format), vk::to_string(depth_format));
// composition_layer_depth_test_supported = false;
if (composition_layer_depth_test_supported)
spdlog::info("Composition layer depth test supported");
else
@@ -121,6 +122,15 @@ 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;
@@ -742,7 +752,8 @@ void scenes::lobby::render(const XrFrameState & frame_state)
height,
composition_layer_depth_test_supported,
composition_layer_depth_test_supported ? layer_lobby | layer_controllers : layer_lobby,
clear_color);
clear_color,
foveation);
if (composition_layer_depth_test_supported)
set_depth_test(true, XR_COMPARE_OP_ALWAYS_FB);
@@ -772,7 +783,8 @@ 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});
{0, 0, 0, 0},
foveation);
if (composition_layer_depth_test_supported)
set_depth_test(true, XR_COMPARE_OP_LESS_OR_EQUAL_FB);
+3
View File
@@ -29,6 +29,7 @@
#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>
@@ -71,6 +72,8 @@ class lobby : public scene_impl<lobby>
xr::face_tracker face_tracker;
std::optional<xr::foveation_profile> foveation;
std::string selected_item;
std::unique_ptr<asset> license;
+25
View File
@@ -625,6 +625,31 @@ 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();
}
{
const auto current = config.resolution_scale;
const auto width = stream_view.recommendedImageRectWidth;
+2
View File
@@ -23,6 +23,8 @@
#define _F(x) fmt::runtime(boost::locale::gettext(x))
#define _S(x) boost::locale::gettext(x).c_str()
#define _cS(c, x) boost::locale::pgettext(c, x).c_str()
#define gettext_noop(x) x
#define gettext_noop_context(c, x) x
std::vector<boost::locale::gnu_gettext::messages_info> get_locales();
std::vector<char> open_locale_file(const std::string & file_name, const std::string & encoding);
+6 -3
View File
@@ -20,14 +20,17 @@
#include "xr/instance.h"
#include "xr/session.h"
xr::foveation_profile::foveation_profile(instance & inst, session & s, XrFoveationLevelFB level, float verticalOffsetDegrees, bool dynamic) :
handle(inst.get_proc<PFN_xrDestroyFoveationProfileFB>("xrDestroyFoveationProfileFB"))
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 = verticalOffsetDegrees,
.verticalOffset = vertical_offset_degrees,
.dynamic = dynamic ? XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_FB : XR_FOVEATION_DYNAMIC_DISABLED_FB,
};
XrFoveationProfileCreateInfoFB info{
+25 -1
View File
@@ -27,7 +27,31 @@ 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, float verticalOffsetDegrees, bool dynamic);
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