bevy/crates
James Liu 12032cd296
Directly copy data into uniform buffers (#9865)
# Objective
This is a minimally disruptive version of #8340. I attempted to update
it, but failed due to the scope of the changes added in #8204.

Fixes #8307. Partially addresses #4642. As seen in
https://github.com/bevyengine/bevy/issues/8284, we're actually copying
data twice in Prepare stage systems. Once into a CPU-side intermediate
scratch buffer, and once again into a mapped buffer. This is inefficient
and effectively doubles the time spent and memory allocated to run these
systems.

## Solution
Skip the scratch buffer entirely and use
`wgpu::Queue::write_buffer_with` to directly write data into mapped
buffers.

Separately, this also directly uses
`wgpu::Limits::min_uniform_buffer_offset_alignment` to set up the
alignment when writing to the buffers. Partially addressing the issue
raised in #4642.

Storage buffers and the abstractions built on top of
`DynamicUniformBuffer` will need to come in followup PRs.

This may not have a noticeable performance difference in this PR, as the
only first-party systems affected by this are view related, and likely
are not going to be particularly heavy.

---

## Changelog
Added: `DynamicUniformBuffer::get_writer`.
Added: `DynamicUniformBufferWriter`.
2023-09-25 19:15:37 +00:00
..
bevy_a11y Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_animation Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
bevy_app Only run event systems if they have tangible work to do (#7728) 2023-09-24 00:16:33 +00:00
bevy_asset Fix the clippy::explicit_iter_loop lint (#9834) 2023-09-19 03:35:22 +00:00
bevy_audio Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
bevy_core Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
bevy_core_pipeline skybox.wgsl: Fix precision issues (#9909) 2023-09-23 22:11:59 +00:00
bevy_derive bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_diagnostic Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
bevy_dylib Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_dynamic_plugin Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_ecs Fix typos. (#9922) 2023-09-25 18:35:46 +00:00
bevy_ecs_compile_fail_tests Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
bevy_encase_derive Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_gilrs Refactor EventReader::iter to read (#9631) 2023-08-30 14:20:03 +00:00
bevy_gizmos Automatic batching/instancing of draw commands (#9685) 2023-09-21 22:12:34 +00:00
bevy_gltf Handle empty morph weights when loading gltf (#9867) 2023-09-20 17:40:00 +00:00
bevy_hierarchy Add as_slice to parent (#9871) 2023-09-22 06:27:58 +00:00
bevy_input Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
bevy_internal "serialize" feature no longer enables the optional "bevy_scene" feature if it's not enabled from elsewhere (#9803) 2023-09-14 21:15:00 +00:00
bevy_log Update tracy-client requirement from 0.15 to 0.16 (#9436) 2023-08-15 07:45:21 +00:00
bevy_macro_utils Add some more helpful errors to BevyManifest when it doesn't find Cargo.toml (#9207) 2023-07-19 12:05:04 +00:00
bevy_macros_compile_fail_tests bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_math Automatic batching/instancing of draw commands (#9685) 2023-09-21 22:12:34 +00:00
bevy_mikktspace Fix erronenous glam version (#9653) 2023-08-31 12:55:17 +00:00
bevy_pbr Directly copy data into uniform buffers (#9865) 2023-09-25 19:15:37 +00:00
bevy_ptr Put #[repr(transparent)] attr to bevy_ptr types (#9068) 2023-07-14 18:55:15 +00:00
bevy_reflect Fix the clippy::explicit_iter_loop lint (#9834) 2023-09-19 03:35:22 +00:00
bevy_reflect_compile_fail_tests Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
bevy_render Directly copy data into uniform buffers (#9865) 2023-09-25 19:15:37 +00:00
bevy_scene Remove useless single tuples and trailing commas (#9720) 2023-09-08 21:46:54 +00:00
bevy_sprite Automatic batching/instancing of draw commands (#9685) 2023-09-21 22:12:34 +00:00
bevy_tasks Remove dependecies from bevy_tasks' README (#9881) 2023-09-20 22:34:28 +00:00
bevy_text register TextLayoutInfo and TextFlags type. (#9919) 2023-09-25 18:59:29 +00:00
bevy_time Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
bevy_transform Rename RemovedComponents::iter/iter_with_id to read/read_with_id (#9778) 2023-09-15 12:37:20 +00:00
bevy_ui register TextLayoutInfo and TextFlags type. (#9919) 2023-09-25 18:59:29 +00:00
bevy_utils Fix typos. (#9922) 2023-09-25 18:35:46 +00:00
bevy_window Fix typos. (#9922) 2023-09-25 18:35:46 +00:00
bevy_winit Fix typos. (#9922) 2023-09-25 18:35:46 +00:00