# Compilation failures when adding SCOPED\_GPU\_EVENT to core rendering files 

**URL:** <https://forums.unrealengine.com/t/compilation-failures-when-adding-scoped-gpu-event-to-core-rendering-files/2690519>\
**Category:** Platform & Builds\
**Tags:** unreal-engine, Epic-Pro-Support, question\
**Created:** [December 5, 2025, 11:13pm UTC](https://forums.unrealengine.com/t/compilation-failures-when-adding-scoped-gpu-event-to-core-rendering-files/2690519 "2025-12-05T23:13:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [December 5, 2025, 11:13pm UTC](https://forums.unrealengine.com/t/compilation-failures-when-adding-scoped-gpu-event-to-core-rendering-files/2690519/1 "2025-12-05T23:13:28Z")

</div>

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:

```auto
#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:

```auto
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`:

```auto
#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.

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [December 5, 2025, 11:13pm UTC](https://forums.unrealengine.com/t/compilation-failures-when-adding-scoped-gpu-event-to-core-rendering-files/2690519/2 "2025-12-05T23:13:32Z")

</div>

**Steps to Reproduce**  
Hi,

I’m trying to add GPU Profiling scopes to some core renderer code. The general pattern for adding these scopes is:

```auto
// SomeFile.cpp

DECLARE_GPU_STAT(MyStat)

void SomeClass::SomeFunction(FRHICommandList& RHICommandList)
{
  SCOPED_GPU_STAT(RHICommandList, MyStat);
}

```

This works just great in other files, but when i try to add `SCOPED_GPU_STAT`s in `RenderCore/Private/RenderGraphUtils.cpp` compilation fails with:

```auto
[1/8] Compile [x64] RenderGraphUtils.cpp
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(798,4): error C2760: syntax error: ',' was unexpected here; expected ')'
                 SCOPED_GPU_STAT(RHICommandList, AlertStat1)
                 ^
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(798,4): error C2760: syntax error: ',' was unexpected here; expected ';'
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(798,4): error C2760: syntax error: ',' was unexpected here; expected '}'
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(798,4): error C2059: syntax error: ','
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(799,3): error C2059: syntax error: ')'
        });
         ^
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(800,1): error C2059: syntax error: '}'
}
^
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(800,1): error C2143: syntax error: missing ';' before '}'
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(822,1): error C2143: syntax error: missing ';' before '{'
{
^
C:\project\Engine\Source\Runtime\RenderCore\Private\RenderGraphUtils.cpp(822,1): error C2447: '{': missing function header (old-style formal list?)

```

---

<div class="post-metadata">

**Author:** ![Keegan\_Prismatic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/keegan_prismatic/32/1223382_2.png) [@Keegan\_Prismatic](https://forums.unrealengine.com/u/Keegan_Prismatic)\
**Post date:** [December 10, 2025, 12:10am UTC](https://forums.unrealengine.com/t/compilation-failures-when-adding-scoped-gpu-event-to-core-rendering-files/2690519/3 "2025-12-10T00:10:12Z")

</div>

Hi there,

Yes, that would work. Here is a narrower change that would only no-op if the CSV Profile isnt available.

```auto
#if STATS
 
	#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);
 
	#define SCOPED_GPU_STAT_VERBOSE(RHICmdList, StatName, Description) FScopedGPUStatEvent PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ); PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ).Begin(RHICmdList, CSV_STAT_FNAME(StatName), GET_STATID( Stat_GPU_##StatName ).GetName(), Description, DrawcallCountCategory_##StatName);
 
#elif CSV_PROFILER
 
	#define SCOPED_GPU_STAT(RHICmdList, StatName) FScopedGPUStatEvent PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ); PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ).Begin(RHICmdList, CSV_STAT_FNAME(StatName), FName(), nullptr , DrawcallCountCategory_##StatName);
 
	#define SCOPED_GPU_STAT_VERBOSE(RHICmdList, StatName, Description) FScopedGPUStatEvent PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ); PREPROCESSOR_JOIN(GPUStatEvent_##StatName, __LINE__ ).Begin(RHICmdList, CSV_STAT_FNAME(StatName), FName(), Description, DrawcallCountCategory_##StatName);
 
#else
 
	#define SCOPED_GPU_STAT(RHICmdList, StatName)            
 
	#define SCOPED_GPU_STAT_VERBOSE(RHICmdList, StatName, Description)
 
#endif

```

Modifying the engine here should be pretty safe, and if you were to do an engine upgrade, it should be noted that SCOPED\_GPU\_STAT in 5.6 onwards has been deprecated in favour of RHI\_BREADCRUMB\_EVENT\_STAT with the new GPU profiler

Here’s a video from Luke Thatcher from Unreal Fest Stockholm 2025 about the new GPU profiler, if interested: [https://dev.epicgames.com/community/learning/tutorials/7Ox6/unreal-engine-new-gpu-profiler-and-rhi-submission-pipeline](https://dev.epicgames.com/community/learning/tutorials/7Ox6/unreal-engine-new-gpu-profiler-and-rhi-submission-pipeline)

Kind Regards

Keegan Gibson
