1+ use bevy_asset:: Handle ;
2+ use bevy_ecs:: resource:: Resource ;
13use bevy_mesh:: BaseMeshPipelineKey ;
2- use crate :: render_resource:: * ;
4+ use bevy_shader:: Shader ;
5+ use crate :: { render:: { MeshLayouts , MeshPipelineViewLayout , MeshPipelineViewLayoutKey , MeshPipelineViewLayouts } , render_resource:: * } ;
36
47use static_assertions:: const_assert_eq;
58
@@ -16,7 +19,50 @@ use static_assertions::const_assert_eq;
1619pub const MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES : usize = 10 ;
1720
1821
19- // pub struct MeshPipeline {
22+ /// All data needed to construct a pipeline for rendering 3D meshes.
23+ #[ derive( Resource , Clone ) ]
24+ pub struct MeshPipeline {
25+ /// A reference to all the mesh pipeline view layouts.
26+ pub view_layouts : MeshPipelineViewLayouts ,
27+ pub clustered_forward_buffer_binding_type : BufferBindingType ,
28+ pub mesh_layouts : MeshLayouts ,
29+ /// The shader asset handle.
30+ pub shader : Handle < Shader > ,
31+ /// `MeshUniform`s are stored in arrays in buffers. If storage buffers are available, they
32+ /// are used and this will be `None`, otherwise uniform buffers will be used with batches
33+ /// of this many `MeshUniform`s, stored at dynamic offsets within the uniform buffer.
34+ /// Use code like this in custom shaders:
35+ /// ```wgsl
36+ /// ##ifdef PER_OBJECT_BUFFER_BATCH_SIZE
37+ /// @group(1) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
38+ /// ##else
39+ /// @group(1) @binding(0) var<storage> mesh: array<Mesh>;
40+ /// ##endif // PER_OBJECT_BUFFER_BATCH_SIZE
41+ /// ```
42+ pub per_object_buffer_batch_size : Option < u32 > ,
43+
44+ /// Whether binding arrays (a.k.a. bindless textures) are usable on the
45+ /// current render device.
46+ ///
47+ /// This affects whether reflection probes can be used.
48+ pub binding_arrays_are_usable : bool ,
49+
50+ /// Whether clustered decals are usable on the current render device.
51+ pub clustered_decals_are_usable : bool ,
52+
53+ /// Whether skins will use uniform buffers on account of storage buffers
54+ /// being unavailable on this platform.
55+ pub skins_use_uniform_buffers : bool ,
56+ }
57+
58+ impl MeshPipeline {
59+ pub fn get_view_layout (
60+ & self ,
61+ layout_key : MeshPipelineViewLayoutKey ,
62+ ) -> & MeshPipelineViewLayout {
63+ self . view_layouts . get_view_layout ( layout_key)
64+ }
65+ }
2066
2167bitflags:: bitflags! {
2268 #[ derive( Default , Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
0 commit comments