gl::Error FenceNV11::finish() { GLboolean finished = GL_FALSE; int loopCount = 0; while (finished != GL_TRUE) { loopCount++; ANGLE_TRY(FenceTestHelper(this, true, &finished)); if (loopCount % kDeviceLostCheckPeriod == 0 && mRenderer->testDeviceLost()) { return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while querying result of an event query."); } ScheduleYield(); } return gl::NoError(); }
gl::Error Query11::getResultBase(T *params) { while (!mQueryFinished) { gl::Error error = testQuery(); if (error.isError()) { return error; } if (!mQueryFinished) { ScheduleYield(); } } ASSERT(mQueryFinished); *params = static_cast<T>(mResult); return gl::Error(GL_NO_ERROR); }
gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult) { ASSERT(outResult); bool flushCommandBuffer = ((flags & GL_SYNC_FLUSH_COMMANDS_BIT) != 0); GLboolean result = GL_FALSE; gl::Error error = FenceTestHelper(this, flushCommandBuffer, &result); if (error.isError()) { *outResult = GL_WAIT_FAILED; return error; } if (result == GL_TRUE) { *outResult = GL_ALREADY_SIGNALED; return gl::Error(GL_NO_ERROR); } if (timeout == 0) { *outResult = GL_TIMEOUT_EXPIRED; return gl::Error(GL_NO_ERROR); } LARGE_INTEGER currentCounter = {}; BOOL success = QueryPerformanceCounter(¤tCounter); ASSERT(success); 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(¤tCounter); ASSERT(success); error = FenceTestHelper(this, flushCommandBuffer, &result); if (error.isError()) { *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) { *outResult = GL_TIMEOUT_EXPIRED; } else { *outResult = GL_CONDITION_SATISFIED; } return gl::Error(GL_NO_ERROR); }