Skip to content
Snippets Groups Projects
Commit 56d09cd9 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

- improved memory leak

parent 26e4e6a3
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
File added
......@@ -90,7 +90,7 @@ void FOptiXContextManager::PreRenderView_RenderThread(FRHICommandListImmediate &
void FOptiXContextManager::PreRenderViewFamily_RenderThread(FRHICommandListImmediate & RHICmdList, FSceneViewFamily & InViewFamily)
{
//UE_LOG(LogTemp, Warning, TEXT("PreRenderViewFamily_RenderThread"));
if (!bIsInitialized)
if (!bIsInitialized && bStartTracing)
{
InitCUDADX();
}
......@@ -214,7 +214,7 @@ void FOptiXContextManager::PostRenderView_RenderThread(FRHICommandListImmediate
UpdateCubemapBuffer(RHICmdList);
}
else
else if(InView.StereoPass == EStereoscopicPass::eSSP_RIGHT_EYE)
{
/*optix::uchar4* Data = static_cast<optix::uchar4*>(OptiXContext->GetBuffer("result_color")->MapNative());
RHICmdList.UpdateTexture2D(OutputTextureColorRightRef, 0, TextureRegion, Size.X * 4, (uint8*)Data);
......@@ -269,6 +269,17 @@ void FOptiXContextManager::PostRenderView_RenderThread(FRHICommandListImmediate
//D3DDeviceContext->Flush();
//end = FPlatformTime::Seconds();
//UE_LOG(LogTemp, Warning, TEXT("Update took %f seconds"), end - start);
else if (InView.StereoPass == EStereoscopicPass::eSSP_FULL)
{
UE_LOG(LogTemp, Display, TEXT("Full Pass"));
}
if (bCleanup)
{
CleanupOptiXOnEnd();
}
}
......@@ -605,6 +616,12 @@ void FOptiXContextManager::InitRendering()
DynamicMaterial->SetTextureParameterValue("DepthRight", DepthTexture.Get());
DynamicMaterial->SetTextureParameterValue("TextureLeft", OutputTexture2.Get());
DynamicMaterial->SetTextureParameterValue("DepthLeft", DepthTexture2.Get());
DynamicMaterial2D = UMaterialInstanceDynamic::Create(RegularMaterial.Get(), OptiXContext.Get(), "DynamicNonVRMaterial");
DynamicMaterial2D->SetTextureParameterValue("Texture", OutputTexture.Get());
DynamicMaterial2D->SetTextureParameterValue("Depth", DepthTexture.Get());
}
else
{
......
......@@ -22,6 +22,11 @@ void AOptiXGameModeBase::InitGame(const FString & MapName, const FString & Optio
FOptiXModule::Get().Init();
}
void AOptiXGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
FOptiXModule::Get().GetOptiXContextManager()->EndPlay();
}
const TArray<FSceneData>& AOptiXGameModeBase::GetOptiXSceneDataArray()
{
return FOptiXModule::Get().GetSceneDataArray();
......
......@@ -113,7 +113,8 @@ public:
void EndPlay()
{
CleanupOptiXOnEnd();
//CleanupOptiXOnEnd();
bCleanup.AtomicSet(true);
}
UOptiXContext* GetOptiXContext()
......@@ -126,6 +127,11 @@ public:
return DynamicMaterial.Get();
}
UMaterialInstanceDynamic* GetOptiXMID2D() // Used to set up the post process
{
return DynamicMaterial2D.Get();
}
void SceneChangedCallback();
// The OptiX context is not thread-safe, so any changes to variables/properties on the game thread
......@@ -570,6 +576,7 @@ private:
LaserIntersectionTexture.Reset();
DynamicMaterial.Reset();
DynamicMaterial2D.Reset();
RegularMaterial.Reset();
VRMaterial.Reset();
LaserMaterial.Reset();
......@@ -688,6 +695,7 @@ private:
TWeakObjectPtr<UTexture2D> DepthTexture2;
TWeakObjectPtr<UMaterialInstanceDynamic> DynamicMaterial;
TWeakObjectPtr<UMaterialInstanceDynamic> DynamicMaterial2D;
TWeakObjectPtr<UMaterial> RegularMaterial;
TWeakObjectPtr<UMaterial> VRMaterial;
bool bWithHMD;
......
......@@ -21,6 +21,8 @@ public:
AOptiXGameModeBase(const FObjectInitializer& ObjectInitializer);
virtual void InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage) override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
UFUNCTION(BlueprintCallable, BlueprintPure)
const TArray<FSceneData>& GetOptiXSceneDataArray();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment