Skip to content
Snippets Groups Projects
Commit be10fa6d authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Adding (hopefully) temporary fix to circumvent the destruction of the...

Adding (hopefully) temporary fix to circumvent the destruction of the StereoRenderingDevice from nDisplay

Problem see https://github.com/EpicGames/UnrealEngine/pull/7738
parent 8aedc6f5
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
void FDisplayClusterExtensionsModule::StartupModule () void FDisplayClusterExtensionsModule::StartupModule ()
{ {
StereoDeviceFix.Register();
} }
void FDisplayClusterExtensionsModule::ShutdownModule() void FDisplayClusterExtensionsModule::ShutdownModule()
{ {
StereoDeviceFix.Unregister();
} }
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE
......
#include "FixNDisplayStereoDevice.h"
void FFixNDisplayStereoDevice::Register()
{
On_Post_World_Initialization_Delegate.BindRaw(this, &FFixNDisplayStereoDevice::OnSessionStart);
StartHandle = FWorldDelegates::OnPostWorldInitialization.Add(On_Post_World_Initialization_Delegate);
On_Pre_World_Finish_Destroy_Delegate.BindRaw(this, &FFixNDisplayStereoDevice::OnSessionEnd);
EndHandle = FWorldDelegates::OnPreWorldFinishDestroy.Add(On_Pre_World_Finish_Destroy_Delegate);
}
void FFixNDisplayStereoDevice::Unregister()
{
FWorldDelegates::OnPostWorldInitialization.Remove(StartHandle);
FWorldDelegates::OnPreWorldFinishDestroy.Remove(EndHandle);
}
void FFixNDisplayStereoDevice::OnSessionStart(UWorld*, const UWorld::InitializationValues)
{
/* Store handle before it is released */
if(GEngine)
{
StoredRenderingDevice = GEngine->StereoRenderingDevice;
}
}
void FFixNDisplayStereoDevice::OnSessionEnd(UWorld*)
{
/* Restore handle after it was released */
if(GEngine)
{
GEngine->StereoRenderingDevice = StoredRenderingDevice;
}
}
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "FixNDisplayStereoDevice.h"
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
class FDisplayClusterExtensionsModule : public IModuleInterface class FDisplayClusterExtensionsModule : public IModuleInterface
{ {
public: public:
virtual void StartupModule () override; virtual void StartupModule () override;
virtual void ShutdownModule() override; virtual void ShutdownModule() override;
private:
FFixNDisplayStereoDevice StereoDeviceFix;
}; };
#pragma once
#include "CoreMinimal.h"
#include "Engine/World.h"
#include "FixNDisplayStereoDevice.generated.h"
/**
* This fixes the behavior of nDisplay DisplayClusterRenderManager, which resets the global stereo render device
* This is problematic, since it resets the pointer (L128) to the StereoRenderDevice, even if it does not re-initialize (L113) it.
* This results in a fine first start, but crashes on the second VR start. For Desktop this seems to still function fine.
*
* For this behavior a Pull-Request is in progress. See https://github.com/EpicGames/UnrealEngine/pull/7738
*/
USTRUCT()
struct DISPLAYCLUSTEREXTENSIONS_API FFixNDisplayStereoDevice
{
GENERATED_BODY()
void Register();
void Unregister();
private:
void OnSessionStart(UWorld*, const UWorld::InitializationValues);
void OnSessionEnd(UWorld*);
TSharedPtr< class IStereoRendering, ESPMode::ThreadSafe > StoredRenderingDevice;
TBaseDelegate<void, UWorld*, const UWorld::InitializationValues> On_Post_World_Initialization_Delegate;
TBaseDelegate<void, UWorld*> On_Pre_World_Finish_Destroy_Delegate;
FDelegateHandle StartHandle;
FDelegateHandle EndHandle;
};
...@@ -20,14 +20,11 @@ ...@@ -20,14 +20,11 @@
"Type": "Runtime", "Type": "Runtime",
"LoadingPhase": "Default" "LoadingPhase": "Default"
}, },
{ {
"Name": "DisplayClusterExtensionsEditor", "Name": "DisplayClusterExtensionsEditor",
"Type": "Editor", "Type": "Editor",
"LoadingPhase": "PostEngineInit" "LoadingPhase": "PostEngineInit"
} }
], ],
"Plugins": [ "Plugins": [
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment