bevy/crates/bevy_render/src/texture
robtfm 91a393a9e2
Throttle render assets (#12622)
# Objective

allow throttling of gpu uploads to prevent choppy framerate when many
textures/meshes are loaded in.

## Solution

- `RenderAsset`s can implement `byte_len()` which reports their size.
implemented this for `Mesh` and `Image`
- users can add a `RenderAssetBytesPerFrame` which specifies max bytes
to attempt to upload in a frame
- `render_assets::<A>` checks how many bytes have been written before
attempting to upload assets. the limit is a soft cap: assets will be
written until the total has exceeded the cap, to ensure some forward
progress every frame

notes:
- this is a stopgap until we have multiple wgpu queues for proper
streaming of data
- requires #12606

issues
- ~~fonts sometimes only partially upload. i have no clue why, needs to
be fixed~~ fixed now.
- choosing the #bytes is tricky as it should be hardware / framerate
dependent
- many features are not tested (env maps, light probes, etc) - they
won't break unless `RenderAssetBytesPerFrame` is explicitly used though

---------

Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
2024-04-26 23:43:33 +00:00
..
basis.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
compressed_image_saver.rs Use async-fn in traits rather than BoxedFuture (#12550) 2024-03-18 17:56:57 +00:00
dds.rs Fixed a bug where skybox ddsfile would crash from wgpu (#12894) 2024-04-08 17:16:25 +00:00
exr_texture_loader.rs Use async-fn in traits rather than BoxedFuture (#12550) 2024-03-18 17:56:57 +00:00
fallback_image.rs Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
hdr_texture_loader.rs Update image requirement from 0.24 to 0.25 (#12458) 2024-03-29 06:40:09 +00:00
image.rs Throttle render assets (#12622) 2024-04-26 23:43:33 +00:00
image_loader.rs Fix extensionless image loading panic (#13005) 2024-04-17 15:13:33 +00:00
image_texture_conversion.rs Remove redundant imports (#12817) 2024-04-01 19:59:08 +00:00
ktx2.rs Fixed crash when transcoding one- or two-channel KTX2 textures (#12629) 2024-04-14 14:40:10 +00:00
mod.rs Consolidate Render(Ui)Materials(2d) into RenderAssets (#12827) 2024-04-09 13:26:34 +00:00
texture_attachment.rs Port bevy_core_pipeline to LinearRgba (#12116) 2024-02-26 12:25:11 +00:00
texture_cache.rs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00