Improved profiler colors.

This commit is contained in:
Бранимир Караџић
2025-11-21 06:48:07 -08:00
committed by Branimir Karadžić
parent c78b573281
commit 8a6a40108a
4 changed files with 64 additions and 61 deletions

View File

@@ -1380,7 +1380,7 @@ namespace bgfx
void Frame::sort() void Frame::sort()
{ {
BGFX_PROFILER_SCOPE("bgfx/Sort", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Sort", kColorSubmit);
ViewId viewRemap[BGFX_CONFIG_MAX_VIEWS]; ViewId viewRemap[BGFX_CONFIG_MAX_VIEWS];
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
@@ -2322,7 +2322,7 @@ namespace bgfx
uint32_t frameNum = m_submit->m_frameNum; uint32_t frameNum = m_submit->m_frameNum;
BGFX_PROFILER_SCOPE("bgfx/API thread frame", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/API thread frame", kColorSubmit);
// wait for render thread to finish // wait for render thread to finish
renderSemWait(); renderSemWait();
frameNoRenderWait(); frameNoRenderWait();
@@ -2441,7 +2441,7 @@ namespace bgfx
RenderFrame::Enum Context::renderFrame(int32_t _msecs) RenderFrame::Enum Context::renderFrame(int32_t _msecs)
{ {
BGFX_PROFILER_SCOPE("bgfx::renderFrame", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx::renderFrame", kColorSubmit);
#if BX_PLATFORM_OSX || BX_PLATFORM_IOS || BX_PLATFORM_VISIONOS #if BX_PLATFORM_OSX || BX_PLATFORM_IOS || BX_PLATFORM_VISIONOS
NSAutoreleasePoolScope pool; NSAutoreleasePoolScope pool;
@@ -2449,27 +2449,27 @@ namespace bgfx
if (!m_flipAfterRender) if (!m_flipAfterRender)
{ {
BGFX_PROFILER_SCOPE("bgfx/flip", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/flip", kColorSubmit);
flip(); flip();
} }
if (apiSemWait(_msecs) ) if (apiSemWait(_msecs) )
{ {
{ {
BGFX_PROFILER_SCOPE("bgfx/Exec commands pre", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Exec commands pre", kColorResource);
rendererExecCommands(m_render->m_cmdPre); rendererExecCommands(m_render->m_cmdPre);
} }
if (m_rendererInitialized) if (m_rendererInitialized)
{ {
{ {
BGFX_PROFILER_SCOPE("bgfx/Render submit", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Render submit", kColorSubmit);
m_renderCtx->submit(m_render, m_clearQuad, m_textVideoMemBlitter); m_renderCtx->submit(m_render, m_clearQuad, m_textVideoMemBlitter);
m_flipped = false; m_flipped = false;
} }
{ {
BGFX_PROFILER_SCOPE("bgfx/Screenshot", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Screenshot", kColorResource);
for (uint8_t ii = 0, num = m_render->m_numScreenShots; ii < num; ++ii) for (uint8_t ii = 0, num = m_render->m_numScreenShots; ii < num; ++ii)
{ {
const ScreenShot& screenShot = m_render->m_screenShot[ii]; const ScreenShot& screenShot = m_render->m_screenShot[ii];
@@ -2479,7 +2479,7 @@ namespace bgfx
} }
{ {
BGFX_PROFILER_SCOPE("bgfx/Exec commands post", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Exec commands post", kColorResource);
rendererExecCommands(m_render->m_cmdPost); rendererExecCommands(m_render->m_cmdPost);
} }
@@ -2487,7 +2487,7 @@ namespace bgfx
if (m_flipAfterRender) if (m_flipAfterRender)
{ {
BGFX_PROFILER_SCOPE("bgfx/flip", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/flip", kColorSubmit);
flip(); flip();
} }
} }
@@ -2543,7 +2543,7 @@ namespace bgfx
void Context::flushTextureUpdateBatch(CommandBuffer& _cmdbuf) void Context::flushTextureUpdateBatch(CommandBuffer& _cmdbuf)
{ {
BGFX_PROFILER_SCOPE("flushTextureUpdateBatch", 0xff2040ff); BGFX_PROFILER_SCOPE("flushTextureUpdateBatch", kColorResource);
if (m_textureUpdateBatch.sort() ) if (m_textureUpdateBatch.sort() )
{ {
const uint32_t pos = _cmdbuf.m_pos; const uint32_t pos = _cmdbuf.m_pos;
@@ -2954,7 +2954,7 @@ namespace bgfx
case CommandBuffer::CreateIndexBuffer: case CommandBuffer::CreateIndexBuffer:
{ {
BGFX_PROFILER_SCOPE("CreateIndexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateIndexBuffer", kColorResource);
IndexBufferHandle handle; IndexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -2973,7 +2973,7 @@ namespace bgfx
case CommandBuffer::DestroyIndexBuffer: case CommandBuffer::DestroyIndexBuffer:
{ {
BGFX_PROFILER_SCOPE("DestroyIndexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyIndexBuffer", kColorResource);
IndexBufferHandle handle; IndexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -2984,7 +2984,7 @@ namespace bgfx
case CommandBuffer::CreateVertexLayout: case CommandBuffer::CreateVertexLayout:
{ {
BGFX_PROFILER_SCOPE("CreateVertexLayout", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateVertexLayout", kColorResource);
VertexLayoutHandle handle; VertexLayoutHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -2998,7 +2998,7 @@ namespace bgfx
case CommandBuffer::DestroyVertexLayout: case CommandBuffer::DestroyVertexLayout:
{ {
BGFX_PROFILER_SCOPE("DestroyVertexLayout", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyVertexLayout", kColorResource);
VertexLayoutHandle handle; VertexLayoutHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3009,7 +3009,7 @@ namespace bgfx
case CommandBuffer::CreateVertexBuffer: case CommandBuffer::CreateVertexBuffer:
{ {
BGFX_PROFILER_SCOPE("CreateVertexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateVertexBuffer", kColorResource);
VertexBufferHandle handle; VertexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3031,7 +3031,7 @@ namespace bgfx
case CommandBuffer::DestroyVertexBuffer: case CommandBuffer::DestroyVertexBuffer:
{ {
BGFX_PROFILER_SCOPE("DestroyVertexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyVertexBuffer", kColorResource);
VertexBufferHandle handle; VertexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3042,7 +3042,7 @@ namespace bgfx
case CommandBuffer::CreateDynamicIndexBuffer: case CommandBuffer::CreateDynamicIndexBuffer:
{ {
BGFX_PROFILER_SCOPE("CreateDynamicIndexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateDynamicIndexBuffer", kColorResource);
IndexBufferHandle handle; IndexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3059,7 +3059,7 @@ namespace bgfx
case CommandBuffer::UpdateDynamicIndexBuffer: case CommandBuffer::UpdateDynamicIndexBuffer:
{ {
BGFX_PROFILER_SCOPE("UpdateDynamicIndexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("UpdateDynamicIndexBuffer", kColorResource);
IndexBufferHandle handle; IndexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3081,7 +3081,7 @@ namespace bgfx
case CommandBuffer::DestroyDynamicIndexBuffer: case CommandBuffer::DestroyDynamicIndexBuffer:
{ {
BGFX_PROFILER_SCOPE("DestroyDynamicIndexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyDynamicIndexBuffer", kColorResource);
IndexBufferHandle handle; IndexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3092,7 +3092,7 @@ namespace bgfx
case CommandBuffer::CreateDynamicVertexBuffer: case CommandBuffer::CreateDynamicVertexBuffer:
{ {
BGFX_PROFILER_SCOPE("CreateDynamicVertexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateDynamicVertexBuffer", kColorResource);
VertexBufferHandle handle; VertexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3109,7 +3109,7 @@ namespace bgfx
case CommandBuffer::UpdateDynamicVertexBuffer: case CommandBuffer::UpdateDynamicVertexBuffer:
{ {
BGFX_PROFILER_SCOPE("UpdateDynamicVertexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("UpdateDynamicVertexBuffer", kColorResource);
VertexBufferHandle handle; VertexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3131,7 +3131,7 @@ namespace bgfx
case CommandBuffer::DestroyDynamicVertexBuffer: case CommandBuffer::DestroyDynamicVertexBuffer:
{ {
BGFX_PROFILER_SCOPE("DestroyDynamicVertexBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyDynamicVertexBuffer", kColorResource);
VertexBufferHandle handle; VertexBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3142,7 +3142,7 @@ namespace bgfx
case CommandBuffer::CreateShader: case CommandBuffer::CreateShader:
{ {
BGFX_PROFILER_SCOPE("CreateShader", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateShader", kColorResource);
ShaderHandle handle; ShaderHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3158,7 +3158,7 @@ namespace bgfx
case CommandBuffer::DestroyShader: case CommandBuffer::DestroyShader:
{ {
BGFX_PROFILER_SCOPE("DestroyShader", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyShader", kColorResource);
ShaderHandle handle; ShaderHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3169,7 +3169,7 @@ namespace bgfx
case CommandBuffer::CreateProgram: case CommandBuffer::CreateProgram:
{ {
BGFX_PROFILER_SCOPE("CreateProgram", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateProgram", kColorResource);
ProgramHandle handle; ProgramHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3186,7 +3186,7 @@ namespace bgfx
case CommandBuffer::DestroyProgram: case CommandBuffer::DestroyProgram:
{ {
BGFX_PROFILER_SCOPE("DestroyProgram", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyProgram", kColorResource);
ProgramHandle handle; ProgramHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3197,7 +3197,7 @@ namespace bgfx
case CommandBuffer::CreateTexture: case CommandBuffer::CreateTexture:
{ {
BGFX_PROFILER_SCOPE("CreateTexture", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateTexture", kColorResource);
TextureHandle handle; TextureHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3240,7 +3240,7 @@ namespace bgfx
case CommandBuffer::UpdateTexture: case CommandBuffer::UpdateTexture:
{ {
BGFX_PROFILER_SCOPE("UpdateTexture", 0xff2040ff); BGFX_PROFILER_SCOPE("UpdateTexture", kColorResource);
if (m_textureUpdateBatch.isFull() ) if (m_textureUpdateBatch.isFull() )
{ {
@@ -3275,7 +3275,7 @@ namespace bgfx
case CommandBuffer::ReadTexture: case CommandBuffer::ReadTexture:
{ {
BGFX_PROFILER_SCOPE("ReadTexture", 0xff2040ff); BGFX_PROFILER_SCOPE("ReadTexture", kColorResource);
TextureHandle handle; TextureHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3292,7 +3292,7 @@ namespace bgfx
case CommandBuffer::ResizeTexture: case CommandBuffer::ResizeTexture:
{ {
BGFX_PROFILER_SCOPE("ResizeTexture", 0xff2040ff); BGFX_PROFILER_SCOPE("ResizeTexture", kColorResource);
TextureHandle handle; TextureHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3315,7 +3315,7 @@ namespace bgfx
case CommandBuffer::DestroyTexture: case CommandBuffer::DestroyTexture:
{ {
BGFX_PROFILER_SCOPE("DestroyTexture", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyTexture", kColorResource);
TextureHandle handle; TextureHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3326,7 +3326,7 @@ namespace bgfx
case CommandBuffer::CreateFrameBuffer: case CommandBuffer::CreateFrameBuffer:
{ {
BGFX_PROFILER_SCOPE("CreateFrameBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateFrameBuffer", kColorResource);
FrameBufferHandle handle; FrameBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3368,7 +3368,7 @@ namespace bgfx
case CommandBuffer::DestroyFrameBuffer: case CommandBuffer::DestroyFrameBuffer:
{ {
BGFX_PROFILER_SCOPE("DestroyFrameBuffer", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyFrameBuffer", kColorResource);
FrameBufferHandle handle; FrameBufferHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3379,7 +3379,7 @@ namespace bgfx
case CommandBuffer::CreateUniform: case CommandBuffer::CreateUniform:
{ {
BGFX_PROFILER_SCOPE("CreateUniform", 0xff2040ff); BGFX_PROFILER_SCOPE("CreateUniform", kColorResource);
UniformHandle handle; UniformHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3401,7 +3401,7 @@ namespace bgfx
case CommandBuffer::DestroyUniform: case CommandBuffer::DestroyUniform:
{ {
BGFX_PROFILER_SCOPE("DestroyUniform", 0xff2040ff); BGFX_PROFILER_SCOPE("DestroyUniform", kColorResource);
UniformHandle handle; UniformHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3412,7 +3412,7 @@ namespace bgfx
case CommandBuffer::UpdateViewName: case CommandBuffer::UpdateViewName:
{ {
BGFX_PROFILER_SCOPE("UpdateViewName", 0xff2040ff); BGFX_PROFILER_SCOPE("UpdateViewName", kColorResource);
ViewId id; ViewId id;
_cmdbuf.read(id); _cmdbuf.read(id);
@@ -3428,7 +3428,7 @@ namespace bgfx
case CommandBuffer::InvalidateOcclusionQuery: case CommandBuffer::InvalidateOcclusionQuery:
{ {
BGFX_PROFILER_SCOPE("InvalidateOcclusionQuery", 0xff2040ff); BGFX_PROFILER_SCOPE("InvalidateOcclusionQuery", kColorResource);
OcclusionQueryHandle handle; OcclusionQueryHandle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);
@@ -3439,7 +3439,7 @@ namespace bgfx
case CommandBuffer::SetName: case CommandBuffer::SetName:
{ {
BGFX_PROFILER_SCOPE("SetName", 0xff2040ff); BGFX_PROFILER_SCOPE("SetName", kColorResource);
Handle handle; Handle handle;
_cmdbuf.read(handle); _cmdbuf.read(handle);

View File

@@ -287,6 +287,25 @@ namespace bgfx
{ {
constexpr uint32_t kChunkMagicTex = BX_MAKEFOURCC('T', 'E', 'X', 0x0); constexpr uint32_t kChunkMagicTex = BX_MAKEFOURCC('T', 'E', 'X', 0x0);
inline constexpr uint32_t toAbgr8(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 0xff)
{
return 0
| (uint32_t(_r) << 24)
| (uint32_t(_g) << 16)
| (uint32_t(_b) << 8)
| (uint32_t(_a))
;
}
constexpr uint32_t kColorFrame = toAbgr8(0xa8, 0xe6, 0xcf);
constexpr uint32_t kColorSubmit = toAbgr8(0xdc, 0xed, 0xc1);
constexpr uint32_t kColorView = toAbgr8(0xff, 0xd3, 0xb6);
constexpr uint32_t kColorDraw = toAbgr8(0x76, 0xb4, 0xbd);
constexpr uint32_t kColorCompute = toAbgr8(0xbd, 0xea, 0xee);
constexpr uint32_t kColorResource = toAbgr8(0x88, 0x74, 0xa3);
constexpr uint32_t kColorMarker = toAbgr8(0xff, 0x00, 0x00);
constexpr uint32_t kColorWait = toAbgr8(0xff, 0x8b, 0x94);
extern InternalData g_internalData; extern InternalData g_internalData;
extern PlatformData g_platformData; extern PlatformData g_platformData;
extern bool g_platformDataChangedSinceReset; extern bool g_platformDataChangedSinceReset;
@@ -3616,7 +3635,7 @@ namespace bgfx
BX_TRACE("render thread exit"); BX_TRACE("render thread exit");
return bx::kExitSuccess; return bx::kExitSuccess;
} }
#endif #endif // BX_CONFIG_SUPPORTS_THREADING
// game thread // game thread
bool init(const Init& _init); bool init(const Init& _init);
@@ -5693,7 +5712,7 @@ namespace bgfx
return true; return true;
} }
BGFX_PROFILER_SCOPE("bgfx/API thread wait", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/API thread wait", kColorWait);
int64_t start = bx::getHPCounter(); int64_t start = bx::getHPCounter();
bool ok = m_apiSem.wait(_msecs); bool ok = m_apiSem.wait(_msecs);
if (ok) if (ok)
@@ -5718,7 +5737,7 @@ namespace bgfx
{ {
if (!m_singleThreaded) if (!m_singleThreaded)
{ {
BGFX_PROFILER_SCOPE("bgfx/Render thread wait", 0xff2040ff); BGFX_PROFILER_SCOPE("bgfx/Render thread wait", kColorWait);
int64_t start = bx::getHPCounter(); int64_t start = bx::getHPCounter();
bool ok = m_renderSem.wait(); bool ok = m_renderSem.wait();
BX_ASSERT(ok, "Semaphore wait failed."); BX_UNUSED(ok); BX_ASSERT(ok, "Semaphore wait failed."); BX_UNUSED(ok);

View File

@@ -10,23 +10,6 @@
namespace bgfx namespace bgfx
{ {
inline constexpr uint32_t toAbgr8(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 0xff)
{
return 0
| (uint32_t(_r)<<24)
| (uint32_t(_g)<<16)
| (uint32_t(_b)<< 8)
| (uint32_t(_a) )
;
}
constexpr uint32_t kColorFrame = toAbgr8(0xff, 0xd7, 0xc9);
constexpr uint32_t kColorView = toAbgr8(0xe4, 0xb4, 0x8e);
constexpr uint32_t kColorDraw = toAbgr8(0xc6, 0xe5, 0xb9);
constexpr uint32_t kColorCompute = toAbgr8(0xa7, 0xdb, 0xd8);
constexpr uint32_t kColorMarker = toAbgr8(0xff, 0x00, 0x00);
constexpr uint32_t kColorResource = toAbgr8(0xff, 0x40, 0x20);
struct BlitState struct BlitState
{ {
BlitState(const Frame* _frame) BlitState(const Frame* _frame)

View File

@@ -8195,7 +8195,7 @@ retry:
if (VK_NULL_HANDLE != m_backBufferFence[m_backBufferColorIdx]) if (VK_NULL_HANDLE != m_backBufferFence[m_backBufferColorIdx])
{ {
BGFX_PROFILER_SCOPE("vkWaitForFences", kColorFrame); BGFX_PROFILER_SCOPE("vkWaitForFences", kColorWait);
VK_CHECK(vkWaitForFences( VK_CHECK(vkWaitForFences(
device device
@@ -8659,7 +8659,7 @@ retry:
CommandList& commandList = m_commandList[m_currentFrameInFlight]; CommandList& commandList = m_commandList[m_currentFrameInFlight];
{ {
BGFX_PROFILER_SCOPE("vkWaitForFences", kColorFrame); BGFX_PROFILER_SCOPE("vkWaitForFences", kColorWait);
result = vkWaitForFences(device, 1, &commandList.m_fence, VK_TRUE, UINT64_MAX); result = vkWaitForFences(device, 1, &commandList.m_fence, VK_TRUE, UINT64_MAX);
} }
@@ -8764,7 +8764,8 @@ retry:
if (_wait) if (_wait)
{ {
BGFX_PROFILER_SCOPE("vkWaitForFences", kColorDraw); BGFX_PROFILER_SCOPE("vkWaitForFences", kColorWait);
VK_CHECK(vkWaitForFences(device, 1, &m_completedFence, VK_TRUE, UINT64_MAX) ); VK_CHECK(vkWaitForFences(device, 1, &m_completedFence, VK_TRUE, UINT64_MAX) );
} }