From 4a1ba7e6bd3ddcab4647a1382d14165a08c0d3b0 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Thu, 17 Sep 2015 10:05:22 -0700 Subject: mesa/cs: Add _mesa_validate_DispatchCompute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move API validation to _mesa_validate_DispatchCompute in api_validate.c. Signed-off-by: Jordan Justen Reviewed-by: Tapani Pälli Reviewed-by: Kristian Høgsberg --- src/mesa/main/api_validate.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/mesa/main/api_validate.c') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 53c8fb8..b46226a 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -882,3 +882,47 @@ _mesa_validate_MultiDrawElementsIndirect(struct gl_context *ctx, return GL_TRUE; } + +static bool +check_valid_to_compute(struct gl_context *ctx, const char *function) +{ + struct gl_shader_program *prog; + + if (!_mesa_has_compute_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "unsupported function (%s) called", + function); + return false; + } + + prog = ctx->Shader.CurrentProgram[MESA_SHADER_COMPUTE]; + if (prog == NULL || prog->_LinkedShaders[MESA_SHADER_COMPUTE] == NULL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(no active compute shader)", + function); + return false; + } + + return true; +} + +GLboolean +_mesa_validate_DispatchCompute(struct gl_context *ctx, + const GLuint *num_groups) +{ + int i; + FLUSH_CURRENT(ctx, 0); + + if (!check_valid_to_compute(ctx, "glDispatchCompute")) + return GL_FALSE; + + for (i = 0; i < 3; i++) { + if (num_groups[i] > ctx->Const.MaxComputeWorkGroupCount[i]) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glDispatchCompute(num_groups_%c)", 'x' + i); + return GL_FALSE; + } + } + + return GL_TRUE; +} -- cgit v1.1