X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fcondrender.c;h=320003aa73f218b36e5e4449d75d92f3324ed3f0;hp=352e2e2b165dbf8cea6a6e42b3edf840d3d1c844;hb=0ca266025ab309d538ed8c804cb46d2945c6a547;hpb=72e30991559017c16d48569e612dbc0970e3b9ca diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c index 352e2e2b165..320003aa73f 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. * @@ -38,50 +37,120 @@ #include "queryobj.h" +static ALWAYS_INLINE void +begin_conditional_render(struct gl_context *ctx, GLuint queryId, GLenum mode, + bool no_error) +{ + struct gl_query_object *q = NULL; + + assert(ctx->Query.CondRenderMode == GL_NONE); + + if (queryId != 0) + q = _mesa_lookup_query_object(ctx, queryId); + + if (!no_error) { + /* 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 (!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: + 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_enum_to_string(mode)); + return; + } + + /* 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->Target != GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB && + q->Target != GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB) || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); + return; + } + } + + ctx->Query.CondRenderQuery = q; + ctx->Query.CondRenderMode = mode; + + if (ctx->Driver.BeginConditionalRender) + ctx->Driver.BeginConditionalRender(ctx, q, mode); +} + + +void GLAPIENTRY +_mesa_BeginConditionalRender_no_error(GLuint queryId, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + begin_conditional_render(ctx, queryId, mode, true); +} + + void GLAPIENTRY _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) { - struct gl_query_object *q; GET_CURRENT_CONTEXT(ctx); + /* 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); + begin_conditional_render(ctx, queryId, mode, false); +} - 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; - 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); +static void +end_conditional_render(struct gl_context *ctx) +{ + FLUSH_VERTICES(ctx, 0x0); - if (q->Target != GL_SAMPLES_PASSED) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); - return; - } + if (ctx->Driver.EndConditionalRender) + ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery); - ctx->Query.CondRenderQuery = q; - ctx->Query.CondRenderMode = mode; + ctx->Query.CondRenderQuery = NULL; + ctx->Query.CondRenderMode = GL_NONE; +} - if (ctx->Driver.BeginConditionalRender) - ctx->Driver.BeginConditionalRender(ctx, q, mode); + +void APIENTRY +_mesa_EndConditionalRender_no_error(void) +{ + GET_CURRENT_CONTEXT(ctx); + end_conditional_render(ctx); } @@ -90,18 +159,12 @@ _mesa_EndConditionalRender(void) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0x0); - if (!ctx->Extensions.NV_conditional_render || !ctx->Query.CondRenderQuery) { _mesa_error(ctx, GL_INVALID_OPERATION, "glEndConditionalRender()"); return; } - if (ctx->Driver.EndConditionalRender) - ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery); - - ctx->Query.CondRenderQuery = NULL; - ctx->Query.CondRenderMode = GL_NONE; + end_conditional_render(ctx); } @@ -135,14 +198,29 @@ _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()", - _mesa_lookup_enum_by_nr(ctx->Query.CondRenderMode)); + _mesa_enum_to_string(ctx->Query.CondRenderMode)); return GL_TRUE; } }