Commit fb9a7409 by Jamie Madill

Move the API parameter validation out of Fence.cpp to libGLESv2.cpp.

TRAC #23446 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Authored-by: Jamie Madill
parent 09752369
......@@ -51,10 +51,7 @@ GLboolean Fence::testFence()
void Fence::finishFence()
{
if (!mFence->isSet())
{
return gl::error(GL_INVALID_OPERATION);
}
ASSERT(mFence->isSet());
while (!mFence->test(true))
{
......@@ -62,12 +59,9 @@ void Fence::finishFence()
}
}
void Fence::getFenceiv(GLenum pname, GLint *params)
GLint Fence::getFencei(GLenum pname)
{
if (!mFence->isSet())
{
return error(GL_INVALID_OPERATION);
}
ASSERT(mFence->isSet());
switch (pname)
{
......@@ -78,21 +72,17 @@ void Fence::getFenceiv(GLenum pname, GLint *params)
// or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
if (mStatus == GL_TRUE)
{
params[0] = GL_TRUE;
return;
return GL_TRUE;
}
mStatus = (mFence->test(false) ? GL_TRUE : GL_FALSE);
params[0] = mStatus;
break;
return mStatus;
}
case GL_FENCE_CONDITION_NV:
params[0] = mCondition;
break;
return mCondition;
default:
return error(GL_INVALID_ENUM);
default: UNREACHABLE(); return 0;
}
}
......
......@@ -30,7 +30,7 @@ class Fence
void setFence(GLenum condition);
GLboolean testFence();
void finishFence();
void getFenceiv(GLenum pname, GLint *params);
GLint getFencei(GLenum pname);
GLboolean getStatus() const { return mStatus; }
GLuint getCondition() const { return mCondition; }
......
......@@ -4018,6 +4018,11 @@ void __stdcall glFinishFenceNV(GLuint fence)
return gl::error(GL_INVALID_OPERATION);
}
if (fenceObject->isFence() != GL_TRUE)
{
return gl::error(GL_INVALID_OPERATION);
}
fenceObject->finishFence();
}
}
......@@ -4900,7 +4905,21 @@ void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
return gl::error(GL_INVALID_OPERATION);
}
fenceObject->getFenceiv(pname, params);
if (fenceObject->isFence() != GL_TRUE)
{
return gl::error(GL_INVALID_OPERATION);
}
switch (pname)
{
case GL_FENCE_STATUS_NV:
case GL_FENCE_CONDITION_NV:
break;
default: return gl::error(GL_INVALID_ENUM);
}
params[0] = fenceObject->getFencei(pname);
}
}
catch(std::bad_alloc&)
......@@ -7056,6 +7075,11 @@ GLboolean __stdcall glTestFenceNV(GLuint fence)
return gl::error(GL_INVALID_OPERATION, GL_TRUE);
}
if (fenceObject->isFence() != GL_TRUE)
{
return gl::error(GL_INVALID_OPERATION, GL_TRUE);
}
return fenceObject->testFence();
}
}
......
......@@ -53,10 +53,7 @@ void Fence11::set()
bool Fence11::test(bool flushCommandBuffer)
{
if (mQuery == NULL)
{
return gl::error(GL_INVALID_OPERATION, true);
}
ASSERT(mQuery);
UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, NULL, 0, getDataFlags);
......
......@@ -52,10 +52,7 @@ void Fence9::set()
bool Fence9::test(bool flushCommandBuffer)
{
if (mQuery == NULL)
{
return gl::error(GL_INVALID_OPERATION, true);
}
ASSERT(mQuery);
DWORD getDataFlags = (flushCommandBuffer ? D3DGETDATA_FLUSH : 0);
HRESULT result = mQuery->GetData(NULL, 0, getDataFlags);
......
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