Added flush after render reset flag.

This commit is contained in:
Branimir Karadžić 2015-05-15 13:14:35 -07:00
parent 4422e7227a
commit 2a49e5a143
6 changed files with 36 additions and 10 deletions

View file

@ -124,6 +124,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|| setOrToggle(s_reset, "hmddbg", BGFX_RESET_HMD_DEBUG, 1, _argc, _argv)
|| setOrToggle(s_reset, "hmdrecenter", BGFX_RESET_HMD_RECENTER, 1, _argc, _argv)
|| setOrToggle(s_reset, "msaa", BGFX_RESET_MSAA_X16, 1, _argc, _argv)
|| setOrToggle(s_reset, "flush", BGFX_RESET_FLUSH_AFTER_RENDER, 1, _argc, _argv)
|| setOrToggle(s_reset, "flip", BGFX_RESET_FLIP_AFTER_RENDER, 1, _argc, _argv)
)
{
@ -178,7 +179,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{ entry::Key::F4, entry::Modifier::LeftCtrl, 1, cmd, "graphics hmddbg" },
{ entry::Key::F7, entry::Modifier::None, 1, cmd, "graphics vsync" },
{ entry::Key::F8, entry::Modifier::None, 1, cmd, "graphics msaa" },
{ entry::Key::F9, entry::Modifier::None, 1, cmd, "graphics flip" },
{ entry::Key::F9, entry::Modifier::None, 1, cmd, "graphics flush" },
{ entry::Key::Print, entry::Modifier::None, 1, cmd, "graphics screenshot" },
INPUT_BINDING_END

View file

@ -324,8 +324,9 @@
#define BGFX_RESET_HMD UINT32_C(0x00000400)
#define BGFX_RESET_HMD_DEBUG UINT32_C(0x00000800)
#define BGFX_RESET_HMD_RECENTER UINT32_C(0x00001000)
#define BGFX_RESET_FLIP_AFTER_RENDER UINT32_C(0x00002000)
#define BGFX_RESET_SRGB_BACKBUFFER UINT32_C(0x00004000)
#define BGFX_RESET_FLUSH_AFTER_RENDER UINT32_C(0x00002000)
#define BGFX_RESET_FLIP_AFTER_RENDER UINT32_C(0x00004000)
#define BGFX_RESET_SRGB_BACKBUFFER UINT32_C(0x00008000)
///
#define BGFX_CAPS_TEXTURE_COMPARE_LEQUAL UINT64_C(0x0000000000000001)

View file

@ -106,6 +106,8 @@ typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap);
typedef void (GL_APIENTRYP PFNGLENABLEIPROC) (GLenum cap, GLuint index);
typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLFINISHPROC) ();
typedef void (GL_APIENTRYP PFNGLFLUSHPROC) ();
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
@ -279,6 +281,8 @@ GL_IMPORT______(false, PFNGLENABLEPROC, glEnable);
GL_IMPORT______(true, PFNGLENABLEIPROC, glEnablei);
GL_IMPORT______(false, PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray);
GL_IMPORT______(true, PFNGLENDQUERYPROC, glEndQuery);
GL_IMPORT______(false, PFNGLFINISHPROC, glFinish);
GL_IMPORT______(false, PFNGLFLUSHPROC, glFlush);
GL_IMPORT______(true, PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer);
GL_IMPORT______(true, PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D);
GL_IMPORT______(false, PFNGLGENBUFFERSPROC, glGenBuffers);

View file

@ -4376,6 +4376,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (0 < _render->m_num)
{
if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
{
deviceCtx->Flush();
}
captureElapsed = -bx::getHPCounter();
capture();
captureElapsed += bx::getHPCounter();

View file

@ -272,6 +272,7 @@ namespace bgfx { namespace d3d9
RendererContextD3D9()
: m_d3d9(NULL)
, m_device(NULL)
, m_flushQuery(NULL)
, m_swapChain(NULL)
, m_captureTexture(NULL)
, m_captureSurface(NULL)
@ -1239,6 +1240,7 @@ namespace bgfx { namespace d3d9
capturePreReset();
DX_RELEASE(m_flushQuery, 0);
m_gpuTimer.preReset();
for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii)
@ -1268,6 +1270,7 @@ namespace bgfx { namespace d3d9
DX_CHECK(m_swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_backBufferColor) );
DX_CHECK(m_device->GetDepthStencilSurface(&m_backBufferDepthStencil) );
DX_CHECK(m_device->CreateQuery(D3DQUERYTYPE_EVENT, &m_flushQuery) );
m_gpuTimer.postReset();
capturePostReset();
@ -1725,6 +1728,7 @@ namespace bgfx { namespace d3d9
IDirect3D9* m_d3d9;
IDirect3DDevice9* m_device;
IDirect3DQuery9* m_flushQuery;
TimerQueryD3D9 m_gpuTimer;
D3DPOOL m_pool;
@ -3514,6 +3518,12 @@ namespace bgfx { namespace d3d9
if (0 < _render->m_num)
{
if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
{
m_flushQuery->Issue(D3DISSUE_END);
m_flushQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
}
captureElapsed = -bx::getHPCounter();
capture();
captureElapsed += bx::getHPCounter();

View file

@ -5590,6 +5590,11 @@ namespace bgfx { namespace gl
if (0 < _render->m_num)
{
if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
{
GL_CHECK(glFlush() );
}
captureElapsed = -bx::getHPCounter();
capture();
captureElapsed += bx::getHPCounter();