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 @@
namespace rx
{
static const int kDeviceLostCheckPeriod = 64;
//
// Template helpers for set and test operations.
//
......@@ -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);
}
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);
*outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
......@@ -89,14 +87,23 @@ gl::Error FenceNV11::test(GLboolean *outFinished)
gl::Error FenceNV11::finish()
{
GLboolean finished = GL_FALSE;
int loopCount = 0;
while (finished != GL_TRUE)
{
loopCount++;
gl::Error error = FenceTestHelper(this, true, &finished);
if (error.isError())
{
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();
}
......@@ -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 endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds;
int loopCount = 0;
while (currentCounter.QuadPart < endCounter && !result)
{
loopCount++;
ScheduleYield();
success = QueryPerformanceCounter(&currentCounter);
UNUSED_ASSERTION_VARIABLE(success);
......@@ -189,6 +198,13 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou
*outResult = GL_WAIT_FAILED;
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)
......
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