Paul Berry | 79134cb | 2014-01-06 15:08:04 -0800 | [diff] [blame] | 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" |
Jordan Justen | 4a1ba7e | 2015-09-17 10:05:22 -0700 | [diff] [blame] | 27 | #include "api_validate.h" |
Paul Berry | 79134cb | 2014-01-06 15:08:04 -0800 | [diff] [blame] | 28 | |
| 29 | void 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 Berry | 8f1423b | 2014-01-09 19:21:41 -0800 | [diff] [blame] | 35 | const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z }; |
Paul Berry | 79134cb | 2014-01-06 15:08:04 -0800 | [diff] [blame] | 36 | |
Jordan Justen | 1665d29 | 2015-09-24 00:19:58 -0700 | [diff] [blame] | 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 | |
Jordan Justen | 4a1ba7e | 2015-09-17 10:05:22 -0700 | [diff] [blame] | 41 | if (!_mesa_validate_DispatchCompute(ctx, num_groups)) |
| 42 | return; |
| 43 | |
Jordan Justen | f28d80f | 2016-02-16 08:21:22 -0800 | [diff] [blame] | 44 | if (num_groups_x == 0u || num_groups_y == 0u || num_groups_z == 0u) |
| 45 | return; |
| 46 | |
Jordan Justen | 4a1ba7e | 2015-09-17 10:05:22 -0700 | [diff] [blame] | 47 | ctx->Driver.DispatchCompute(ctx, num_groups); |
Paul Berry | 79134cb | 2014-01-06 15:08:04 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | extern void GLAPIENTRY |
| 51 | _mesa_DispatchComputeIndirect(GLintptr indirect) |
| 52 | { |
| 53 | GET_CURRENT_CONTEXT(ctx); |
| 54 | |
Jordan Justen | 1665d29 | 2015-09-24 00:19:58 -0700 | [diff] [blame] | 55 | if (MESA_VERBOSE & VERBOSE_API) |
Rhys Kidd | 83018f5 | 2015-09-30 23:18:52 +1000 | [diff] [blame] | 56 | _mesa_debug(ctx, "glDispatchComputeIndirect(%ld)\n", (long) indirect); |
Jordan Justen | 1665d29 | 2015-09-24 00:19:58 -0700 | [diff] [blame] | 57 | |
Jordan Justen | d11d018 | 2015-09-17 11:14:45 -0700 | [diff] [blame] | 58 | if (!_mesa_validate_DispatchComputeIndirect(ctx, indirect)) |
| 59 | return; |
| 60 | |
| 61 | ctx->Driver.DispatchComputeIndirect(ctx, indirect); |
Paul Berry | 79134cb | 2014-01-06 15:08:04 -0800 | [diff] [blame] | 62 | } |
Samuel Pitoiset | a063f30 | 2016-09-06 16:23:58 +0200 | [diff] [blame] | 63 | |
| 64 | void 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 Pitoiset | 45ab63c | 2016-09-07 21:52:08 +0200 | [diff] [blame] | 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 }; |
Samuel Pitoiset | a063f30 | 2016-09-06 16:23:58 +0200 | [diff] [blame] | 72 | |
Samuel Pitoiset | 45ab63c | 2016-09-07 21:52:08 +0200 | [diff] [blame] | 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); |
Samuel Pitoiset | a063f30 | 2016-09-06 16:23:58 +0200 | [diff] [blame] | 87 | } |