From a05acba1ee56a57624e5b3ec31464be8de7fe6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 5 Oct 2014 00:14:21 -0700 Subject: [PATCH] Added state cache info to debug panel. --- src/renderer_d3d11.cpp | 17 +++++++++++++++-- src/renderer_d3d11.h | 5 +++++ src/renderer_d3d9.cpp | 3 ++- src/renderer_gl.cpp | 18 +++++++++++++++--- src/renderer_gl.h | 10 ++++++++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 0179d8b1..ca4164b0 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -31,7 +31,7 @@ namespace bgfx { D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, 3, 1, 2 }, { D3D11_PRIMITIVE_TOPOLOGY_LINELIST, 2, 2, 0 }, { D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, 1, 1, 0 }, - { D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED, 0, 0, 0 }, + { D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, 0, 0, 0 }, }; static const char* s_primName[] = @@ -267,7 +267,7 @@ namespace bgfx }; BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attrib) ); - static const DXGI_FORMAT s_attribType[AttribType::Count][4][2] = + static const DXGI_FORMAT s_attribType[][4][2] = { { { DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UNORM }, @@ -294,6 +294,7 @@ namespace bgfx { DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT }, }, }; + BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); static D3D11_INPUT_ELEMENT_DESC* fillVertexDecl(D3D11_INPUT_ELEMENT_DESC* _out, const VertexDecl& _decl) { @@ -3545,6 +3546,18 @@ RENDERDOC_IMPORT tvm.printf(10, pos++, 0x8e, " DVB size: %7d", _render->m_vboffset); tvm.printf(10, pos++, 0x8e, " DIB size: %7d", _render->m_iboffset); + pos++; + tvm.printf(10, pos++, 0x8e, " State cache: "); + tvm.printf(10, pos++, 0x8e, " Blend | DepthS | Input | Raster | Sampler "); + tvm.printf(10, pos++, 0x8e, " %6d | %6d | %6d | %6d | %6d " + , m_blendStateCache.getCount() + , m_depthStencilStateCache.getCount() + , m_inputLayoutCache.getCount() + , m_rasterizerStateCache.getCount() + , m_samplerStateCache.getCount() + ); + pos++; + double captureMs = double(captureElapsed)*toMs; tvm.printf(10, pos++, 0x8e, " Capture: %3.4f [ms]", captureMs); diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index 97830956..d51ed7ef 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -75,6 +75,11 @@ namespace bgfx m_hashMap.clear(); } + uint32_t getCount() const + { + return uint32_t(m_hashMap.size() ); + } + private: typedef stl::unordered_map HashMap; HashMap m_hashMap; diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index ada4a3ac..bed15596 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1801,7 +1801,7 @@ namespace bgfx }; BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attrib)-1); - static const D3DDECLTYPE s_attribType[AttribType::Count][4][2] = + static const D3DDECLTYPE s_attribType[][4][2] = { { { D3DDECLTYPE_UBYTE4, D3DDECLTYPE_UBYTE4N }, @@ -1828,6 +1828,7 @@ namespace bgfx { D3DDECLTYPE_FLOAT4, D3DDECLTYPE_FLOAT4 }, }, }; + BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); static D3DVERTEXELEMENT9* fillVertexDecl(D3DVERTEXELEMENT9* _out, const VertexDecl& _decl) { diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index a82003a5..895c86b8 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -59,7 +59,7 @@ namespace bgfx }; BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attribName) ); - static const char* s_instanceDataName[BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT] = + static const char* s_instanceDataName[] = { "i_data0", "i_data1", @@ -67,21 +67,24 @@ namespace bgfx "i_data3", "i_data4", }; + BX_STATIC_ASSERT(BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT == BX_COUNTOF(s_instanceDataName) ); - static const GLenum s_access[Access::Count] = + static const GLenum s_access[] = { GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE, }; + BX_STATIC_ASSERT(Access::Count == BX_COUNTOF(s_access) ); - static const GLenum s_attribType[AttribType::Count] = + static const GLenum s_attribType[] = { GL_UNSIGNED_BYTE, GL_SHORT, GL_HALF_FLOAT, GL_FLOAT, }; + BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) ); struct Blend { @@ -4904,6 +4907,15 @@ namespace bgfx tvm.printf(10, pos++, 0x8e, " DVB size: %7d", _render->m_vboffset); tvm.printf(10, pos++, 0x8e, " DIB size: %7d", _render->m_iboffset); + pos++; + tvm.printf(10, pos++, 0x8e, " State cache: "); + tvm.printf(10, pos++, 0x8e, " VAO | Sampler "); + tvm.printf(10, pos++, 0x8e, " %6d | %6d " + , m_vaoStateCache.getCount() + , m_samplerStateCache.getCount() + ); + pos++; + double captureMs = double(captureElapsed)*toMs; tvm.printf(10, pos++, 0x8e, " Capture: %3.4f [ms]", captureMs); diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 3ae71ef6..5fd31f16 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -599,6 +599,11 @@ namespace bgfx m_hashMap.clear(); } + uint32_t getCount() const + { + return uint32_t(m_hashMap.size() ); + } + private: typedef stl::unordered_map HashMap; HashMap m_hashMap; @@ -671,6 +676,11 @@ namespace bgfx m_hashMap.clear(); } + uint32_t getCount() const + { + return uint32_t(m_hashMap.size() ); + } + private: typedef stl::unordered_map HashMap; HashMap m_hashMap;