diff options
author | Samuel Pitoiset <[email protected]> | 2017-07-20 11:05:39 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-08-02 12:54:31 +0200 |
commit | e1750e0a179ff50a7c3603d1003445a608d4cb6c (patch) | |
tree | fabc36a6ebf62638f7e0abc4f2bd5910a2e5c196 /src/mesa/main/condrender.c | |
parent | 3f05193734c86750c7943e31949dc8c23c0e7d72 (diff) |
mesa: add begin_conditional_render() helper
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/condrender.c')
-rw-r--r-- | src/mesa/main/condrender.c | 121 |
1 files changed, 66 insertions, 55 deletions
diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c index 2ea2c8821d8..95d6d6ad5f0 100644 --- a/src/mesa/main/condrender.c +++ b/src/mesa/main/condrender.c @@ -37,80 +37,91 @@ #include "queryobj.h" -void GLAPIENTRY -_mesa_BeginConditionalRender(GLuint queryId, GLenum mode) +static ALWAYS_INLINE void +begin_conditional_render(struct gl_context *ctx, GLuint queryId, GLenum mode, + bool no_error) { struct gl_query_object *q = NULL; - 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); - /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: - * - * "The error INVALID_VALUE is generated if <id> 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); + if (!no_error) { + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: + * + * "The error INVALID_VALUE is generated if <id> 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) + 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 */ - /* fallthrough - invalid */ - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBeginConditionalRender(mode=%s)", - _mesa_enum_to_string(mode)); - return; + 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 <id> is the name of a + * query object with a target other than SAMPLES_PASSED, or <id> 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(GLuint queryId, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: * - * "The error INVALID_OPERATION is generated if <id> is the name of a - * query object with a target other than SAMPLES_PASSED, or <id> is the - * name of a query currently in progress." + * "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 ((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) { + if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) { _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); + begin_conditional_render(ctx, queryId, mode, false); } |