diff --git a/include/bgfx.h b/include/bgfx.h index 77b551f1..7462fc22 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -1064,6 +1064,14 @@ namespace bgfx /// @remarks /// This is debug only feature. /// + /// In graphics debugger view name will appear as: + /// + /// "nnnce " + /// ^ ^^ ^ + /// | |+-- eye (L/R) + /// | +-- compute (C) + /// +-- view id + /// void setViewName(uint8_t _id, const char* _name); /// Set view rectangle. Draw primitive outside view will be clipped. diff --git a/src/config.h b/src/config.h index 07fde558..791f39a7 100644 --- a/src/config.h +++ b/src/config.h @@ -180,7 +180,7 @@ # define BGFX_CONFIG_MAX_VIEWS 256 #endif // BGFX_CONFIG_MAX_VIEWS -#define BGFX_CONFIG_MAX_VIEW_NAME_RESERVED 5 +#define BGFX_CONFIG_MAX_VIEW_NAME_RESERVED 6 #ifndef BGFX_CONFIG_MAX_VIEW_NAME # define BGFX_CONFIG_MAX_VIEW_NAME 256 diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index c208773d..01aaab31 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -796,7 +796,7 @@ namespace bgfx { namespace d3d11 for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { char name[BGFX_CONFIG_MAX_VIEW_NAME_RESERVED+1]; - bx::snprintf(name, sizeof(name), "%3d ", ii); + bx::snprintf(name, sizeof(name), "%3d ", ii); mbstowcs(s_viewNameW[ii], name, BGFX_CONFIG_MAX_VIEW_NAME_RESERVED); } @@ -1073,10 +1073,13 @@ namespace bgfx { namespace d3d11 void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE { - mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] - , _name - , BX_COUNTOF(s_viewNameW[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED - ); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] + , _name + , BX_COUNTOF(s_viewNameW[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED + ); + } } void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) BX_OVERRIDE @@ -3217,18 +3220,26 @@ namespace bgfx { namespace d3d11 viewState.m_rect = _render->m_rect[view]; if (viewRestart) { - wchar_t* viewNameW = s_viewNameW[view]; - viewNameW[3] = eye ? L'R' : L'L'; - PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + wchar_t* viewNameW = s_viewNameW[view]; + viewNameW[3] = L' '; + viewNameW[4] = eye ? L'R' : L'L'; + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + } viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2; viewState.m_rect.m_width /= 2; } else { - wchar_t* viewNameW = s_viewNameW[view]; - viewNameW[3] = L' '; - PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + wchar_t* viewNameW = s_viewNameW[view]; + viewNameW[3] = L' '; + viewNameW[4] = L' '; + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + } } const Rect& scissorRect = _render->m_scissor[view]; @@ -3258,6 +3269,14 @@ namespace bgfx { namespace d3d11 { wasCompute = true; + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + wchar_t* viewNameW = s_viewNameW[view]; + viewNameW[3] = L'C'; + PIX_ENDEVENT(); + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + } + deviceCtx->IASetVertexBuffers(0, 2, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero); deviceCtx->IASetIndexBuffer(NULL, DXGI_FORMAT_R16_UINT, 0); @@ -3376,6 +3395,14 @@ namespace bgfx { namespace d3d11 if (wasCompute) { + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + wchar_t* viewNameW = s_viewNameW[view]; + viewNameW[3] = L' '; + PIX_ENDEVENT(); + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + } + wasCompute = false; programIdx = invalidHandle; @@ -3722,6 +3749,14 @@ namespace bgfx { namespace d3d11 if (wasCompute) { + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + wchar_t* viewNameW = s_viewNameW[view]; + viewNameW[3] = L'C'; + PIX_ENDEVENT(); + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW); + } + invalidateCompute(); } diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index c497ac7f..022fbd9e 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -598,7 +598,7 @@ namespace bgfx { namespace d3d9 for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { char name[BGFX_CONFIG_MAX_VIEW_NAME_RESERVED+1]; - bx::snprintf(name, sizeof(name), "%3d ", ii); + bx::snprintf(name, sizeof(name), "%3d ", ii); mbstowcs(s_viewNameW[ii], name, BGFX_CONFIG_MAX_VIEW_NAME_RESERVED); } @@ -874,10 +874,13 @@ namespace bgfx { namespace d3d9 void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE { - mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] - , _name - , BX_COUNTOF(s_viewNameW[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED - ); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + mbstowcs(&s_viewNameW[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] + , _name + , BX_COUNTOF(s_viewNameW[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED + ); + } } void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) BX_OVERRIDE diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index c35e9c5a..84bd844e 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1540,7 +1540,7 @@ namespace bgfx { namespace gl // Init reserved part of view name. for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { - bx::snprintf(s_viewName[ii], BGFX_CONFIG_MAX_VIEW_NAME_RESERVED+1, "%3d ", ii); + bx::snprintf(s_viewName[ii], BGFX_CONFIG_MAX_VIEW_NAME_RESERVED+1, "%3d ", ii); } ovrPostReset(); @@ -1795,10 +1795,13 @@ namespace bgfx { namespace gl void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE { - bx::strlcpy(&s_viewName[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] - , _name - , BX_COUNTOF(s_viewName[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED - ); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + bx::strlcpy(&s_viewName[_id][BGFX_CONFIG_MAX_VIEW_NAME_RESERVED] + , _name + , BX_COUNTOF(s_viewName[0])-BGFX_CONFIG_MAX_VIEW_NAME_RESERVED + ); + } } void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) BX_OVERRIDE @@ -4508,6 +4511,7 @@ namespace bgfx { namespace gl uint32_t baseVertex = 0; GLuint currentVao = 0; + bool wasCompute = false; bool viewHasScissor = false; Rect viewScissorRect; viewScissorRect.clear(); @@ -4592,18 +4596,26 @@ namespace bgfx { namespace gl viewState.m_rect = _render->m_rect[view]; if (viewRestart) { - char* viewName = s_viewName[view]; - viewName[3] = eye ? 'R' : 'L'; - GL_CHECK(glInsertEventMarker(0, viewName) ); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + char* viewName = s_viewName[view]; + viewName[3] = ' '; + viewName[4] = eye ? 'R' : 'L'; + GL_CHECK(glInsertEventMarker(0, viewName) ); + } viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2; viewState.m_rect.m_width /= 2; } else { - char* viewName = s_viewName[view]; - viewName[3] = ' '; - GL_CHECK(glInsertEventMarker(0, viewName) ); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + char* viewName = s_viewName[view]; + viewName[3] = ' '; + viewName[4] = ' '; + GL_CHECK(glInsertEventMarker(0, viewName) ); + } } const Rect& scissorRect = _render->m_scissor[view]; @@ -4633,6 +4645,18 @@ namespace bgfx { namespace gl if (isCompute) { + if (!wasCompute) + { + wasCompute = true; + + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + char* viewName = s_viewName[view]; + viewName[3] = 'C'; + GL_CHECK(glInsertEventMarker(0, viewName) ); + } + } + if (computeSupported) { const RenderCompute& compute = renderItem.compute; @@ -4703,6 +4727,18 @@ namespace bgfx { namespace gl continue; } + if (wasCompute) + { + wasCompute = false; + + if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) ) + { + char* viewName = s_viewName[view]; + viewName[3] = ' '; + GL_CHECK(glInsertEventMarker(0, viewName) ); + } + } + const RenderDraw& draw = renderItem.draw; const uint64_t newFlags = draw.m_flags;