Do not panic if specialising mesh pipeline fails (#23)
--------- Co-authored-by: Arjo Chakravarty <arjoc@google.com>
This commit is contained in:
parent
ae5c331450
commit
84ae12953f
100
src/draw.rs
100
src/draw.rs
@ -70,24 +70,26 @@ pub(crate) fn queue_outline_stencil_mesh(
|
|||||||
if stencil_flags.depth_mode == DepthMode::Invalid {
|
if stencil_flags.depth_mode == DepthMode::Invalid {
|
||||||
continue; // DepthMode not propagated
|
continue; // DepthMode not propagated
|
||||||
}
|
}
|
||||||
if let Some(mesh) = render_meshes.get(mesh_handle) {
|
let Some(mesh) = render_meshes.get(mesh_handle) else {
|
||||||
let key = base_key
|
continue; // No mesh
|
||||||
.with_primitive_topology(mesh.primitive_topology)
|
};
|
||||||
.with_depth_mode(stencil_flags.depth_mode)
|
let key = base_key
|
||||||
.with_offset_zero(stencil_uniform.offset == 0.0)
|
.with_primitive_topology(mesh.primitive_topology)
|
||||||
.with_morph_targets(mesh.morph_targets.is_some());
|
.with_depth_mode(stencil_flags.depth_mode)
|
||||||
let pipeline = pipelines
|
.with_offset_zero(stencil_uniform.offset == 0.0)
|
||||||
|
.with_morph_targets(mesh.morph_targets.is_some());
|
||||||
|
let Ok(pipeline) = pipelines
|
||||||
.specialize(&pipeline_cache, &stencil_pipeline, key, &mesh.layout)
|
.specialize(&pipeline_cache, &stencil_pipeline, key, &mesh.layout)
|
||||||
.unwrap();
|
else {
|
||||||
let distance =
|
continue; // No pipeline
|
||||||
rangefinder.distance(&Mat4::from_translation(stencil_uniform.origin));
|
};
|
||||||
stencil_phase.add(StencilOutline {
|
let distance = rangefinder.distance(&Mat4::from_translation(stencil_uniform.origin));
|
||||||
entity,
|
stencil_phase.add(StencilOutline {
|
||||||
pipeline,
|
entity,
|
||||||
draw_function: draw_stencil,
|
pipeline,
|
||||||
distance,
|
draw_function: draw_stencil,
|
||||||
});
|
distance,
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,38 +153,40 @@ pub(crate) fn queue_outline_volume_mesh(
|
|||||||
if volume_flags.depth_mode == DepthMode::Invalid {
|
if volume_flags.depth_mode == DepthMode::Invalid {
|
||||||
continue; // DepthMode not propagated
|
continue; // DepthMode not propagated
|
||||||
}
|
}
|
||||||
if let Some(mesh) = render_meshes.get(mesh_handle) {
|
let Some(mesh) = render_meshes.get(mesh_handle) else {
|
||||||
let transparent = fragment_uniform.colour[3] < 1.0;
|
continue; // No mesh
|
||||||
let key = base_key
|
};
|
||||||
.with_primitive_topology(mesh.primitive_topology)
|
let transparent = fragment_uniform.colour[3] < 1.0;
|
||||||
.with_pass_type(if transparent {
|
let key = base_key
|
||||||
PassType::Transparent
|
.with_primitive_topology(mesh.primitive_topology)
|
||||||
} else {
|
.with_pass_type(if transparent {
|
||||||
PassType::Opaque
|
PassType::Transparent
|
||||||
})
|
|
||||||
.with_depth_mode(volume_flags.depth_mode)
|
|
||||||
.with_offset_zero(volume_uniform.offset == 0.0)
|
|
||||||
.with_hdr_format(view.hdr)
|
|
||||||
.with_morph_targets(mesh.morph_targets.is_some());
|
|
||||||
let pipeline = pipelines
|
|
||||||
.specialize(&pipeline_cache, &outline_pipeline, key, &mesh.layout)
|
|
||||||
.unwrap();
|
|
||||||
let distance = rangefinder.distance(&Mat4::from_translation(volume_uniform.origin));
|
|
||||||
if transparent {
|
|
||||||
transparent_phase.add(TransparentOutline {
|
|
||||||
entity,
|
|
||||||
pipeline,
|
|
||||||
draw_function: draw_transparent_outline,
|
|
||||||
distance,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
opaque_phase.add(OpaqueOutline {
|
PassType::Opaque
|
||||||
entity,
|
})
|
||||||
pipeline,
|
.with_depth_mode(volume_flags.depth_mode)
|
||||||
draw_function: draw_opaque_outline,
|
.with_offset_zero(volume_uniform.offset == 0.0)
|
||||||
distance,
|
.with_hdr_format(view.hdr)
|
||||||
});
|
.with_morph_targets(mesh.morph_targets.is_some());
|
||||||
}
|
let Ok(pipeline) = pipelines
|
||||||
|
.specialize(&pipeline_cache, &outline_pipeline, key, &mesh.layout) else {
|
||||||
|
continue; // No pipeline
|
||||||
|
};
|
||||||
|
let distance = rangefinder.distance(&Mat4::from_translation(volume_uniform.origin));
|
||||||
|
if transparent {
|
||||||
|
transparent_phase.add(TransparentOutline {
|
||||||
|
entity,
|
||||||
|
pipeline,
|
||||||
|
draw_function: draw_transparent_outline,
|
||||||
|
distance,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
opaque_phase.add(OpaqueOutline {
|
||||||
|
entity,
|
||||||
|
pipeline,
|
||||||
|
draw_function: draw_opaque_outline,
|
||||||
|
distance,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user