1// Types needed for GPU mesh uniform building.3#define_import_path bevy_pbr::mesh_preprocess_types5// Per-frame data that the CPU supplies to the GPU.6struct MeshInput {7 // The model transform.8 world_from_local: mat3x4<f32>,9 // The lightmap UV rect, packed into 64 bits.10 lightmap_uv_rect: vec2<u32>,11 // Various flags.12 flags: u32,13 previous_input_index: u32,14 first_vertex_index: u32,15 first_index_index: u32,16 index_count: u32,17 current_skin_index: u32,18 // Low 16 bits: index of the material inside the bind group data.19 // High 16 bits: index of the lightmap in the binding array.20 material_and_lightmap_bind_group_slot: u32,21 timestamp: u32,22 // User supplied index to identify the mesh instance23 tag: u32,24 // The index of the morph descriptor for this mesh instance in the25 // `morph_descriptors` table.26 //27 // If the mesh has no morph targets, this is `u32::MAX`.28 morph_descriptor_index: u32,29}31// The `wgpu` indirect parameters structure. This is a union of two structures.32// For more information, see the corresponding comment in33// `gpu_preprocessing.rs`.34struct IndirectParametersIndexed {35 // `vertex_count` or `index_count`.36 index_count: u32,37 // `instance_count` in both structures.38 instance_count: u32,39 // `first_vertex` or `first_index`.40 first_index: u32,41 // `base_vertex` or `first_instance`.42 base_vertex: u32,43 // A read-only copy of `instance_index`.44 first_instance: u32,45}47struct IndirectParametersNonIndexed {48 vertex_count: u32,49 instance_count: u32,50 base_vertex: u32,51 first_instance: u32,52}54struct IndirectParametersCpuMetadata {55 base_output_index: u32,56 batch_set_index: u32,57}59struct IndirectParametersGpuMetadata {60 mesh_index: u32,61#ifdef WRITE_INDIRECT_PARAMETERS_METADATA62 early_instance_count: atomic<u32>,63 late_instance_count: atomic<u32>,64#else // WRITE_INDIRECT_PARAMETERS_METADATA65 early_instance_count: u32,66 late_instance_count: u32,67#endif // WRITE_INDIRECT_PARAMETERS_METADATA68}70struct IndirectBatchSet {71 indirect_parameters_count: atomic<u32>,72 indirect_parameters_base: u32,73}75// One invocation of this compute shader: i.e. one mesh instance in a view.76struct PreprocessWorkItem {77 // The index of the `MeshInput` in the `current_input` buffer that we read78 // from.79 input_index: u32,80 // In direct mode, the index of the `Mesh` in `output` that we write to. In81 // indirect mode, the index of the `IndirectParameters` in82 // `indirect_parameters` that we write to.83 output_or_indirect_parameters_index: u32,84}