blob: bb6253906bc53b11b05894a3a6a95548deb347e7 [file] [log] [blame]
Paul Berry79134cb2014-01-06 15:08:04 -08001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "glheader.h"
25#include "compute.h"
26#include "context.h"
Jordan Justen4a1ba7e2015-09-17 10:05:22 -070027#include "api_validate.h"
Paul Berry79134cb2014-01-06 15:08:04 -080028
29void GLAPIENTRY
30_mesa_DispatchCompute(GLuint num_groups_x,
31 GLuint num_groups_y,
32 GLuint num_groups_z)
33{
34 GET_CURRENT_CONTEXT(ctx);
Paul Berry8f1423b2014-01-09 19:21:41 -080035 const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
Paul Berry79134cb2014-01-06 15:08:04 -080036
Jordan Justen1665d292015-09-24 00:19:58 -070037 if (MESA_VERBOSE & VERBOSE_API)
38 _mesa_debug(ctx, "glDispatchCompute(%d, %d, %d)\n",
39 num_groups_x, num_groups_y, num_groups_z);
40
Jordan Justen4a1ba7e2015-09-17 10:05:22 -070041 if (!_mesa_validate_DispatchCompute(ctx, num_groups))
42 return;
43
Jordan Justenf28d80f2016-02-16 08:21:22 -080044 if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u)
45 return;
46
Jordan Justen4a1ba7e2015-09-17 10:05:22 -070047 ctx->Driver.DispatchCompute(ctx, num_groups);
Paul Berry79134cb2014-01-06 15:08:04 -080048}
49
50extern void GLAPIENTRY
51_mesa_DispatchComputeIndirect(GLintptr indirect)
52{
53 GET_CURRENT_CONTEXT(ctx);
54
Jordan Justen1665d292015-09-24 00:19:58 -070055 if (MESA_VERBOSE & VERBOSE_API)
Rhys Kidd83018f52015-09-30 23:18:52 +100056 _mesa_debug(ctx, "glDispatchComputeIndirect(%ld)\n", (long) indirect);
Jordan Justen1665d292015-09-24 00:19:58 -070057
Jordan Justend11d0182015-09-17 11:14:45 -070058 if (!_mesa_validate_DispatchComputeIndirect(ctx, indirect))
59 return;
60
61 ctx->Driver.DispatchComputeIndirect(ctx, indirect);
Paul Berry79134cb2014-01-06 15:08:04 -080062}
Samuel Pitoiseta063f302016-09-06 16:23:58 +020063
64void GLAPIENTRY
65_mesa_DispatchComputeGroupSizeARB(GLuint num_groups_x, GLuint num_groups_y,
66 GLuint num_groups_z, GLuint group_size_x,
67 GLuint group_size_y, GLuint group_size_z)
68{
Samuel Pitoiset45ab63c2016-09-07 21:52:08 +020069 GET_CURRENT_CONTEXT(ctx);
70 const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
71 const GLuint group_size[3] = { group_size_x, group_size_y, group_size_z };
Samuel Pitoiseta063f302016-09-06 16:23:58 +020072
Samuel Pitoiset45ab63c2016-09-07 21:52:08 +020073 if (MESA_VERBOSE & VERBOSE_API)
74 _mesa_debug(ctx,
75 "glDispatchComputeGroupSizeARB(%d, %d, %d, %d, %d, %d)\n",
76 num_groups_x, num_groups_y, num_groups_z,
77 group_size_x, group_size_y, group_size_z);
78
79 if (!_mesa_validate_DispatchComputeGroupSizeARB(ctx, num_groups,
80 group_size))
81 return;
82
83 if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u)
84 return;
85
86 ctx->Driver.DispatchComputeGroupSize(ctx, num_groups, group_size);
Samuel Pitoiseta063f302016-09-06 16:23:58 +020087}