bevy/crates/bevy_pbr/src
Patrick Walton 465306bc5e
Reextract a mesh on the next frame if its material couldn't be prepared on the frame we first encountered it. (#17963)
We might not be able to prepare a material on the first frame we
encounter a mesh using it for various reasons, including that the
material hasn't been loaded yet or that preparing the material is
exceeding the per-frame cap on number of bytes to load. When this
happens, we currently try to find the material in the
`MaterialBindGroupAllocator`, fail, and then fall back to group 0, slot
0, the default `MaterialBindGroupId`, which is obviously incorrect.
Worse, we then fail to dirty the mesh and reextract it when we *do*
finish preparing the material, so the mesh will continue to be rendered
with an incorrect material.

This patch fixes both problems. In `collect_meshes_for_gpu_building`, if
we fail to find a mesh's material in the `MeshBindGroupAllocator`, then
we detect that case, bail out, and add it to a list,
`MeshesToReextractNextFrame`. On subsequent frames, we process all the
meshes in `MeshesToReextractNextFrame` as though they were changed. This
ensures both that we don't render a mesh if its material hasn't been
loaded and that we start rendering the mesh once its material does load.

This was first noticed in the intermittent Pixel Eagle failures in the
`testbed_3d` patch in #17898, although the problem has actually existed
for some time. I believe it just so happened that the changes to the
allocator in that PR caused the problem to appear more commonly than it
did before.
2025-02-22 08:19:25 +00:00
..
atmosphere Use dual-source blending for rendering the sky (#17672) 2025-02-10 23:53:53 +00:00
cluster Disable clustered decals on Metal. (#17554) 2025-01-27 05:39:07 +00:00
decal Build batches across phases in parallel. (#17764) 2025-02-13 00:02:20 +00:00
deferred Remove prepasses from the render world when they're removed from the main world. (#17565) 2025-02-14 06:43:35 +00:00
light Don't mark newly-hidden meshes invisible until all visibility-determining systems run. (#17922) 2025-02-18 09:35:22 +00:00
light_probe Weak handle migration (#17695) 2025-02-05 22:44:20 +00:00
lightmap Weak handle migration (#17695) 2025-02-05 22:44:20 +00:00
meshlet Implement occlusion culling for directional light shadow maps. (#17951) 2025-02-21 05:56:15 +00:00
prepass Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
render Reextract a mesh on the next frame if its material couldn't be prepared on the frame we first encountered it. (#17963) 2025-02-22 08:19:25 +00:00
ssao Weak handle migration (#17695) 2025-02-05 22:44:20 +00:00
ssr Update typos to 1.29.6 (#17850) 2025-02-13 19:44:47 +00:00
volumetric_fog Weak handle migration (#17695) 2025-02-05 22:44:20 +00:00
components.rs Support non-Vec data structures in relations (#17447) 2025-01-20 21:26:08 +00:00
extended_material.rs Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
fog.rs Remove all deprecated code (#16338) 2025-01-05 20:33:39 +00:00
lib.rs Implement occlusion culling for directional light shadow maps. (#17951) 2025-02-21 05:56:15 +00:00
material_bind_groups.rs Fix bugs in the new non-bindless mesh material allocator. (#17980) 2025-02-22 06:29:00 +00:00
material.rs Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
mesh_material.rs Cold Specialization (#17567) 2025-02-05 18:31:20 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
wireframe.rs Weak handle migration (#17695) 2025-02-05 22:44:20 +00:00