Skip to content

Instantly share code, notes, and snippets.

@ikrima
Last active February 28, 2024 06:14
Show Gist options
  • Save ikrima/5500527155f4ba83f15508570a100d46 to your computer and use it in GitHub Desktop.
Save ikrima/5500527155f4ba83f15508570a100d46 to your computer and use it in GitHub Desktop.
RenderDocPlugin In Packaged Builds
C:\ikrima\src\knl\Bebylon\UnrealEngine\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11Device.cpp
Line 310
#if PLATFORM_WINDOWS
IUnknown* RenderDoc;
IID RenderDocID;
if (SUCCEEDED(IIDFromString(L"{A7AA6116-9C8D-4BBA-9083-B4D816B71B78}", &RenderDocID)))
{
// @third party code - BEGIN Bebylon - #Eng-FIX-RenderDoc: Disable Forced Ideal GPU Capture - Bc we use renderdoc in packaged games
bool bUseRenderDoc = false;
FParse::Bool(FCommandLine::Get(), TEXT("renderdoc"), bUseRenderDoc);
if (SUCCEEDED(Direct3DDevice->QueryInterface(RenderDocID, (void**)(&RenderDoc)))
&& (GIsEditor || bUseRenderDoc) )
// @third party code - END Bebylon
{
C:\ikrima\src\knl\Bebylon\UnrealEngine\Engine\Plugins\Developer\RenderDocPlugin\Source\RenderDocPlugin\Private\RenderDocPluginLoader.cpp
Line 1:
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#include "RenderDocPluginLoader.h"
#include "RenderDocPluginModule.h"
#include "RenderDocPluginSettings.h"
#include "Internationalization/Internationalization.h"
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Enable relative gamepath specification from game directory
#if !UE_BUILD_SHIPPING
#include "Developer/DesktopPlatform/public/DesktopPlatformModule.h"
#endif
// @third party code - END Bebylon
Line 31:
static void* LoadAndCheckRenderDocLibrary(FRenderDocPluginLoader::RENDERDOC_API_CONTEXT*& RenderDocAPI, const FString& RenderdocPath)
{
check(nullptr == RenderDocAPI);
if (RenderdocPath.IsEmpty())
{
return(nullptr);
}
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Enable relative gamepath specification from game directory
FString PathToRenderDocDLL = [&RenderdocPath]() {
FString renderDocDllPath = FPaths::Combine(*RenderdocPath, *FString("renderdoc.dll"));
FString pathToAttempt = FPaths::IsRelative(renderDocDllPath) ? FPaths::ConvertRelativePathToFull(renderDocDllPath) : renderDocDllPath;
if (FPaths::FileExists(pathToAttempt))
{ return pathToAttempt; }
pathToAttempt = FPaths::Combine(FPaths::ProjectDir(), renderDocDllPath);
if (FPaths::FileExists(pathToAttempt))
{ return pathToAttempt; }
pathToAttempt = FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::EngineDir(), renderDocDllPath));
if (FPaths::FileExists(pathToAttempt))
{ return pathToAttempt; }
return FString("");
}();
// @third party code - END Bebylon
if (!FPaths::FileExists(PathToRenderDocDLL))
{
UE_LOG(RenderDocPlugin, Warning, TEXT("unable to locate RenderDoc library at: %s"), *PathToRenderDocDLL);
return(nullptr);
}
Line 123:
// 2) Check for a RenderDoc system installation in the registry:
if (RenderDocDLL == nullptr)
{
FString RenderdocPath;
FWindowsPlatformMisc::QueryRegKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Classes\\RenderDoc.RDCCapture.1\\DefaultIcon\\"), TEXT(""), RenderdocPath);
RenderdocPath = FPaths::GetPath(RenderdocPath);
RenderDocDLL = LoadAndCheckRenderDocLibrary(RenderDocAPI, RenderdocPath);
if (RenderDocDLL)
{
CVarRenderDocBinaryPath.AsVariable()->Set(*RenderdocPath, ECVF_SetByProjectSetting);
}
}
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Enable relative gamepath specification from game directory
#if !UE_BUILD_SHIPPING
// @third party code - END Bebylon
// 3) Check for a RenderDoc custom installation by prompting the user:
if (RenderDocDLL == nullptr)
{
//Renderdoc does not seem to be installed, but it might be built from source or downloaded by archive,
//so prompt the user to navigate to the main exe file
UE_LOG(RenderDocPlugin, Log, TEXT("RenderDoc library not found; provide a custom installation location..."));
FString RenderdocPath;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
FString Filter = TEXT("Renderdoc executable|renderdocui.exe");
TArray<FString> OutFiles;
if (DesktopPlatform->OpenFileDialog(nullptr, TEXT("Locate main Renderdoc executable..."), TEXT(""), TEXT(""), Filter, EFileDialogFlags::None, OutFiles))
{
RenderdocPath = OutFiles[0];
}
}
RenderdocPath = FPaths::GetPath(RenderdocPath);
RenderDocDLL = LoadAndCheckRenderDocLibrary(RenderDocAPI, RenderdocPath);
if (RenderDocDLL)
{
CVarRenderDocBinaryPath.AsVariable()->Set(*RenderdocPath, ECVF_SetByProjectSetting);
}
}
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Enable relative gamepath specification from game directory
#endif
// @third party code - END Bebylon
// 4) All bets are off; aborting...
if (RenderDocDLL == nullptr)
{
UE_LOG(RenderDocPlugin, Warning, TEXT("unable to initialize the plugin because no RenderDoc libray has been located."));
return;
}
C:\ikrima\src\knl\Bebylon\UnrealEngine\Engine\Plugins\Developer\RenderDocPlugin\Source\RenderDocPlugin\Private\RenderDocPluginModule.cpp
Line 16:
#if WITH_EDITOR
#include "UnrealClient.h"
#include "Editor/EditorEngine.h"
extern UNREALED_API UEditorEngine* GEditor;
#include "ISettingsModule.h"
#include "ISettingsSection.h"
#else
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Include GEngine to allow RenderDoc to be packaged in Runtime builds
#include "Engine/Engine.h"
extern ENGINE_API class UEngine* GEngine;
// @third party code - END Bebylon
#endif
C:\ikrima\src\knl\Bebylon\UnrealEngine\Engine\Plugins\Developer\RenderDocPlugin\Source\RenderDocPlugin\RenderDocPlugin.Build.cs
Line 9:
public RenderDocPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PrivateDependencyModuleNames.AddRange(new string[] { });
PublicDependencyModuleNames.AddRange(new string[]
{
"Core"
, "CoreUObject"
, "Engine"
, "InputCore"
, "DesktopPlatform"
, "Projects"
, "RenderCore"
, "InputDevice"
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Include GEngine to allow RenderDoc to be packaged in Runtime builds
//, "MainFrame"
// @third party code - END Bebylon
, "RHI" // RHI module: required for accessing the UE4 flag GUsingNullRHI.
});
// @third party code - BEGIN Bebylon - #Eng-Workaround-RenderDoc: Include GEngine to allow RenderDoc to be packaged in Runtime builds
if (Target.Configuration != UnrealTargetConfiguration.Shipping)
{
PublicDependencyModuleNames.Add("DesktopPlatform");
}
IsRedistributableOverride = true;
// @third party code - END Bebylon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment