Commit 9949f04d by Corentin Wallez Committed by Commit Bot

Fence11: When busy looping on a fence, test for device loss

Previously the code only checked is the device had already seen as lost but never updating the lost status. Since checking for device loss can be expensive, only do it every 128 loop iterations. BUG=angleproject:1463 Change-Id: Ib481aebbb73d0f279e7ef835ac3a96c0a4663d58 Reviewed-on: https://chromium-review.googlesource.com/365736Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 55033e58
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
namespace rx namespace rx
{ {
static const int kDeviceLostCheckPeriod = 64;
// //
// Template helpers for set and test operations. // Template helpers for set and test operations.
// //
...@@ -50,10 +52,6 @@ gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean ...@@ -50,10 +52,6 @@ gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean
{ {
return gl::Error(GL_OUT_OF_MEMORY, "Failed to get query data, result: 0x%X.", result); return gl::Error(GL_OUT_OF_MEMORY, "Failed to get query data, result: 0x%X.", result);
} }
else if (fence->mRenderer->isDeviceLost())
{
return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while querying result of an event query.");
}
ASSERT(result == S_OK || result == S_FALSE); ASSERT(result == S_OK || result == S_FALSE);
*outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE); *outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
...@@ -89,14 +87,23 @@ gl::Error FenceNV11::test(GLboolean *outFinished) ...@@ -89,14 +87,23 @@ gl::Error FenceNV11::test(GLboolean *outFinished)
gl::Error FenceNV11::finish() gl::Error FenceNV11::finish()
{ {
GLboolean finished = GL_FALSE; GLboolean finished = GL_FALSE;
int loopCount = 0;
while (finished != GL_TRUE) while (finished != GL_TRUE)
{ {
loopCount++;
gl::Error error = FenceTestHelper(this, true, &finished); gl::Error error = FenceTestHelper(this, true, &finished);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
if (loopCount % kDeviceLostCheckPeriod == 0 && mRenderer->testDeviceLost())
{
return gl::Error(GL_OUT_OF_MEMORY,
"Device was lost while querying result of an event query.");
}
ScheduleYield(); ScheduleYield();
} }
...@@ -176,8 +183,10 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou ...@@ -176,8 +183,10 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou
LONGLONG timeoutInSeconds = static_cast<LONGLONG>(timeout) * static_cast<LONGLONG>(1000000ll); LONGLONG timeoutInSeconds = static_cast<LONGLONG>(timeout) * static_cast<LONGLONG>(1000000ll);
LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds; LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds;
int loopCount = 0;
while (currentCounter.QuadPart < endCounter && !result) while (currentCounter.QuadPart < endCounter && !result)
{ {
loopCount++;
ScheduleYield(); ScheduleYield();
success = QueryPerformanceCounter(&currentCounter); success = QueryPerformanceCounter(&currentCounter);
UNUSED_ASSERTION_VARIABLE(success); UNUSED_ASSERTION_VARIABLE(success);
...@@ -189,6 +198,13 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou ...@@ -189,6 +198,13 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou
*outResult = GL_WAIT_FAILED; *outResult = GL_WAIT_FAILED;
return error; return error;
} }
if ((loopCount % kDeviceLostCheckPeriod) == 0 && mRenderer->testDeviceLost())
{
*outResult = GL_WAIT_FAILED;
return gl::Error(GL_OUT_OF_MEMORY,
"Device was lost while querying result of an event query.");
}
} }
if (currentCounter.QuadPart >= endCounter) if (currentCounter.QuadPart >= endCounter)
......
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