diff --git a/assets/environment_maps/cubes_reflection_probe_specular_rgb9e5_zstd.ktx2 b/assets/environment_maps/cubes_reflection_probe_specular_rgb9e5_zstd.ktx2 index 9c2f2a85a3..a4ffc2ba8f 100644 Binary files a/assets/environment_maps/cubes_reflection_probe_specular_rgb9e5_zstd.ktx2 and b/assets/environment_maps/cubes_reflection_probe_specular_rgb9e5_zstd.ktx2 differ diff --git a/assets/environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2 b/assets/environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2 index e260df24bd..b1d9e7abaa 100644 Binary files a/assets/environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2 and b/assets/environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2 differ diff --git a/assets/environment_maps/pisa_specular_rgb9e5_zstd.ktx2 b/assets/environment_maps/pisa_specular_rgb9e5_zstd.ktx2 index 2018838de5..84eef71c82 100644 Binary files a/assets/environment_maps/pisa_specular_rgb9e5_zstd.ktx2 and b/assets/environment_maps/pisa_specular_rgb9e5_zstd.ktx2 differ diff --git a/assets/lightmaps/CornellBox-Box.zstd.ktx2 b/assets/lightmaps/CornellBox-Box.zstd.ktx2 index 0a31dd4854..52f3fd1ddc 100644 Binary files a/assets/lightmaps/CornellBox-Box.zstd.ktx2 and b/assets/lightmaps/CornellBox-Box.zstd.ktx2 differ diff --git a/assets/lightmaps/CornellBox-Large.zstd.ktx2 b/assets/lightmaps/CornellBox-Large.zstd.ktx2 index c41ef9b032..71a7b34274 100644 Binary files a/assets/lightmaps/CornellBox-Large.zstd.ktx2 and b/assets/lightmaps/CornellBox-Large.zstd.ktx2 differ diff --git a/assets/lightmaps/CornellBox-Small.zstd.ktx2 b/assets/lightmaps/CornellBox-Small.zstd.ktx2 index 9b1b72cd13..c59b2c6b89 100644 Binary files a/assets/lightmaps/CornellBox-Small.zstd.ktx2 and b/assets/lightmaps/CornellBox-Small.zstd.ktx2 differ diff --git a/assets/lightmaps/MixedLightingExample-Baked.zstd.ktx2 b/assets/lightmaps/MixedLightingExample-Baked.zstd.ktx2 index 6f699f561f..f41b3da977 100644 Binary files a/assets/lightmaps/MixedLightingExample-Baked.zstd.ktx2 and b/assets/lightmaps/MixedLightingExample-Baked.zstd.ktx2 differ diff --git a/assets/lightmaps/MixedLightingExample-MixedDirect.zstd.ktx2 b/assets/lightmaps/MixedLightingExample-MixedDirect.zstd.ktx2 index 1977d638e1..2b3476ee6b 100644 Binary files a/assets/lightmaps/MixedLightingExample-MixedDirect.zstd.ktx2 and b/assets/lightmaps/MixedLightingExample-MixedDirect.zstd.ktx2 differ diff --git a/assets/lightmaps/MixedLightingExample-MixedIndirect.zstd.ktx2 b/assets/lightmaps/MixedLightingExample-MixedIndirect.zstd.ktx2 index 070d8ac613..e68566f7b5 100644 Binary files a/assets/lightmaps/MixedLightingExample-MixedIndirect.zstd.ktx2 and b/assets/lightmaps/MixedLightingExample-MixedIndirect.zstd.ktx2 differ diff --git a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_anisotropy.ktx2 b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_anisotropy.ktx2 index 32ef2d17d3..e51e77c489 100644 Binary files a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_anisotropy.ktx2 and b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_anisotropy.ktx2 differ diff --git a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_normalbump.ktx2 b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_normalbump.ktx2 index 8099744a8a..f3f375a14f 100644 Binary files a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_normalbump.ktx2 and b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_normalbump.ktx2 differ diff --git a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_occlusionroughnessmetal.ktx2 b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_occlusionroughnessmetal.ktx2 index af0ae73cd4..281bbb5c1f 100644 Binary files a/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_occlusionroughnessmetal.ktx2 and b/assets/models/AnisotropyBarnLamp/AnisotropyBarnLamp_occlusionroughnessmetal.ktx2 differ diff --git a/assets/textures/Ryfjallet_cubemap_astc4x4.ktx2 b/assets/textures/Ryfjallet_cubemap_astc4x4.ktx2 index 78696cadca..d30a21c150 100644 Binary files a/assets/textures/Ryfjallet_cubemap_astc4x4.ktx2 and b/assets/textures/Ryfjallet_cubemap_astc4x4.ktx2 differ diff --git a/assets/textures/Ryfjallet_cubemap_bc7.ktx2 b/assets/textures/Ryfjallet_cubemap_bc7.ktx2 index 17e67c7c9f..569782a130 100644 Binary files a/assets/textures/Ryfjallet_cubemap_bc7.ktx2 and b/assets/textures/Ryfjallet_cubemap_bc7.ktx2 differ diff --git a/assets/textures/Ryfjallet_cubemap_etc2.ktx2 b/assets/textures/Ryfjallet_cubemap_etc2.ktx2 index 22a389cfd9..fd40f8ba3c 100644 Binary files a/assets/textures/Ryfjallet_cubemap_etc2.ktx2 and b/assets/textures/Ryfjallet_cubemap_etc2.ktx2 differ diff --git a/crates/bevy_anti_alias/src/smaa/SMAAAreaLUT.ktx2 b/crates/bevy_anti_alias/src/smaa/SMAAAreaLUT.ktx2 index e7d160f62e..90bf16490e 100644 Binary files a/crates/bevy_anti_alias/src/smaa/SMAAAreaLUT.ktx2 and b/crates/bevy_anti_alias/src/smaa/SMAAAreaLUT.ktx2 differ diff --git a/crates/bevy_anti_alias/src/smaa/SMAASearchLUT.ktx2 b/crates/bevy_anti_alias/src/smaa/SMAASearchLUT.ktx2 index 29089f1e90..1d6d92df69 100644 Binary files a/crates/bevy_anti_alias/src/smaa/SMAASearchLUT.ktx2 and b/crates/bevy_anti_alias/src/smaa/SMAASearchLUT.ktx2 differ diff --git a/crates/bevy_core_pipeline/src/tonemapping/luts/AgX-default_contrast.ktx2 b/crates/bevy_core_pipeline/src/tonemapping/luts/AgX-default_contrast.ktx2 index 040fb1def2..8633be506c 100644 Binary files a/crates/bevy_core_pipeline/src/tonemapping/luts/AgX-default_contrast.ktx2 and b/crates/bevy_core_pipeline/src/tonemapping/luts/AgX-default_contrast.ktx2 differ diff --git a/crates/bevy_core_pipeline/src/tonemapping/luts/Blender_-11_12.ktx2 b/crates/bevy_core_pipeline/src/tonemapping/luts/Blender_-11_12.ktx2 index db07c847a1..43bca82e4e 100644 Binary files a/crates/bevy_core_pipeline/src/tonemapping/luts/Blender_-11_12.ktx2 and b/crates/bevy_core_pipeline/src/tonemapping/luts/Blender_-11_12.ktx2 differ diff --git a/crates/bevy_core_pipeline/src/tonemapping/luts/tony_mc_mapface.ktx2 b/crates/bevy_core_pipeline/src/tonemapping/luts/tony_mc_mapface.ktx2 index 143759429e..be665043fa 100644 Binary files a/crates/bevy_core_pipeline/src/tonemapping/luts/tony_mc_mapface.ktx2 and b/crates/bevy_core_pipeline/src/tonemapping/luts/tony_mc_mapface.ktx2 differ diff --git a/crates/bevy_image/Cargo.toml b/crates/bevy_image/Cargo.toml index f45a92afee..50f683ffd6 100644 --- a/crates/bevy_image/Cargo.toml +++ b/crates/bevy_image/Cargo.toml @@ -79,7 +79,7 @@ futures-lite = "2.0.1" guillotiere = "0.6.0" rectangle-pack = "0.4" ddsfile = { version = "0.5.2", optional = true } -ktx2 = { version = "0.4.0", optional = true } +ktx2 = { version = "0.5.0", optional = true } # For ktx2 supercompression flate2 = { version = "1.0.22", optional = true } zstd = { version = "0.13.3", optional = true } diff --git a/crates/bevy_image/src/ktx2.rs b/crates/bevy_image/src/ktx2.rs index a8362434dd..6fbd04a7da 100644 --- a/crates/bevy_image/src/ktx2.rs +++ b/crates/bevy_image/src/ktx2.rs @@ -10,8 +10,8 @@ use bevy_utils::default; #[cfg(any(feature = "flate2", feature = "zstd_rust", feature = "zstd_c"))] use ktx2::SupercompressionScheme; use ktx2::{ - ChannelTypeQualifiers, ColorModel, DfdBlockBasic, DfdBlockHeaderBasic, DfdHeader, Header, - SampleInformation, + dfd::{Basic, Block, ChannelTypeQualifiers, SampleInformation}, + ColorModel, Header, }; use wgpu_types::{ AstcBlock, AstcChannel, Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor, @@ -402,17 +402,8 @@ pub fn ktx2_get_texture_format>( } for data_format_descriptor in ktx2.dfd_blocks() { - if data_format_descriptor.header == DfdHeader::BASIC { - let basic_data_format_descriptor = DfdBlockBasic::parse(data_format_descriptor.data) - .map_err(|err| TextureError::InvalidData(format!("KTX2: {err:?}")))?; - let sample_information = basic_data_format_descriptor - .sample_information() - .collect::>(); - return ktx2_dfd_header_to_texture_format( - &basic_data_format_descriptor.header, - &sample_information, - is_srgb, - ); + if let Block::Basic(basic_data_format_descriptor) = data_format_descriptor { + return ktx2_dfd_header_to_texture_format(basic_data_format_descriptor, is_srgb); } } @@ -485,11 +476,11 @@ fn sample_information_to_data_type( /// Returns an error for invalid or unsupported texture formats. #[cfg(feature = "ktx2")] pub fn ktx2_dfd_header_to_texture_format( - data_format_descriptor: &DfdBlockHeaderBasic, - sample_information: &[SampleInformation], + basic_data_format_descriptor: &Basic, is_srgb: bool, ) -> Result { - Ok(match data_format_descriptor.color_model { + let sample_information = &basic_data_format_descriptor.sample_information; + Ok(match basic_data_format_descriptor.color_model { Some(ColorModel::RGBSDA) => { match sample_information.len() { 1 => { @@ -898,13 +889,13 @@ pub fn ktx2_dfd_header_to_texture_format( | Some(ColorModel::CIEXYY) => { return Err(TextureError::UnsupportedTextureFormat(format!( "{:?}", - data_format_descriptor.color_model + basic_data_format_descriptor.color_model ))); } Some(ColorModel::XYZW) => { // Same number of channels in both texel block dimensions and sample info descriptions assert_eq!( - data_format_descriptor.texel_block_dimensions[0].get() as usize, + basic_data_format_descriptor.texel_block_dimensions[0].get() as usize, sample_information.len() ); match sample_information.len() { @@ -1132,8 +1123,8 @@ pub fn ktx2_dfd_header_to_texture_format( }, Some(ColorModel::ASTC) => TextureFormat::Astc { block: match ( - data_format_descriptor.texel_block_dimensions[0].get(), - data_format_descriptor.texel_block_dimensions[1].get(), + basic_data_format_descriptor.texel_block_dimensions[0].get(), + basic_data_format_descriptor.texel_block_dimensions[1].get(), ) { (4, 4) => AstcBlock::B4x4, (5, 4) => AstcBlock::B5x4, @@ -1199,7 +1190,7 @@ pub fn ktx2_dfd_header_to_texture_format( _ => { return Err(TextureError::UnsupportedTextureFormat(format!( "Unknown KTX2 color model: {:?}", - data_format_descriptor.color_model + basic_data_format_descriptor.color_model ))); } })