Skip to content

Commit

Permalink
Fixed crash when wgpu tries to read past image data for dds skybox
Browse files Browse the repository at this point in the history
Upgraded ddsfile dependency to 0.5.2
  • Loading branch information
Hexorg committed Mar 21, 2024
1 parent ed44eb3 commit 4f75a3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_render/Cargo.toml
Expand Up @@ -82,7 +82,7 @@ thread_local = "1.1"
thiserror = "1.0"
futures-lite = "2.0.1"
hexasphere = "10.0"
ddsfile = { version = "0.5.0", optional = true }
ddsfile = { version = "0.5.2", optional = true }
ktx2 = { version = "0.3.0", optional = true }
# For ktx2 supercompression
flate2 = { version = "1.0.22", optional = true }
Expand Down
13 changes: 6 additions & 7 deletions crates/bevy_render/src/texture/dds.rs
Expand Up @@ -24,23 +24,22 @@ pub fn dds_buffer_to_image(
}
let mut image = Image::default();
let is_cubemap = dds.header.caps2.contains(Caps2::CUBEMAP);
let mut depth_or_array_layers = if dds.get_num_array_layers() > 1 {
let depth_or_array_layers = if dds.get_num_array_layers() > 1 {
dds.get_num_array_layers()
} else {
dds.get_depth()
};
if is_cubemap {
if !dds.header.caps2.contains(
if is_cubemap
&& !dds.header.caps2.contains(
Caps2::CUBEMAP_NEGATIVEX
| Caps2::CUBEMAP_NEGATIVEY
| Caps2::CUBEMAP_NEGATIVEZ
| Caps2::CUBEMAP_POSITIVEX
| Caps2::CUBEMAP_POSITIVEY
| Caps2::CUBEMAP_POSITIVEZ,
) {
return Err(TextureError::IncompleteCubemap);
}
depth_or_array_layers *= 6;
)
{
return Err(TextureError::IncompleteCubemap);
}
image.texture_descriptor.size = Extent3d {
width: dds.get_width(),
Expand Down

0 comments on commit 4f75a3b

Please sign in to comment.