summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2015-09-17 11:14:45 -0700
committerJordan Justen <jordan.l.justen@intel.com>2015-09-24 19:15:13 -0700
commitd11d018ce38b76a580242d64e61e8e30dad035e8 (patch)
treefe4af75361501903afe069991ac214c5dabe53a0 /src/mesa
parent12cf91db0236291ebaff71f602d929064b1ec096 (diff)
downloadexternal_mesa3d-d11d018ce38b76a580242d64e61e8e30dad035e8.zip
external_mesa3d-d11d018ce38b76a580242d64e61e8e30dad035e8.tar.gz
external_mesa3d-d11d018ce38b76a580242d64e61e8e30dad035e8.tar.bz2
mesa/cs: Implement glDispatchComputeIndirect
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/api_validate.c64
-rw-r--r--src/mesa/main/api_validate.h4
-rw-r--r--src/mesa/main/compute.c10
-rw-r--r--src/mesa/main/dd.h1
4 files changed, 73 insertions, 6 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index b46226a..a46c194 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -926,3 +926,67 @@ _mesa_validate_DispatchCompute(struct gl_context *ctx,
return GL_TRUE;
}
+
+static GLboolean
+valid_dispatch_indirect(struct gl_context *ctx,
+ GLintptr indirect,
+ GLsizei size, const char *name)
+{
+ GLintptr end = (GLintptr)indirect + size;
+
+ if (!check_valid_to_compute(ctx, name))
+ return GL_FALSE;
+
+ /* From the ARB_compute_shader specification:
+ *
+ * "An INVALID_OPERATION error is generated [...] if <indirect> is less
+ * than zero or not a multiple of the size, in basic machine units, of
+ * uint."
+ */
+ if ((GLintptr)indirect & (sizeof(GLuint) - 1)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(indirect is not aligned)", name);
+ return GL_FALSE;
+ }
+
+ if ((GLintptr)indirect < 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(indirect is less than zero)", name);
+ return GL_FALSE;
+ }
+
+ if (!_mesa_is_bufferobj(ctx->DispatchIndirectBuffer)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s: no buffer bound to DISPATCH_INDIRECT_BUFFER", name);
+ return GL_FALSE;
+ }
+
+ if (_mesa_check_disallowed_mapping(ctx->DispatchIndirectBuffer)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(DISPATCH_INDIRECT_BUFFER is mapped)", name);
+ return GL_FALSE;
+ }
+
+ /* From the ARB_compute_shader specification:
+ *
+ * "An INVALID_OPERATION error is generated if this command sources data
+ * beyond the end of the buffer object [...]"
+ */
+ if (ctx->DispatchIndirectBuffer->Size < end) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(DISPATCH_INDIRECT_BUFFER too small)", name);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+_mesa_validate_DispatchComputeIndirect(struct gl_context *ctx,
+ GLintptr indirect)
+{
+ FLUSH_CURRENT(ctx, 0);
+
+ return valid_dispatch_indirect(ctx, indirect, 3 * sizeof(GLuint),
+ "glDispatchComputeIndirect");
+}
diff --git a/src/mesa/main/api_validate.h b/src/mesa/main/api_validate.h
index ef2c794..5d030a7 100644
--- a/src/mesa/main/api_validate.h
+++ b/src/mesa/main/api_validate.h
@@ -109,5 +109,9 @@ extern GLboolean
_mesa_validate_DispatchCompute(struct gl_context *ctx,
const GLuint *num_groups);
+extern GLboolean
+_mesa_validate_DispatchComputeIndirect(struct gl_context *ctx,
+ GLintptr indirect);
+
#endif
diff --git a/src/mesa/main/compute.c b/src/mesa/main/compute.c
index f67ffbb..a0120cf 100644
--- a/src/mesa/main/compute.c
+++ b/src/mesa/main/compute.c
@@ -45,10 +45,8 @@ _mesa_DispatchComputeIndirect(GLintptr indirect)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->Extensions.ARB_compute_shader) {
- assert(!"TODO");
- } else {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "unsupported function (glDispatchComputeIndirect) called");
- }
+ if (!_mesa_validate_DispatchComputeIndirect(ctx, indirect))
+ return;
+
+ ctx->Driver.DispatchComputeIndirect(ctx, indirect);
}
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 2c746fc..88f3727 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1021,6 +1021,7 @@ struct dd_function_table {
*/
/*@{*/
void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
+ void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr indirect);
/*@}*/
};