diff --git a/src/oculus/oculus_manager.cpp b/src/oculus/oculus_manager.cpp index 1d041ef..9890bb3 100644 --- a/src/oculus/oculus_manager.cpp +++ b/src/oculus/oculus_manager.cpp @@ -275,6 +275,7 @@ namespace vrperfkit { void OculusManager::PostProcessD3D11(ovrLayerEyeFovDepth &eyeLayer) { auto projCenters = CalculateProjectionCenter(eyeLayer.Fov); bool successfulPostprocessing = false; + bool isFlippedY = eyeLayer.Header.Flags & ovrLayerFlag_TextureOriginAtBottomLeft; for (int eye = 0; eye < 2; ++eye) { int index; @@ -311,6 +312,11 @@ namespace vrperfkit { input.inputViewport.height = eyeLayer.Viewport[eye].Size.h; input.eye = eye; input.projectionCenter = projCenters.eyeCenter[eye]; + + if (isFlippedY) { + input.projectionCenter.y = 1.f - input.projectionCenter.y; + } + if (submittedEyeChains[1] == nullptr || submittedEyeChains[1] == submittedEyeChains[0]) { if (d3d11Res->usingArrayTex) { input.mode = TextureMode::ARRAY; @@ -333,7 +339,11 @@ namespace vrperfkit { D3D11_TEXTURE2D_DESC td; input.inputTexture->GetDesc(&td); - d3d11Res->variableRateShading->UpdateTargetInformation(td.Width, td.Height, input.mode, projCenters.eyeCenter[0].x, projCenters.eyeCenter[0].y, projCenters.eyeCenter[1].x, projCenters.eyeCenter[1].y); + float projLX = projCenters.eyeCenter[0].x; + float projLY = isFlippedY ? 1.f - projCenters.eyeCenter[0].y : projCenters.eyeCenter[0].y; + float projRX = projCenters.eyeCenter[1].x; + float projRY = isFlippedY ? 1.f - projCenters.eyeCenter[1].y : projCenters.eyeCenter[1].y; + d3d11Res->variableRateShading->UpdateTargetInformation(td.Width, td.Height, input.mode, projLX, projLY, projRX, projRY); } if (successfulPostprocessing) { diff --git a/src/openvr/openvr_hooks.cpp b/src/openvr/openvr_hooks.cpp index 0871924..7458d4d 100644 --- a/src/openvr/openvr_hooks.cpp +++ b/src/openvr/openvr_hooks.cpp @@ -30,7 +30,7 @@ namespace vrperfkit { g_openVr.PreCompositorWorkCall(true); auto error = hooks::CallOriginal(IVRCompositor009Hook_Submit)(self, info.eye, info.texture, info.bounds, info.submitFlags); if (error != vr::VRCompositorError_None) { - LOG_ERROR << "OpenVR submit failed: " << error; + LOG_DEBUG << "OpenVR submit failed: " << error; } g_openVr.PostCompositorWorkCall(true); return error; @@ -62,7 +62,7 @@ namespace vrperfkit { auto error = hooks::CallOriginal(IVRCompositorHook_WaitGetPoses)(self, pRenderPoseArray, unRenderPoseArrayCount, pGamePoseArray, unGamePoseArrayCount); g_openVr.PostCompositorWorkCall(); if (error != vr::VRCompositorError_None) { - LOG_ERROR << "OpenVR WaitGetPoses failed: " << error; + LOG_DEBUG << "OpenVR WaitGetPoses failed: " << error; } return error; } diff --git a/src/openvr/openvr_manager.cpp b/src/openvr/openvr_manager.cpp index b591cb0..9383e00 100644 --- a/src/openvr/openvr_manager.cpp +++ b/src/openvr/openvr_manager.cpp @@ -361,6 +361,9 @@ namespace vrperfkit { inputTexture->GetDesc(&itd); d3d11Res->outputTexture->GetDesc(&otd); + bool isFlippedX = info.bounds->uMin > info.bounds->uMax; + bool isFlippedY = info.bounds->vMin > info.bounds->vMax; + bool inputIsSrgb = info.texture->eColorSpace == ColorSpace_Gamma || (info.texture->eColorSpace == ColorSpace_Auto && IsConsideredSrgbByOpenVR(itd.Format)); bool isCombinedTex = float(itd.Width) / itd.Height >= 1.5f * aspectRatio && std::abs(info.bounds->uMax - info.bounds->uMin) <= 0.5f; @@ -378,12 +381,25 @@ namespace vrperfkit { input.projectionCenter = projCenters.eyeCenter[info.eye]; input.mode = d3d11Res->usingArrayTex ? TextureMode::ARRAY : (isCombinedTex ? TextureMode::COMBINED : TextureMode::SINGLE); + if (isFlippedX) { + input.projectionCenter.x = 1.f - input.projectionCenter.x; + } + if (isFlippedY) { + input.projectionCenter.y = 1.f - input.projectionCenter.y; + } + Viewport outputViewport; if (d3d11Res->postProcessor->Apply(input, outputViewport)) { outputBounds.uMin = float(outputViewport.x) / otd.Width; outputBounds.vMin = float(outputViewport.y) / otd.Height; outputBounds.uMax = float(outputViewport.width + outputViewport.x) / otd.Width; outputBounds.vMax = float(outputViewport.height + outputViewport.y) / otd.Height; + if (info.bounds->uMin > info.bounds->uMax) { + std::swap(outputBounds.uMin, outputBounds.uMax); + } + if (info.bounds->vMin > info.bounds->vMax) { + std::swap(outputBounds.vMin, outputBounds.vMax); + } info.bounds = &outputBounds; PrepareOutputTexInfo(info.texture, info.submitFlags); @@ -392,7 +408,11 @@ namespace vrperfkit { info.texture = outputTexInfo.get(); } - d3d11Res->variableRateShading->UpdateTargetInformation(itd.Width, itd.Height, input.mode, projCenters.eyeCenter[0].x, projCenters.eyeCenter[0].y, projCenters.eyeCenter[1].x, projCenters.eyeCenter[1].y); + float projLX = isFlippedX ? 1.f - projCenters.eyeCenter[0].x : projCenters.eyeCenter[0].x; + float projLY = isFlippedY ? 1.f - projCenters.eyeCenter[0].y : projCenters.eyeCenter[0].y; + float projRX = isFlippedX ? 1.f - projCenters.eyeCenter[1].x : projCenters.eyeCenter[1].x; + float projRY = isFlippedY ? 1.f - projCenters.eyeCenter[1].y : projCenters.eyeCenter[1].y; + d3d11Res->variableRateShading->UpdateTargetInformation(itd.Width, itd.Height, input.mode, projLX, projLY, projRX, projRY); } void OpenVrManager::PatchDxvkSubmit(OpenVrSubmitInfo &info) {