Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f87fac5

Browse files
null77Commit Bot
authored andcommitted
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/+/2060688 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 parent e96da53 commit f87fac5

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/libANGLE/Context.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle)
12391239

12401240
void Context::beginQuery(QueryType target, QueryID query)
12411241
{
1242-
Query *queryObject = getQuery(query, true, target);
1242+
Query *queryObject = getOrCreateQuery(query, target);
12431243
ASSERT(queryObject);
12441244

12451245
// begin query
@@ -1267,7 +1267,7 @@ void Context::queryCounter(QueryID id, QueryType target)
12671267
{
12681268
ASSERT(target == QueryType::Timestamp);
12691269

1270-
Query *queryObject = getQuery(id, true, target);
1270+
Query *queryObject = getOrCreateQuery(id, target);
12711271
ASSERT(queryObject);
12721272

12731273
ANGLE_CONTEXT_TRY(queryObject->queryCounter(this));
@@ -1386,15 +1386,15 @@ FenceNV *Context::getFenceNV(FenceNVID handle)
13861386
return mFenceNVMap.query(handle);
13871387
}
13881388

1389-
Query *Context::getQuery(QueryID handle, bool create, QueryType type)
1389+
Query *Context::getOrCreateQuery(QueryID handle, QueryType type)
13901390
{
13911391
if (!mQueryMap.contains(handle))
13921392
{
13931393
return nullptr;
13941394
}
13951395

13961396
Query *query = mQueryMap.query(handle);
1397-
if (!query && create)
1397+
if (!query)
13981398
{
13991399
ASSERT(type != QueryType::InvalidEnum);
14001400
query = new Query(mImplementation.get(), type, handle);
@@ -7083,9 +7083,14 @@ void Context::deleteQueries(GLsizei n, const QueryID *ids)
70837083
}
70847084
}
70857085

7086+
bool Context::isQueryGenerated(QueryID query) const
7087+
{
7088+
return mQueryMap.contains(query);
7089+
}
7090+
70867091
GLboolean Context::isQuery(QueryID id)
70877092
{
7088-
return ConvertToGLBoolean(getQuery(id, false, QueryType::InvalidEnum) != nullptr);
7093+
return ConvertToGLBoolean(getQuery(id) != nullptr);
70897094
}
70907095

70917096
void Context::uniformMatrix2x3fv(GLint location,

src/libANGLE/Context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
385385
Renderbuffer *getRenderbuffer(RenderbufferID handle) const;
386386
VertexArray *getVertexArray(VertexArrayID handle) const;
387387
Sampler *getSampler(SamplerID handle) const;
388-
Query *getQuery(QueryID handle, bool create, QueryType type);
388+
Query *getOrCreateQuery(QueryID handle, QueryType type);
389389
Query *getQuery(QueryID handle) const;
390390
TransformFeedback *getTransformFeedback(TransformFeedbackID handle) const;
391391
ProgramPipeline *getProgramPipeline(ProgramPipelineID handle) const;
@@ -553,6 +553,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
553553
bool isRenderbufferGenerated(RenderbufferID renderbuffer) const;
554554
bool isFramebufferGenerated(FramebufferID framebuffer) const;
555555
bool isProgramPipelineGenerated(ProgramPipelineID pipeline) const;
556+
bool isQueryGenerated(QueryID query) const;
556557

557558
bool usingDisplayTextureShareGroup() const;
558559

src/libANGLE/validationES.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,17 +1672,16 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, QueryID id)
16721672
return false;
16731673
}
16741674

1675-
Query *queryObject = context->getQuery(id, true, target);
1676-
16771675
// check that name was obtained with glGenQueries
1678-
if (!queryObject)
1676+
if (!context->isQueryGenerated(id))
16791677
{
16801678
context->validationError(GL_INVALID_OPERATION, kInvalidQueryId);
16811679
return false;
16821680
}
16831681

1684-
// check for type mismatch
1685-
if (queryObject->getType() != target)
1682+
// Check for type mismatch. If query is not yet started we're good to go.
1683+
Query *queryObject = context->getQuery(id);
1684+
if (queryObject && queryObject->getType() != target)
16861685
{
16871686
context->validationError(GL_INVALID_OPERATION, kQueryTargetMismatch);
16881687
return false;
@@ -1748,14 +1747,15 @@ bool ValidateQueryCounterEXT(Context *context, QueryID id, QueryType target)
17481747
return false;
17491748
}
17501749

1751-
Query *queryObject = context->getQuery(id, true, target);
1752-
if (queryObject == nullptr)
1750+
if (!context->isQueryGenerated(id))
17531751
{
17541752
context->validationError(GL_INVALID_OPERATION, kInvalidQueryId);
17551753
return false;
17561754
}
17571755

1758-
if (context->getState().isQueryActive(queryObject))
1756+
// If query object is not started, that's fine.
1757+
Query *queryObject = context->getQuery(id);
1758+
if (queryObject && context->getState().isQueryActive(queryObject))
17591759
{
17601760
context->validationError(GL_INVALID_OPERATION, kQueryActive);
17611761
return false;
@@ -1872,7 +1872,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, QueryID id, GLenum pname,
18721872
}
18731873
}
18741874

1875-
Query *queryObject = context->getQuery(id, false, QueryType::InvalidEnum);
1875+
Query *queryObject = context->getQuery(id);
18761876

18771877
if (!queryObject)
18781878
{

0 commit comments

Comments
 (0)