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