Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_material/src/specialize.rs
9331 views
1
use bevy_ecs::world::World;
2
use bevy_mesh::{MeshVertexBufferLayoutRef, MissingVertexAttributeError};
3
use bevy_platform::sync::Arc;
4
use core::any::Any;
5
use thiserror::Error;
6
7
use crate::{
8
descriptor::{CachedRenderPipelineId, RenderPipelineDescriptor},
9
key::ErasedMaterialPipelineKey,
10
MaterialProperties,
11
};
12
13
/// A type erased function pointer for specializing a material pipeline. The implementation is
14
/// expected to:
15
/// - Look up the appropriate specializer from the world
16
/// - Downcast the erased key to the concrete key type
17
/// - Call `SpecializedMeshPipelines::specialize` with the specializer and return the resulting pipeline id
18
pub type BaseSpecializeFn = fn(
19
&mut World,
20
ErasedMaterialPipelineKey,
21
&MeshVertexBufferLayoutRef,
22
&Arc<MaterialProperties>,
23
) -> Result<CachedRenderPipelineId, SpecializedMeshPipelineError>;
24
25
/// A type erased function pointer for specializing a material prepass pipeline. The implementation is
26
/// expected to:
27
/// - Look up the appropriate specializer from the world
28
/// - Downcast the erased key to the concrete key type
29
/// - Call `SpecializedMeshPipelines::specialize` with the specializer and return the resulting pipeline id
30
pub type PrepassSpecializeFn = fn(
31
&mut World,
32
ErasedMaterialPipelineKey,
33
&MeshVertexBufferLayoutRef,
34
&Arc<MaterialProperties>,
35
) -> Result<CachedRenderPipelineId, SpecializedMeshPipelineError>;
36
37
/// A type erased function pointer for specializing a material prepass pipeline. The implementation is
38
/// expected to:
39
/// - Look up the appropriate specializer from the world
40
/// - Downcast the erased key to the concrete key type
41
/// - Call `SpecializedMeshPipelines::specialize` with the specializer and return the resulting pipeline id
42
pub type UserSpecializeFn = fn(
43
&dyn Any,
44
&mut RenderPipelineDescriptor,
45
&MeshVertexBufferLayoutRef,
46
ErasedMaterialPipelineKey,
47
) -> Result<(), SpecializedMeshPipelineError>;
48
49
#[derive(Error, Debug)]
50
pub enum SpecializedMeshPipelineError {
51
#[error(transparent)]
52
MissingVertexAttribute(#[from] MissingVertexAttributeError),
53
}
54
55