• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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"
27 #include "api_validate.h"
28 
29 void GLAPIENTRY
_mesa_DispatchCompute(GLuint num_groups_x,GLuint num_groups_y,GLuint num_groups_z)30 _mesa_DispatchCompute(GLuint num_groups_x,
31                       GLuint num_groups_y,
32                       GLuint num_groups_z)
33 {
34    GET_CURRENT_CONTEXT(ctx);
35    const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
36 
37    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 
41    if (!_mesa_validate_DispatchCompute(ctx, num_groups))
42       return;
43 
44    if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u)
45        return;
46 
47    ctx->Driver.DispatchCompute(ctx, num_groups);
48 }
49 
50 extern void GLAPIENTRY
_mesa_DispatchComputeIndirect(GLintptr indirect)51 _mesa_DispatchComputeIndirect(GLintptr indirect)
52 {
53    GET_CURRENT_CONTEXT(ctx);
54 
55    if (MESA_VERBOSE & VERBOSE_API)
56       _mesa_debug(ctx, "glDispatchComputeIndirect(%ld)\n", (long) indirect);
57 
58    if (!_mesa_validate_DispatchComputeIndirect(ctx, indirect))
59       return;
60 
61    ctx->Driver.DispatchComputeIndirect(ctx, indirect);
62 }
63 
64 void GLAPIENTRY
_mesa_DispatchComputeGroupSizeARB(GLuint num_groups_x,GLuint num_groups_y,GLuint num_groups_z,GLuint group_size_x,GLuint group_size_y,GLuint group_size_z)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 {
69    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 };
72 
73    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);
87 }
88