diff --git a/examples/common/aviwriter.h b/examples/common/aviwriter.h index 6095b3c1..199e1800 100644 --- a/examples/common/aviwriter.h +++ b/examples/common/aviwriter.h @@ -91,8 +91,8 @@ struct AviWriter bx::write(&m_writer, UINT16_C(0) ); // wPriority bx::write(&m_writer, UINT16_C(0) ); // wLanguage bx::write(&m_writer, UINT32_C(0) ); // dwInitialFrames - bx::write(&m_writer, UINT32_C(1000) ); // dwScale - bx::write(&m_writer, 1000*_fps); // dwRate + bx::write(&m_writer, UINT32_C(1) ); // dwScale + bx::write(&m_writer, _fps); // dwRate bx::write(&m_writer, UINT32_C(0) ); // dwStart m_lengthOffset = m_writer.seek(); @@ -137,19 +137,24 @@ struct AviWriter { int64_t pos = m_writer.seek(); m_writer.seek(m_moviListOffset, bx::Whence::Begin); - bx::write(&m_writer, uint32_t(pos-m_moviListOffset+4) ); + bx::write(&m_writer, uint32_t(pos-m_moviListOffset-4) ); m_writer.seek(pos, bx::Whence::Begin); bx::write(&m_writer, BX_MAKEFOURCC('i', 'd', 'x', '1') ); - bx::write(&m_writer, UINT32_C(16) ); - bx::write(&m_writer, BX_MAKEFOURCC('0', '0', 'd', 'b') ); - bx::write(&m_writer, UINT32_C(16) ); - bx::write(&m_writer, UINT32_C(4) ); - bx::write(&m_writer, m_frameSize); + bx::write(&m_writer, m_numFrames*16); + + for (uint32_t ii = 0, offset = 4; ii < m_numFrames; ++ii) + { + bx::write(&m_writer, BX_MAKEFOURCC('0', '0', 'd', 'b') ); + bx::write(&m_writer, UINT32_C(16) ); + bx::write(&m_writer, offset); + bx::write(&m_writer, m_frameSize); + offset += m_frameSize + 8; + } pos = m_writer.seek(); m_writer.seek(m_riffSizeOffset, bx::Whence::Begin); - bx::write(&m_writer, uint32_t(pos-m_riffSizeOffset+4) ); + bx::write(&m_writer, uint32_t(pos-m_riffSizeOffset-4) ); m_writer.seek(m_totalFramesOffset, bx::Whence::Begin); bx::write(&m_writer, m_numFrames); diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 576430da..d21e2c1b 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1924,6 +1924,9 @@ namespace bgfx s_renderCtx.updateResolution(m_render->m_resolution); + int64_t elapsed = -bx::getHPCounter(); + int64_t captureElapsed = 0; + if (0 < m_render->m_iboffset) { TransientIndexBuffer* ib = m_render->m_transientIb; @@ -1966,8 +1969,6 @@ namespace bgfx uint32_t statsNumInstances = 0; uint32_t statsNumPrimsRendered = 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) @@ -2380,6 +2381,13 @@ namespace bgfx statsNumPrimsRendered += numPrimsRendered; } } + + if (0 < m_render->m_num) + { + captureElapsed = -bx::getHPCounter(); + s_renderCtx.capture(); + captureElapsed += bx::getHPCounter(); + } } int64_t now = bx::getHPCounter(); @@ -2407,7 +2415,6 @@ 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; @@ -2418,6 +2425,8 @@ namespace bgfx , double(max)*toMs , freq/frameTime ); + + double elapsedCpuMs = double(elapsed)*toMs; tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms]" , m_render->m_num , elapsedCpuMs @@ -2427,6 +2436,9 @@ namespace bgfx , statsNumInstances , statsNumPrimsSubmitted ); + + double captureMs = double(captureElapsed)*toMs; + tvm.printf(10, pos++, 0x8e, " Capture: %3.4f [ms]", captureMs); tvm.printf(10, pos++, 0x8e, " Indices: %7d", statsNumIndices); tvm.printf(10, pos++, 0x8e, " DVB size: %7d", m_render->m_vboffset); tvm.printf(10, pos++, 0x8e, " DIB size: %7d", m_render->m_iboffset); diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 4ad3ba11..adce237c 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1997,6 +1997,9 @@ namespace bgfx s_renderCtx.updateResolution(m_render->m_resolution); + int64_t elapsed = -bx::getHPCounter(); + int64_t captureElapsed = 0; + device->BeginScene(); if (0 < m_render->m_iboffset) @@ -2038,8 +2041,6 @@ namespace bgfx uint32_t statsNumInstances = 0; uint32_t statsNumPrimsRendered = 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) @@ -2586,15 +2587,18 @@ namespace bgfx } PIX_ENDEVENT(); + + if (0 < m_render->m_num) + { + captureElapsed = -bx::getHPCounter(); + s_renderCtx.capture(); + captureElapsed += bx::getHPCounter(); + } } int64_t now = bx::getHPCounter(); elapsed += now; - int64_t captureElapsed = -bx::getHPCounter(); - s_renderCtx.capture(); - captureElapsed += bx::getHPCounter(); - static int64_t last = now; int64_t frameTime = now - last; last = now; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 56ab4ffb..2ba3912d 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2352,6 +2352,8 @@ namespace bgfx s_renderCtx.updateResolution(m_render->m_resolution); int64_t elapsed = -bx::getHPCounter(); + int64_t captureElapsed = 0; + #if BGFX_CONFIG_RENDERER_OPENGL if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) { @@ -2972,15 +2974,18 @@ namespace bgfx } } } + + if (0 < m_render->m_num) + { + captureElapsed = -bx::getHPCounter(); + s_renderCtx.capture(); + captureElapsed += bx::getHPCounter(); + } } int64_t now = bx::getHPCounter(); elapsed += now; - int64_t captureElapsed = -bx::getHPCounter(); - s_renderCtx.capture(); - captureElapsed += bx::getHPCounter(); - static int64_t last = now; int64_t frameTime = now - last; last = now;