Make the StandardMaterial
bindless index table have a fixed size regardless of the features that are enabled. (#18771)
Due to the preprocessor usage in the shader, different combinations of features could cause the fields of `StandardMaterialBindings` to shift around. In certain cases, this could cause them to not line up with the bindings specified in `StandardMaterial`. This resulted in #18104. This commit fixes the issue by making `StandardMaterialBindings` have a fixed size. On the CPU side, it uses the `#[bindless(index_table(range(M..N)))]` feature I added to `AsBindGroup` in #18025 to do so. Thus this patch has a dependency on #18025. Closes #18104. --------- Co-authored-by: Robert Swain <robert.swain@gmail.com>
This commit is contained in:
parent
bc259fad04
commit
065a95e0a1
@ -32,7 +32,7 @@ pub enum UvChannel {
|
||||
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone)]
|
||||
#[bind_group_data(StandardMaterialKey)]
|
||||
#[data(0, StandardMaterialUniform, binding_array(10))]
|
||||
#[bindless]
|
||||
#[bindless(index_table(range(0..31)))]
|
||||
#[reflect(Default, Debug, Clone)]
|
||||
pub struct StandardMaterial {
|
||||
/// The color of the surface of the material before lighting.
|
||||
|
@ -17,32 +17,24 @@ struct StandardMaterialBindings {
|
||||
normal_map_sampler: u32, // 10
|
||||
depth_map_texture: u32, // 11
|
||||
depth_map_sampler: u32, // 12
|
||||
#ifdef PBR_ANISOTROPY_TEXTURE_SUPPORTED
|
||||
anisotropy_texture: u32, // 13
|
||||
anisotropy_sampler: u32, // 14
|
||||
#endif // PBR_ANISOTROPY_TEXTURE_SUPPORTED
|
||||
#ifdef PBR_TRANSMISSION_TEXTURES_SUPPORTED
|
||||
specular_transmission_texture: u32, // 15
|
||||
specular_transmission_sampler: u32, // 16
|
||||
thickness_texture: u32, // 17
|
||||
thickness_sampler: u32, // 18
|
||||
diffuse_transmission_texture: u32, // 19
|
||||
diffuse_transmission_sampler: u32, // 20
|
||||
#endif // PBR_TRANSMISSION_TEXTURES_SUPPORTED
|
||||
#ifdef PBR_MULTI_LAYER_MATERIAL_TEXTURES_SUPPORTED
|
||||
clearcoat_texture: u32, // 21
|
||||
clearcoat_sampler: u32, // 22
|
||||
clearcoat_roughness_texture: u32, // 23
|
||||
clearcoat_roughness_sampler: u32, // 24
|
||||
clearcoat_normal_texture: u32, // 25
|
||||
clearcoat_normal_sampler: u32, // 26
|
||||
#endif // PBR_MULTI_LAYER_MATERIAL_TEXTURES_SUPPORTED
|
||||
#ifdef PBR_SPECULAR_TEXTURES_SUPPORTED
|
||||
specular_texture: u32, // 27
|
||||
specular_sampler: u32, // 28
|
||||
specular_tint_texture: u32, // 29
|
||||
specular_tint_sampler: u32, // 30
|
||||
#endif // PBR_SPECULAR_TEXTURES_SUPPORTED
|
||||
}
|
||||
|
||||
@group(2) @binding(0) var<storage> material_indices: array<StandardMaterialBindings>;
|
||||
|
Loading…
Reference in New Issue
Block a user