The problem ends up being that `SCOPED_GPU_STAT` depends on the define `CSV_PROFILER` being true but it doesn’t check for that. `SCOPED_GPU_STAT` expands out to:
#define SCOPED_GPU_STAT(RHICmdList, StatName) \
FScopedGPUStatEvent PREPROCESSOR_JOIN(GPUStatEvent_##StatName,__LINE__); \
PREPROCESSOR_JOIN(GPUStatEvent_##StatName,__LINE__).Begin(RHICmdList, \
CSV_STAT_FNAME(StatName), \
GET_STATID( Stat_GPU_##StatName ).GetName(), \
nullptr , \
DrawcallCountCategory_##StatName);
And the `CSV_STAT_FNAME` and (maybe also the) `GET_STATID` calls require `CSV_PROFILER` to be true. If it isn’t true, they noop, and we get output like:
FScopedGPUStatEvent GPUStatEvent_SomeStat1795; GPUStatEvent_SomeStat1795.Begin(RHICommandList,, FName(), nullptr , DrawcallCountCategory_SomeStat);
Which is clearly going to cause compilation errors.
My question is: how would you recommend modifying engine code such that `SCOPED_GPU_STAT` will actually no-op instead of cause compilation errors when its being evaluated in contexts which cannot support it. I believe the specific crash is occurring when building `UnrealPak` / `ShaderCompilationWorker`, since in that context there is `WITH_ENGINE` is false, and `CSV_PROFILER` is also false.
Would something like this be preferred in `Engine/Source/Runtime/RenderCore/Public/ProfilingDebugging/RealtimeGPUProfiler.h`:
#if HAS_GPU_STATS
...
// #if STATS <-- original code
#if STATS && WITH_ENGINE
#define SCOPED_GPU_STAT(RHICmdList, StatName) ...
#else
// no-op
#endif
...
#endif
Thanks for your support.