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

@ -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();
}

View file

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

View file

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