bevy/crates/bevy_render/src
Patrick Walton 37522fd0ae
Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791)
This commit makes the following optimizations:

## `MeshPipelineKey`/`BaseMeshPipelineKey` split

`MeshPipelineKey` has been split into `BaseMeshPipelineKey`, which lives
in `bevy_render` and `MeshPipelineKey`, which lives in `bevy_pbr`.
Conceptually, `BaseMeshPipelineKey` is a superclass of
`MeshPipelineKey`. For `BaseMeshPipelineKey`, the bits start at the
highest (most significant) bit and grow downward toward the lowest bit;
for `MeshPipelineKey`, the bits start at the lowest bit and grow upward
toward the highest bit. This prevents them from colliding.

The goal of this is to avoid having to reassemble bits of the pipeline
key for every mesh every frame. Instead, we can just use a bitwise or
operation to combine the pieces that make up a `MeshPipelineKey`.

## `specialize_slow`

Previously, all of `specialize()` was marked as `#[inline]`. This
bloated `queue_material_meshes` unnecessarily, as a large chunk of it
ended up being a slow path that was rarely hit. This commit refactors
the function to move the slow path to `specialize_slow()`.

Together, these two changes shave about 5% off `queue_material_meshes`:

![Screenshot 2024-03-29
130002](https://github.com/bevyengine/bevy/assets/157897/a7e5a994-a807-4328-b314-9003429dcdd2)

## Migration Guide

- The `primitive_topology` field on `GpuMesh` is now an accessor method:
`GpuMesh::primitive_topology()`.
- For performance reasons, `MeshPipelineKey` has been split into
`BaseMeshPipelineKey`, which lives in `bevy_render`, and
`MeshPipelineKey`, which lives in `bevy_pbr`. These two should be
combined with bitwise-or to produce the final `MeshPipelineKey`.
2024-04-01 21:58:53 +00:00
..
batching Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
camera Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
diagnostic Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
mesh Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
primitives Reflect default in some types on bevy_render (#12580) 2024-03-19 22:50:17 +00:00
render_graph Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
render_phase Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
render_resource Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
renderer Get Bevy building for WebAssembly with multithreading (#12205) 2024-03-25 19:10:18 +00:00
texture Remove redundant imports (#12817) 2024-04-01 19:59:08 +00:00
view Normalize warning messages with Nvidia drivers (#12833) 2024-04-01 19:56:56 +00:00
alpha.rs Move AlphaMode into bevy_render (#12012) 2024-02-21 19:34:10 +00:00
extract_component.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
extract_instances.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
extract_param.rs Enable the unsafe_op_in_unsafe_fn lint (#11591) 2024-01-28 23:18:11 +00:00
extract_resource.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
globals.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +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 Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
lib.rs remove DeterministicRenderingConfig (#12811) 2024-04-01 09:32:47 +00:00
maths.wgsl Add support for KHR_texture_transform (#11904) 2024-02-21 01:11:28 +00:00
pipelined_rendering.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
render_asset.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
settings.rs Update to wgpu 0.19 and raw-window-handle 0.6 (#11280) 2024-01-26 18:14:21 +00:00
spatial_bundle.rs Implement Clone for VisibilityBundle and SpatialBundle (#10394) 2023-11-07 21:25:00 +00:00