mirror of https://github.com/bkaradzic/bgfx
Fixed texture flags shifts. Added GL GPU timing.
This commit is contained in:
parent
2a918ab4e0
commit
2b607e0f8f
|
@ -112,16 +112,16 @@ namespace bgfx
|
|||
#define BGFX_TEXTURE_W_REPEAT UINT32_C(0x00000000)
|
||||
#define BGFX_TEXTURE_W_MIRROR UINT32_C(0x00000100)
|
||||
#define BGFX_TEXTURE_W_CLAMP UINT32_C(0x00000200)
|
||||
#define BGFX_TEXTURE_W_SHIFT 4
|
||||
#define BGFX_TEXTURE_W_SHIFT 8
|
||||
#define BGFX_TEXTURE_W_MASK UINT32_C(0x00000300)
|
||||
#define BGFX_TEXTURE_MIN_POINT UINT32_C(0x00001000)
|
||||
#define BGFX_TEXTURE_MIN_SHIFT 8
|
||||
#define BGFX_TEXTURE_MIN_SHIFT 12
|
||||
#define BGFX_TEXTURE_MIN_MASK UINT32_C(0x00001000)
|
||||
#define BGFX_TEXTURE_MAG_POINT UINT32_C(0x00010000)
|
||||
#define BGFX_TEXTURE_MAG_SHIFT 12
|
||||
#define BGFX_TEXTURE_MAG_SHIFT 16
|
||||
#define BGFX_TEXTURE_MAG_MASK UINT32_C(0x00010000)
|
||||
#define BGFX_TEXTURE_MIP_POINT UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_MIP_SHIFT 16
|
||||
#define BGFX_TEXTURE_MIP_SHIFT 20
|
||||
#define BGFX_TEXTURE_MIP_MASK UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_SRGB UINT32_C(0x00200000)
|
||||
|
||||
|
|
|
@ -406,10 +406,17 @@ namespace bgfx
|
|||
void init()
|
||||
{
|
||||
setRenderContextSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
m_queries.create();
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
m_queries.destroy();
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
#if BGFX_USE_WGL
|
||||
if (NULL != m_hdc)
|
||||
{
|
||||
|
@ -438,6 +445,9 @@ namespace bgfx
|
|||
RenderTarget m_renderTargets[BGFX_CONFIG_MAX_RENDER_TARGETS];
|
||||
UniformRegistry m_uniformReg;
|
||||
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
Queries m_queries;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
TextVideoMem m_textVideoMem;
|
||||
|
||||
|
@ -1841,6 +1851,14 @@ namespace bgfx
|
|||
{
|
||||
s_renderCtx.updateResolution(m_render->m_resolution);
|
||||
|
||||
int64_t elapsed = -bx::getHPCounter();
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
|
||||
{
|
||||
s_renderCtx.m_queries.begin(0, GL_TIME_ELAPSED);
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
if (0 < m_render->m_iboffset)
|
||||
{
|
||||
TransientIndexBuffer* ib = m_render->m_transientIb;
|
||||
|
@ -1880,8 +1898,6 @@ namespace bgfx
|
|||
uint32_t statsNumPrims = 0;
|
||||
uint32_t statsNumIndices = 0;
|
||||
|
||||
int64_t elapsed = -bx::getHPCounter();
|
||||
|
||||
if (0 == (m_render->m_debug&BGFX_DEBUG_IFH) )
|
||||
{
|
||||
for (uint32_t item = 0, numItems = m_render->m_num; item < numItems; ++item)
|
||||
|
@ -2373,6 +2389,13 @@ namespace bgfx
|
|||
|
||||
if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
|
||||
{
|
||||
double elapsedGpuMs = 0.0;
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
s_renderCtx.m_queries.end(GL_TIME_ELAPSED);
|
||||
uint64_t elapsedGl = s_renderCtx.m_queries.getResult(0);
|
||||
elapsedGpuMs = double(elapsedGl)/1e6;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
TextVideoMem& tvm = s_renderCtx.m_textVideoMem;
|
||||
|
||||
static int64_t next = now;
|
||||
|
@ -2382,11 +2405,17 @@ namespace bgfx
|
|||
next = now + bx::getHPFrequency();
|
||||
double freq = double(bx::getHPFrequency() );
|
||||
double toMs = 1000.0/freq;
|
||||
double elapsedCpuMs = double(elapsed)*toMs;
|
||||
|
||||
tvm.clear();
|
||||
uint16_t pos = 10;
|
||||
tvm.printf(10, pos++, 0x8e, " Frame: %3.4f [ms] / %3.2f", double(frameTime)*toMs, freq/frameTime);
|
||||
tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / %3.4f [ms]", m_render->m_num, double(elapsed)*toMs);
|
||||
tvm.printf(10, pos++, 0x8e, " Frame CPU: %3.4f [ms] / %3.2f", double(frameTime)*toMs, freq/frameTime);
|
||||
tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms] %c GPU %3.4f [ms]"
|
||||
, m_render->m_num
|
||||
, elapsedCpuMs
|
||||
, elapsedCpuMs > elapsedGpuMs ? '>' : '<'
|
||||
, elapsedGpuMs
|
||||
);
|
||||
tvm.printf(10, pos++, 0x8e, " Prims: %7d", statsNumPrims);
|
||||
tvm.printf(10, pos++, 0x8e, " Indices: %7d", statsNumIndices);
|
||||
tvm.printf(10, pos++, 0x8e, " DVB size: %7d", m_render->m_vboffset);
|
||||
|
|
|
@ -350,6 +350,40 @@ namespace bgfx
|
|||
uint8_t m_numPredefined;
|
||||
};
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
struct Queries
|
||||
{
|
||||
void create()
|
||||
{
|
||||
glGenQueries(countof(m_queries), m_queries);
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
glDeleteQueries(countof(m_queries), m_queries);
|
||||
}
|
||||
|
||||
void begin(uint16_t _id, GLenum _target) const
|
||||
{
|
||||
glBeginQuery(_target, m_queries[_id]);
|
||||
}
|
||||
|
||||
void end(GLenum _target) const
|
||||
{
|
||||
glEndQuery(_target);
|
||||
}
|
||||
|
||||
uint64_t getResult(uint16_t _id) const
|
||||
{
|
||||
uint64_t result;
|
||||
glGetQueryObjectui64v(m_queries[_id], GL_QUERY_RESULT, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
GLuint m_queries[64];
|
||||
};
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
} // namespace bgfx
|
||||
|
||||
#endif // __RENDERER_GL_H__
|
||||
|
|
Loading…
Reference in New Issue