Blender V5.3
draw_mesh_to_corner.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
13
14#pragma once
15
16#include "draw_defines.hh"
17
19#include "gpu_shader_compat.hh"
20
21namespace draw::mesh {
22
27
28template<typename T> struct GatherResources {
29 [[storage(0, read)]] const T (&src)[];
31 [[storage(1, read)]] const int (&indices)[];
32 [[storage(2, write)]] T (&dst)[];
33
34 [[push_constant]] const int start;
35 [[push_constant]] const int count;
36};
37
38template struct GatherResources<StoredUint>;
39template struct GatherResources<StoredUint2>;
40template struct GatherResources<StoredUint3>;
41template struct GatherResources<StoredUint4>;
42
44template<typename T>
47 [[global_invocation_id]] const uint3 global_id)
48{
49 if (global_id.x >= uint(srt.count)) {
50 return;
51 }
52 const uint i = uint(srt.start) + global_id.x;
53 srt.dst[i] = srt.src[srt.indices[i]];
54}
55
60
61template<typename T> struct ScatterFacesResources {
62 [[storage(0, read)]] const T (&src)[];
64 [[storage(1, read)]] const uint (&face_offsets)[];
65 [[storage(2, write)]] T (&dst)[];
66
67 [[push_constant]] const int start;
68 [[push_constant]] const int count;
69};
70
75
77template<typename T>
80 [[global_invocation_id]] const uint3 global_id)
81{
82 if (global_id.x >= uint(srt.count)) {
83 return;
84 }
85 const uint face = uint(srt.start) + global_id.x;
86 const T value = srt.src[face];
87 for (uint corner = srt.face_offsets[face]; corner < srt.face_offsets[face + 1]; corner++) {
88 srt.dst[corner] = value;
89 }
90}
91
96
105
106} // namespace draw::mesh
#define DRW_MESH_TO_CORNER_GROUP_SIZE
#define storage(slot, qualifiers)
#define push_constant
#define resource_table
#define global_invocation_id
#define compute
#define local_size(...)
#define T
PipelineCompute gather_12(gather_main< StoredUint3 >)
void scatter_faces_main(ScatterFacesResources< T > &srt, const uint3 global_id)
PipelineCompute scatter_faces_4(scatter_faces_main< StoredUint >)
PipelineCompute gather_16(gather_main< StoredUint4 >)
PipelineCompute scatter_faces_12(scatter_faces_main< StoredUint3 >)
PipelineCompute scatter_faces_8(scatter_faces_main< StoredUint2 >)
PipelineCompute scatter_faces_16(scatter_faces_main< StoredUint4 >)
void gather_main(GatherResources< T > &srt, const uint3 global_id)
PipelineCompute gather_4(gather_main< StoredUint >)
PipelineCompute gather_8(gather_main< StoredUint2 >)