Skip to content

Commit 9d25689

Browse files
authored
Remove Image::from_buffer name argument (only present in debug "dds" builds) (#18538)
# Objective - Fixes #17891 - Cherry-picked from #18411 ## Solution The `name` argument could either be made permanent (by removing the `#[cfg(...)]` condition) or eliminated entirely. I opted to remove it, as debugging a specific DDS texture edge case in GLTF files doesn't seem necessary, and there isn't any other foreseeable need to have it. ## Migration Guide - `Image::from_buffer()` no longer has a `name` argument that's only present in debug builds when the `"dds"` feature is enabled. If you happen to pass a name, remove it.
1 parent 8342608 commit 9d25689

File tree

11 files changed

+5
-41
lines changed

11 files changed

+5
-41
lines changed

crates/bevy_anti_aliasing/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ keywords = ["bevy"]
1212
trace = []
1313
webgl = []
1414
webgpu = []
15-
dds = ["bevy_render/dds", "bevy_image/dds", "bevy_core_pipeline/dds"]
1615
smaa_luts = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"]
1716

1817
[dependencies]

crates/bevy_anti_aliasing/src/smaa/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ impl Plugin for SmaaPlugin {
297297
SMAA_AREA_LUT_TEXTURE_HANDLE,
298298
"SMAAAreaLUT.ktx2",
299299
|bytes, _: String| Image::from_buffer(
300-
#[cfg(all(debug_assertions, feature = "dds"))]
301-
"SMAAAreaLUT".to_owned(),
302300
bytes,
303301
bevy_image::ImageType::Format(bevy_image::ImageFormat::Ktx2),
304302
bevy_image::CompressedImageFormats::NONE,
@@ -315,8 +313,6 @@ impl Plugin for SmaaPlugin {
315313
SMAA_SEARCH_LUT_TEXTURE_HANDLE,
316314
"SMAASearchLUT.ktx2",
317315
|bytes, _: String| Image::from_buffer(
318-
#[cfg(all(debug_assertions, feature = "dds"))]
319-
"SMAASearchLUT".to_owned(),
320316
bytes,
321317
bevy_image::ImageType::Format(bevy_image::ImageFormat::Ktx2),
322318
bevy_image::CompressedImageFormats::NONE,

crates/bevy_core_pipeline/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ license = "MIT OR Apache-2.0"
1313
keywords = ["bevy"]
1414

1515
[features]
16-
dds = ["bevy_render/dds", "bevy_image/dds"]
1716
trace = []
1817
webgl = []
1918
webgpu = []

crates/bevy_core_pipeline/src/tonemapping/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ fn setup_tonemapping_lut_image(bytes: &[u8], image_type: ImageType) -> Image {
449449
..default()
450450
});
451451
Image::from_buffer(
452-
#[cfg(all(debug_assertions, feature = "dds"))]
453-
"Tonemapping LUT sampler".to_string(),
454452
bytes,
455453
image_type,
456454
CompressedImageFormats::NONE,

crates/bevy_gltf/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ license = "MIT OR Apache-2.0"
99
keywords = ["bevy"]
1010

1111
[features]
12-
dds = ["bevy_render/dds", "bevy_image/dds", "bevy_core_pipeline/dds"]
1312
pbr_transmission_textures = ["bevy_pbr/pbr_transmission_textures"]
1413
pbr_multi_layer_material_textures = [
1514
"bevy_pbr/pbr_multi_layer_material_textures",

crates/bevy_gltf/src/loader/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -976,18 +976,13 @@ async fn load_image<'a, 'b>(
976976
) -> Result<ImageOrPath, GltfError> {
977977
let is_srgb = !linear_textures.contains(&gltf_texture.index());
978978
let sampler_descriptor = texture_sampler(&gltf_texture);
979-
#[cfg(all(debug_assertions, feature = "dds"))]
980-
let name = gltf_texture
981-
.name()
982-
.map_or("Unknown GLTF Texture".to_string(), ToString::to_string);
979+
983980
match gltf_texture.source().source() {
984981
Source::View { view, mime_type } => {
985982
let start = view.offset();
986983
let end = view.offset() + view.length();
987984
let buffer = &buffer_data[view.buffer().index()][start..end];
988985
let image = Image::from_buffer(
989-
#[cfg(all(debug_assertions, feature = "dds"))]
990-
name,
991986
buffer,
992987
ImageType::MimeType(mime_type),
993988
supported_compressed_formats,
@@ -1010,8 +1005,6 @@ async fn load_image<'a, 'b>(
10101005
let image_type = ImageType::MimeType(data_uri.mime_type);
10111006
Ok(ImageOrPath::Image {
10121007
image: Image::from_buffer(
1013-
#[cfg(all(debug_assertions, feature = "dds"))]
1014-
name,
10151008
&bytes,
10161009
mime_type.map(ImageType::MimeType).unwrap_or(image_type),
10171010
supported_compressed_formats,

crates/bevy_image/src/dds.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use super::{CompressedImageFormats, Image, TextureError, TranscodeFormat};
1212

1313
#[cfg(feature = "dds")]
1414
pub fn dds_buffer_to_image(
15-
#[cfg(debug_assertions)] name: String,
1615
buffer: &[u8],
1716
supported_compressed_formats: CompressedImageFormats,
1817
is_srgb: bool,
@@ -65,10 +64,7 @@ pub fn dds_buffer_to_image(
6564
let mip_map_level = match dds.get_num_mipmap_levels() {
6665
0 => {
6766
#[cfg(debug_assertions)]
68-
once!(warn!(
69-
"Mipmap levels for texture {} are 0, bumping them to 1",
70-
name
71-
));
67+
once!(warn!("Mipmap levels for texture are 0, bumping them to 1",));
7268
1
7369
}
7470
t => t,
@@ -409,7 +405,7 @@ mod test {
409405
0x49, 0x92, 0x24, 0x16, 0x95, 0xae, 0x42, 0xfc, 0, 0xaa, 0x55, 0xff, 0xff, 0x49, 0x92,
410406
0x24, 0x49, 0x92, 0x24, 0xd8, 0xad, 0xae, 0x42, 0xaf, 0x0a, 0xaa, 0x55,
411407
];
412-
let r = dds_buffer_to_image("".into(), &buffer, CompressedImageFormats::BC, true);
408+
let r = dds_buffer_to_image(&buffer, CompressedImageFormats::BC, true);
413409
assert!(r.is_ok());
414410
if let Ok(r) = r {
415411
fake_wgpu_create_texture_with_data(&r.texture_descriptor, r.data.as_ref().unwrap());

crates/bevy_image/src/image.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@ impl Image {
928928
/// Load a bytes buffer in a [`Image`], according to type `image_type`, using the `image`
929929
/// crate
930930
pub fn from_buffer(
931-
#[cfg(all(debug_assertions, feature = "dds"))] name: String,
932931
buffer: &[u8],
933932
image_type: ImageType,
934933
#[cfg_attr(
@@ -954,13 +953,7 @@ impl Image {
954953
basis_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?
955954
}
956955
#[cfg(feature = "dds")]
957-
ImageFormat::Dds => dds_buffer_to_image(
958-
#[cfg(debug_assertions)]
959-
name,
960-
buffer,
961-
supported_compressed_formats,
962-
is_srgb,
963-
)?,
956+
ImageFormat::Dds => dds_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?,
964957
#[cfg(feature = "ktx2")]
965958
ImageFormat::Ktx2 => {
966959
ktx2_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?

crates/bevy_image/src/image_loader.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ impl AssetLoader for ImageLoader {
150150
}
151151
};
152152
Ok(Image::from_buffer(
153-
#[cfg(all(debug_assertions, feature = "dds"))]
154-
load_context.path().display().to_string(),
155153
&bytes,
156154
image_type,
157155
self.supported_compressed_formats,

crates/bevy_internal/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ sysinfo_plugin = ["bevy_diagnostic/sysinfo_plugin"]
3030

3131
# Texture formats that have specific rendering support (HDR enabled by default)
3232
basis-universal = ["bevy_image/basis-universal", "bevy_render/basis-universal"]
33-
dds = [
34-
"bevy_image/dds",
35-
"bevy_render/dds",
36-
"bevy_core_pipeline/dds",
37-
"bevy_anti_aliasing/dds",
38-
"bevy_gltf?/dds",
39-
]
4033
exr = ["bevy_image/exr", "bevy_render/exr"]
4134
hdr = ["bevy_image/hdr", "bevy_render/hdr"]
4235
ktx2 = ["bevy_image/ktx2", "bevy_render/ktx2"]
@@ -57,6 +50,7 @@ qoi = ["bevy_image/qoi"]
5750
tga = ["bevy_image/tga"]
5851
tiff = ["bevy_image/tiff"]
5952
webp = ["bevy_image/webp"]
53+
dds = ["bevy_image/dds"]
6054

6155
# Enable SPIR-V passthrough
6256
spirv_shader_passthrough = ["bevy_render/spirv_shader_passthrough"]

crates/bevy_render/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ decoupled_naga = []
2323

2424
# Texture formats (require more than just image support)
2525
basis-universal = ["bevy_image/basis-universal"]
26-
dds = ["bevy_image/dds"]
2726
exr = ["bevy_image/exr"]
2827
hdr = ["bevy_image/hdr"]
2928
ktx2 = ["dep:ktx2", "bevy_image/ktx2"]

0 commit comments

Comments
 (0)