bevy/crates/bevy_render/src/render_resource
Torstein Grindvik 12f30f5667 Shaders can now have #else ifdef chains (#7431)
# Objective

Currently, shaders may only have syntax such as

```wgsl
#ifdef FOO
// foo code
#else
#ifdef BAR
// bar code
#else
#ifdef BAZ
// baz code
#else
// fallback code
#endif
#endif
#endif
```

This is hard to read and follow.
Add a way to allow writing `#else ifdef DEFINE` to reduce the number of scopes introduced and to increase readability.

## Solution

Refactor the current preprocessing a bit and add logic to allow `#else ifdef DEFINE`.
This includes per-scope tracking of whether a branch has been accepted.
Add a few tests for this feature.

With these changes we may now write:

```wgsl
#ifdef FOO
// foo code
#else ifdef BAR
// bar code
#else ifdef BAZ
// baz code
#else
// fallback code
#endif
```

instead.

---

## Changelog

- Add `#else ifdef` to shader preprocessing.
2023-02-04 15:29:35 +00:00
..
bind_group_layout.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
bind_group.rs Support storage buffers in derive AsBindGroup (#6129) 2023-01-09 18:50:55 +00:00
buffer_vec.rs Directly extract joints into SkinnedMeshJoints (#6833) 2022-12-20 16:17:05 +00:00
buffer.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
mod.rs improve compile time by type-erasing wgpu structs (#5950) 2022-11-18 22:04:23 +00:00
pipeline_cache.rs Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
pipeline_specializer.rs Make PipelineCache internally mutable. (#7205) 2023-01-16 15:41:14 +00:00
pipeline.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
resource_macros.rs Reduce branching in TrackedRenderPass (#7053) 2023-01-09 19:24:56 +00:00
shader.rs Shaders can now have #else ifdef chains (#7431) 2023-02-04 15:29:35 +00:00
storage_buffer.rs add a debug label to storage buffers (#5341) 2022-07-28 20:37:49 +00:00
texture.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
uniform_buffer.rs add a debug label to storage buffers (#5341) 2022-07-28 20:37:49 +00:00