bevy/crates/bevy_render/src
Patrick Walton fde7968168
Unbreak shadows by retaining work item buffers corresponding to ExtractedViews, not ViewTargets. (#17039)
OK, so this is tricky. Every frame, `delete_old_work_item_buffers`
deletes the mesh preprocessing index buffers (a.k.a. work item buffers)
for views that don't have `ViewTarget`s. This was always wrong for
shadow map views, as shadow maps only have `ExtractedView` components,
not `ViewTarget`s. However, before #16836, the problem was masked,
because uploading the mesh preprocessing index buffers for shadow views
had already completed by the time `delete_old_work_item_buffers` ran.
But PR #16836 moved `delete_old_work_item_buffers` from the
`ManageViews` phase to `PrepareResources`, which runs before
`write_batched_instance_buffers` uploads the work item buffers to the
GPU.

This itself isn't wrong, but it exposed the bug, because now it's
possible for work item buffers to get deleted before they're uploaded in
`write_batched_instance_buffers`. This is actually intermittent! It's
possible for the old work item buffers to get deleted, and then
*recreated* in `batch_and_prepare_binned_render_phase`, which runs
during `PrepareResources` as well, and under that system ordering, there
will be no problem other than a little inefficiency arising from
recreating the buffers every frame. But, if
`delete_old_work_item_buffers` runs *after*
`batch_and_prepare_render_phase`, then the work item buffers
corresponding to shadow views will get deleted, and then the shadows
will disappear.

The fact that this is racy is what made it look like #16922 solved the
issue. In fact, it didn't: it just perturbed the ordering on the build
bots enough that the issue stopped appearing. However, on my system, the
shadows still don't appear with #16922.

This commit solves the problem by making `delete_old_work_item_buffers`
look at `ExtractedView`s, not `ViewTarget`s, preventing work item
buffers corresponding to live shadow map views from being deleted.
2024-12-30 20:06:40 +00:00
..
batching Unbreak shadows by retaining work item buffers corresponding to ExtractedViews, not ViewTargets. (#17039) 2024-12-30 20:06:40 +00:00
camera impl EntityBorrow for more types (#16917) 2024-12-24 02:47:03 +00:00
diagnostic Ensure Bevy's rendering byte usage is little-endian (#15750) 2024-10-08 22:43:35 +00:00
mesh Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
primitives Add .contains_aabb for Frustum (#16022) 2024-12-01 21:30:01 +00:00
render_graph Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
render_phase track_change_detection: Also track spawns/despawns (#16047) 2024-12-17 04:46:31 +00:00
render_resource Move futures.rs, ConditionalSend and BoxedFuture types to bevy_tasks (#16951) 2024-12-29 19:29:53 +00:00
renderer Don't overalign aligned values in gpu_readback::align_byte_size (#17007) 2024-12-30 05:51:37 +00:00
texture Change GpuImage::size from UVec2 to Extent3d (#16815) 2024-12-17 19:08:09 +00:00
view Make RawHandleWrapper fields private to save users from themselves (#16968) 2024-12-29 19:54:57 +00:00
alpha.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
color_operations.wgsl move wgsl color operations from bevy_pbr to bevy_render (#13209) 2024-05-04 10:30:23 +00:00
extract_component.rs Remove ExtractComponent::Out (#15926) 2024-10-15 23:42:35 +00:00
extract_instances.rs Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
extract_param.rs Implement WorldQuery for MainWorld and RenderWorld components (#15745) 2024-10-13 20:58:46 +00:00
extract_resource.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
globals.rs Remove bevy_core (#16897) 2024-12-19 18:36:51 +00:00
globals.wgsl Refactor Globals and View structs into separate shaders (#7512) 2023-02-11 17:55:18 +00:00
gpu_component_array_buffer.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
gpu_readback.rs Don't overalign aligned values in gpu_readback::align_byte_size (#17007) 2024-12-30 05:51:37 +00:00
lib.rs Fix several regressions from recent rendering changes. (#16890) 2024-12-22 23:03:06 +00:00
maths.wgsl add tonemapping LUT bindings for sprite and mesh2d pipelines (#13262) 2024-05-28 12:09:26 +00:00
pipelined_rendering.rs Synchronize removed components with the render world (#15582) 2024-10-08 22:23:17 +00:00
render_asset.rs Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
settings.rs cleanup bevy_render/lib.rs (#16481) 2024-11-22 22:32:04 +00:00
spatial_bundle.rs Deprecate SpatialBundle (#15830) 2024-10-13 17:28:22 +00:00
storage.rs Add a bindless mode to AsBindGroup. (#16368) 2024-12-03 18:00:34 +00:00
sync_component.rs Synchronize removed components with the render world (#15582) 2024-10-08 22:23:17 +00:00
sync_world.rs impl EntityBorrow for more types (#16917) 2024-12-24 02:47:03 +00:00