Skip to content

Commit 9ee0cb6

Browse files
committed
Move RenderMeshInstances, RenderMeshInstancesCpu, RenderMeshInstancesGpu, RenderMeshQueueData to bevy_render
1 parent 8b0f22e commit 9ee0cb6

File tree

8 files changed

+849
-797
lines changed

8 files changed

+849
-797
lines changed

crates/bevy_internal/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ android-game-activity = ["bevy_winit/android-game-activity"]
145145

146146
# Transmission textures in `StandardMaterial`:
147147
pbr_transmission_textures = [
148+
"bevy_render?/pbr_transmission_textures",
148149
"bevy_pbr?/pbr_transmission_textures",
149150
"bevy_gltf?/pbr_transmission_textures",
150151
]
@@ -154,27 +155,34 @@ pbr_clustered_decals = ["bevy_pbr?/pbr_clustered_decals"]
154155

155156
# Light Texture support
156157
pbr_light_textures = [
158+
"bevy_render?/pbr_light_textures",
157159
"bevy_pbr?/pbr_clustered_decals",
158160
"bevy_pbr?/pbr_light_textures",
159161
]
160162

161163
# Multi-layer material textures in `StandardMaterial`:
162164
pbr_multi_layer_material_textures = [
165+
"bevy_render?/pbr_multi_layer_material_textures",
163166
"bevy_pbr?/pbr_multi_layer_material_textures",
164167
"bevy_gltf?/pbr_multi_layer_material_textures",
165168
]
166169

167170
# Anisotropy texture in `StandardMaterial`:
168171
pbr_anisotropy_texture = [
172+
"bevy_render?/pbr_anisotropy_texture",
169173
"bevy_pbr?/pbr_anisotropy_texture",
170174
"bevy_gltf?/pbr_anisotropy_texture",
171175
]
172176

173177
# Percentage-closer soft shadows
174-
experimental_pbr_pcss = ["bevy_pbr?/experimental_pbr_pcss"]
178+
experimental_pbr_pcss = [
179+
"bevy_render?/experimental_pbr_pcss",
180+
"bevy_pbr?/experimental_pbr_pcss",
181+
]
175182

176183
# Specular textures in `StandardMaterial`:
177184
pbr_specular_textures = [
185+
"bevy_render?/pbr_specular_textures",
178186
"bevy_pbr?/pbr_specular_textures",
179187
"bevy_gltf?/pbr_specular_textures",
180188
]

crates/bevy_material/src/render/mesh.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
use bevy_asset::Handle;
2+
use bevy_ecs::resource::Resource;
13
use bevy_mesh::BaseMeshPipelineKey;
2-
use crate::render_resource::*;
4+
use bevy_shader::Shader;
5+
use crate::{render::{MeshLayouts, MeshPipelineViewLayout, MeshPipelineViewLayoutKey, MeshPipelineViewLayouts}, render_resource::*};
36

47
use static_assertions::const_assert_eq;
58

@@ -16,7 +19,50 @@ use static_assertions::const_assert_eq;
1619
pub 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

2167
bitflags::bitflags! {
2268
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Hash)]

crates/bevy_pbr/src/prepass/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod prepass_bindings;
33
use crate::{
44
alpha_mode_pipeline_key, binding_arrays_are_usable, buffer_layout,
55
collect_meshes_for_gpu_building, init_material_pipeline, set_mesh_motion_vector_flags,
6-
setup_morph_and_skinning_defs, skin, DeferredDrawFunction, DeferredFragmentShader,
6+
skin, DeferredDrawFunction, DeferredFragmentShader,
77
DeferredVertexShader, DrawMesh, EntitySpecializationTicks, ErasedMaterialPipelineKey,
88
MaterialPipeline, MaterialProperties, MeshLayouts, MeshPipeline, MeshPipelineKey,
99
OpaqueRendererMethod, PreparedMaterial, PrepassDrawFunction, PrepassFragmentShader,
@@ -27,7 +27,7 @@ use bevy_render::{
2727
alpha::AlphaMode,
2828
batching::gpu_preprocessing::GpuPreprocessingSupport,
2929
globals::{GlobalsBuffer, GlobalsUniform},
30-
mesh::{allocator::MeshAllocator, RenderMesh},
30+
mesh::{allocator::MeshAllocator, pipeline::setup_morph_and_skinning_defs, RenderMesh},
3131
render_asset::{prepare_assets, RenderAssets},
3232
render_phase::*,
3333
render_resource::{binding_types::uniform_buffer, *},

0 commit comments

Comments
 (0)