Flutter Engine
The Flutter Engine
ComputeTypes.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_ComputeTypes_DEFINED
9#define skgpu_graphite_ComputeTypes_DEFINED
10
12
13namespace skgpu::graphite {
14
15// The maximum number of shared resource binding slots permitted for ComputeSteps of a DispatchGroup
16constexpr int kMaxComputeDataFlowSlots = 28;
17
18// The minimum element stride of an indirect dispatch argument array in bytes
20 uint32_t global_size_x;
21 uint32_t global_size_y;
22 uint32_t global_size_z;
23};
25
26/**
27 * Defines the space that a compute shader operates on. A problem space is logically divided into
28 * abstract "work groups" (or "thread groups" in Metal/D3D12).
29 *
30 * The "work group count" or "global size" of the work group is a 3-dimensional number that defines
31 * the size of the problem space. The user must provide the global size to define the number of
32 * work groups that execute as part of a dispatch.
33 *
34 * The local size of a work group defines the number of parallel execution units that run in that
35 * group. The local group size is defined in terms of the "raw number of threads" that run within
36 * the group.
37 *
38 * A local group is further divided into fixed-sized SIMD units called "subgroups" (in Vulkan
39 * terminology - these are referred to as "SIMD groups"/"threads" in Metal, "wavefronts" in OpenCL,
40 * "warps" in CUDA).
41 *
42 * The local size is defined in 3 dimensions and must be determined based on hardware limitations,
43 * which can be queried via Caps::maxComputeWorkgroupSize() (for each individual dimension) and
44 * Caps::maxComputeInvocationsPerWorkgroup().
45 *
46 * The WorkgroupSize type is used to represent both global size and local size.
47 */
49 WorkgroupSize() = default;
50 WorkgroupSize(uint32_t width, uint32_t height, uint32_t depth)
51 : fWidth(width)
53 , fDepth(depth) {}
54
55 uint32_t scalarSize() const { return fWidth * fHeight * fDepth; }
56
57 uint32_t fWidth = 1;
58 uint32_t fHeight = 1;
59 uint32_t fDepth = 1;
60};
61
62} // namespace skgpu::graphite
63
64#endif // skgpu_graphite_ComputeTypes_DEFINED
constexpr size_t kIndirectDispatchArgumentSize
Definition: ComputeTypes.h:24
constexpr int kMaxComputeDataFlowSlots
Definition: ComputeTypes.h:16
int32_t height
int32_t width
WorkgroupSize(uint32_t width, uint32_t height, uint32_t depth)
Definition: ComputeTypes.h:50