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`.
This commit is contained in:
parent
a949867a1c
commit
1a410efd24
@ -351,12 +351,9 @@ pub fn prepare_material_meshlet_meshes_prepass(
|
|||||||
shader_defs.push("MESHLET_MESH_MATERIAL_PASS".into());
|
shader_defs.push("MESHLET_MESH_MATERIAL_PASS".into());
|
||||||
|
|
||||||
let view_layout = if view_key.contains(MeshPipelineKey::MOTION_VECTOR_PREPASS) {
|
let view_layout = if view_key.contains(MeshPipelineKey::MOTION_VECTOR_PREPASS) {
|
||||||
prepass_pipeline.internal.view_layout_motion_vectors.clone()
|
prepass_pipeline.view_layout_motion_vectors.clone()
|
||||||
} else {
|
} else {
|
||||||
prepass_pipeline
|
prepass_pipeline.view_layout_no_motion_vectors.clone()
|
||||||
.internal
|
|
||||||
.view_layout_no_motion_vectors
|
|
||||||
.clone()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let fragment_shader = if view_key.contains(MeshPipelineKey::DEFERRED_PREPASS) {
|
let fragment_shader = if view_key.contains(MeshPipelineKey::DEFERRED_PREPASS) {
|
||||||
@ -381,7 +378,7 @@ pub fn prepare_material_meshlet_meshes_prepass(
|
|||||||
label: material_pipeline_descriptor.label,
|
label: material_pipeline_descriptor.label,
|
||||||
layout: vec![
|
layout: vec![
|
||||||
view_layout,
|
view_layout,
|
||||||
prepass_pipeline.internal.empty_layout.clone(),
|
prepass_pipeline.empty_layout.clone(),
|
||||||
resource_manager.material_shade_bind_group_layout.clone(),
|
resource_manager.material_shade_bind_group_layout.clone(),
|
||||||
material
|
material
|
||||||
.properties
|
.properties
|
||||||
|
@ -254,14 +254,6 @@ pub fn update_mesh_previous_global_transforms(
|
|||||||
|
|
||||||
#[derive(Resource, Clone)]
|
#[derive(Resource, Clone)]
|
||||||
pub struct PrepassPipeline {
|
pub struct PrepassPipeline {
|
||||||
pub internal: PrepassPipelineInternal,
|
|
||||||
pub material_pipeline: MaterialPipeline,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Internal fields of the `PrepassPipeline` that don't need the generic bound
|
|
||||||
/// This is done as an optimization to not recompile the same code multiple time
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PrepassPipelineInternal {
|
|
||||||
pub view_layout_motion_vectors: BindGroupLayout,
|
pub view_layout_motion_vectors: BindGroupLayout,
|
||||||
pub view_layout_no_motion_vectors: BindGroupLayout,
|
pub view_layout_no_motion_vectors: BindGroupLayout,
|
||||||
pub mesh_layouts: MeshLayouts,
|
pub mesh_layouts: MeshLayouts,
|
||||||
@ -277,6 +269,7 @@ pub struct PrepassPipelineInternal {
|
|||||||
/// Whether binding arrays (a.k.a. bindless textures) are usable on the
|
/// Whether binding arrays (a.k.a. bindless textures) are usable on the
|
||||||
/// current render device.
|
/// current render device.
|
||||||
pub binding_arrays_are_usable: bool,
|
pub binding_arrays_are_usable: bool,
|
||||||
|
pub material_pipeline: MaterialPipeline,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromWorld for PrepassPipeline {
|
impl FromWorld for PrepassPipeline {
|
||||||
@ -339,7 +332,7 @@ impl FromWorld for PrepassPipeline {
|
|||||||
let depth_clip_control_supported = render_device
|
let depth_clip_control_supported = render_device
|
||||||
.features()
|
.features()
|
||||||
.contains(WgpuFeatures::DEPTH_CLIP_CONTROL);
|
.contains(WgpuFeatures::DEPTH_CLIP_CONTROL);
|
||||||
let internal = PrepassPipelineInternal {
|
PrepassPipeline {
|
||||||
view_layout_motion_vectors,
|
view_layout_motion_vectors,
|
||||||
view_layout_no_motion_vectors,
|
view_layout_no_motion_vectors,
|
||||||
mesh_layouts: mesh_pipeline.mesh_layouts.clone(),
|
mesh_layouts: mesh_pipeline.mesh_layouts.clone(),
|
||||||
@ -348,9 +341,6 @@ impl FromWorld for PrepassPipeline {
|
|||||||
depth_clip_control_supported,
|
depth_clip_control_supported,
|
||||||
binding_arrays_are_usable: binding_arrays_are_usable(render_device, render_adapter),
|
binding_arrays_are_usable: binding_arrays_are_usable(render_device, render_adapter),
|
||||||
empty_layout: render_device.create_bind_group_layout("prepass_empty_layout", &[]),
|
empty_layout: render_device.create_bind_group_layout("prepass_empty_layout", &[]),
|
||||||
};
|
|
||||||
PrepassPipeline {
|
|
||||||
internal,
|
|
||||||
material_pipeline: world.resource::<MaterialPipeline>().clone(),
|
material_pipeline: world.resource::<MaterialPipeline>().clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,12 +363,9 @@ impl SpecializedMeshPipeline for PrepassPipelineSpecializer {
|
|||||||
if self.properties.bindless {
|
if self.properties.bindless {
|
||||||
shader_defs.push("BINDLESS".into());
|
shader_defs.push("BINDLESS".into());
|
||||||
}
|
}
|
||||||
let mut descriptor = self.pipeline.internal.specialize(
|
let mut descriptor =
|
||||||
key.mesh_key,
|
self.pipeline
|
||||||
shader_defs,
|
.specialize(key.mesh_key, shader_defs, layout, &self.properties)?;
|
||||||
layout,
|
|
||||||
&self.properties,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// This is a bit risky because it's possible to change something that would
|
// This is a bit risky because it's possible to change something that would
|
||||||
// break the prepass but be fine in the main pass.
|
// break the prepass but be fine in the main pass.
|
||||||
@ -396,7 +383,7 @@ impl SpecializedMeshPipeline for PrepassPipelineSpecializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrepassPipelineInternal {
|
impl PrepassPipeline {
|
||||||
fn specialize(
|
fn specialize(
|
||||||
&self,
|
&self,
|
||||||
mesh_key: MeshPipelineKey,
|
mesh_key: MeshPipelineKey,
|
||||||
@ -726,7 +713,7 @@ impl FromWorld for PrepassViewBindGroup {
|
|||||||
let render_device = world.resource::<RenderDevice>();
|
let render_device = world.resource::<RenderDevice>();
|
||||||
let empty_bind_group = render_device.create_bind_group(
|
let empty_bind_group = render_device.create_bind_group(
|
||||||
"prepass_view_empty_bind_group",
|
"prepass_view_empty_bind_group",
|
||||||
&pipeline.internal.empty_layout,
|
&pipeline.empty_layout,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
PrepassViewBindGroup {
|
PrepassViewBindGroup {
|
||||||
@ -753,7 +740,7 @@ pub fn prepare_prepass_view_bind_group(
|
|||||||
) {
|
) {
|
||||||
prepass_view_bind_group.no_motion_vectors = Some(render_device.create_bind_group(
|
prepass_view_bind_group.no_motion_vectors = Some(render_device.create_bind_group(
|
||||||
"prepass_view_no_motion_vectors_bind_group",
|
"prepass_view_no_motion_vectors_bind_group",
|
||||||
&prepass_pipeline.internal.view_layout_no_motion_vectors,
|
&prepass_pipeline.view_layout_no_motion_vectors,
|
||||||
&BindGroupEntries::with_indices((
|
&BindGroupEntries::with_indices((
|
||||||
(0, view_binding.clone()),
|
(0, view_binding.clone()),
|
||||||
(1, globals_binding.clone()),
|
(1, globals_binding.clone()),
|
||||||
@ -764,7 +751,7 @@ pub fn prepare_prepass_view_bind_group(
|
|||||||
if let Some(previous_view_uniforms_binding) = previous_view_uniforms.uniforms.binding() {
|
if let Some(previous_view_uniforms_binding) = previous_view_uniforms.uniforms.binding() {
|
||||||
prepass_view_bind_group.motion_vectors = Some(render_device.create_bind_group(
|
prepass_view_bind_group.motion_vectors = Some(render_device.create_bind_group(
|
||||||
"prepass_view_motion_vectors_bind_group",
|
"prepass_view_motion_vectors_bind_group",
|
||||||
&prepass_pipeline.internal.view_layout_motion_vectors,
|
&prepass_pipeline.view_layout_motion_vectors,
|
||||||
&BindGroupEntries::with_indices((
|
&BindGroupEntries::with_indices((
|
||||||
(0, view_binding),
|
(0, view_binding),
|
||||||
(1, globals_binding),
|
(1, globals_binding),
|
||||||
|
Loading…
Reference in New Issue
Block a user