Set refresh rate on client
This commit is contained in:
@@ -1394,6 +1394,12 @@ void application::poll_events()
|
|||||||
"session");
|
"session");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB: {
|
||||||
|
spdlog::info("Refresh rate changed from {} to {}",
|
||||||
|
e.refresh_rate_changed.fromDisplayRefreshRate,
|
||||||
|
e.refresh_rate_changed.toDisplayRefreshRate);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
spdlog::info("Received event type {}", xr::to_string(e.header.type));
|
spdlog::info("Received event type {}", xr::to_string(e.header.type));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -548,6 +548,15 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
|||||||
{
|
{
|
||||||
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
session.set_refresh_rate(description.fps);
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
|
||||||
|
}
|
||||||
|
|
||||||
accumulator_images dec;
|
accumulator_images dec;
|
||||||
dec.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index);
|
dec.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index);
|
||||||
dec.decoder->set_blit_targets(blit_targets, vk::Format::eA8B8G8R8SrgbPack32);
|
dec.decoder->set_blit_targets(blit_targets, vk::Format::eA8B8G8R8SrgbPack32);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ union event
|
|||||||
XrEventDataInteractionProfileChanged interaction_profile_changed;
|
XrEventDataInteractionProfileChanged interaction_profile_changed;
|
||||||
XrEventDataReferenceSpaceChangePending space_changed_pending;
|
XrEventDataReferenceSpaceChangePending space_changed_pending;
|
||||||
XrEventDataSessionStateChanged state_changed;
|
XrEventDataSessionStateChanged state_changed;
|
||||||
|
XrEventDataDisplayRefreshRateChangedFB refresh_rate_changed;
|
||||||
};
|
};
|
||||||
class instance : public utils::handle<XrInstance>
|
class instance : public utils::handle<XrInstance>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -233,6 +233,14 @@ std::vector<float> xr::session::get_refresh_rates()
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xr::session::set_refresh_rate(float refresh_rate)
|
||||||
|
{
|
||||||
|
static auto xrRequestDisplayRefreshRateFB = inst->get_proc<PFN_xrRequestDisplayRefreshRateFB>("xrRequestDisplayRefreshRateFB");
|
||||||
|
|
||||||
|
if (xrRequestDisplayRefreshRateFB)
|
||||||
|
CHECK_XR(xrRequestDisplayRefreshRateFB(id, refresh_rate));
|
||||||
|
}
|
||||||
|
|
||||||
void xr::session::sync_actions(std::span<XrActionSet> action_sets)
|
void xr::session::sync_actions(std::span<XrActionSet> action_sets)
|
||||||
{
|
{
|
||||||
std::vector<XrActiveActionSet> active_action_sets(action_sets.size());
|
std::vector<XrActiveActionSet> active_action_sets(action_sets.size());
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
float get_current_refresh_rate();
|
float get_current_refresh_rate();
|
||||||
std::vector<float> get_refresh_rates();
|
std::vector<float> get_refresh_rates();
|
||||||
|
void set_refresh_rate(float);
|
||||||
|
|
||||||
void sync_actions(XrActionSet action_set, XrPath subaction_path = XR_NULL_PATH);
|
void sync_actions(XrActionSet action_set, XrPath subaction_path = XR_NULL_PATH);
|
||||||
void sync_actions(XrActionSet action_set, const std::string & subaction_path);
|
void sync_actions(XrActionSet action_set, const std::string & subaction_path);
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ wivrn_hmd::wivrn_hmd(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx,
|
|||||||
auto scale = config.scale.value_or(std::array<double, 2>{1., 1.});
|
auto scale = config.scale.value_or(std::array<double, 2>{1., 1.});
|
||||||
auto foveated_eye_width = info.recommended_eye_width * scale[0];
|
auto foveated_eye_width = info.recommended_eye_width * scale[0];
|
||||||
auto foveated_eye_height = info.recommended_eye_height * scale[1];
|
auto foveated_eye_height = info.recommended_eye_height * scale[1];
|
||||||
fps = info.preferred_refresh_rate;
|
|
||||||
|
|
||||||
// Setup info.
|
// Setup info.
|
||||||
hmd->blend_modes[0] = XRT_BLEND_MODE_OPAQUE;
|
hmd->blend_modes[0] = XRT_BLEND_MODE_OPAQUE;
|
||||||
@@ -225,7 +224,7 @@ wivrn_hmd::wivrn_hmd(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx,
|
|||||||
hmd->distortion.preferred = XRT_DISTORTION_MODEL_COMPUTE;
|
hmd->distortion.preferred = XRT_DISTORTION_MODEL_COMPUTE;
|
||||||
hmd->screens[0].w_pixels = foveated_eye_width * 2;
|
hmd->screens[0].w_pixels = foveated_eye_width * 2;
|
||||||
hmd->screens[0].h_pixels = foveated_eye_height;
|
hmd->screens[0].h_pixels = foveated_eye_height;
|
||||||
hmd->screens[0].nominal_frame_interval_ns = 1000000000 / fps;
|
hmd->screens[0].nominal_frame_interval_ns = 1000000000 / info.preferred_refresh_rate;
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
hmd->views[0].display.w_pixels = eye_width;
|
hmd->views[0].display.w_pixels = eye_width;
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ class wivrn_hmd : public xrt_device
|
|||||||
{
|
{
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
||||||
float fps;
|
|
||||||
|
|
||||||
xrt_input pose_input;
|
xrt_input pose_input;
|
||||||
xrt_hmd_parts hmd_parts;
|
xrt_hmd_parts hmd_parts;
|
||||||
xrt_tracking_origin tracking_origin;
|
xrt_tracking_origin tracking_origin;
|
||||||
|
|||||||
Reference in New Issue
Block a user