2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension.
9 #include "libGLESv2/Fence.h"
11 #include "libGLESv2/main.h"
32 GLboolean Fence::isFence()
35 // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
36 return mQuery != NULL;
39 void Fence::setFence(GLenum condition)
47 if (FAILED(getDevice()->CreateQuery(D3DQUERYTYPE_EVENT, &mQuery)))
49 return error(GL_OUT_OF_MEMORY);
52 HRESULT result = mQuery->Issue(D3DISSUE_END);
53 ASSERT(SUCCEEDED(result));
55 mCondition = condition;
59 GLboolean Fence::testFence()
63 return error(GL_INVALID_OPERATION, GL_TRUE);
66 HRESULT result = mQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
68 if (result == D3DERR_DEVICELOST)
70 return error(GL_OUT_OF_MEMORY, GL_TRUE);
73 ASSERT(result == S_OK || result == S_FALSE);
74 mStatus = result == S_OK;
78 void Fence::finishFence()
82 return error(GL_INVALID_OPERATION);
91 void Fence::getFenceiv(GLenum pname, GLint *params)
95 return error(GL_INVALID_OPERATION);
100 case GL_FENCE_STATUS_NV:
103 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
104 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
111 HRESULT result = mQuery->GetData(NULL, 0, 0);
113 if (result == D3DERR_DEVICELOST)
116 return error(GL_OUT_OF_MEMORY);
119 ASSERT(result == S_OK || result == S_FALSE);
120 mStatus = result == S_OK;
125 case GL_FENCE_CONDITION_NV:
126 params[0] = mCondition;
129 return error(GL_INVALID_ENUM);