openvr
openvr copied to clipboard
SteamVR OpenXR runtime call to XR_META_recommended_layer_resolution does not return correct rendering resolution
I've been exploring sample code for running OpenXR and seeing its behavior with SteamVR as a runtime. I've noticed that when making calls to XR_META_recommended_layer_resolution, the rendering resolution it returns is 80% of the actual resolution, and if I increase the rendering resolution past 150% internally, it stops updating. Do you know why this might be the case, and/or if there are extra settings that need to be applied to get the actual custom rendering resolution being used by SteamVR via OpenXR functions?
Here's a snippet of the code in question:
if (layer != nullptr)
{
XrResult result = xrGetInstanceProcAddr(xr_instance, "xrGetRecommendedLayerResolutionMETA", (PFN_xrVoidFunction*)&ext_xrGetRecommendedLayerResolutionMETA_fn);
if (XR_SUCCEEDED(result)) {
XrRecommendedLayerResolutionGetInfoMETA resolutionInfo = {};
resolutionInfo.type = XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_GET_INFO_META;
resolutionInfo.layer = layer;
resolutionInfo.predictedDisplayTime = frame_state.predictedDisplayTime;
XrRecommendedLayerResolutionMETA resolution = {};
XrResult result = ext_xrGetRecommendedLayerResolutionMETA_fn(xr_session, &resolutionInfo, &resolution);
if (XR_SUCCEEDED(result)) {
// Use the recommended resolution to adjust your swapchain or view rendering
if (recommendedWidth != resolution.recommendedImageDimensions.width || recommendedHeight != resolution.recommendedImageDimensions.height)
{
DWORD time = timeGetTime();
if (time < startTime)
startTime = time;
time = time - startTime;
recommendedWidth = resolution.recommendedImageDimensions.width;
recommendedHeight = resolution.recommendedImageDimensions.height;
// Use sprintf to format the message
char message[100];
sprintf(message, "(%u) Meta new recommended resolution: %u x %u\n", time, recommendedWidth, recommendedHeight);
// Send the formatted string to the Output Window
OutputDebugStringA(message); // Use OutputDebugStringA for ANSI strings
printf(message);
}
}
else {
// Handle error
}
}
else
{
}
}
This is also available via a forked repository linked here: https://github.com/velocity7/OpenXRSamples