Skip to content

Fix the texture_binding_array, specialized_mesh_pipeline, and custom_shader_instancing examples after the bindless change. #16641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 54 additions & 12 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,24 +1038,24 @@ impl<M: Material> RenderAsset for PreparedMaterial<M> {
return Err(PrepareAssetError::RetryNextUpdate(material));
};

let method = match material.opaque_render_method() {
OpaqueRendererMethod::Forward => OpaqueRendererMethod::Forward,
OpaqueRendererMethod::Deferred => OpaqueRendererMethod::Deferred,
OpaqueRendererMethod::Auto => default_opaque_render_method.0,
};
let mut mesh_pipeline_key_bits = MeshPipelineKey::empty();
mesh_pipeline_key_bits.set(
MeshPipelineKey::READS_VIEW_TRANSMISSION_TEXTURE,
material.reads_view_transmission_texture(),
);

match material.unprepared_bind_group(
&pipeline.material_layout,
render_device,
material_param,
) {
Ok(unprepared) => {
let method = match material.opaque_render_method() {
OpaqueRendererMethod::Forward => OpaqueRendererMethod::Forward,
OpaqueRendererMethod::Deferred => OpaqueRendererMethod::Deferred,
OpaqueRendererMethod::Auto => default_opaque_render_method.0,
};
let mut mesh_pipeline_key_bits = MeshPipelineKey::empty();
mesh_pipeline_key_bits.set(
MeshPipelineKey::READS_VIEW_TRANSMISSION_TEXTURE,
material.reads_view_transmission_texture(),
);

bind_group_allocator.init(*material_binding_id, unprepared);
bind_group_allocator.init(render_device, *material_binding_id, unprepared);

Ok(PreparedMaterial {
binding: *material_binding_id,
Expand All @@ -1070,9 +1070,51 @@ impl<M: Material> RenderAsset for PreparedMaterial<M> {
phantom: PhantomData,
})
}

Err(AsBindGroupError::RetryNextUpdate) => {
Err(PrepareAssetError::RetryNextUpdate(material))
}

Err(AsBindGroupError::CreateBindGroupDirectly) => {
// This material has opted out of automatic bind group creation
// and is requesting a fully-custom bind group. Invoke
// `as_bind_group` as requested, and store the resulting bind
// group in the slot.
match material.as_bind_group(
&pipeline.material_layout,
render_device,
material_param,
) {
Ok(prepared_bind_group) => {
// Store the resulting bind group directly in the slot.
bind_group_allocator.init_custom(
*material_binding_id,
prepared_bind_group.bind_group,
prepared_bind_group.data,
);

Ok(PreparedMaterial {
binding: *material_binding_id,
properties: MaterialProperties {
alpha_mode: material.alpha_mode(),
depth_bias: material.depth_bias(),
reads_view_transmission_texture: mesh_pipeline_key_bits
.contains(MeshPipelineKey::READS_VIEW_TRANSMISSION_TEXTURE),
render_method: method,
mesh_pipeline_key_bits,
},
phantom: PhantomData,
})
}

Err(AsBindGroupError::RetryNextUpdate) => {
Err(PrepareAssetError::RetryNextUpdate(material))
}

Err(other) => Err(PrepareAssetError::AsBindGroupError(other)),
}
}

Err(other) => Err(PrepareAssetError::AsBindGroupError(other)),
}
}
Expand Down
Loading
Loading