Skip to content

Fix asset extraction for GpuAutoExposureCompensationCurve#22803

Merged
alice-i-cecile merged 3 commits intobevyengine:mainfrom
Breakdown-Dog:fix_auto_exposure_extract
Feb 6, 2026
Merged

Fix asset extraction for GpuAutoExposureCompensationCurve#22803
alice-i-cecile merged 3 commits intobevyengine:mainfrom
Breakdown-Dog:fix_auto_exposure_extract

Conversation

@Breakdown-Dog
Copy link
Contributor

Objective

  • When I am running the example auto_exposure on the main branch. I get errors, and the auto exposure effect does not work correctly.
2026-02-04T05:36:29.462198Z ERROR bevy_render::render_asset: bevy_post_process::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve with RenderAssetUsages == RENDER_WORLD cannot be extracted: The asset type does not support extraction. To clone the asset to the renderworld, use `RenderAssetUsages::default()`
2026-02-04T05:36:29.462407Z ERROR bevy_render::render_asset: bevy_post_process::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve with RenderAssetUsages == RENDER_WORLD cannot be extracted: The asset type does not support extraction. To clone the asset to the renderworld, use `RenderAssetUsages::default()`
  • I believe the reason is that GpuAutoExposureCompensationCurve is missing the take_gpu_data function from the RenderAsset trait.

  • The code snippet that outputs error information (crates\bevy_render\src\render_asset.rs).

for id in needs_extracting.drain() {
  if let Some(asset) = assets.get(id) {
      let asset_usage = A::asset_usage(asset);
      if asset_usage.contains(RenderAssetUsages::RENDER_WORLD) {
          if asset_usage == RenderAssetUsages::RENDER_WORLD {
              if let Some(asset) = assets.get_mut_untracked(id) {
                  let previous_asset = maybe_render_assets.as_ref().and_then(|render_assets| render_assets.get(id));
                  match A::take_gpu_data(asset, previous_asset) {
                      Ok(gpu_data_asset) => {
                          extracted_assets.push((id, gpu_data_asset));
                          added.insert(id);
                      }
                      Err(e) => {
                          error!("{} with RenderAssetUsages == RENDER_WORLD cannot be extracted: {e}", core::any::type_name::<A>());
                      }
                  };
              }
          } else {
              extracted_assets.push((id, asset.clone()));
              added.insert(id);
          }
      }
  }
}

Solution

  • Add take_gpu_data() function.

Testing

  • The example auto_exposure works correctly.
  • CI

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 4, 2026
Copy link
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

Looks like a straightforward fix. Approving for correctness

@kfc35 kfc35 added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Feb 4, 2026
Copy link
Contributor

@greeble-dev greeble-dev left a comment

Choose a reason for hiding this comment

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

This was accidentally regressed by #21732. Fix seems good and I've tested before/after. Just requesting one change to make the fix smaller.

@greeble-dev greeble-dev added this to the 0.18.1 milestone Feb 4, 2026
@greeble-dev
Copy link
Contributor

Adding to 0.18.1 milestone as this was a regression from 0.17 -> 0.18.

@greeble-dev greeble-dev 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 Feb 5, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 6, 2026
Merged via the queue into bevyengine:main with commit 758b8fa Feb 6, 2026
40 checks passed
alice-i-cecile pushed a commit that referenced this pull request Mar 2, 2026
# Objective

- When I am running the example `auto_exposure` on the main branch. I
get errors, and the auto exposure effect does not work correctly.
```
2026-02-04T05:36:29.462198Z ERROR bevy_render::render_asset: bevy_post_process::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve with RenderAssetUsages == RENDER_WORLD cannot be extracted: The asset type does not support extraction. To clone the asset to the renderworld, use `RenderAssetUsages::default()`
2026-02-04T05:36:29.462407Z ERROR bevy_render::render_asset: bevy_post_process::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve with RenderAssetUsages == RENDER_WORLD cannot be extracted: The asset type does not support extraction. To clone the asset to the renderworld, use `RenderAssetUsages::default()`
```

- I believe the reason is that` GpuAutoExposureCompensationCurve` is
missing the `take_gpu_data` function from the `RenderAsset` trait.

- The code snippet that outputs error information
`(crates\bevy_render\src\render_asset.rs)`.
``` rust
for id in needs_extracting.drain() {
  if let Some(asset) = assets.get(id) {
      let asset_usage = A::asset_usage(asset);
      if asset_usage.contains(RenderAssetUsages::RENDER_WORLD) {
          if asset_usage == RenderAssetUsages::RENDER_WORLD {
              if let Some(asset) = assets.get_mut_untracked(id) {
                  let previous_asset = maybe_render_assets.as_ref().and_then(|render_assets| render_assets.get(id));
                  match A::take_gpu_data(asset, previous_asset) {
                      Ok(gpu_data_asset) => {
                          extracted_assets.push((id, gpu_data_asset));
                          added.insert(id);
                      }
                      Err(e) => {
                          error!("{} with RenderAssetUsages == RENDER_WORLD cannot be extracted: {e}", core::any::type_name::<A>());
                      }
                  };
              }
          } else {
              extracted_assets.push((id, asset.clone()));
              added.insert(id);
          }
      }
  }
}
```

## Solution

- Add `take_gpu_data()` function. 

## Testing

- The example `auto_exposure` works correctly.
- CI

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants