mesa/cs: Add dispatch API stubs for ARB_compute_shader.
authorPaul Berry <stereotype441@gmail.com>
Mon, 6 Jan 2014 23:08:04 +0000 (15:08 -0800)
committerPaul Berry <stereotype441@gmail.com>
Wed, 5 Feb 2014 17:00:14 +0000 (09:00 -0800)
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mapi/glapi/gen/ARB_compute_shader.xml [new file with mode: 0644]
src/mapi/glapi/gen/Makefile.am
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/gl_genexec.py
src/mesa/Makefile.sources
src/mesa/SConscript
src/mesa/main/compute.c [new file with mode: 0644]
src/mesa/main/compute.h [new file with mode: 0644]
src/mesa/main/tests/dispatch_sanity.cpp

diff --git a/src/mapi/glapi/gen/ARB_compute_shader.xml b/src/mapi/glapi/gen/ARB_compute_shader.xml
new file mode 100644 (file)
index 0000000..1db373e
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+
+<OpenGLAPI>
+
+<category name="GL_ARB_compute_shader" number="122">
+  <enum name="COMPUTE_SHADER"                                  value="0x91B9"/>
+  <enum name="MAX_COMPUTE_UNIFORM_BLOCKS"                      value="0x91BB"/>
+  <enum name="MAX_COMPUTE_TEXTURE_IMAGE_UNITS"                 value="0x91BC"/>
+  <enum name="MAX_COMPUTE_IMAGE_UNIFORMS"                      value="0x91BD"/>
+  <enum name="MAX_COMPUTE_SHARED_MEMORY_SIZE"                  value="0x8262"/>
+  <enum name="MAX_COMPUTE_UNIFORM_COMPONENTS"                  value="0x8263"/>
+  <enum name="MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"              value="0x8264"/>
+  <enum name="MAX_COMPUTE_ATOMIC_COUNTERS"                     value="0x8265"/>
+  <enum name="MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"         value="0x8266"/>
+  <enum name="MAX_COMPUTE_WORK_GROUP_INVOCATIONS"              value="0x90EB"/>
+  <enum name="MAX_COMPUTE_WORK_GROUP_COUNT"                    value="0x91BE"/>
+  <enum name="MAX_COMPUTE_WORK_GROUP_SIZE"                     value="0x91BF"/>
+  <enum name="COMPUTE_WORK_GROUP_SIZE"                         value="0x8267"/>
+  <enum name="UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER"      value="0x90EC"/>
+  <enum name="ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER"  value="0x90ED"/>
+  <enum name="DISPATCH_INDIRECT_BUFFER"                        value="0x90EE"/>
+  <enum name="DISPATCH_INDIRECT_BUFFER_BINDING"                value="0x90EF"/>
+  <enum name="COMPUTE_SHADER_BIT"                              value="0x00000020"/>
+
+  <function name="DispatchCompute" offset="assign">
+    <param name="num_groups_x" type="GLuint"/>
+    <param name="num_groups_y" type="GLuint"/>
+    <param name="num_groups_z" type="GLuint"/>
+  </function>
+
+  <function name="DispatchComputeIndirect" offset="assign">
+    <param name="indirect" type="GLintptr"/>
+  </function>
+</category>
+
+</OpenGLAPI>
index 7354725df9cc75788036c711090c73f6b4ed77fa..9e6fe52612f65dedff6f8bc4c196438b9ac04957 100644 (file)
@@ -91,6 +91,7 @@ API_XML = \
        ARB_base_instance.xml \
        ARB_blend_func_extended.xml \
        ARB_color_buffer_float.xml \
+       ARB_compute_shader.xml \
        ARB_copy_buffer.xml \
        ARB_debug_output.xml \
        ARB_depth_buffer_float.xml \
index 193ee370c0dd497ca6115762ab95efc9e7c2a912..0715bbf817640337b52bae5a5d0ac229f164a101 100644 (file)
 
 <xi:include href="ARB_clear_buffer_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
-<!-- ARB extensions #122...#123 -->
+<xi:include href="ARB_compute_shader.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+<!-- ARB extension #123 -->
 
 <xi:include href="ARB_texture_view.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
index 982286a3c12dc6924ab1283d5627f1eb1fafec6b..1765a51ad26cd00efe01525fb9122c7537cc980b 100644 (file)
@@ -58,6 +58,7 @@ header = """/**
 #include "main/clear.h"
 #include "main/clip.h"
 #include "main/colortab.h"
+#include "main/compute.h"
 #include "main/condrender.h"
 #include "main/context.h"
 #include "main/convolve.h"
index 3cdcae21368d229ddfc662c21e66751006d6a83e..bd02d3ee802225816f519cf0e10ef01d4d07f2c1 100644 (file)
@@ -24,6 +24,7 @@ MAIN_FILES = \
        $(SRCDIR)main/clear.c \
        $(SRCDIR)main/clip.c \
        $(SRCDIR)main/colortab.c \
+       $(SRCDIR)main/compute.c \
        $(SRCDIR)main/condrender.c \
        $(SRCDIR)main/context.c \
        $(SRCDIR)main/convolve.c \
index 5b3358d5bedd3a074dd67c673306ba74a5cf1e2f..b52bbdc23d45b0a1604465ca8ef5f72b027c1447 100644 (file)
@@ -52,6 +52,7 @@ main_sources = [
     'main/clear.c',
     'main/clip.c',
     'main/colortab.c',
+    'main/compute.c',
     'main/condrender.c',
     'main/context.c',
     'main/convolve.c',
diff --git a/src/mesa/main/compute.c b/src/mesa/main/compute.c
new file mode 100644 (file)
index 0000000..5756666
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "compute.h"
+#include "context.h"
+
+void GLAPIENTRY
+_mesa_DispatchCompute(GLuint num_groups_x,
+                      GLuint num_groups_y,
+                      GLuint num_groups_z)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (ctx->Extensions.ARB_compute_shader) {
+      assert(!"TODO");
+   } else {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "unsupported function (glDispatchCompute) called");
+   }
+}
+
+extern void GLAPIENTRY
+_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");
+   }
+}
diff --git a/src/mesa/main/compute.h b/src/mesa/main/compute.h
new file mode 100644 (file)
index 0000000..0cc034f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef COMPUTE_H
+#define COMPUTE_H
+
+
+#include "glheader.h"
+
+extern void GLAPIENTRY
+_mesa_DispatchCompute(GLuint num_groups_x,
+                      GLuint num_groups_y,
+                      GLuint num_groups_z);
+
+extern void GLAPIENTRY
+_mesa_DispatchComputeIndirect(GLintptr indirect);
+
+#endif
index 78a218ea17b09fdb15c870bb694f1adc5369e635..d8969e268b90bfac27e36f5e9609706dec8ab538 100644 (file)
@@ -850,8 +850,8 @@ const struct function gl_core_functions_possible[] = {
    { "glClearBufferSubData", 43, -1 },
 // { "glClearNamedBufferDataEXT", 43, -1 },             // XXX: Add to xml
 // { "glClearNamedBufferSubDataEXT", 43, -1 },          // XXX: Add to xml
-// { "glDispatchCompute", 43, -1 },                     // XXX: Add to xml
-// { "glDispatchComputeIndirect", 43, -1 },             // XXX: Add to xml
+   { "glDispatchCompute", 43, -1 },
+   { "glDispatchComputeIndirect", 43, -1 },
 // { "glCopyImageSubData", 43, -1 },                    // XXX: Add to xml
    { "glTextureView", 43, -1 },
    { "glBindVertexBuffer", 43, -1 },