GLboolean Query::testQuery() { if (mQuery != NULL && mStatus != GL_TRUE) { DWORD numPixels = 0; HRESULT hres = mQuery->GetData(&numPixels, sizeof(DWORD), D3DGETDATA_FLUSH); if (hres == S_OK) { mStatus = GL_TRUE; switch (mType) { case GL_ANY_SAMPLES_PASSED_EXT: case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; break; default: ASSERT(false); } } else if (checkDeviceLost(hres)) { return error(GL_OUT_OF_MEMORY, GL_TRUE); } return mStatus; } return GL_TRUE; // prevent blocking when query is null }
GLboolean Fence::testFence() { if (mQuery == NULL) { return error(GL_INVALID_OPERATION, GL_TRUE); } HRESULT result = mQuery->GetData(NULL, 0, D3DGETDATA_FLUSH); if (checkDeviceLost(result)) { return error(GL_OUT_OF_MEMORY, GL_TRUE); } ASSERT(result == S_OK || result == S_FALSE); mStatus = result == S_OK; return mStatus; }
void Fence::getFenceiv(GLenum pname, GLint *params) { if (mQuery == NULL) { return error(GL_INVALID_OPERATION); } switch (pname) { case GL_FENCE_STATUS_NV: { // GL_NV_fence spec: // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. if (mStatus) { params[0] = GL_TRUE; return; } HRESULT result = mQuery->GetData(NULL, 0, 0); if (checkDeviceLost(result)) { params[0] = GL_TRUE; return error(GL_OUT_OF_MEMORY); } ASSERT(result == S_OK || result == S_FALSE); mStatus = result == S_OK; params[0] = mStatus; break; } case GL_FENCE_CONDITION_NV: params[0] = mCondition; break; default: return error(GL_INVALID_ENUM); break; } }