bevy/examples/shader
Carter Anderson 17edf4f7c7
Copy on Write AssetPaths (#9729)
# Objective

The `AssetServer` and `AssetProcessor` do a lot of `AssetPath` cloning
(across many threads). To store the path on the handle, to store paths
in dependency lists, to pass an owned path to the offloaded thread, to
pass a path to the LoadContext, etc , etc. Cloning multiple string
allocations multiple times like this will add up. It is worth optimizing
this.

Referenced in #9714 

## Solution

Added a new `CowArc<T>` type to `bevy_util`, which behaves a lot like
`Cow<T>`, but the Owned variant is an `Arc<T>`. Use this in place of
`Cow<str>` and `Cow<Path>` on `AssetPath`.

---

## Changelog

- `AssetPath` now internally uses `CowArc`, making clone operations much
cheaper
- `AssetPath` now serializes as `AssetPath("some_path.extension#Label")`
instead of as `AssetPath { path: "some_path.extension", label:
Some("Label) }`


## Migration Guide

```rust
// Old
AssetPath::new("logo.png", None);

// New
AssetPath::new("logo.png");

// Old
AssetPath::new("scene.gltf", Some("Mesh0");

// New
AssetPath::new("scene.gltf").with_label("Mesh0");
```

`AssetPath` now serializes as `AssetPath("some_path.extension#Label")`
instead of as `AssetPath { path: "some_path.extension", label:
Some("Label) }`

---------

Co-authored-by: Pascal Hertleif <killercup@gmail.com>
2023-09-09 23:15:10 +00:00
..
animate_shader.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
array_texture.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
compute_shader_game_of_life.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
custom_vertex_attribute.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
fallback_image.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
post_processing.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
shader_defs.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
shader_instancing.rs Reorder render sets, refactor bevy_sprite to take advantage (#9236) 2023-08-27 14:33:49 +00:00
shader_material.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
shader_material_glsl.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
shader_material_screenspace_texture.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
shader_prepass.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
texture_binding_array.rs Copy on Write AssetPaths (#9729) 2023-09-09 23:15:10 +00:00