Added view name flag for compute.

This commit is contained in:
Branimir Karadžić 2015-04-02 11:57:53 -07:00
parent 85bf5493c3
commit 5a9b02ca31
5 changed files with 110 additions and 28 deletions

View file

@ -1064,6 +1064,14 @@ namespace bgfx
/// @remarks
/// This is debug only feature.
///
/// In graphics debugger view name will appear as:
///
/// "nnnce <view name>"
/// ^ ^^ ^
/// | |+-- 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.

View file

@ -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

View file

@ -1072,12 +1072,15 @@ namespace bgfx { namespace d3d11
}
void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE
{
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
{
@ -3216,20 +3219,28 @@ namespace bgfx { namespace d3d11
viewState.m_rect = _render->m_rect[view];
if (viewRestart)
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
{
wchar_t* viewNameW = s_viewNameW[view];
viewNameW[3] = eye ? L'R' : L'L';
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
{
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];
viewHasScissor = !scissorRect.isZero();
@ -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();
}

View file

@ -873,12 +873,15 @@ namespace bgfx { namespace d3d9
}
void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE
{
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
{

View file

@ -1794,12 +1794,15 @@ namespace bgfx { namespace gl
}
void updateViewName(uint8_t _id, const char* _name) BX_OVERRIDE
{
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();
@ -4591,20 +4595,28 @@ namespace bgfx { namespace gl
viewState.m_rect = _render->m_rect[view];
if (viewRestart)
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
{
char* viewName = s_viewName[view];
viewName[3] = eye ? 'R' : 'L';
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
{
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];
viewHasScissor = !scissorRect.isZero();
@ -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;