1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! GPU-driven culling service published to plugins.
//!
//! A plugin that submits its own instanced geometry can run the lib's
//! frustum-cull compute against its instance AABB buffer to get a compacted
//! visibility list and a `DrawIndexedIndirect` entry suitable for
//! `draw_indexed_indirect`.
//!
//! [`CullSubmission`] carries the buffers for a multi-batch cull: one big
//! AABB list, one [`BatchMeta`] entry per batch, one atomic counter slot per
//! batch, and one indirect-draw entry per batch. Plugins with many meshes
//! pack them all into one submission so the renderer dispatches the compute
//! pass once for the whole group.
//!
//! For the common one-mesh-N-instances case, see
//! [`crate::renderer::ViewportRenderer::submit_cull_single_mesh`]. It takes
//! the per-mesh draw parameters directly and fills the lib's scratch meta +
//! counter buffers for you.
//!
//! Submit via [`crate::renderer::ViewportRenderer::submit_cull`] or
//! [`crate::renderer::ViewportRenderer::submit_cull_shadow`].
pub use crateBatchMeta;
/// Per-instance world-space bounding box for GPU culling.
///
/// Plugin code builds an `array<InstanceAabb>` storage buffer, one entry per
/// drawable instance, and passes it via [`CullSubmission::instance_aabbs`].
///
/// Layout matches the cull shader's contract (32 bytes per entry).
/// `batch_index` selects which [`BatchMeta`] entry the instance belongs to;
/// for a single-batch submission set it to 0. `cast_shadows` is honoured
/// when [`CullSubmission::shadow_pass`] is `true` or the submission goes
/// through `submit_cull_shadow`.
const _: = assert!;
/// Inputs to one cull dispatch.
///
/// Buffer requirements:
///
/// - `instance_aabbs`: `STORAGE`. `instance_count` x [`InstanceAabb`].
/// - `batch_meta`: `STORAGE`. `batch_count` x [`BatchMeta`].
/// - `counter`: `STORAGE`. `batch_count` x `u32`, used as atomic counters.
/// The renderer zeroes this slot before the dispatch.
/// - `visible_out`: `STORAGE`. Holds up to `instance_count` x `u32`, the
/// compacted list of visible instance indices written by the cull pass.
/// - `indirect_out`: `STORAGE | INDIRECT`. `batch_count` x
/// `DrawIndexedIndirect` (20 bytes per entry). The static fields
/// (`index_count`, `first_index`, `base_vertex`, `first_instance`) come
/// from the matching [`BatchMeta`] entry; `instance_count` is overwritten
/// by the cull pass.
///
/// After the encoder runs, draw each batch with
/// `pass.draw_indexed_indirect(indirect_out, batch_idx * 20)` using
/// `visible_out` as the per-instance lookup buffer.
/// Draw parameters for a one-mesh-N-instances submission.
///
/// Passed to [`crate::renderer::ViewportRenderer::submit_cull_single_mesh`]
/// when a plugin only has one mesh to cull. The renderer fills its scratch
/// `BatchMeta` and counter slots from these fields, so the plugin does not
/// have to allocate either buffer.