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 @@ ...@@ -11,7 +11,6 @@
namespace gl namespace gl
{ {
Query::Query(rx::QueryImpl *impl, GLuint id) Query::Query(rx::QueryImpl *impl, GLuint id)
: RefCountObject(id), : RefCountObject(id),
mQuery(impl) mQuery(impl)
...@@ -25,7 +24,11 @@ Query::~Query() ...@@ -25,7 +24,11 @@ Query::~Query()
void Query::begin() 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() void Query::end()
...@@ -50,7 +53,7 @@ GLenum Query::getType() const ...@@ -50,7 +53,7 @@ GLenum Query::getType() const
bool Query::isStarted() const bool Query::isStarted() const
{ {
return mQuery->isStarted(); return mStarted;
} }
} }
...@@ -40,6 +40,8 @@ class Query : public RefCountObject ...@@ -40,6 +40,8 @@ class Query : public RefCountObject
private: private:
DISALLOW_COPY_AND_ASSIGN(Query); DISALLOW_COPY_AND_ASSIGN(Query);
bool mStarted;
rx::QueryImpl *mQuery; rx::QueryImpl *mQuery;
}; };
......
...@@ -19,20 +19,15 @@ namespace rx ...@@ -19,20 +19,15 @@ namespace rx
class QueryImpl class QueryImpl
{ {
public: public:
explicit QueryImpl(GLenum type) : mType(type), mStatus(GL_FALSE), mResult(0) { } explicit QueryImpl(GLenum type) { mType = type; }
virtual ~QueryImpl() { } virtual ~QueryImpl() { }
virtual void begin() = 0; virtual bool begin() = 0;
virtual void end() = 0; virtual void end() = 0;
virtual GLuint getResult() = 0; virtual GLuint getResult() = 0;
virtual GLboolean isResultAvailable() = 0; virtual GLboolean isResultAvailable() = 0;
virtual bool isStarted() const = 0;
GLenum getType() const { return mType; } GLenum getType() const { return mType; }
protected:
GLuint mResult;
GLboolean mStatus;
private: private:
DISALLOW_COPY_AND_ASSIGN(QueryImpl); DISALLOW_COPY_AND_ASSIGN(QueryImpl);
......
...@@ -30,7 +30,7 @@ static bool checkStreamOutPrimitivesWritten(ID3D11DeviceContext *context, ID3D11 ...@@ -30,7 +30,7 @@ static bool checkStreamOutPrimitivesWritten(ID3D11DeviceContext *context, ID3D11
return (result == S_OK); 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; mRenderer = renderer;
mQuery = NULL; mQuery = NULL;
...@@ -41,7 +41,7 @@ Query11::~Query11() ...@@ -41,7 +41,7 @@ Query11::~Query11()
SafeRelease(mQuery); SafeRelease(mQuery);
} }
void Query11::begin() bool Query11::begin()
{ {
if (mQuery == NULL) if (mQuery == NULL)
{ {
...@@ -51,11 +51,12 @@ void Query11::begin() ...@@ -51,11 +51,12 @@ void Query11::begin()
if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery))) 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); mRenderer->getDeviceContext()->Begin(mQuery);
return true;
} }
void Query11::end() void Query11::end()
...@@ -148,9 +149,4 @@ GLboolean Query11::testQuery() ...@@ -148,9 +149,4 @@ GLboolean Query11::testQuery()
return GL_TRUE; // prevent blocking when query is null return GL_TRUE; // prevent blocking when query is null
} }
bool Query11::isStarted() const
{
return (mQuery != NULL);
}
} }
...@@ -21,17 +21,19 @@ class Query11 : public QueryImpl ...@@ -21,17 +21,19 @@ class Query11 : public QueryImpl
Query11(rx::Renderer11 *renderer, GLenum type); Query11(rx::Renderer11 *renderer, GLenum type);
virtual ~Query11(); virtual ~Query11();
virtual void begin(); virtual bool begin();
virtual void end(); virtual void end();
virtual GLuint getResult(); virtual GLuint getResult();
virtual GLboolean isResultAvailable(); virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Query11); DISALLOW_COPY_AND_ASSIGN(Query11);
GLboolean testQuery(); GLboolean testQuery();
GLuint mResult;
GLboolean mStatus;
rx::Renderer11 *mRenderer; rx::Renderer11 *mRenderer;
ID3D11Query *mQuery; ID3D11Query *mQuery;
}; };
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
namespace rx namespace rx
{ {
Query9::Query9(rx::Renderer9 *renderer, GLenum type) : QueryImpl(type), mStatus(GL_FALSE), mResult(0)
Query9::Query9(rx::Renderer9 *renderer, GLenum type) : QueryImpl(type)
{ {
mRenderer = renderer; mRenderer = renderer;
mQuery = NULL; mQuery = NULL;
...@@ -27,19 +26,20 @@ Query9::~Query9() ...@@ -27,19 +26,20 @@ Query9::~Query9()
SafeRelease(mQuery); SafeRelease(mQuery);
} }
void Query9::begin() bool Query9::begin()
{ {
if (mQuery == NULL) if (mQuery == NULL)
{ {
if (FAILED(mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery))) 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); HRESULT result = mQuery->Issue(D3DISSUE_BEGIN);
UNUSED_ASSERTION_VARIABLE(result); UNUSED_ASSERTION_VARIABLE(result);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
return true;
} }
void Query9::end() void Query9::end()
...@@ -117,9 +117,4 @@ GLboolean Query9::testQuery() ...@@ -117,9 +117,4 @@ GLboolean Query9::testQuery()
return GL_TRUE; // prevent blocking when query is null return GL_TRUE; // prevent blocking when query is null
} }
bool Query9::isStarted() const
{
return (mQuery != NULL);
}
} }
...@@ -21,17 +21,19 @@ class Query9 : public QueryImpl ...@@ -21,17 +21,19 @@ class Query9 : public QueryImpl
Query9(rx::Renderer9 *renderer, GLenum type); Query9(rx::Renderer9 *renderer, GLenum type);
virtual ~Query9(); virtual ~Query9();
virtual void begin(); virtual bool begin();
virtual void end(); virtual void end();
virtual GLuint getResult(); virtual GLuint getResult();
virtual GLboolean isResultAvailable(); virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Query9); DISALLOW_COPY_AND_ASSIGN(Query9);
GLboolean testQuery(); GLboolean testQuery();
GLuint mResult;
GLboolean mStatus;
rx::Renderer9 *mRenderer; rx::Renderer9 *mRenderer;
IDirect3DQuery9 *mQuery; 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