Commit 97d65b79 by Shannon Woods

Clean up Query classes.

BUG=angle:717 Change-Id: I8f29f24964a9661d9f0bea5dca48cebddbf9b0b2 Reviewed-on: https://chromium-review.googlesource.com/211136Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent 2d8c879f
......@@ -11,7 +11,6 @@
namespace gl
{
Query::Query(rx::QueryImpl *impl, GLuint id)
: RefCountObject(id),
mQuery(impl)
......@@ -25,7 +24,11 @@ Query::~Query()
void Query::begin()
{
mQuery->begin();
// TODO: Rather than keeping track of whether the query was successfully
// created via a boolean in the GL-level Query object, we should probably
// use the error system to track these failed creations at the context level,
// and reset the active query ID for the target to 0 upon failure.
mStarted = mQuery->begin();
}
void Query::end()
......@@ -50,7 +53,7 @@ GLenum Query::getType() const
bool Query::isStarted() const
{
return mQuery->isStarted();
return mStarted;
}
}
......@@ -40,6 +40,8 @@ class Query : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(Query);
bool mStarted;
rx::QueryImpl *mQuery;
};
......
......@@ -19,21 +19,16 @@ namespace rx
class QueryImpl
{
public:
explicit QueryImpl(GLenum type) : mType(type), mStatus(GL_FALSE), mResult(0) { }
explicit QueryImpl(GLenum type) { mType = type; }
virtual ~QueryImpl() { }
virtual void begin() = 0;
virtual bool begin() = 0;
virtual void end() = 0;
virtual GLuint getResult() = 0;
virtual GLboolean isResultAvailable() = 0;
virtual bool isStarted() const = 0;
GLenum getType() const { return mType; }
protected:
GLuint mResult;
GLboolean mStatus;
private:
DISALLOW_COPY_AND_ASSIGN(QueryImpl);
......
......@@ -30,7 +30,7 @@ static bool checkStreamOutPrimitivesWritten(ID3D11DeviceContext *context, ID3D11
return (result == S_OK);
}
Query11::Query11(rx::Renderer11 *renderer, GLenum type) : QueryImpl(type)
Query11::Query11(rx::Renderer11 *renderer, GLenum type) : QueryImpl(type), mStatus(GL_FALSE), mResult(0)
{
mRenderer = renderer;
mQuery = NULL;
......@@ -41,7 +41,7 @@ Query11::~Query11()
SafeRelease(mQuery);
}
void Query11::begin()
bool Query11::begin()
{
if (mQuery == NULL)
{
......@@ -51,11 +51,12 @@ void Query11::begin()
if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery)))
{
return gl::error(GL_OUT_OF_MEMORY);
return gl::error(GL_OUT_OF_MEMORY, false);
}
}
mRenderer->getDeviceContext()->Begin(mQuery);
return true;
}
void Query11::end()
......@@ -148,9 +149,4 @@ GLboolean Query11::testQuery()
return GL_TRUE; // prevent blocking when query is null
}
bool Query11::isStarted() const
{
return (mQuery != NULL);
}
}
......@@ -21,17 +21,19 @@ class Query11 : public QueryImpl
Query11(rx::Renderer11 *renderer, GLenum type);
virtual ~Query11();
virtual void begin();
virtual bool begin();
virtual void end();
virtual GLuint getResult();
virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query11);
GLboolean testQuery();
GLuint mResult;
GLboolean mStatus;
rx::Renderer11 *mRenderer;
ID3D11Query *mQuery;
};
......
......@@ -15,8 +15,7 @@
namespace rx
{
Query9::Query9(rx::Renderer9 *renderer, GLenum type) : QueryImpl(type)
Query9::Query9(rx::Renderer9 *renderer, GLenum type) : QueryImpl(type), mStatus(GL_FALSE), mResult(0)
{
mRenderer = renderer;
mQuery = NULL;
......@@ -27,19 +26,20 @@ Query9::~Query9()
SafeRelease(mQuery);
}
void Query9::begin()
bool Query9::begin()
{
if (mQuery == NULL)
{
if (FAILED(mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery)))
{
return gl::error(GL_OUT_OF_MEMORY);
return gl::error(GL_OUT_OF_MEMORY, false);
}
}
HRESULT result = mQuery->Issue(D3DISSUE_BEGIN);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(SUCCEEDED(result));
return true;
}
void Query9::end()
......@@ -117,9 +117,4 @@ GLboolean Query9::testQuery()
return GL_TRUE; // prevent blocking when query is null
}
bool Query9::isStarted() const
{
return (mQuery != NULL);
}
}
......@@ -21,17 +21,19 @@ class Query9 : public QueryImpl
Query9(rx::Renderer9 *renderer, GLenum type);
virtual ~Query9();
virtual void begin();
virtual bool begin();
virtual void end();
virtual GLuint getResult();
virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query9);
GLboolean testQuery();
GLuint mResult;
GLboolean mStatus;
rx::Renderer9 *mRenderer;
IDirect3DQuery9 *mQuery;
};
......
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