bevy/crates/bevy_pbr/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
..
deferred Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
light Moving structs PointLight, SpotLight, and DirectionalLight out of light/mod.rs (#12656) 2024-03-23 02:16:07 +00:00
light_probe Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
lightmap Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
meshlet Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
prepass Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
render Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
ssao Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bundle.rs Move EntityHash related types into bevy_ecs (#11498) 2024-02-12 15:02:24 +00:00
extended_material.rs Meshlet rendering (initial feature) (#10164) 2024-03-25 19:08:27 +00:00
fog.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
lib.rs Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
material.rs Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Pack the StandardMaterialKey into a single scalar instead of a structure. (#12783) 2024-03-29 18:34:27 +00:00
wireframe.rs Intern mesh vertex buffer layouts so that we don't have to compare them over and over. (#12216) 2024-03-01 20:56:21 +00:00