Add GPU profile events to WebGPU and use the by default in non-Release builds

This commit is contained in:
Wojtek Figat
2026-02-26 11:08:12 +01:00
parent d2a8ac54cf
commit ac4526744a
4 changed files with 32 additions and 2 deletions

View File

@@ -115,6 +115,27 @@ void GPUContextWebGPU::FrameEnd()
Flush();
}
#if GPU_ALLOW_PROFILE_EVENTS
#include "Engine/Utilities/StringConverter.h"
void GPUContextWebGPU::EventBegin(const Char* name)
{
StringAsANSI<> nameAnsi(name);
wgpuCommandEncoderPushDebugGroup(Encoder, { nameAnsi.Get(), (size_t)nameAnsi.Length() });
}
void GPUContextWebGPU::EventEnd()
{
// Cannot insert commands in encoder during render pass
if (_renderPass)
EndRenderPass();
wgpuCommandEncoderPopDebugGroup(Encoder);
}
#endif
void* GPUContextWebGPU::GetNativePtr() const
{
return Encoder;

View File

@@ -57,7 +57,7 @@ private:
int32 _indexBuffer32Bit : 1;
int32 _blendFactorDirty : 1;
int32 _blendFactorSet : 1;
int32 _renderTargetCount : 3;
int32 _renderTargetCount : 4;
int32 _vertexBufferCount : 3;
uint32 _stencilRef;
Float4 _blendFactor;
@@ -97,6 +97,10 @@ public:
// [GPUContext]
void FrameBegin() override;
void FrameEnd() override;
#if GPU_ALLOW_PROFILE_EVENTS
void EventBegin(const Char* name) override;
void EventEnd() override;
#endif
void* GetNativePtr() const override;
bool IsDepthBufferBinded() override;
void Clear(GPUTextureView* rt, const Color& color) override;

View File

@@ -18,7 +18,8 @@
// Configure graphics
#define GPU_ALLOW_TESSELLATION_SHADERS 0
#define GPU_ALLOW_GEOMETRY_SHADERS 0
#define GPU_ALLOW_PROFILE_EVENTS 0
//#define GPU_ALLOW_PROFILE_EVENTS 0
#define GPU_AUTO_PROFILE_EVENTS (!BUILD_RELEASE)
#define GPU_ENABLE_PRELOADING_RESOURCES 0 // Don't preload things unless needed
// Threading is optional

View File

@@ -16,7 +16,11 @@ RenderStatsData RenderStatsData::Counter;
int32 ProfilerGPU::_depth = 0;
bool ProfilerGPU::Enabled = false;
#if GPU_AUTO_PROFILE_EVENTS
bool ProfilerGPU::EventsEnabled = true;
#else
bool ProfilerGPU::EventsEnabled = false;
#endif
int32 ProfilerGPU::CurrentBuffer = 0;
ProfilerGPU::EventBuffer ProfilerGPU::Buffers[PROFILER_GPU_EVENTS_FRAMES];