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