Integrated the new rx::Fence class into gl::Fence.

TRAC #22418 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1845 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent cfe787e7
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -7,129 +7,44 @@ ...@@ -7,129 +7,44 @@
// Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension. // Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension.
#include "libGLESv2/Fence.h" #include "libGLESv2/Fence.h"
#include "libGLESv2/renderer/FenceImpl.h"
#include "libGLESv2/renderer/renderer9_utils.h"
namespace gl namespace gl
{ {
Fence::Fence(rx::Renderer *renderer) Fence::Fence(rx::Renderer *renderer)
{ {
mRenderer = rx::Renderer9::makeRenderer9(renderer); // D3D9_REPLACE mFence = renderer->createFence();
mQuery = NULL;
mCondition = GL_NONE;
mStatus = GL_FALSE;
} }
Fence::~Fence() Fence::~Fence()
{ {
if (mQuery != NULL) delete mFence;
{
mRenderer->freeEventQuery(mQuery);
}
} }
GLboolean Fence::isFence() GLboolean Fence::isFence()
{ {
// GL_NV_fence spec: return mFence->isFence();
// A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
return mQuery != NULL;
} }
// D3D9_REPLACE
void Fence::setFence(GLenum condition) void Fence::setFence(GLenum condition)
{ {
if (!mQuery) mFence->setFence(condition);
{
mQuery = mRenderer->allocateEventQuery();
if (!mQuery)
{
return error(GL_OUT_OF_MEMORY);
}
}
HRESULT result = mQuery->Issue(D3DISSUE_END);
ASSERT(SUCCEEDED(result));
mCondition = condition;
mStatus = GL_FALSE;
} }
// D3D9_REPLACE
GLboolean Fence::testFence() GLboolean Fence::testFence()
{ {
if (mQuery == NULL) return mFence->testFence();
{
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::finishFence() void Fence::finishFence()
{ {
if (mQuery == NULL) mFence->finishFence();
{
return error(GL_INVALID_OPERATION);
}
while (!testFence())
{
Sleep(0);
}
} }
void Fence::getFenceiv(GLenum pname, GLint *params) void Fence::getFenceiv(GLenum pname, GLint *params)
{ {
if (mQuery == NULL) mFence->getFenceiv(pname, params);
{
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); // D3D9_REPLACE
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;
}
} }
} }
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <d3d9.h>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/renderer/Renderer9.h" #include "libGLESv2/renderer/Renderer.h"
namespace gl namespace gl
{ {
...@@ -34,10 +33,7 @@ class Fence ...@@ -34,10 +33,7 @@ class Fence
private: private:
DISALLOW_COPY_AND_ASSIGN(Fence); DISALLOW_COPY_AND_ASSIGN(Fence);
rx::Renderer9 *mRenderer; // D3D9_REPLACE rx::FenceImpl *mFence;
IDirect3DQuery9* mQuery; // D3D9_REPLACE
GLenum mCondition;
GLboolean mStatus;
}; };
} }
......
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