Merge branch 'sync' of https://github.com/Vindicus999/WiVRn into sync
This commit is contained in:
@@ -140,7 +140,7 @@ decoder::decoder(
|
||||
// latency mode
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, width);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, height);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.fps));
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.frame_rate));
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0);
|
||||
|
||||
media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec[stream_index])));
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "gui_common.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "configuration.h"
|
||||
#include "render/imgui_impl.h"
|
||||
#include "utils/i18n.h"
|
||||
@@ -114,4 +115,86 @@ bool refresh_rate(
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
static std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB:
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB:
|
||||
return _C("openxr_post_processing", "Normal");
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB:
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB:
|
||||
return _C("openxr_post_processing", "Quality");
|
||||
default:
|
||||
return _C("openxr_post_processing", "Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
bool post_processing(
|
||||
imgui_context & imgui_ctx,
|
||||
configuration & config)
|
||||
{
|
||||
bool changed = false;
|
||||
if (not application::get_openxr_post_processing_supported())
|
||||
return changed;
|
||||
|
||||
ImGui::Text("%s", _S("OpenXR post-processing"));
|
||||
ImGui::Indent();
|
||||
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
|
||||
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
spdlog::info("Setting OpenXR super sampling to {}", openxr_post_processing_flag_name(option));
|
||||
config.openxr_post_processing.super_sampling = option;
|
||||
config.save();
|
||||
changed = true;
|
||||
}
|
||||
imgui_ctx.vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx.vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
imgui_ctx.tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
}
|
||||
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
|
||||
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
spdlog::info("Setting OpenXR sharpening to {}", openxr_post_processing_flag_name(option));
|
||||
config.openxr_post_processing.sharpening = option;
|
||||
config.save();
|
||||
changed = true;
|
||||
}
|
||||
imgui_ctx.vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx.vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
imgui_ctx.tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
}
|
||||
|
||||
ImGui::Unindent();
|
||||
return changed;
|
||||
}
|
||||
} // namespace wivrn::gui
|
||||
|
||||
@@ -40,5 +40,9 @@ bool refresh_rate(
|
||||
imgui_context & imgui_ctx,
|
||||
configuration & config);
|
||||
|
||||
}
|
||||
bool post_processing(
|
||||
imgui_context & imgui_ctx,
|
||||
configuration & config);
|
||||
|
||||
} // namespace gui
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -93,21 +93,6 @@ static void display_recentering_tip(imgui_context & ctx, const std::string & tip
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB:
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB:
|
||||
return _cS("openxr_post_processing", "Normal");
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB:
|
||||
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB:
|
||||
return _cS("openxr_post_processing", "Quality");
|
||||
default:
|
||||
return _cS("openxr_post_processing", "Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_connecting(locked_notifiable<pin_request_data> & pin_request)
|
||||
{
|
||||
using constants::style::button_size;
|
||||
@@ -883,67 +868,8 @@ void scenes::lobby::gui_settings()
|
||||
|
||||
void scenes::lobby::gui_post_processing()
|
||||
{
|
||||
auto & config = application::get_config();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20, 20));
|
||||
|
||||
if (application::get_openxr_post_processing_supported())
|
||||
{
|
||||
ImGui::Text("%s", _S("OpenXR post-processing"));
|
||||
ImGui::Indent();
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
|
||||
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
config.openxr_post_processing.super_sampling = option;
|
||||
config.save();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
}
|
||||
}
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
|
||||
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
config.openxr_post_processing.sharpening = option;
|
||||
config.save();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
}
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
gui::post_processing(*imgui_ctx, application::get_config());
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
+144
-140
@@ -823,8 +823,6 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
if (device.waitForFences(*fence, VK_TRUE, UINT64_MAX) == vk::Result::eTimeout)
|
||||
throw std::runtime_error("Vulkan fence timeout");
|
||||
|
||||
device.resetFences(*fence);
|
||||
|
||||
// We don't need those after vkWaitForFences
|
||||
current_blit_handles.fill(nullptr);
|
||||
|
||||
@@ -942,159 +940,165 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
}
|
||||
}
|
||||
|
||||
XrExtent2Di extents[view_count];
|
||||
// Allow the headset to time warp if we are redisplaying a frame
|
||||
if (std::ranges::any_of(current_blit_handles, [](const auto & h) { return h and h->feedback.times_displayed < 2; }) or
|
||||
is_gui_interactable())
|
||||
{
|
||||
int32_t max_width = 0;
|
||||
int32_t max_height = 0;
|
||||
for (size_t i = 0; i < view_count; ++i)
|
||||
XrExtent2Di extents[view_count];
|
||||
{
|
||||
extents[i] = stream_defoveator::defoveated_size(foveation[i]);
|
||||
max_width = std::max(max_width, extents[i].width);
|
||||
max_height = std::max(max_height, extents[i].height);
|
||||
}
|
||||
if (not swapchain)
|
||||
setup_reprojection_swapchain(max_width, max_height);
|
||||
else if (swapchain.width() < max_width or swapchain.height() < max_height)
|
||||
{
|
||||
// If the defoveated image is larger than the swapchain, try to reallocate one
|
||||
try
|
||||
int32_t max_width = 0;
|
||||
int32_t max_height = 0;
|
||||
for (size_t i = 0; i < view_count; ++i)
|
||||
{
|
||||
spdlog::info("Recreating swapchain, from {}x{} to {}x{}",
|
||||
swapchain.width(),
|
||||
swapchain.height(),
|
||||
max_width,
|
||||
max_height);
|
||||
setup_reprojection_swapchain(max_width, max_height);
|
||||
extents[i] = stream_defoveator::defoveated_size(foveation[i]);
|
||||
max_width = std::max(max_width, extents[i].width);
|
||||
max_height = std::max(max_height, extents[i].height);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
if (not swapchain)
|
||||
setup_reprojection_swapchain(max_width, max_height);
|
||||
else if (swapchain.width() < max_width or swapchain.height() < max_height)
|
||||
{
|
||||
spdlog::warn("failed to increase swapchain size");
|
||||
for (size_t i = 0; i < view_count; ++i)
|
||||
// If the defoveated image is larger than the swapchain, try to reallocate one
|
||||
try
|
||||
{
|
||||
extents[i].width = std::min(extents[i].width, swapchain.width());
|
||||
extents[i].height = std::min(extents[i].height, swapchain.height());
|
||||
spdlog::info("Recreating swapchain, from {}x{} to {}x{}",
|
||||
swapchain.width(),
|
||||
swapchain.height(),
|
||||
max_width,
|
||||
max_height);
|
||||
setup_reprojection_swapchain(max_width, max_height);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("failed to increase swapchain size");
|
||||
for (size_t i = 0; i < view_count; ++i)
|
||||
{
|
||||
extents[i].width = std::min(extents[i].width, swapchain.width());
|
||||
extents[i].height = std::min(extents[i].height, swapchain.height());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(swapchain);
|
||||
// defoveate the image, apply scale/bias
|
||||
int image_index = swapchain.acquire();
|
||||
swapchain.wait();
|
||||
assert(swapchain);
|
||||
// defoveate the image, apply scale/bias
|
||||
int image_index = swapchain.acquire();
|
||||
swapchain.wait();
|
||||
|
||||
switch (gui_status)
|
||||
{
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
case stream_tab::compact:
|
||||
case stream_tab::overlay_only:
|
||||
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
}
|
||||
|
||||
dimming = std::clamp<float>(dimming, 0, 1);
|
||||
float x = dimming * dimming * (3 - 2 * dimming); // Easing function
|
||||
|
||||
const float scale = std::lerp(1, constants::stream::dimming_scale, x);
|
||||
const float bias = std::lerp(0, constants::stream::dimming_bias, x);
|
||||
|
||||
defoveator->defoveate(command_buffer,
|
||||
foveation,
|
||||
images,
|
||||
{scale, scale, scale, 1.},
|
||||
{bias, bias, bias, 0.},
|
||||
image_index);
|
||||
|
||||
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
|
||||
|
||||
command_buffer.end();
|
||||
vk::SubmitInfo submit_info;
|
||||
submit_info.setCommandBuffers(*command_buffer);
|
||||
|
||||
inplace_vector<vk::Semaphore, decoder_count> semaphores;
|
||||
inplace_vector<uint64_t, decoder_count> semaphore_vals;
|
||||
inplace_vector<vk::PipelineStageFlags, decoder_count> wait_stages;
|
||||
for (auto b: current_blit_handles)
|
||||
{
|
||||
if (b and b->semaphore)
|
||||
switch (gui_status)
|
||||
{
|
||||
assert(b->semaphore_val);
|
||||
semaphores.push_back(b->semaphore);
|
||||
semaphore_vals.push_back(*b->semaphore_val);
|
||||
wait_stages.push_back(vk::PipelineStageFlagBits::eFragmentShader);
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
case stream_tab::compact:
|
||||
case stream_tab::overlay_only:
|
||||
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
submit_info.setWaitDstStageMask(wait_stages);
|
||||
submit_info.setWaitSemaphores(semaphores);
|
||||
vk::TimelineSemaphoreSubmitInfo sem_info{
|
||||
.waitSemaphoreValueCount = uint32_t(semaphore_vals.size()),
|
||||
.pWaitSemaphoreValues = semaphore_vals.data(),
|
||||
};
|
||||
submit_info.pNext = &sem_info;
|
||||
|
||||
queue.lock()->submit(submit_info, *fence);
|
||||
dimming = std::clamp<float>(dimming, 0, 1);
|
||||
float x = dimming * dimming * (3 - 2 * dimming); // Easing function
|
||||
|
||||
const float scale = std::lerp(1, constants::stream::dimming_scale, x);
|
||||
const float bias = std::lerp(0, constants::stream::dimming_bias, x);
|
||||
|
||||
defoveator->defoveate(command_buffer,
|
||||
foveation,
|
||||
images,
|
||||
{scale, scale, scale, 1.},
|
||||
{bias, bias, bias, 0.},
|
||||
image_index);
|
||||
|
||||
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
|
||||
|
||||
command_buffer.end();
|
||||
vk::SubmitInfo submit_info;
|
||||
submit_info.setCommandBuffers(*command_buffer);
|
||||
|
||||
inplace_vector<vk::Semaphore, decoder_count> semaphores;
|
||||
inplace_vector<uint64_t, decoder_count> semaphore_vals;
|
||||
inplace_vector<vk::PipelineStageFlags, decoder_count> wait_stages;
|
||||
for (auto b: current_blit_handles)
|
||||
{
|
||||
if (b and b->semaphore)
|
||||
{
|
||||
assert(b->semaphore_val);
|
||||
semaphores.push_back(b->semaphore);
|
||||
semaphore_vals.push_back(*b->semaphore_val);
|
||||
wait_stages.push_back(vk::PipelineStageFlagBits::eFragmentShader);
|
||||
}
|
||||
}
|
||||
submit_info.setWaitDstStageMask(wait_stages);
|
||||
submit_info.setWaitSemaphores(semaphores);
|
||||
vk::TimelineSemaphoreSubmitInfo sem_info{
|
||||
.waitSemaphoreValueCount = uint32_t(semaphore_vals.size()),
|
||||
.pWaitSemaphoreValues = semaphore_vals.data(),
|
||||
};
|
||||
submit_info.pNext = &sem_info;
|
||||
|
||||
device.resetFences(*fence);
|
||||
queue.lock()->submit(submit_info, *fence);
|
||||
#if WIVRN_FEATURE_RENDERDOC
|
||||
renderdoc_end(*vk_instance);
|
||||
renderdoc_end(*vk_instance);
|
||||
#endif
|
||||
swapchain.release();
|
||||
swapchain.release();
|
||||
|
||||
if (use_alpha)
|
||||
session.enable_passthrough(system);
|
||||
else
|
||||
session.disable_passthrough();
|
||||
|
||||
render_start(use_alpha, frame_state.predictedDisplayTime);
|
||||
|
||||
// Add the layer with the streamed content
|
||||
std::array<XrCompositionLayerProjectionView, view_count> layer_view;
|
||||
for (uint32_t view = 0; view < view_count; view++)
|
||||
{
|
||||
layer_view[view] =
|
||||
{
|
||||
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW,
|
||||
.pose = pose[view],
|
||||
.fov = fov[view],
|
||||
|
||||
.subImage = {
|
||||
.swapchain = swapchain,
|
||||
.imageRect = {
|
||||
.offset = {0, 0},
|
||||
.extent = extents[view],
|
||||
},
|
||||
.imageArrayIndex = view,
|
||||
},
|
||||
};
|
||||
}
|
||||
add_projection_layer(
|
||||
use_alpha ? XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT : 0,
|
||||
application::space(xr::spaces::world),
|
||||
layer_view);
|
||||
|
||||
if (const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
|
||||
(openxr_post_processing.sharpening | openxr_post_processing.super_sampling) > 0)
|
||||
set_layer_settings(openxr_post_processing.sharpening | openxr_post_processing.super_sampling);
|
||||
|
||||
accumulate_metrics(frame_state.predictedDisplayTime, current_blit_handles, timestamps);
|
||||
|
||||
draw_gui(frame_state.predictedDisplayTime, frame_state.predictedDisplayPeriod);
|
||||
|
||||
try
|
||||
{
|
||||
render_end();
|
||||
}
|
||||
catch (std::system_error & e)
|
||||
{
|
||||
if (e.code().category() == xr::error_category() and e.code().value() == XR_ERROR_POSE_INVALID)
|
||||
spdlog::info("Invalid pose submitted");
|
||||
if (use_alpha)
|
||||
session.enable_passthrough(system);
|
||||
else
|
||||
throw;
|
||||
session.disable_passthrough();
|
||||
|
||||
render_start(use_alpha, frame_state.predictedDisplayTime);
|
||||
|
||||
// Add the layer with the streamed content
|
||||
std::array<XrCompositionLayerProjectionView, view_count> layer_view;
|
||||
for (uint32_t view = 0; view < view_count; view++)
|
||||
{
|
||||
layer_view[view] =
|
||||
{
|
||||
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW,
|
||||
.pose = pose[view],
|
||||
.fov = fov[view],
|
||||
|
||||
.subImage = {
|
||||
.swapchain = swapchain,
|
||||
.imageRect = {
|
||||
.offset = {0, 0},
|
||||
.extent = extents[view],
|
||||
},
|
||||
.imageArrayIndex = view,
|
||||
},
|
||||
};
|
||||
}
|
||||
add_projection_layer(
|
||||
use_alpha ? XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT : 0,
|
||||
application::space(xr::spaces::world),
|
||||
layer_view);
|
||||
|
||||
if (const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
|
||||
(openxr_post_processing.sharpening | openxr_post_processing.super_sampling) > 0)
|
||||
set_layer_settings(openxr_post_processing.sharpening | openxr_post_processing.super_sampling);
|
||||
|
||||
accumulate_metrics(frame_state.predictedDisplayTime, current_blit_handles, timestamps);
|
||||
|
||||
draw_gui(frame_state.predictedDisplayTime, frame_state.predictedDisplayPeriod);
|
||||
|
||||
try
|
||||
{
|
||||
render_end();
|
||||
}
|
||||
catch (std::system_error & e)
|
||||
{
|
||||
if (e.code().category() == xr::error_category() and e.code().value() == XR_ERROR_POSE_INVALID)
|
||||
spdlog::info("Invalid pose submitted");
|
||||
else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Network operations may be blocking, do them once everything was submitted
|
||||
@@ -1165,7 +1169,7 @@ void scenes::stream::exit()
|
||||
|
||||
void scenes::stream::setup(const to_headset::video_stream_description & description)
|
||||
{
|
||||
session.set_refresh_rate(description.fps);
|
||||
session.set_refresh_rate(description.refresh_rate);
|
||||
|
||||
std::unique_lock lock(decoder_mutex);
|
||||
if (video_stream_description == description)
|
||||
@@ -1189,7 +1193,7 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
|
||||
assert(swapchain_width);
|
||||
assert(swapchain_height);
|
||||
device.waitIdle();
|
||||
session.set_refresh_rate(video_stream_description->fps);
|
||||
session.set_refresh_rate(video_stream_description->refresh_rate);
|
||||
|
||||
auto views = system.view_configuration_views(viewconfig);
|
||||
|
||||
|
||||
@@ -380,16 +380,15 @@ void scenes::stream::gui_compact_view()
|
||||
|
||||
static void send_settings_changed_packet(xr::session & session, wivrn_session * network, const configuration & config)
|
||||
{
|
||||
from_headset::settings_changed packet{
|
||||
.preferred_refresh_rate = config.preferred_refresh_rate,
|
||||
.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0),
|
||||
.fps_divider = config.fps_divider,
|
||||
.bitrate_bps = config.bitrate_bps,
|
||||
};
|
||||
network->send_control(std::move(packet));
|
||||
network->send_control(
|
||||
from_headset::settings_changed{
|
||||
.preferred_refresh_rate = config.preferred_refresh_rate,
|
||||
.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0),
|
||||
.fps_divider = config.fps_divider,
|
||||
.bitrate_bps = config.bitrate_bps,
|
||||
});
|
||||
}
|
||||
|
||||
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag); // TODO declaration in a .h file
|
||||
void scenes::stream::gui_settings(float predicted_display_period)
|
||||
{
|
||||
const ImGuiStyle & style = ImGui::GetStyle();
|
||||
@@ -414,64 +413,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
imgui_ctx->tooltip(_("Click to adjust bitrate"));
|
||||
}
|
||||
|
||||
if (application::get_openxr_post_processing_supported())
|
||||
{
|
||||
ImGui::Text("%s", _S("OpenXR post-processing"));
|
||||
ImGui::Indent();
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
|
||||
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
spdlog::info("Setting OpenXR super sampling to {}", openxr_post_processing_flag_name(option));
|
||||
config.openxr_post_processing.super_sampling = option;
|
||||
config.save();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
}
|
||||
}
|
||||
{
|
||||
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
|
||||
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
|
||||
{
|
||||
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
|
||||
0,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
|
||||
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
|
||||
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
|
||||
{
|
||||
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
spdlog::info("Setting OpenXR sharpening to {}", openxr_post_processing_flag_name(option));
|
||||
config.openxr_post_processing.sharpening = option;
|
||||
config.save();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
}
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
gui::post_processing(*imgui_ctx, config);
|
||||
|
||||
bool send_packet = false;
|
||||
bool save_config = false;
|
||||
|
||||
@@ -111,10 +111,10 @@ void scenes::stream::operator()(to_headset::video_stream_description && desc)
|
||||
|
||||
void scenes::stream::operator()(to_headset::refresh_rate_change && rate)
|
||||
{
|
||||
session.set_refresh_rate(rate.fps);
|
||||
session.set_refresh_rate(rate.hz);
|
||||
std::shared_lock lock(decoder_mutex);
|
||||
if (video_stream_description)
|
||||
video_stream_description->fps = rate.fps;
|
||||
video_stream_description->refresh_rate = rate.hz;
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::stream_tab_change && tab)
|
||||
|
||||
@@ -678,7 +678,8 @@ struct video_stream_description
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
std::array<video_codec, 3> codec; // left, right, alpha
|
||||
float fps;
|
||||
float frame_rate;
|
||||
float refresh_rate;
|
||||
|
||||
bool operator==(const video_stream_description &) const = default;
|
||||
};
|
||||
@@ -765,7 +766,7 @@ struct feature_control
|
||||
|
||||
struct refresh_rate_change
|
||||
{
|
||||
float fps;
|
||||
float hz;
|
||||
};
|
||||
|
||||
struct stream_tab_change
|
||||
|
||||
@@ -28,21 +28,12 @@ ColumnLayout {
|
||||
"is_custom": false
|
||||
});
|
||||
}
|
||||
|
||||
select_game.load();
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: apps
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: WivrnServer
|
||||
function onJsonConfigurationChanged() {
|
||||
select_game.load();
|
||||
}
|
||||
}
|
||||
|
||||
Dialogs.FileDialog {
|
||||
id: app_browse
|
||||
onAccepted: {
|
||||
@@ -74,11 +65,6 @@ ColumnLayout {
|
||||
}
|
||||
|
||||
function load() {
|
||||
if (WivrnServer.jsonConfiguration == "")
|
||||
return;
|
||||
|
||||
Settings.load(WivrnServer);
|
||||
|
||||
var found = false;
|
||||
var custom_idx = -1;
|
||||
for (var i = 0; i < apps.count; i++) {
|
||||
|
||||
@@ -85,6 +85,7 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
SelectGame {
|
||||
id: select_game
|
||||
Kirigami.FormData.label: i18n("Autostart application:")
|
||||
}
|
||||
|
||||
@@ -287,6 +288,7 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
function load() {
|
||||
select_game.load();
|
||||
debug_gui.checked = Settings.debugGui;
|
||||
steamvr_lh.checked = Settings.steamVrLh;
|
||||
hid_forwarding.checked = Settings.hidForwarding;
|
||||
|
||||
@@ -550,7 +550,7 @@ xrt_result_t compositor::request_display_refresh_rate(float hz)
|
||||
try
|
||||
{
|
||||
requested_refresh_rate = hz;
|
||||
session.send_control(to_headset::refresh_rate_change{.fps = hz});
|
||||
session.send_control(to_headset::refresh_rate_change{.hz = hz});
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
@@ -641,8 +641,9 @@ void compositor::send_video_stream_description()
|
||||
to_headset::video_stream_description desc{
|
||||
.width = uint16_t(images[0].image.info().extent.width),
|
||||
.height = uint16_t(images[0].image.info().extent.height),
|
||||
.fps = settings[0].fps,
|
||||
.frame_rate = settings[0].fps,
|
||||
};
|
||||
get_display_refresh_rate(&desc.refresh_rate);
|
||||
static_assert(std::tuple_size_v<decltype(settings)> == std::tuple_size_v<decltype(desc.codec)>);
|
||||
std::ranges::transform(settings, desc.codec.begin(), &encoder_settings::codec);
|
||||
session.send_control(std::move(desc));
|
||||
|
||||
@@ -401,9 +401,10 @@ void wivrn_session::resume_session()
|
||||
|
||||
if (target_fps != current_fps)
|
||||
{
|
||||
auto s = settings.lock();
|
||||
(*this)(from_headset::refresh_rate_changed{
|
||||
.from = current_fps,
|
||||
.to = target_fps,
|
||||
.from = current_fps * s->fps_divider,
|
||||
.to = target_fps * s->fps_divider,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -964,7 +965,7 @@ struct refresh_rate_adjuster
|
||||
if (requested != last)
|
||||
{
|
||||
U_LOG_I("requesting refresh rate: %.0f (app rate %.1f)", requested, app_rate);
|
||||
cnx.send_control(to_headset::refresh_rate_change{.fps = requested});
|
||||
cnx.send_control(to_headset::refresh_rate_change{.hz = requested});
|
||||
last = requested;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,12 +603,12 @@ std::array<int, 2> video_encoder_nvenc::get_max_size(video_codec codec)
|
||||
auto encodeGUID = encode_guid(codec);
|
||||
for (auto [cap, res]: {
|
||||
std::pair{NV_ENC_CAPS_WIDTH_MAX, &result[0]},
|
||||
{NV_ENC_CAPS_WIDTH_MAX, &result[1]},
|
||||
{NV_ENC_CAPS_HEIGHT_MAX, &result[1]},
|
||||
})
|
||||
{
|
||||
NV_ENC_CAPS_PARAM cap_params{
|
||||
.version = NV_ENC_CAPS_PARAM_VER,
|
||||
.capsToQuery = NV_ENC_CAPS_WIDTH_MAX,
|
||||
.capsToQuery = cap,
|
||||
};
|
||||
|
||||
check_encode_guid_supported(state, session_handle, encodeGUID);
|
||||
|
||||
Reference in New Issue
Block a user