Added transient buffer stats.

This commit is contained in:
Branimir Karadžić 2018-04-18 16:35:57 -07:00
parent b0a2514913
commit 28e1839342
6 changed files with 32 additions and 9 deletions

View File

@ -601,6 +601,8 @@ namespace bgfx
struct Limits struct Limits
{ {
uint16_t maxEncoders; //!< Maximum number of encoder threads. uint16_t maxEncoders; //!< Maximum number of encoder threads.
uint32_t transientVbSize; //!<
uint32_t transientIbSize; //!<
}; };
Limits limits; Limits limits;
@ -689,6 +691,8 @@ namespace bgfx
uint32_t maxUniforms; //!< Maximum number of uniform handles. uint32_t maxUniforms; //!< Maximum number of uniform handles.
uint32_t maxOcclusionQueries; //!< Maximum number of occlusion query handles. uint32_t maxOcclusionQueries; //!< Maximum number of occlusion query handles.
uint32_t maxEncoders; //!< Maximum number of encoder threads. uint32_t maxEncoders; //!< Maximum number of encoder threads.
uint32_t transientVbSize; //!<
uint32_t transientIbSize; //!<
}; };
Limits limits; Limits limits;
@ -898,6 +902,8 @@ namespace bgfx
int64_t textureMemoryUsed; //!< int64_t textureMemoryUsed; //!<
int64_t rtMemoryUsed; //!< int64_t rtMemoryUsed; //!<
int32_t transientVbUsed; //!<
int32_t transientIbUsed; //!<
int64_t gpuMemoryMax; //!< Maximum available GPU memory for application. int64_t gpuMemoryMax; //!< Maximum available GPU memory for application.
int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application. int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application.

View File

@ -388,6 +388,8 @@ typedef struct bgfx_stats_s
int64_t textureMemoryUsed; int64_t textureMemoryUsed;
int64_t rtMemoryUsed; int64_t rtMemoryUsed;
int32_t transientVbUsed;
int32_t transientIbUsed;
int64_t gpuMemoryMax; int64_t gpuMemoryMax;
int64_t gpuMemoryUsed; int64_t gpuMemoryUsed;
@ -512,6 +514,8 @@ typedef struct bgfx_caps_limits_s
uint32_t maxUniforms; uint32_t maxUniforms;
uint32_t maxOcclusionQueries; uint32_t maxOcclusionQueries;
uint32_t maxEncoders; uint32_t maxEncoders;
uint32_t transientVbSize;
uint32_t transientIbSize;
} bgfx_caps_limits_t; } bgfx_caps_limits_t;
@ -600,6 +604,8 @@ typedef struct bgfx_resolution_s
typedef struct bgfx_init_limits_s typedef struct bgfx_init_limits_s
{ {
uint16_t maxEncoders; uint16_t maxEncoders;
uint32_t transientVbSize;
uint32_t transientIbSize;
} bgfx_init_limits_t; } bgfx_init_limits_t;

View File

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

View File

@ -1268,6 +1268,8 @@ namespace bgfx
LIMITS(maxUniforms); LIMITS(maxUniforms);
LIMITS(maxOcclusionQueries); LIMITS(maxOcclusionQueries);
LIMITS(maxEncoders); LIMITS(maxEncoders);
LIMITS(transientVbSize);
LIMITS(transientIbSize);
#undef LIMITS #undef LIMITS
BX_TRACE(""); BX_TRACE("");
@ -1508,14 +1510,14 @@ namespace bgfx
m_textVideoMemBlitter.init(); m_textVideoMemBlitter.init();
m_clearQuad.init(); m_clearQuad.init();
m_submit->m_transientVb = createTransientVertexBuffer(BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE); m_submit->m_transientVb = createTransientVertexBuffer(_init.limits.transientVbSize);
m_submit->m_transientIb = createTransientIndexBuffer(BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE); m_submit->m_transientIb = createTransientIndexBuffer(_init.limits.transientIbSize);
frame(); frame();
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) ) if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
{ {
m_submit->m_transientVb = createTransientVertexBuffer(BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE); m_submit->m_transientVb = createTransientVertexBuffer(_init.limits.transientVbSize);
m_submit->m_transientIb = createTransientIndexBuffer(BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE); m_submit->m_transientIb = createTransientIndexBuffer(_init.limits.transientIbSize);
frame(); frame();
} }
@ -2778,6 +2780,8 @@ namespace bgfx
, allocator(NULL) , allocator(NULL)
{ {
limits.maxEncoders = BGFX_CONFIG_DEFAULT_MAX_ENCODERS; limits.maxEncoders = BGFX_CONFIG_DEFAULT_MAX_ENCODERS;
limits.transientVbSize = BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE;
limits.transientIbSize = BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE;
} }
bool init(const Init& _init) bool init(const Init& _init)
@ -2855,6 +2859,8 @@ namespace bgfx
g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCLUSION_QUERIES; g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCLUSION_QUERIES;
g_caps.limits.maxFBAttachments = 1; g_caps.limits.maxFBAttachments = 1;
g_caps.limits.maxEncoders = (0 != BGFX_CONFIG_MULTITHREADED) ? _init.limits.maxEncoders : 1; g_caps.limits.maxEncoders = (0 != BGFX_CONFIG_MULTITHREADED) ? _init.limits.maxEncoders : 1;
g_caps.limits.transientVbSize = _init.limits.transientVbSize;
g_caps.limits.transientIbSize = _init.limits.transientIbSize;
g_caps.vendorId = _init.vendorId; g_caps.vendorId = _init.vendorId;
g_caps.deviceId = _init.deviceId; g_caps.deviceId = _init.deviceId;

View File

@ -1835,6 +1835,9 @@ namespace bgfx
void start() void start()
{ {
m_perfStats.transientVbUsed = m_vboffset;
m_perfStats.transientIbUsed = m_iboffset;
m_frameCache.reset(); m_frameCache.reset();
m_numRenderItems = 0; m_numRenderItems = 0;
m_numBlitItems = 0; m_numBlitItems = 0;
@ -1866,7 +1869,7 @@ namespace bgfx
{ {
uint32_t offset = bx::strideAlign(m_iboffset, sizeof(uint16_t) ); uint32_t offset = bx::strideAlign(m_iboffset, sizeof(uint16_t) );
uint32_t iboffset = offset + _num*sizeof(uint16_t); uint32_t iboffset = offset + _num*sizeof(uint16_t);
iboffset = bx::min<uint32_t>(iboffset, BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE); iboffset = bx::min<uint32_t>(iboffset, g_caps.limits.transientIbSize);
uint32_t num = (iboffset-offset)/sizeof(uint16_t); uint32_t num = (iboffset-offset)/sizeof(uint16_t);
return num; return num;
} }
@ -1885,7 +1888,7 @@ namespace bgfx
{ {
uint32_t offset = bx::strideAlign(m_vboffset, _stride); uint32_t offset = bx::strideAlign(m_vboffset, _stride);
uint32_t vboffset = offset + _num * _stride; uint32_t vboffset = offset + _num * _stride;
vboffset = bx::min<uint32_t>(vboffset, BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE); vboffset = bx::min<uint32_t>(vboffset, g_caps.limits.transientVbSize);
uint32_t num = (vboffset-offset)/_stride; uint32_t num = (vboffset-offset)/_stride;
return num; return num;
} }

View File

@ -236,6 +236,8 @@ struct View
, m_inLinear(false) , m_inLinear(false)
{ {
load(); load();
m_textureInfo.format = bgfx::TextureFormat::Count;
} }
~View() ~View()