Conversation
…l` now returns an `Option<UntypedAssetId>`
| let material_bindings_index = mesh_material | ||
| .and_then(|mesh_material| render_material_bindings.get(&mesh_material).copied()) |
There was a problem hiding this comment.
There's potential for a subtle behavior change if render_material_bindings somehow contained a DUMMY_MESH_MATERIAL with a non-default material binding. But that seems unlikely, and the new behavior is arguably more correct.
There was a problem hiding this comment.
We explicitly state that assigning to ::invalid() results in "undefined behavior" (I don't like the wording but the words are correct). So if that's what you mean by "non-default material binding" I think it's ok.
andriyDev
left a comment
There was a problem hiding this comment.
@IceSentry you've been working on rendering perf, so you might care to look at this? Not sure if we're down to counting branches there :P
| let material_bindings_index = mesh_material | ||
| .and_then(|mesh_material| render_material_bindings.get(&mesh_material).copied()) |
There was a problem hiding this comment.
We explicitly state that assigning to ::invalid() results in "undefined behavior" (I don't like the wording but the words are correct). So if that's what you mean by "non-default material binding" I think it's ok.
|
Waiting on a full rendering review before merging. |
Objective
Progress #19024 by avoiding
AssetId::invalid. This helps assets-as-entities, and may help with future render optimizations as it's one step towards reducingAssetIdto anEntity.Solution
Previously,
RenderMeshInstances::mesh_materialwould return anUntypedAssetId. The magic valueDUMMY_MESH_MATERIALwould signal "not found".DUMMY_MESH_MATERIALwas equal toAssetId::<StandardMaterial>::invalid().This PR makes
RenderMeshInstances::mesh_materialreturnOption<UntypedAssetId>, so "not found" becomesNone.Testing
Tested on Native/Win10 and WASM/Chrome/Win10/WebGL. This covers both the CPU and GPU mesh paths.
cargo run --example specialized_mesh_pipeline cargo run --example testbed_3d cargo run --example meshlet --features "meshlet meshlet_processor https free_camera"Performance
Tested
many_foxeswith CPU and GPU mesh paths. Difference was below the noise floor (<5%). Probably a very minor optimization if it replaces a fullUntypedAssetIdcomparison with anis_none.