Fix 1x1 dds textures being interpreted as 1-dimensional (#17890)

# Objective

Fixes #8615

## Solution

Bevy currently interprets 1x1 dds textures as 1-dimensional. I think it
might be more common for game engines to assume two dimensions in this
ambiguous case. [citation needed]

I reworked the dimension choosing logic to only use 1d if there's a
dimension > 1, and assume 2d otherwise. I kept the assumption that
compressed textures are probably 2d.

## Testing

Modified `sprite.rs` to use `Tex_0012_0.dds` from the linked issue.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
Rob Parrett 2025-02-21 18:59:51 -07:00 committed by GitHub
parent a7cb061d6c
commit 9046859ca8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,10 +66,14 @@ pub fn dds_buffer_to_image(
image.texture_descriptor.format = texture_format;
image.texture_descriptor.dimension = if dds.get_depth() > 1 {
TextureDimension::D3
} else if image.is_compressed() || dds.get_height() > 1 {
TextureDimension::D2
} else {
// 1x1 textures should generally be interpreted as solid 2D
} else if ((dds.get_width() > 1 || dds.get_height() > 1)
&& !(dds.get_width() > 1 && dds.get_height() > 1))
&& !image.is_compressed()
{
TextureDimension::D1
} else {
TextureDimension::D2
};
if is_cubemap {
let dimension = if image.texture_descriptor.size.depth_or_array_layers > 6 {