Skip to content

Commit 1208ca0

Browse files
committed
Fix game looking low res due to downsampling before OpenXR
This is especially true for lower then 2k resolutions where there's not as much original pixels. This does break Meta XR Simulator. But I tested it with VDXR and air link and it works fine.
1 parent 689c42e commit 1208ca0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/rendering/renderer.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ void RND_Renderer::EndFrame() {
135135
RND_Renderer::Layer3D::Layer3D(VkExtent2D extent) {
136136
auto viewConfs = VRManager::instance().XR->GetViewConfigurations();
137137

138+
this->m_recommendedAspectRatios[OpenXR::EyeSide::LEFT] = (float)viewConfs[0].recommendedImageRectWidth / (float)viewConfs[0].recommendedImageRectHeight;
139+
this->m_recommendedAspectRatios[OpenXR::EyeSide::RIGHT] = (float)viewConfs[1].recommendedImageRectWidth / (float)viewConfs[1].recommendedImageRectHeight;
140+
138141
this->m_presentPipelines[OpenXR::EyeSide::LEFT] = std::make_unique<RND_D3D12::PresentPipeline<true>>(VRManager::instance().XR->GetRenderer());
139142
this->m_presentPipelines[OpenXR::EyeSide::RIGHT] = std::make_unique<RND_D3D12::PresentPipeline<true>>(VRManager::instance().XR->GetRenderer());
140143

141-
// note: it's possible to make a swapchain that matches Cemu's internal resolution and let the headset downsample it, although I doubt there's a benefit
142-
this->m_swapchains[OpenXR::EyeSide::LEFT] = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(viewConfs[0].recommendedImageRectWidth, viewConfs[0].recommendedImageRectHeight, viewConfs[0].recommendedSwapchainSampleCount);
143-
this->m_swapchains[OpenXR::EyeSide::RIGHT] = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(viewConfs[1].recommendedImageRectWidth, viewConfs[1].recommendedImageRectHeight, viewConfs[1].recommendedSwapchainSampleCount);
144-
this->m_depthSwapchains[OpenXR::EyeSide::LEFT] = std::make_unique<Swapchain<DXGI_FORMAT_D32_FLOAT>>(viewConfs[0].recommendedImageRectWidth, viewConfs[0].recommendedImageRectHeight, viewConfs[0].recommendedSwapchainSampleCount);
145-
this->m_depthSwapchains[OpenXR::EyeSide::RIGHT] = std::make_unique<Swapchain<DXGI_FORMAT_D32_FLOAT>>(viewConfs[1].recommendedImageRectWidth, viewConfs[1].recommendedImageRectHeight, viewConfs[1].recommendedSwapchainSampleCount);
144+
this->m_swapchains[OpenXR::EyeSide::LEFT] = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(extent.width, extent.height, viewConfs[0].recommendedSwapchainSampleCount);
145+
this->m_swapchains[OpenXR::EyeSide::RIGHT] = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(extent.width, extent.height, viewConfs[1].recommendedSwapchainSampleCount);
146+
this->m_depthSwapchains[OpenXR::EyeSide::LEFT] = std::make_unique<Swapchain<DXGI_FORMAT_D32_FLOAT>>(extent.width, extent.height, viewConfs[0].recommendedSwapchainSampleCount);
147+
this->m_depthSwapchains[OpenXR::EyeSide::RIGHT] = std::make_unique<Swapchain<DXGI_FORMAT_D32_FLOAT>>(extent.width, extent.height, viewConfs[1].recommendedSwapchainSampleCount);
146148

147149
this->m_presentPipelines[OpenXR::EyeSide::LEFT]->BindSettings((float)this->m_swapchains[OpenXR::EyeSide::LEFT]->GetWidth(), (float)this->m_swapchains[OpenXR::EyeSide::LEFT]->GetHeight());
148150
this->m_presentPipelines[OpenXR::EyeSide::RIGHT]->BindSettings((float)this->m_swapchains[OpenXR::EyeSide::RIGHT]->GetWidth(), (float)this->m_swapchains[OpenXR::EyeSide::RIGHT]->GetHeight());
@@ -403,8 +405,7 @@ RND_Renderer::Layer2D::Layer2D(VkExtent2D extent) {
403405

404406
this->m_presentPipeline = std::make_unique<RND_D3D12::PresentPipeline<false>>(VRManager::instance().XR->GetRenderer());
405407

406-
// note: it's possible to make a swapchain that matches Cemu's internal resolution and let the headset downsample it, although I doubt there's a benefit
407-
this->m_swapchain = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(viewConfs[0].recommendedImageRectWidth, viewConfs[0].recommendedImageRectHeight, viewConfs[0].recommendedSwapchainSampleCount);
408+
this->m_swapchain = std::make_unique<Swapchain<DXGI_FORMAT_R8G8B8A8_UNORM_SRGB>>(extent.width, extent.height, viewConfs[0].recommendedSwapchainSampleCount);
408409

409410
this->m_presentPipeline->BindSettings((float)this->m_swapchain->GetWidth(), (float)this->m_swapchain->GetHeight());
410411

src/rendering/renderer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class RND_Renderer {
114114
void Render(OpenXR::EyeSide side, long frameIdx);
115115
const std::array<XrCompositionLayerProjectionView, 2>& FinishRendering(long frameIdx);
116116

117-
float GetAspectRatio(OpenXR::EyeSide side) const { return m_swapchains[side]->GetWidth() / (float)m_swapchains[side]->GetHeight(); }
117+
float GetAspectRatio(OpenXR::EyeSide side) const { return m_recommendedAspectRatios[side]; }
118118
long GetCurrentFrameIdx() const { return m_currentFrameIdx; }
119119

120120
private:
@@ -123,6 +123,7 @@ class RND_Renderer {
123123
std::array<std::unique_ptr<RND_D3D12::PresentPipeline<true>>, 2> m_presentPipelines;
124124
std::array<std::array<std::unique_ptr<SharedTexture>, 2>, 2> m_textures;
125125
std::array<std::array<std::unique_ptr<SharedTexture>, 2>, 2> m_depthTextures;
126+
std::array<float, 2> m_recommendedAspectRatios = { 1.0f, 1.0f };
126127

127128
std::array<XrCompositionLayerProjectionView, 2> m_projectionViews = {};
128129
std::array<XrCompositionLayerDepthInfoKHR, 2> m_projectionViewsDepthInfo = {};

0 commit comments

Comments
 (0)