RHIinit() calls GRHICommandList.GetImmediateCommandList().GetContext() to make sure that GDynamicRHI->Init() initialized the immediate command list (by calling FRHICommandListImmediate::InitializeImmediateContexts()). This works in Debug and Development because the lambda enqueued by SwitchPipeline runs immediately, as Bypass() returns true before the RHI thread is started. However, in Test and Shipping Bypass() always returns false, so the switch pipelines command is enqueued rather than executed, and nothing sets up the contexts on the immediate command list.
However, checks are normally disabled in Test and Shipping, so the checkf() inside GetContext() doesn't fire. Two wrongs make a right in this case. :> When USE_CHECKS_IN_SHIPPING is 1, the check fires, and the engine crashes on startup.
Note that this doesn't happen in server builds because RHIInit takes a different path (it uses the null RHI and doesn't perform this check).
We either need to flush commands before calling GetContext(), or we need to find another way of ensuring that the dynamic RHI has called InitializeImmediateContexts().
Download the licensee repro from here:
[Link Removed]
Compile a Win64 test package of the project (either via the editor or buildcookrun etc)
Launch the test package. If using Visual Studio, launch Test/Win64/TestProjectUDN. Crash occurs on startup.
Alternative steps:
Assertion failed: GraphicsContext [File:Engine\Source\Runtime\RHI\Public\RHICommandList.h] [Line: 581] There is no active graphics context on this command list. There may be a missing call to SwitchPipeline().
Assertion failed: GraphicsContext [File:D:\Unreal\UE5_Release-5.1\Engine\Source\Runtime\RHI\Public\RHICommandList.h] [Line: 581] There is no active graphics context on this command list. There may be a missing call to SwitchPipeline(). A breakpoint instruction (__debugbreak() statement or a similar call) was executed in TestProjectUDN-Win64-Test.exe. > [Inline Frame] TestProjectUDN-Win64-Test.exe!FRHICommandListBase::GetContext() Line 581 C++ TestProjectUDN-Win64-Test.exe!RHIInit(bool bHasEditorToken) Line 347 C++ [Inline Frame] TestProjectUDN-Win64-Test.exe!FCpuProfilerTrace::FEventScope::{ctor}(unsigned int &) Line 120 C++ TestProjectUDN-Win64-Test.exe!FEngineLoop::PreInitPreStartupScreen(const wchar_t * CmdLine) Line 2814 C++ [Inline Frame] TestProjectUDN-Win64-Test.exe!FEngineLoop::PreInit(const wchar_t *) Line 3939 C++ [Inline Frame] TestProjectUDN-Win64-Test.exe!EnginePreInit(const wchar_t *) Line 46 C++ TestProjectUDN-Win64-Test.exe!GuardedMain(const wchar_t * CmdLine) Line 154 C++ TestProjectUDN-Win64-Test.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 233 C++ TestProjectUDN-Win64-Test.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 282 C++ [External Code]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-171275 in the post.
17 |
Component | UE - Rendering Architecture - RHI |
---|---|
Affects Versions | 5.1 |
Target Fix | 5.6 |
Created | Nov 29, 2022 |
---|---|
Updated | Sep 25, 2024 |