Last active
July 6, 2024 12:36
-
-
Save fredemmott/172f2f7e91405c0d1baa0a1b85e5f875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/injectables/CMakeLists.txt b/src/injectables/CMakeLists.txt | |
index cf1d951e..3db56d7a 100644 | |
--- a/src/injectables/CMakeLists.txt | |
+++ b/src/injectables/CMakeLists.txt | |
@@ -48,6 +48,8 @@ target_link_libraries( | |
ThirdParty::DirectXTK | |
detours-ext | |
oculus-sdk-headers | |
+ PRIVATE | |
+ OpenKneeboard-D3D11 | |
) | |
ok_add_library(openvr-hooks STATIC IVRCompositorWaitGetPosesHook.cpp) | |
diff --git a/src/injectables/OculusD3D11Kneeboard.cpp b/src/injectables/OculusD3D11Kneeboard.cpp | |
index f3f1738f..5bb4d77f 100644 | |
--- a/src/injectables/OculusD3D11Kneeboard.cpp | |
+++ b/src/injectables/OculusD3D11Kneeboard.cpp | |
@@ -19,11 +19,12 @@ | |
*/ | |
#include "OculusD3D11Kneeboard.h" | |
+#include <OpenKneeboard/config.h> | |
+ | |
#include "OVRProxy.h" | |
#include <OpenKneeboard/D3D11.h> | |
-#include <OpenKneeboard/config.h> | |
#include <OpenKneeboard/dprint.h> | |
#include <OVR_CAPI_D3D.h> | |
@@ -118,7 +119,8 @@ void OculusD3D11Kneeboard::RenderLayers( | |
OPENKNEEBOARD_TraceLoggingScopedActivity( | |
activity, "OculusD3D11::RenderLayers"); | |
- D3D11::SavedState state(mD3D11DeviceContext); | |
+ // TESTING: disable to avoid nested saved states within OpenKneeboard | |
+ // D3D11::SavedState state(mD3D11DeviceContext); | |
mRenderer->RenderLayers( | |
*mSwapchain, | |
diff --git a/src/injectables/OculusD3D11Kneeboard.h b/src/injectables/OculusD3D11Kneeboard.h | |
index 2feeda72..40820d12 100644 | |
--- a/src/injectables/OculusD3D11Kneeboard.h | |
+++ b/src/injectables/OculusD3D11Kneeboard.h | |
@@ -19,6 +19,8 @@ | |
*/ | |
#pragma once | |
+#include <OpenKneeboard/config.h> | |
+ | |
#include "IDXGISwapChainHook.h" | |
#include "OculusKneeboard.h" | |
@@ -26,8 +28,6 @@ | |
#include <OpenKneeboard/D3D11/Renderer.h> | |
#include <OpenKneeboard/SHM/D3D11.h> | |
-#include <OpenKneeboard/config.h> | |
- | |
#include <shims/winrt/base.h> | |
#include <array> | |
@@ -56,6 +56,10 @@ class OculusD3D11Kneeboard final : public OculusKneeboard::Renderer { | |
const SHM::Snapshot& snapshot, | |
const std::span<SHM::LayerSprite>& layers) override; | |
+ auto GetD3D11DeviceContext() const { | |
+ return mD3D11DeviceContext; | |
+ } | |
+ | |
private: | |
winrt::com_ptr<ID3D11Device> mD3D11Device; | |
winrt::com_ptr<ID3D11DeviceContext> mD3D11DeviceContext; | |
diff --git a/src/injectables/OculusKneeboard.cpp b/src/injectables/OculusKneeboard.cpp | |
index bd74953d..bab96991 100644 | |
--- a/src/injectables/OculusKneeboard.cpp | |
+++ b/src/injectables/OculusKneeboard.cpp | |
@@ -19,6 +19,9 @@ | |
*/ | |
#include "OculusKneeboard.h" | |
+#include "OculusD3D11Kneeboard.h" | |
+ | |
+#include <OpenKneeboard/D3D11.h> | |
#include <OpenKneeboard/Spriting.h> | |
#include <OpenKneeboard/dprint.h> | |
@@ -104,6 +107,15 @@ ovrResult OculusKneeboard::OnOVREndFrame( | |
return passthrough(); | |
} | |
+ ///// TESTING ONLY - DO NOT COMMIT ///// | |
+ std::unique_ptr<D3D11::SavedState> d3d11State; | |
+ // RAII wrapper around CreateDeviceContextState() + SwapDeviceContextState() | |
+ if (auto d3d11Renderer = dynamic_cast<OculusD3D11Kneeboard*>(mRenderer)) { | |
+ if (auto ctx = d3d11Renderer->GetD3D11DeviceContext()) { | |
+ d3d11State = std::make_unique<D3D11::SavedState>(ctx); | |
+ } | |
+ } | |
+ | |
const auto swapchainDimensions | |
= Spriting::GetBufferSize(metadata.GetLayerCount()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment