Added primitive count to perf stats.

This commit is contained in:
Branimir Karadžić
2018-05-17 17:24:10 -07:00
parent 0e7aff8dce
commit 0e0da47e61
12 changed files with 120 additions and 110 deletions

View File

@@ -298,6 +298,24 @@ namespace bgfx
};
};
///
/// @attention C99 equivalent is `bgfx_topology_t`.
///
struct Topology
{
///
enum Enum
{
TriList, //!<
TriStrip, //!<
LineList, //!<
LineStrip, //!<
PointList, //!<
Count
};
};
/// Topology conversion function.
///
/// @attention C99 equivalent is `bgfx_topology_convert_t`.
@@ -871,53 +889,55 @@ namespace bgfx
/// time frequencies define timestamps-per-second for that hardware.
struct Stats
{
int64_t cpuTimeFrame; //!< CPU time between two `bgfx::frame` calls.
int64_t cpuTimeBegin; //!< Render thread CPU submit begin time.
int64_t cpuTimeEnd; //!< Render thread CPU submit end time.
int64_t cpuTimerFreq; //!< CPU timer frequency. Timestamps-per-second
int64_t cpuTimeFrame; //!< CPU time between two `bgfx::frame` calls.
int64_t cpuTimeBegin; //!< Render thread CPU submit begin time.
int64_t cpuTimeEnd; //!< Render thread CPU submit end time.
int64_t cpuTimerFreq; //!< CPU timer frequency. Timestamps-per-second
int64_t gpuTimeBegin; //!< GPU frame begin time.
int64_t gpuTimeEnd; //!< GPU frame end time.
int64_t gpuTimerFreq; //!< GPU timer frequency.
int64_t gpuTimeBegin; //!< GPU frame begin time.
int64_t gpuTimeEnd; //!< GPU frame end time.
int64_t gpuTimerFreq; //!< GPU timer frequency.
int64_t waitRender; //!< Time spent waiting for render backend thread to finish issuing
//! draw commands to underlying graphics API.
int64_t waitSubmit; //!< Time spent waiting for submit thread to advance to next frame.
int64_t waitRender; //!< Time spent waiting for render backend thread to finish issuing
//! draw commands to underlying graphics API.
int64_t waitSubmit; //!< Time spent waiting for submit thread to advance to next frame.
uint32_t numDraw; //!< Number of draw calls submitted.
uint32_t numCompute; //!< Number of compute calls submitted.
uint32_t maxGpuLatency; //!< GPU driver latency.
uint32_t numDraw; //!< Number of draw calls submitted.
uint32_t numCompute; //!< Number of compute calls submitted.
uint32_t maxGpuLatency; //!< GPU driver latency.
uint16_t numDynamicIndexBuffers; //!< Number of used dynamic index buffers.
uint16_t numDynamicVertexBuffers; //!< Number of used dynamic vertex buffers.
uint16_t numFrameBuffers; //!< Number of used frame buffers.
uint16_t numIndexBuffers; //!< Number of used index buffers.
uint16_t numOcclusionQueries; //!< Number of used occlusion queries.
uint16_t numPrograms; //!< Number of used programs.
uint16_t numShaders; //!< Number of used shaders.
uint16_t numTextures; //!< Number of used textures.
uint16_t numUniforms; //!< Number of used uniforms.
uint16_t numVertexBuffers; //!< Number of used vertex buffers.
uint16_t numVertexDecls; //!< Number of used vertex declarations.
uint16_t numDynamicIndexBuffers; //!< Number of used dynamic index buffers.
uint16_t numDynamicVertexBuffers; //!< Number of used dynamic vertex buffers.
uint16_t numFrameBuffers; //!< Number of used frame buffers.
uint16_t numIndexBuffers; //!< Number of used index buffers.
uint16_t numOcclusionQueries; //!< Number of used occlusion queries.
uint16_t numPrograms; //!< Number of used programs.
uint16_t numShaders; //!< Number of used shaders.
uint16_t numTextures; //!< Number of used textures.
uint16_t numUniforms; //!< Number of used uniforms.
uint16_t numVertexBuffers; //!< Number of used vertex buffers.
uint16_t numVertexDecls; //!< Number of used vertex declarations.
int64_t textureMemoryUsed; //!<
int64_t rtMemoryUsed; //!<
int32_t transientVbUsed; //!<
int32_t transientIbUsed; //!<
int64_t textureMemoryUsed; //!<
int64_t rtMemoryUsed; //!<
int32_t transientVbUsed; //!<
int32_t transientIbUsed; //!<
int64_t gpuMemoryMax; //!< Maximum available GPU memory for application.
int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application.
uint32_t numPrims[Topology::Count]; //!<
uint16_t width; //!< Backbuffer width in pixels.
uint16_t height; //!< Backbuffer height in pixels.
uint16_t textWidth; //!< Debug text width in characters.
uint16_t textHeight; //!< Debug text height in characters.
int64_t gpuMemoryMax; //!< Maximum available GPU memory for application.
int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application.
uint16_t numViews; //!< Number of view stats.
ViewStats* viewStats; //!< Array of View stats.
uint16_t width; //!< Backbuffer width in pixels.
uint16_t height; //!< Backbuffer height in pixels.
uint16_t textWidth; //!< Debug text width in characters.
uint16_t textHeight; //!< Debug text height in characters.
uint8_t numEncoders; //!< Number of encoders used during frame.
EncoderStats* encoderStats; //!< Array of encoder stats.
uint16_t numViews; //!< Number of view stats.
ViewStats* viewStats; //!< Array of View stats.
uint8_t numEncoders; //!< Number of encoders used during frame.
EncoderStats* encoderStats; //!< Array of encoder stats.
};
/// Encoders are used for submitting draw calls from multiple threads, so one encoder per thread.

View File

@@ -233,6 +233,18 @@ typedef enum bgfx_occlusion_query_result
} bgfx_occlusion_query_result_t;
typedef enum bgfx_topology
{
BGFX_TOPOLOGY_TRI_LIST,
BGFX_TOPOLOGY_TRI_STRIP,
BGFX_TOPOLOGY_LINE_LIST,
BGFX_TOPOLOGY_LINE_STRIP,
BGFX_TOPOLOGY_POINT_LIST,
BGFX_TOPOLOGY_COUNT
} bgfx_topology_t;
typedef enum bgfx_topology_convert
{
BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING,
@@ -391,6 +403,8 @@ typedef struct bgfx_stats_s
int32_t transientVbUsed;
int32_t transientIbUsed;
uint32_t numPrims[BGFX_TOPOLOGY_COUNT];
int64_t gpuMemoryMax;
int64_t gpuMemoryUsed;

View File

@@ -6,7 +6,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(67)
#define BGFX_API_VERSION UINT32_C(68)
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.

View File

@@ -1363,6 +1363,21 @@ namespace bgfx
return s_ctx->m_uniformRef[_handle.idx].m_name.getPtr();
}
static const char* s_topologyName[] =
{
"TriList",
"TriStrip",
"Line",
"LineStrip",
"Point",
};
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_topologyName) );
const char* getName(Topology::Enum _topology)
{
return s_topologyName[_topology];
}
static TextureFormat::Enum s_emulatedFormats[] =
{
TextureFormat::BC1,
@@ -4566,6 +4581,7 @@ BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT);
BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT);
#undef BGFX_C99_ENUM_CHECK

View File

@@ -462,6 +462,7 @@ namespace bgfx
TextureFormat::Enum getViableTextureFormat(const bimg::ImageContainer& _imageContainer);
const char* getName(TextureFormat::Enum _fmt);
const char* getName(UniformHandle _handle);
const char* getName(Topology::Enum _topology);
template<typename Ty>
inline void release(Ty)

View File

@@ -34,16 +34,7 @@ namespace bgfx { namespace d3d11
{ D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, 1, 1, 0 },
{ D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, 0, 0, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"LineStrip",
"Point",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_primInfo) == BX_COUNTOF(s_primName)+1);
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
union Zero
{
@@ -5638,7 +5629,7 @@ namespace bgfx { namespace d3d11
if (BGFX_CLEAR_NONE != (clr.m_flags & BGFX_CLEAR_MASK) )
{
clearQuad(_clearQuad, viewState.m_rect, clr, _render->m_colorPalette);
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update after clear quad.
prim = s_primInfo[Topology::Count]; // Force primitive type update after clear quad.
}
submitBlit(bs, view);
@@ -6384,6 +6375,7 @@ namespace bgfx { namespace d3d11
perfStats.numDraw = statsKeyType[0];
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
m_nvapi.getMemoryInfo(perfStats.gpuMemoryUsed, perfStats.gpuMemoryMax);
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
@@ -6469,10 +6461,10 @@ namespace bgfx { namespace d3d11
maxGpuLatency = 0;
maxGpuElapsed = 0.0;
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
for (uint32_t ii = 0; ii < Topology::Count; ++ii)
{
tvm.printf(10, pos++, 0x8b, " %10s: %7d (#inst: %5d), submitted: %7d, indirect %7d"
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -38,18 +38,11 @@ namespace bgfx { namespace d3d12
{ D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 3, 3, 0 },
{ D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 3, 1, 2 },
{ D3D_PRIMITIVE_TOPOLOGY_LINELIST, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, 2, 2, 0 },
{ D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, 2, 1, 1 },
{ D3D_PRIMITIVE_TOPOLOGY_POINTLIST, D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT, 1, 1, 0 },
{ D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED, 0, 0, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"Point",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_primInfo) == BX_COUNTOF(s_primName)+1);
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
static const uint32_t s_checkMsaa[] =
{
@@ -5708,7 +5701,7 @@ namespace bgfx { namespace d3d12
clearQuad(clearRect, clr, _render->m_colorPalette);
}
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update.
prim = s_primInfo[Topology::Count]; // Force primitive type update.
submitBlit(bs, view);
}
@@ -6356,6 +6349,7 @@ namespace bgfx { namespace d3d12
perfStats.numDraw = statsKeyType[0];
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
perfStats.gpuMemoryMax = -INT64_MAX;
perfStats.gpuMemoryUsed = -INT64_MAX;
@@ -6477,10 +6471,10 @@ namespace bgfx { namespace d3d12
, elapsedCpuMs
);
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
for (uint32_t ii = 0; ii < Topology::Count; ++ii)
{
tvm.printf(10, pos++, 0x8b, " %9s: %7d (#inst: %5d), submitted: %7d "
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -31,16 +31,7 @@ namespace bgfx { namespace d3d9
{ D3DPT_POINTLIST, 1, 1, 0 },
{ D3DPRIMITIVETYPE(0), 0, 0, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"LineStrip",
"Point",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_primInfo) == BX_COUNTOF(s_primName)+1);
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
static const D3DMULTISAMPLE_TYPE s_checkMsaa[] =
{
@@ -4390,6 +4381,7 @@ namespace bgfx { namespace d3d9
perfStats.numDraw = statsKeyType[0];
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
m_nvapi.getMemoryInfo(perfStats.gpuMemoryUsed, perfStats.gpuMemoryMax);
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
@@ -4451,10 +4443,10 @@ namespace bgfx { namespace d3d9
maxGpuLatency = 0;
maxGpuElapsed = 0.0;
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
for (uint32_t ii = 0; ii < Topology::Count; ++ii)
{
tvm.printf(10, pos++, 0x8b, " %10s: %7d (#inst: %5d), submitted: %7d"
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -30,16 +30,9 @@ namespace bgfx { namespace gl
{ GL_LINES, 2, 2, 0 },
{ GL_LINE_STRIP, 2, 1, 1 },
{ GL_POINTS, 1, 1, 0 },
{ GL_ZERO, 0, 0, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"LineStrip",
"Point",
};
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
static const char* s_attribName[] =
{
@@ -7702,6 +7695,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
perfStats.numDraw = statsKeyType[0];
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
perfStats.gpuMemoryMax = -INT64_MAX;
perfStats.gpuMemoryUsed = -INT64_MAX;
@@ -7769,7 +7763,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primInfo); ++ii)
{
tvm.printf(10, pos++, 0x8b, " %10s: %7d (#inst: %5d), submitted: %7d "
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -76,16 +76,7 @@ namespace bgfx { namespace mtl
{ MTLPrimitiveTypeLineStrip, 2, 1, 1 },
{ MTLPrimitiveTypePoint, 1, 1, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"LineStrip",
"Point",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_primInfo) == BX_COUNTOF(s_primName) );
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo) );
static const char* s_attribName[] =
{
@@ -4061,6 +4052,7 @@ namespace bgfx { namespace mtl
perfStats.numDraw = statsKeyType[0];
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
perfStats.gpuMemoryMax = -INT64_MAX;
perfStats.gpuMemoryUsed = -INT64_MAX;
@@ -4116,10 +4108,10 @@ namespace bgfx { namespace mtl
maxGpuLatency = 0;
maxGpuElapsed = 0.0;
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
for (uint32_t ii = 0; ii < Topology::Count; ++ii)
{
tvm.printf(10, pos++, 0x8b, " %10s: %7d (#inst: %5d), submitted: %7d"
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -25,18 +25,11 @@ namespace bgfx { namespace vk
{ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 3, 3, 0 },
{ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, 3, 1, 2 },
{ VK_PRIMITIVE_TOPOLOGY_LINE_LIST, 2, 2, 0 },
{ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, 2, 1, 1 },
{ VK_PRIMITIVE_TOPOLOGY_POINT_LIST, 1, 1, 0 },
{ VK_PRIMITIVE_TOPOLOGY_MAX_ENUM, 0, 0, 0 },
};
static const char* s_primName[] =
{
"TriList",
"TriStrip",
"Line",
"Point",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_primInfo) == BX_COUNTOF(s_primName)+1);
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
static const uint32_t s_checkMsaa[] =
{
@@ -3833,7 +3826,7 @@ BX_UNUSED(currentSamplerStateIdx);
clearQuad(clearRect, clr, _render->m_colorPalette);
}
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update.
prim = s_primInfo[Topology::Count]; // Force primitive type update.
submitBlit(bs, view);
}
@@ -4399,6 +4392,7 @@ BX_UNUSED(presentMin, presentMax);
// perfStats.numDraw = statsKeyType[0];
// perfStats.numCompute = statsKeyType[1];
// perfStats.maxGpuLatency = maxGpuLatency;
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
perfStats.gpuMemoryMax = -INT64_MAX;
perfStats.gpuMemoryUsed = -INT64_MAX;
@@ -4504,10 +4498,10 @@ BX_UNUSED(presentMin, presentMax);
, elapsedCpuMs
);
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
for (uint32_t ii = 0; ii < Topology::Count; ++ii)
{
tvm.printf(10, pos++, 0x8b, " %9s: %7d (#inst: %5d), submitted: %7d "
, s_primName[ii]
, getName(Topology::Enum(ii) )
, statsNumPrimsRendered[ii]
, statsNumInstances[ii]
, statsNumPrimsSubmitted[ii]

View File

@@ -1277,6 +1277,7 @@ int _main_(int _argc, char** _argv)
auto anyActive = [&]() -> bool
{
return false
|| ImGui::MouseOverArea()
|| menuFade.isActive()
|| mip.isActive()
|| layer.isActive()