Fixed mouse grab issue, added EnginePatch, improvements to build-everything

This commit is contained in:
2024-11-05 20:26:39 -05:00
parent 29dc91e43c
commit bf5e3e7a2a
3 changed files with 70 additions and 135 deletions

52
EnginePatches/EnginePatch Normal file
View File

@@ -0,0 +1,52 @@
diff --git a/Engine/Source/Runtime/ApplicationCore/Private/Linux/LinuxPlatformApplicationMisc.cpp b/Engine/Source/Runtime/ApplicationCore/Private/Linux/LinuxPlatformApplicationMisc.cpp
index ca5f4b5fb5ff..a436a624d5b7 100644
--- a/Engine/Source/Runtime/ApplicationCore/Private/Linux/LinuxPlatformApplicationMisc.cpp
+++ b/Engine/Source/Runtime/ApplicationCore/Private/Linux/LinuxPlatformApplicationMisc.cpp
@@ -299,6 +299,9 @@ bool FLinuxPlatformApplicationMisc::InitSDL()
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_SHOW_CURSOR, "1"); // When relative mouse mode is acive, don't hide cursor.
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "0"); // Don't warp the cursor to the center in relative mouse mode.
+ // Unreal does its own dynamic capturing, we don't need SDL to do it.
+ SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
+
// If we're rendering offscreen, use the "dummy" SDL video driver
if (FParse::Param(FCommandLine::Get(), TEXT("RenderOffScreen")) && !getenv("SDL_VIDEODRIVER"))
{
diff --git a/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp b/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp
index 1677269adb69..dae6bcde6c25 100644
--- a/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp
+++ b/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp
@@ -10,6 +10,13 @@
#include "Stats/Stats.h"
#include "ProfilingDebugging/CsvProfiler.h"
+namespace UBreakPoint {
+ volatile int OnLogError_V;
+ FORCENOINLINE static void OnLogError() {
+ OnLogError_V = 0;
+ }
+}
+
void StaticFailDebugV(const TCHAR* Error, const ANSICHAR* Expression, const ANSICHAR* File, int32 Line, bool bIsEnsure, void* ProgramCounter, const TCHAR* DescriptionFormat, va_list DescriptionArgs);
CSV_DEFINE_CATEGORY(FMsgLogf, true);
@@ -35,6 +42,9 @@ void FMsg::LogfImpl(const ANSICHAR* File, int32 Line, const FLogCategoryName& Ca
}
GROWABLE_LOGF(LogOverride ? LogOverride->Log(Category, Verbosity, Buffer)
: GLog->RedirectLog(Category, Verbosity, Buffer))
+ if (Verbosity == ELogVerbosity::Error) {
+ UBreakPoint::OnLogError();
+ }
}
else
{
@@ -79,6 +89,9 @@ void FMsg::LogV(const ANSICHAR* File, int32 Line, const FLogCategoryName& Catego
{
(OutputDevice ? OutputDevice : GLog)->Serialize(Message, Verbosity, Category);
});
+ if (Verbosity == ELogVerbosity::Error) {
+ UBreakPoint::OnLogError();
+ }
}
else
{

View File

@@ -1,122 +0,0 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Logging/LogMacros.h"
#include "CoreGlobals.h"
#include "HAL/Platform.h"
#include "Misc/ScopeLock.h"
#include "Misc/OutputDeviceRedirector.h"
#include "Misc/FeedbackContext.h"
#include "Misc/VarargsHelper.h"
#include "Stats/Stats.h"
#include "ProfilingDebugging/CsvProfiler.h"
namespace UBreakPoint {
volatile int OnLogError_V;
FORCENOINLINE static void OnLogError() {
OnLogError_V = 0;
}
}
void StaticFailDebugV(const TCHAR* Error, const ANSICHAR* Expression, const ANSICHAR* File, int32 Line, bool bIsEnsure, void* ProgramCounter, const TCHAR* DescriptionFormat, va_list DescriptionArgs);
CSV_DEFINE_CATEGORY(FMsgLogf, true);
void FMsg::LogfImpl(const ANSICHAR* File, int32 Line, const FLogCategoryName& Category, ELogVerbosity::Type Verbosity, const TCHAR* Fmt, ...)
{
#if !NO_LOGGING
if (LIKELY(Verbosity != ELogVerbosity::Fatal))
{
// SetColour is routed to GWarn just like the other verbosities and handled in the
// device that does the actual printing.
FOutputDevice* LogOverride = nullptr;
switch (Verbosity)
{
case ELogVerbosity::Error:
case ELogVerbosity::Warning:
case ELogVerbosity::Display:
case ELogVerbosity::SetColor:
LogOverride = GWarn;
break;
default:
break;
}
GROWABLE_LOGF(LogOverride ? LogOverride->Log(Category, Verbosity, Buffer)
: GLog->RedirectLog(Category, Verbosity, Buffer))
if (Verbosity == ELogVerbosity::Error) {
UBreakPoint::OnLogError();
}
}
else
{
va_list Args;
va_start(Args, Fmt);
StaticFailDebugV(TEXT("Fatal error:"), "", File, Line, /*bIsEnsure*/ false, PLATFORM_RETURN_ADDRESS(), Fmt, Args);
va_end(Args);
va_start(Args, Fmt);
FDebug::AssertFailedV("", File, Line, Fmt, Args);
va_end(Args);
}
#endif
}
void FMsg::LogV(const ANSICHAR* File, int32 Line, const FLogCategoryName& Category, ELogVerbosity::Type Verbosity, const TCHAR* Fmt, va_list Args)
{
#if !NO_LOGGING
LLM_SCOPE_BYNAME("EngineMisc/FMsgLogf")
QUICK_SCOPE_CYCLE_COUNTER(STAT_FMsgLogf);
CSV_CUSTOM_STAT(FMsgLogf, FMsgLogfCount, 1, ECsvCustomStatOp::Accumulate);
if (LIKELY(Verbosity != ELogVerbosity::Fatal))
{
TStringBuilder<512> Buffer;
Buffer.AppendV(Fmt, Args);
const TCHAR* Message = *Buffer;
FOutputDevice* OutputDevice = nullptr;
switch (Verbosity)
{
case ELogVerbosity::Error:
case ELogVerbosity::Warning:
case ELogVerbosity::Display:
case ELogVerbosity::SetColor:
OutputDevice = GWarn;
break;
default:
break;
}
// Logging is always done in the open as we want logs even with transactionalized code.
AutoRTFM::Open([OutputDevice, Message, Verbosity, Category]
{
(OutputDevice ? OutputDevice : GLog)->Serialize(Message, Verbosity, Category);
});
if (Verbosity == ELogVerbosity::Error) {
UBreakPoint::OnLogError();
}
}
else
{
StaticFailDebugV(TEXT("Fatal error:"), "", File, Line, /*bIsEnsure*/ false, PLATFORM_RETURN_ADDRESS(), Fmt, Args);
}
#endif
}
void FMsg::Logf_InternalImpl(const ANSICHAR* File, int32 Line, const FLogCategoryName& Category, ELogVerbosity::Type Verbosity, const TCHAR* Fmt, ...)
{
#if !NO_LOGGING
va_list Args;
va_start(Args, Fmt);
LogV(File, Line, Category, Verbosity, Fmt, Args);
va_end(Args);
#endif
}
/** Sends a formatted message to a remote tool. */
void VARARGS FMsg::SendNotificationStringfImpl( const TCHAR *Fmt, ... )
{
GROWABLE_LOGF(SendNotificationString(Buffer));
}
void FMsg::SendNotificationString( const TCHAR* Message )
{
FPlatformMisc::LowLevelOutputDebugString(Message);
}

View File

@@ -7,7 +7,7 @@
# - Hardwiring paths into Source/Integration/lpx-paths.hpp # - Hardwiring paths into Source/Integration/lpx-paths.hpp
# - Generating Integration.uproject # - Generating Integration.uproject
# - Generating Integration.code-workspace # - Generating Integration.code-workspace
# - Patching LogMacros.cpp in UnrealEngine repository # - Applies patch to Unreal Engine source.
# - Running Setup.sh in the UnrealEngine repository # - Running Setup.sh in the UnrealEngine repository
# - Building luprex # - Building luprex
# - Building ShaderCompileWorker # - Building ShaderCompileWorker
@@ -22,7 +22,7 @@
# It's much faster to edit and recompile using the IDE. # It's much faster to edit and recompile using the IDE.
# #
import sys, os, json, shutil import sys, os, json, shutil, subprocess
from pathlib import Path from pathlib import Path
# #
@@ -37,6 +37,10 @@ def writefile(fn, str):
with open(fn, "w") as f: with open(fn, "w") as f:
f.write(str) f.write(str)
def shell(cmd):
print("Running:", cmd)
subprocess.run(cmd, shell=True, check=True)
# #
# These are some directory paths that we will need. # These are some directory paths that we will need.
# #
@@ -61,7 +65,6 @@ Path(f"Makefile").unlink(missing_ok=True)
Path(f"Source/Integration/lpx-paths.hpp").unlink(missing_ok=True) Path(f"Source/Integration/lpx-paths.hpp").unlink(missing_ok=True)
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True) Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True) Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
Path(f"{UNREALENGINE}/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp").unlink(missing_ok=True)
# #
# Write BuildConfiguration.xml # Write BuildConfiguration.xml
@@ -81,11 +84,16 @@ writefile("Source/Integration/lpx-paths.hpp", f"""
""") """)
# #
# Write LogMacros.cpp # Apply patch to the unreal engine source.
# Restore any affected sourcefiles before applying patch.
# #
LOGMACROS=readfile("EnginePatches/LogMacros.cpp") os.chdir(UNREALENGINE)
writefile(f"{UNREALENGINE}/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp", LOGMACROS) print("Applying patch to Unreal Engine...")
shell("git checkout HEAD Engine/Source/Runtime/ApplicationCore/Private/Linux/LinuxPlatformApplicationMisc.cpp")
shell("git checkout HEAD Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp")
shell(f"git apply {INTEGRATION}/EnginePatches/EnginePatch")
os.chdir(INTEGRATION)
# #
# Write Integration.uproject. # Write Integration.uproject.
@@ -101,17 +109,14 @@ with open("Integration.uproject", "w") as rewritten:
# #
os.chdir(UNREALENGINE) os.chdir(UNREALENGINE)
print("Running setup.sh...") shell("./Setup.sh")
os.system("./Setup.sh")
os.chdir(INTEGRATION) os.chdir(INTEGRATION)
# #
# Use UnrealBuildTool to generate a rough draft of Integration.code-workspace. # Use UnrealBuildTool to generate a rough draft of Integration.code-workspace.
# #
BUILDPROJECTFILES = f'{UNREALENGINE}/GenerateProjectFiles.sh -projectfiles -project="{INTEGRATION}/Integration.uproject" -game' shell(f'{UNREALENGINE}/GenerateProjectFiles.sh -projectfiles -project="{INTEGRATION}/Integration.uproject" -game')
print(BUILDPROJECTFILES)
os.system(BUILDPROJECTFILES)
# #
# Load the rough Integration.code-workspace into RAM, then delete the rough draft. # Load the rough Integration.code-workspace into RAM, then delete the rough draft.
@@ -190,7 +195,7 @@ with open("Integration.code-workspace", "w") as rewritten:
os.chdir(f"{INTEGRATION}/luprex") os.chdir(f"{INTEGRATION}/luprex")
print("Building luprex...") print("Building luprex...")
os.system("make") shell("make")
os.chdir(INTEGRATION) os.chdir(INTEGRATION)
# #
@@ -199,7 +204,7 @@ os.chdir(INTEGRATION)
os.chdir(UNREALENGINE) os.chdir(UNREALENGINE)
print("Building ShaderCompileWorker...") print("Building ShaderCompileWorker...")
os.system("Engine/Build/BatchFiles/Linux/Build.sh ShaderCompileWorker Linux Shipping -waitmutex") shell("Engine/Build/BatchFiles/Linux/Build.sh ShaderCompileWorker Linux Shipping -waitmutex")
Path("Engine/Binaries/Linux/ShaderCompileWorker").unlink(missing_ok=True) Path("Engine/Binaries/Linux/ShaderCompileWorker").unlink(missing_ok=True)
shutil.copyfile("Engine/Binaries/Linux/ShaderCompileWorker-Linux-Shipping", "Engine/Binaries/Linux/ShaderCompileWorker") shutil.copyfile("Engine/Binaries/Linux/ShaderCompileWorker-Linux-Shipping", "Engine/Binaries/Linux/ShaderCompileWorker")
os.chdir(INTEGRATION) os.chdir(INTEGRATION)