X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fcondrender.c;h=77e4b95ee8f2e4171c51859f779264970533f7e4;hb=2768a0b1b42f3c1531ab9c3647a93f0504002280;hp=c8195a520cf3187eae8351c46f95f8ffb4b2da0e;hpb=7371224c069357319b3f2ee9e9b017fc284897cb;p=mesa.git diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c index c8195a520cf..77e4b95ee8f 100644 --- a/src/mesa/main/condrender.c +++ b/src/mesa/main/condrender.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.8 * * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * @@ -41,39 +40,66 @@ void GLAPIENTRY _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) { - struct gl_query_object *q; + struct gl_query_object *q = NULL; GET_CURRENT_CONTEXT(ctx); - if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery || - queryId == 0) { + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: + * + * "If BeginConditionalRender is called while conditional rendering is + * in progress, or if EndConditionalRender is called while conditional + * rendering is not in progress, the error INVALID_OPERATION is + * generated." + */ + if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); return; } - ASSERT(ctx->Query.CondRenderMode == GL_NONE); + assert(ctx->Query.CondRenderMode == GL_NONE); + + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: + * + * "The error INVALID_VALUE is generated if is not the name of an + * existing query object query." + */ + if (queryId != 0) + q = _mesa_lookup_query_object(ctx, queryId); + + if (!q) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBeginConditionalRender(bad queryId=%u)", queryId); + return; + } + assert(q->Id == queryId); switch (mode) { case GL_QUERY_WAIT: case GL_QUERY_NO_WAIT: case GL_QUERY_BY_REGION_WAIT: case GL_QUERY_BY_REGION_NO_WAIT: - /* OK */ - break; + break; /* OK */ + case GL_QUERY_WAIT_INVERTED: + case GL_QUERY_NO_WAIT_INVERTED: + case GL_QUERY_BY_REGION_WAIT_INVERTED: + case GL_QUERY_BY_REGION_NO_WAIT_INVERTED: + if (ctx->Extensions.ARB_conditional_render_inverted) + break; /* OK */ + /* fallthrough - invalid */ default: _mesa_error(ctx, GL_INVALID_ENUM, "glBeginConditionalRender(mode=%s)", _mesa_lookup_enum_by_nr(mode)); return; } - q = _mesa_lookup_query_object(ctx, queryId); - if (!q) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glBeginConditionalRender(bad queryId=%u)", queryId); - return; - } - ASSERT(q->Id == queryId); - - if (q->Target != GL_SAMPLES_PASSED) { + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: + * + * "The error INVALID_OPERATION is generated if is the name of a + * query object with a target other than SAMPLES_PASSED, or is the + * name of a query currently in progress." + */ + if ((q->Target != GL_SAMPLES_PASSED && + q->Target != GL_ANY_SAMPLES_PASSED && + q->Target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE) || q->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); return; } @@ -136,10 +162,25 @@ _mesa_check_conditional_render(struct gl_context *ctx) ctx->Driver.WaitQuery(ctx, q); } return q->Result > 0; + case GL_QUERY_BY_REGION_WAIT_INVERTED: + /* fall-through */ + case GL_QUERY_WAIT_INVERTED: + if (!q->Ready) { + ctx->Driver.WaitQuery(ctx, q); + } + return q->Result == 0; case GL_QUERY_BY_REGION_NO_WAIT: /* fall-through */ case GL_QUERY_NO_WAIT: + if (!q->Ready) + ctx->Driver.CheckQuery(ctx, q); return q->Ready ? (q->Result > 0) : GL_TRUE; + case GL_QUERY_BY_REGION_NO_WAIT_INVERTED: + /* fall-through */ + case GL_QUERY_NO_WAIT_INVERTED: + if (!q->Ready) + ctx->Driver.CheckQuery(ctx, q); + return q->Ready ? (q->Result == 0) : GL_TRUE; default: _mesa_problem(ctx, "Bad cond render mode %s in " " _mesa_check_conditional_render()",