Commit f87fac56 by Jamie Madill Committed by Commit Bot

Use non-mutating getQuery in validation.

Previously the validation layer would create the query if not created. This change should be a no-op that makes the validation layer work in a more "const-friendly" way. Bug: angleproject:1280 Change-Id: Ife0c216c8a0dcda2a33d1182821c51e4ed5f67e0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2060688Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e96da533
...@@ -1239,7 +1239,7 @@ void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle) ...@@ -1239,7 +1239,7 @@ void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle)
void Context::beginQuery(QueryType target, QueryID query) void Context::beginQuery(QueryType target, QueryID query)
{ {
Query *queryObject = getQuery(query, true, target); Query *queryObject = getOrCreateQuery(query, target);
ASSERT(queryObject); ASSERT(queryObject);
// begin query // begin query
...@@ -1267,7 +1267,7 @@ void Context::queryCounter(QueryID id, QueryType target) ...@@ -1267,7 +1267,7 @@ void Context::queryCounter(QueryID id, QueryType target)
{ {
ASSERT(target == QueryType::Timestamp); ASSERT(target == QueryType::Timestamp);
Query *queryObject = getQuery(id, true, target); Query *queryObject = getOrCreateQuery(id, target);
ASSERT(queryObject); ASSERT(queryObject);
ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); ANGLE_CONTEXT_TRY(queryObject->queryCounter(this));
...@@ -1386,7 +1386,7 @@ FenceNV *Context::getFenceNV(FenceNVID handle) ...@@ -1386,7 +1386,7 @@ FenceNV *Context::getFenceNV(FenceNVID handle)
return mFenceNVMap.query(handle); return mFenceNVMap.query(handle);
} }
Query *Context::getQuery(QueryID handle, bool create, QueryType type) Query *Context::getOrCreateQuery(QueryID handle, QueryType type)
{ {
if (!mQueryMap.contains(handle)) if (!mQueryMap.contains(handle))
{ {
...@@ -1394,7 +1394,7 @@ Query *Context::getQuery(QueryID handle, bool create, QueryType type) ...@@ -1394,7 +1394,7 @@ Query *Context::getQuery(QueryID handle, bool create, QueryType type)
} }
Query *query = mQueryMap.query(handle); Query *query = mQueryMap.query(handle);
if (!query && create) if (!query)
{ {
ASSERT(type != QueryType::InvalidEnum); ASSERT(type != QueryType::InvalidEnum);
query = new Query(mImplementation.get(), type, handle); query = new Query(mImplementation.get(), type, handle);
...@@ -7083,9 +7083,14 @@ void Context::deleteQueries(GLsizei n, const QueryID *ids) ...@@ -7083,9 +7083,14 @@ void Context::deleteQueries(GLsizei n, const QueryID *ids)
} }
} }
bool Context::isQueryGenerated(QueryID query) const
{
return mQueryMap.contains(query);
}
GLboolean Context::isQuery(QueryID id) GLboolean Context::isQuery(QueryID id)
{ {
return ConvertToGLBoolean(getQuery(id, false, QueryType::InvalidEnum) != nullptr); return ConvertToGLBoolean(getQuery(id) != nullptr);
} }
void Context::uniformMatrix2x3fv(GLint location, void Context::uniformMatrix2x3fv(GLint location,
......
...@@ -385,7 +385,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -385,7 +385,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
Renderbuffer *getRenderbuffer(RenderbufferID handle) const; Renderbuffer *getRenderbuffer(RenderbufferID handle) const;
VertexArray *getVertexArray(VertexArrayID handle) const; VertexArray *getVertexArray(VertexArrayID handle) const;
Sampler *getSampler(SamplerID handle) const; Sampler *getSampler(SamplerID handle) const;
Query *getQuery(QueryID handle, bool create, QueryType type); Query *getOrCreateQuery(QueryID handle, QueryType type);
Query *getQuery(QueryID handle) const; Query *getQuery(QueryID handle) const;
TransformFeedback *getTransformFeedback(TransformFeedbackID handle) const; TransformFeedback *getTransformFeedback(TransformFeedbackID handle) const;
ProgramPipeline *getProgramPipeline(ProgramPipelineID handle) const; ProgramPipeline *getProgramPipeline(ProgramPipelineID handle) const;
...@@ -553,6 +553,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -553,6 +553,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isRenderbufferGenerated(RenderbufferID renderbuffer) const; bool isRenderbufferGenerated(RenderbufferID renderbuffer) const;
bool isFramebufferGenerated(FramebufferID framebuffer) const; bool isFramebufferGenerated(FramebufferID framebuffer) const;
bool isProgramPipelineGenerated(ProgramPipelineID pipeline) const; bool isProgramPipelineGenerated(ProgramPipelineID pipeline) const;
bool isQueryGenerated(QueryID query) const;
bool usingDisplayTextureShareGroup() const; bool usingDisplayTextureShareGroup() const;
......
...@@ -1672,17 +1672,16 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, QueryID id) ...@@ -1672,17 +1672,16 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, QueryID id)
return false; return false;
} }
Query *queryObject = context->getQuery(id, true, target);
// check that name was obtained with glGenQueries // check that name was obtained with glGenQueries
if (!queryObject) if (!context->isQueryGenerated(id))
{ {
context->validationError(GL_INVALID_OPERATION, kInvalidQueryId); context->validationError(GL_INVALID_OPERATION, kInvalidQueryId);
return false; return false;
} }
// check for type mismatch // Check for type mismatch. If query is not yet started we're good to go.
if (queryObject->getType() != target) Query *queryObject = context->getQuery(id);
if (queryObject && queryObject->getType() != target)
{ {
context->validationError(GL_INVALID_OPERATION, kQueryTargetMismatch); context->validationError(GL_INVALID_OPERATION, kQueryTargetMismatch);
return false; return false;
...@@ -1748,14 +1747,15 @@ bool ValidateQueryCounterEXT(Context *context, QueryID id, QueryType target) ...@@ -1748,14 +1747,15 @@ bool ValidateQueryCounterEXT(Context *context, QueryID id, QueryType target)
return false; return false;
} }
Query *queryObject = context->getQuery(id, true, target); if (!context->isQueryGenerated(id))
if (queryObject == nullptr)
{ {
context->validationError(GL_INVALID_OPERATION, kInvalidQueryId); context->validationError(GL_INVALID_OPERATION, kInvalidQueryId);
return false; return false;
} }
if (context->getState().isQueryActive(queryObject)) // If query object is not started, that's fine.
Query *queryObject = context->getQuery(id);
if (queryObject && context->getState().isQueryActive(queryObject))
{ {
context->validationError(GL_INVALID_OPERATION, kQueryActive); context->validationError(GL_INVALID_OPERATION, kQueryActive);
return false; return false;
...@@ -1872,7 +1872,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, QueryID id, GLenum pname, ...@@ -1872,7 +1872,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, QueryID id, GLenum pname,
} }
} }
Query *queryObject = context->getQuery(id, false, QueryType::InvalidEnum); Query *queryObject = context->getQuery(id);
if (!queryObject) if (!queryObject)
{ {
......
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