Skip to content

Conversation

@andriyDev
Copy link
Contributor

@andriyDev andriyDev commented Dec 22, 2025

Objective

  • The glTF loader previously did two loads for textures: the first did all the expected parsing and loading. The second would intentionally try to perform the same load to A) avoid doing a second load, and B) to add the handle as a dependency specifically for the material - so that the material would not be "loaded with dependencies" until all its textures were loaded.
  • In general, it's possible for an asset to have a handle to another asset, without that handle being considered a dependency according to the LoadContext.
  • Also, some handles in the StandardMaterial were missing the #[dependency] attribute.

Solution

  • Add the dependency attribute to all handles in StandardMaterial.
  • Make the gltf anisotropy extension also use the parse_material_extension_texture function like all the other extensions (the existing implementation matched exactly).
  • Made LoadContext::finish update the list of dependencies with VisitDependencies.
  • Propagate the list of texture handles through the GltfLoader and clone the handle out when necessary.

Testing

  • Added tests to bevy_asset to verify tracking dependencies works - this also fails before the rest of this PR.
  • Ran the load_gltf example and it still works. This won't show whether the dependency tracking works correctly though.

@andriyDev andriyDev added A-Assets Load files from disk to use for things like images, models, and sounds S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-glTF Related to the glTF 3D scene/model format C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Dec 22, 2025
Copy link
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read through the code and it all seems reasonable to me. +100 on the deduplication.

@andriyDev andriyDev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 26, 2025
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Dec 29, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 30, 2025
Merged via the queue into bevyengine:main with commit ab138b0 Dec 30, 2025
38 checks passed
mockersf pushed a commit that referenced this pull request Dec 30, 2025
…exture load in GltfLoader. (#22227)

- The glTF loader previously did two loads for textures: the first did
all the expected parsing and loading. The second would **intentionally**
try to perform the same load to A) avoid doing a second load, and B) to
add the handle as a dependency specifically for the material - so that
the material would not be "loaded with dependencies" until all its
textures were loaded.
- In general, it's possible for an asset to have a handle to another
asset, without that handle being considered a dependency according to
the `LoadContext`.
- Also, some handles in the `StandardMaterial` were missing the
`#[dependency]` attribute.

- Add the dependency attribute to all handles in `StandardMaterial`.
- Make the gltf anisotropy extension also use the
`parse_material_extension_texture` function like all the other
extensions (the existing implementation matched exactly).
- Made `LoadContext::finish` update the list of dependencies with
`VisitDependencies`.
- Propagate the list of texture handles through the `GltfLoader` and
clone the handle out when necessary.

- Added tests to `bevy_asset` to verify tracking dependencies works -
this also fails before the rest of this PR.
- Ran the `load_gltf` example and it still works. This won't show
whether the dependency tracking works correctly though.
mockersf pushed a commit that referenced this pull request Dec 30, 2025
…exture load in GltfLoader. (#22227)

- The glTF loader previously did two loads for textures: the first did
all the expected parsing and loading. The second would **intentionally**
try to perform the same load to A) avoid doing a second load, and B) to
add the handle as a dependency specifically for the material - so that
the material would not be "loaded with dependencies" until all its
textures were loaded.
- In general, it's possible for an asset to have a handle to another
asset, without that handle being considered a dependency according to
the `LoadContext`.
- Also, some handles in the `StandardMaterial` were missing the
`#[dependency]` attribute.

- Add the dependency attribute to all handles in `StandardMaterial`.
- Make the gltf anisotropy extension also use the
`parse_material_extension_texture` function like all the other
extensions (the existing implementation matched exactly).
- Made `LoadContext::finish` update the list of dependencies with
`VisitDependencies`.
- Propagate the list of texture handles through the `GltfLoader` and
clone the handle out when necessary.

- Added tests to `bevy_asset` to verify tracking dependencies works -
this also fails before the rest of this PR.
- Ran the `load_gltf` example and it still works. This won't show
whether the dependency tracking works correctly though.
mockersf pushed a commit that referenced this pull request Dec 30, 2025
…exture load in GltfLoader. (#22227)

- The glTF loader previously did two loads for textures: the first did
all the expected parsing and loading. The second would **intentionally**
try to perform the same load to A) avoid doing a second load, and B) to
add the handle as a dependency specifically for the material - so that
the material would not be "loaded with dependencies" until all its
textures were loaded.
- In general, it's possible for an asset to have a handle to another
asset, without that handle being considered a dependency according to
the `LoadContext`.
- Also, some handles in the `StandardMaterial` were missing the
`#[dependency]` attribute.

- Add the dependency attribute to all handles in `StandardMaterial`.
- Make the gltf anisotropy extension also use the
`parse_material_extension_texture` function like all the other
extensions (the existing implementation matched exactly).
- Made `LoadContext::finish` update the list of dependencies with
`VisitDependencies`.
- Propagate the list of texture handles through the `GltfLoader` and
clone the handle out when necessary.

- Added tests to `bevy_asset` to verify tracking dependencies works -
this also fails before the rest of this PR.
- Ran the `load_gltf` example and it still works. This won't show
whether the dependency tracking works correctly though.
mockersf pushed a commit that referenced this pull request Dec 30, 2025
…exture load in GltfLoader. (#22227)

- The glTF loader previously did two loads for textures: the first did
all the expected parsing and loading. The second would **intentionally**
try to perform the same load to A) avoid doing a second load, and B) to
add the handle as a dependency specifically for the material - so that
the material would not be "loaded with dependencies" until all its
textures were loaded.
- In general, it's possible for an asset to have a handle to another
asset, without that handle being considered a dependency according to
the `LoadContext`.
- Also, some handles in the `StandardMaterial` were missing the
`#[dependency]` attribute.

- Add the dependency attribute to all handles in `StandardMaterial`.
- Make the gltf anisotropy extension also use the
`parse_material_extension_texture` function like all the other
extensions (the existing implementation matched exactly).
- Made `LoadContext::finish` update the list of dependencies with
`VisitDependencies`.
- Propagate the list of texture handles through the `GltfLoader` and
clone the handle out when necessary.

- Added tests to `bevy_asset` to verify tracking dependencies works -
this also fails before the rest of this PR.
- Ran the `load_gltf` example and it still works. This won't show
whether the dependency tracking works correctly though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds A-glTF Related to the glTF 3D scene/model format C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants