Commit 575e7910 by apatrick@chromium.org

Changed glFlush to not wait until issued event is processed.

I think these reduced synchronization guarantees are still compliant with the spec. I found that this significantly improved the frame rate for some of our demos (40 fps to 50fps for one on my box). I will change the demo so that it does not call glFlush at all but I still think this is a valuable change. The OpenGL ES2 spec says: "The command void Flush( void ); indicates that all commands that have previously been sent to the GL must complete in finite time." My reading of it is that any GL calls previously issued will be processed at some point in the future but not necessarily prior to glFlush returning. I believe that issuing the D3D event and then calling GetData once with the flush flag should meet these requirements. I also added some assertions to glFinish because I was paranoid that if issuing an event ever failed, the spin loop might never terminate. Review URL: http://codereview.appspot.com/1941049 git-svn-id: https://angleproject.googlecode.com/svn/trunk@401 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 58e54298
...@@ -2627,7 +2627,8 @@ void Context::finish() ...@@ -2627,7 +2627,8 @@ void Context::finish()
IDirect3DStateBlock9 *savedState = NULL; IDirect3DStateBlock9 *savedState = NULL;
device->CreateStateBlock(D3DSBT_ALL, &savedState); device->CreateStateBlock(D3DSBT_ALL, &savedState);
occlusionQuery->Issue(D3DISSUE_BEGIN); HRESULT result = occlusionQuery->Issue(D3DISSUE_BEGIN);
ASSERT(SUCCEEDED(result));
// Render something outside the render target // Render something outside the render target
device->SetStreamSourceFreq(0, 1); device->SetStreamSourceFreq(0, 1);
...@@ -2638,7 +2639,8 @@ void Context::finish() ...@@ -2638,7 +2639,8 @@ void Context::finish()
display->startScene(); display->startScene();
device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, data, sizeof(data)); device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, data, sizeof(data));
occlusionQuery->Issue(D3DISSUE_END); result = occlusionQuery->Issue(D3DISSUE_END);
ASSERT(SUCCEEDED(result));
while (occlusionQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) while (occlusionQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE)
{ {
...@@ -2672,15 +2674,16 @@ void Context::flush() ...@@ -2672,15 +2674,16 @@ void Context::flush()
if (eventQuery) if (eventQuery)
{ {
eventQuery->Issue(D3DISSUE_END); HRESULT result = eventQuery->Issue(D3DISSUE_END);
ASSERT(SUCCEEDED(result));
result = eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
eventQuery->Release();
while (eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) if (result == D3DERR_DEVICELOST)
{ {
// Keep polling, but allow other threads to do something useful first error(GL_OUT_OF_MEMORY);
Sleep(0);
} }
eventQuery->Release();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment