Skip to content

Commit 1a410ef

Browse files
authored
Flatten PrepassPipelineInternal into PrepassPipeline. (#19909)
# Objective - PrepassPipelineInternal used to exist to optimize compile time and binary size when PrepassPipeline was generic over the material. - After #19667, PrepassPipeline is no longer generic! ## Solution - Flatten all the fields of `PrepassPipelineInternal` into `PrepassPipeline`.
1 parent a949867 commit 1a410ef

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,9 @@ pub fn prepare_material_meshlet_meshes_prepass(
351351
shader_defs.push("MESHLET_MESH_MATERIAL_PASS".into());
352352

353353
let view_layout = if view_key.contains(MeshPipelineKey::MOTION_VECTOR_PREPASS) {
354-
prepass_pipeline.internal.view_layout_motion_vectors.clone()
354+
prepass_pipeline.view_layout_motion_vectors.clone()
355355
} else {
356-
prepass_pipeline
357-
.internal
358-
.view_layout_no_motion_vectors
359-
.clone()
356+
prepass_pipeline.view_layout_no_motion_vectors.clone()
360357
};
361358

362359
let fragment_shader = if view_key.contains(MeshPipelineKey::DEFERRED_PREPASS) {
@@ -381,7 +378,7 @@ pub fn prepare_material_meshlet_meshes_prepass(
381378
label: material_pipeline_descriptor.label,
382379
layout: vec![
383380
view_layout,
384-
prepass_pipeline.internal.empty_layout.clone(),
381+
prepass_pipeline.empty_layout.clone(),
385382
resource_manager.material_shade_bind_group_layout.clone(),
386383
material
387384
.properties

crates/bevy_pbr/src/prepass/mod.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ pub fn update_mesh_previous_global_transforms(
254254

255255
#[derive(Resource, Clone)]
256256
pub struct PrepassPipeline {
257-
pub internal: PrepassPipelineInternal,
258-
pub material_pipeline: MaterialPipeline,
259-
}
260-
261-
/// Internal fields of the `PrepassPipeline` that don't need the generic bound
262-
/// This is done as an optimization to not recompile the same code multiple time
263-
#[derive(Clone)]
264-
pub struct PrepassPipelineInternal {
265257
pub view_layout_motion_vectors: BindGroupLayout,
266258
pub view_layout_no_motion_vectors: BindGroupLayout,
267259
pub mesh_layouts: MeshLayouts,
@@ -277,6 +269,7 @@ pub struct PrepassPipelineInternal {
277269
/// Whether binding arrays (a.k.a. bindless textures) are usable on the
278270
/// current render device.
279271
pub binding_arrays_are_usable: bool,
272+
pub material_pipeline: MaterialPipeline,
280273
}
281274

282275
impl FromWorld for PrepassPipeline {
@@ -339,7 +332,7 @@ impl FromWorld for PrepassPipeline {
339332
let depth_clip_control_supported = render_device
340333
.features()
341334
.contains(WgpuFeatures::DEPTH_CLIP_CONTROL);
342-
let internal = PrepassPipelineInternal {
335+
PrepassPipeline {
343336
view_layout_motion_vectors,
344337
view_layout_no_motion_vectors,
345338
mesh_layouts: mesh_pipeline.mesh_layouts.clone(),
@@ -348,9 +341,6 @@ impl FromWorld for PrepassPipeline {
348341
depth_clip_control_supported,
349342
binding_arrays_are_usable: binding_arrays_are_usable(render_device, render_adapter),
350343
empty_layout: render_device.create_bind_group_layout("prepass_empty_layout", &[]),
351-
};
352-
PrepassPipeline {
353-
internal,
354344
material_pipeline: world.resource::<MaterialPipeline>().clone(),
355345
}
356346
}
@@ -373,12 +363,9 @@ impl SpecializedMeshPipeline for PrepassPipelineSpecializer {
373363
if self.properties.bindless {
374364
shader_defs.push("BINDLESS".into());
375365
}
376-
let mut descriptor = self.pipeline.internal.specialize(
377-
key.mesh_key,
378-
shader_defs,
379-
layout,
380-
&self.properties,
381-
)?;
366+
let mut descriptor =
367+
self.pipeline
368+
.specialize(key.mesh_key, shader_defs, layout, &self.properties)?;
382369

383370
// This is a bit risky because it's possible to change something that would
384371
// break the prepass but be fine in the main pass.
@@ -396,7 +383,7 @@ impl SpecializedMeshPipeline for PrepassPipelineSpecializer {
396383
}
397384
}
398385

399-
impl PrepassPipelineInternal {
386+
impl PrepassPipeline {
400387
fn specialize(
401388
&self,
402389
mesh_key: MeshPipelineKey,
@@ -726,7 +713,7 @@ impl FromWorld for PrepassViewBindGroup {
726713
let render_device = world.resource::<RenderDevice>();
727714
let empty_bind_group = render_device.create_bind_group(
728715
"prepass_view_empty_bind_group",
729-
&pipeline.internal.empty_layout,
716+
&pipeline.empty_layout,
730717
&[],
731718
);
732719
PrepassViewBindGroup {
@@ -753,7 +740,7 @@ pub fn prepare_prepass_view_bind_group(
753740
) {
754741
prepass_view_bind_group.no_motion_vectors = Some(render_device.create_bind_group(
755742
"prepass_view_no_motion_vectors_bind_group",
756-
&prepass_pipeline.internal.view_layout_no_motion_vectors,
743+
&prepass_pipeline.view_layout_no_motion_vectors,
757744
&BindGroupEntries::with_indices((
758745
(0, view_binding.clone()),
759746
(1, globals_binding.clone()),
@@ -764,7 +751,7 @@ pub fn prepare_prepass_view_bind_group(
764751
if let Some(previous_view_uniforms_binding) = previous_view_uniforms.uniforms.binding() {
765752
prepass_view_bind_group.motion_vectors = Some(render_device.create_bind_group(
766753
"prepass_view_motion_vectors_bind_group",
767-
&prepass_pipeline.internal.view_layout_motion_vectors,
754+
&prepass_pipeline.view_layout_motion_vectors,
768755
&BindGroupEntries::with_indices((
769756
(0, view_binding),
770757
(1, globals_binding),

0 commit comments

Comments
 (0)