Skip to content

Commit

Permalink
openxr: add native quad view support
Browse files Browse the repository at this point in the history
At least Pimax now includes quad view foveated rendering support in
their runtime, so if the runtime provides support for quad view
rendering, it is favoured over Quad-Views-Foveated layer.
  • Loading branch information
Detegr committed Oct 25, 2024
1 parent 53060c4 commit 32b25ff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
## 1.1.0

- Update DXVK version to 2.4.1
- Add OpenXR runtime validation in initialization
- Use Pimax's native quad view rendering over Quad-Views-Foveated if it's
enabled
- Add 32-bit OpenXR runtime validation in initialization
- Improve OpenXR initialization error messages
- Fix invalid openRBRVR version number shown inside the game
- Fix "Could not create VR render target for view 0" by changing the way
available depth surface formats are tested

## 1.0.4

Expand Down
2 changes: 2 additions & 0 deletions src/Dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ namespace dx {
const auto& [flw, flh] = g::vr->get_render_resolution(FocusLeft);
const auto& [frw, frh] = g::vr->get_render_resolution(FocusRight);
g::game->WriteText(0, 18 * ++i, std::format(" {}x{} (focus left), {}x{} (focus right)", flw, flh, frw, frh).c_str());
const auto qv = reinterpret_cast<OpenXR*>(g::vr)->native_quad_views;
g::game->WriteText(0, 18 * ++i, std::format("{}oveated rendering {}", qv ? "Native F" : "F", qv ? "" : "via Quad-Views-Foveated OpenXR layer").c_str());
}
if (g::vr->is_using_quad_view_rendering()) {
g::game->WriteText(0, 18 * ++i, std::format("Anti-aliasing: {}x, peripheral: {}x", static_cast<int>(g::vr->get_current_render_context()->msaa), static_cast<int>(g::cfg.peripheral_msaa)).c_str());
Expand Down
31 changes: 24 additions & 7 deletions src/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,33 @@ OpenXR::OpenXR()
}

if (g::cfg.quad_view_rendering) {
auto quad_views_layer = std::ranges::find_if(available_api_layers, [](const XrApiLayerProperties& p) {
return std::string(p.layerName) == "XR_APILAYER_MBUCCHIA_quad_views_foveated";
auto quad_views_extension = std::ranges::find_if(available_extensions, [](const XrExtensionProperties& p) {
return std::string(p.extensionName) == "XR_VARJO_quad_views";
});
if (quad_views_layer == available_api_layers.cend()) {
MessageBoxA(nullptr, "Tried to enable quad view rendering but Quad-Views-Foveated API layer was not found.\nPlease make sure all files are installed.", "OpenXR layer init error", MB_OK);
g::cfg.quad_view_rendering = false;
auto foveated_rendering_extension = std::ranges::find_if(available_extensions, [](const XrExtensionProperties& p) {
return std::string(p.extensionName) == "XR_VARJO_foveated_rendering";
});

if (quad_views_extension == available_extensions.cend()) {
// No native quad view support, use Quad-Views-Foveated
auto quad_views_layer = std::ranges::find_if(available_api_layers, [](const XrApiLayerProperties& p) {
return std::string(p.layerName) == "XR_APILAYER_MBUCCHIA_quad_views_foveated";
});
if (quad_views_layer == available_api_layers.cend()) {
MessageBoxA(nullptr, "Tried to enable quad view rendering but Quad-Views-Foveated API layer was not found.\nPlease make sure all files are installed and that you're not running the application as an admin.", "OpenXR layer init error", MB_OK);
g::cfg.quad_view_rendering = false;
} else {
native_quad_views = false;
extensions.push_back("XR_VARJO_quad_views");
extensions.push_back("XR_VARJO_foveated_rendering");
api_layers.push_back("XR_APILAYER_MBUCCHIA_quad_views_foveated");
}
} else {
native_quad_views = true;
extensions.push_back("XR_VARJO_quad_views");
extensions.push_back("XR_VARJO_foveated_rendering");
api_layers.push_back("XR_APILAYER_MBUCCHIA_quad_views_foveated");
if (foveated_rendering_extension != available_extensions.cend()) {
extensions.push_back("XR_VARJO_foveated_rendering");
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/OpenXR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class OpenXR : public VRInterface {
OpenXR& operator=(const OpenXR&) = delete;
OpenXR& operator=(const OpenXR&&) = delete;

bool native_quad_views;

void init(IDirect3DDevice9* dev, IDirect3DVR9** vrdev, uint32_t companionWindowWidth, uint32_t companionWindowHeight, std::optional<XrPosef> old_view_pose = std::nullopt);
virtual ~OpenXR()
{
Expand Down

0 comments on commit 32b25ff

Please sign in to comment.