Skip to content

Commit 098aaae

Browse files
authored
Extend texture tests with exhaust (#9172)
1 parent a53ffff commit 098aaae

File tree

10 files changed

+171
-220
lines changed

10 files changed

+171
-220
lines changed

.deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ skip = [
2424
# Deno uses an old version
2525
{ name = "bincode", version = "1.3.3" },
2626
{ name = "which", version = "6.0.3" },
27+
{ name = "itertools", version = "0.13.0" },
2728

2829
# Winit uses an old version via android-activity → jni
2930
{ name = "windows-sys", version = "0.45" },

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ diff = "0.1"
124124
document-features = "0.2.10"
125125
encase = "0.12"
126126
env_logger = { version = "0.11", default-features = false }
127+
exhaust = "0.2"
127128
fern = "0.7"
128129
flume = "0.12"
129130
futures-lite = "2"

wgpu-info/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ rust-version.workspace = true
1414
anyhow.workspace = true
1515
bitflags.workspace = true
1616
env_logger.workspace = true
17+
exhaust.workspace = true
1718
hashbrown = { workspace = true, features = ["serde"] }
1819
pico-args.workspace = true
1920
pollster.workspace = true
2021
serde = { workspace = true, features = ["default"] }
2122
serde_json.workspace = true
22-
wgpu.workspace = true
23+
wgpu = { workspace = true, features = ["exhaust"] }
2324

2425
[lints.clippy]
2526
disallowed_types = "allow"

wgpu-info/src/human.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::io;
22

33
use bitflags::Flags;
4+
use exhaust::Exhaust;
45
use wgpu::AdapterInfo;
56

67
use crate::{
78
report::{AdapterReport, GpuReport},
8-
texture::{self, TEXTURE_FORMAT_LIST},
9+
texture,
910
};
1011

1112
trait FlagsExt: Flags {
@@ -288,7 +289,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
288289

289290
write!(output, "\t\t {texture_format_whitespace}")?;
290291
wgpu::TextureUsages::println_table_header(output)?;
291-
for format in TEXTURE_FORMAT_LIST {
292+
for format in wgpu::TextureFormat::exhaust() {
292293
let features = texture_format_features[&format];
293294
let format_name = texture::texture_format_name(format);
294295
write!(output, "\t\t{format_name:>max_format_name_size$}")?;
@@ -316,7 +317,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
316317
write!(output, "\t\t {texture_format_whitespace}")?;
317318
wgpu::TextureFormatFeatureFlags::println_table_header(output)?;
318319

319-
for format in TEXTURE_FORMAT_LIST {
320+
for format in wgpu::TextureFormat::exhaust() {
320321
let features = texture_format_features[&format];
321322
let format_name = texture::texture_format_name(format);
322323

wgpu-info/src/report.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use std::io;
22

3+
use exhaust::Exhaust;
34
use hashbrown::HashMap;
45
use serde::{Deserialize, Serialize};
56
use wgpu::{
67
AdapterInfo, DownlevelCapabilities, Dx12Compiler, Features, Limits, TextureFormat,
78
TextureFormatFeatures,
89
};
910

10-
use crate::texture;
11-
1211
/// Report specifying the capabilities of the GPUs on the system.
1312
///
1413
/// Must be synchronized with the definition on tests/src/report.rs.
@@ -33,8 +32,7 @@ impl GpuReport {
3332
let features = adapter.features();
3433
let limits = adapter.limits();
3534
let downlevel_caps = adapter.get_downlevel_capabilities();
36-
let texture_format_features = texture::TEXTURE_FORMAT_LIST
37-
.into_iter()
35+
let texture_format_features = wgpu::TextureFormat::exhaust()
3836
.map(|format| (format, adapter.get_texture_format_features(format)))
3937
.collect();
4038

wgpu-info/src/texture.rs

Lines changed: 3 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,8 @@
1-
// Lets keep these on one line
2-
#[rustfmt::skip]
3-
pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 118] = [
4-
wgpu::TextureFormat::R8Unorm,
5-
wgpu::TextureFormat::R8Snorm,
6-
wgpu::TextureFormat::R8Uint,
7-
wgpu::TextureFormat::R8Sint,
8-
wgpu::TextureFormat::R16Uint,
9-
wgpu::TextureFormat::R16Sint,
10-
wgpu::TextureFormat::R16Unorm,
11-
wgpu::TextureFormat::R16Snorm,
12-
wgpu::TextureFormat::R16Float,
13-
wgpu::TextureFormat::Rg8Unorm,
14-
wgpu::TextureFormat::Rg8Snorm,
15-
wgpu::TextureFormat::Rg8Uint,
16-
wgpu::TextureFormat::Rg8Sint,
17-
wgpu::TextureFormat::R32Uint,
18-
wgpu::TextureFormat::R32Sint,
19-
wgpu::TextureFormat::R32Float,
20-
wgpu::TextureFormat::Rg16Uint,
21-
wgpu::TextureFormat::Rg16Sint,
22-
wgpu::TextureFormat::Rg16Unorm,
23-
wgpu::TextureFormat::Rg16Snorm,
24-
wgpu::TextureFormat::Rg16Float,
25-
wgpu::TextureFormat::Rgba8Unorm,
26-
wgpu::TextureFormat::Rgba8UnormSrgb,
27-
wgpu::TextureFormat::Rgba8Snorm,
28-
wgpu::TextureFormat::Rgba8Uint,
29-
wgpu::TextureFormat::Rgba8Sint,
30-
wgpu::TextureFormat::Bgra8Unorm,
31-
wgpu::TextureFormat::Bgra8UnormSrgb,
32-
wgpu::TextureFormat::Rgb9e5Ufloat,
33-
wgpu::TextureFormat::Rgb10a2Uint,
34-
wgpu::TextureFormat::Rgb10a2Unorm,
35-
wgpu::TextureFormat::Rg11b10Ufloat,
36-
wgpu::TextureFormat::R64Uint,
37-
wgpu::TextureFormat::Rg32Uint,
38-
wgpu::TextureFormat::Rg32Sint,
39-
wgpu::TextureFormat::Rg32Float,
40-
wgpu::TextureFormat::Rgba16Uint,
41-
wgpu::TextureFormat::Rgba16Sint,
42-
wgpu::TextureFormat::Rgba16Unorm,
43-
wgpu::TextureFormat::Rgba16Snorm,
44-
wgpu::TextureFormat::Rgba16Float,
45-
wgpu::TextureFormat::Rgba32Uint,
46-
wgpu::TextureFormat::Rgba32Sint,
47-
wgpu::TextureFormat::Rgba32Float,
48-
wgpu::TextureFormat::Stencil8,
49-
wgpu::TextureFormat::Depth16Unorm,
50-
wgpu::TextureFormat::Depth24Plus,
51-
wgpu::TextureFormat::Depth24PlusStencil8,
52-
wgpu::TextureFormat::Depth32Float,
53-
wgpu::TextureFormat::Depth32FloatStencil8,
54-
wgpu::TextureFormat::NV12,
55-
wgpu::TextureFormat::P010,
56-
wgpu::TextureFormat::Bc1RgbaUnorm,
57-
wgpu::TextureFormat::Bc1RgbaUnormSrgb,
58-
wgpu::TextureFormat::Bc2RgbaUnorm,
59-
wgpu::TextureFormat::Bc2RgbaUnormSrgb,
60-
wgpu::TextureFormat::Bc3RgbaUnorm,
61-
wgpu::TextureFormat::Bc3RgbaUnormSrgb,
62-
wgpu::TextureFormat::Bc4RUnorm,
63-
wgpu::TextureFormat::Bc4RSnorm,
64-
wgpu::TextureFormat::Bc5RgUnorm,
65-
wgpu::TextureFormat::Bc5RgSnorm,
66-
wgpu::TextureFormat::Bc6hRgbUfloat,
67-
wgpu::TextureFormat::Bc6hRgbFloat,
68-
wgpu::TextureFormat::Bc7RgbaUnorm,
69-
wgpu::TextureFormat::Bc7RgbaUnormSrgb,
70-
wgpu::TextureFormat::Etc2Rgb8Unorm,
71-
wgpu::TextureFormat::Etc2Rgb8UnormSrgb,
72-
wgpu::TextureFormat::Etc2Rgb8A1Unorm,
73-
wgpu::TextureFormat::Etc2Rgb8A1UnormSrgb,
74-
wgpu::TextureFormat::Etc2Rgba8Unorm,
75-
wgpu::TextureFormat::Etc2Rgba8UnormSrgb,
76-
wgpu::TextureFormat::EacR11Unorm,
77-
wgpu::TextureFormat::EacR11Snorm,
78-
wgpu::TextureFormat::EacRg11Unorm,
79-
wgpu::TextureFormat::EacRg11Snorm,
80-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B4x4, channel: wgpu::AstcChannel::Unorm },
81-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B4x4, channel: wgpu::AstcChannel::UnormSrgb },
82-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B4x4, channel: wgpu::AstcChannel::Hdr },
83-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x4, channel: wgpu::AstcChannel::Unorm },
84-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x4, channel: wgpu::AstcChannel::UnormSrgb },
85-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x4, channel: wgpu::AstcChannel::Hdr },
86-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x5, channel: wgpu::AstcChannel::Unorm },
87-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x5, channel: wgpu::AstcChannel::UnormSrgb },
88-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B5x5, channel: wgpu::AstcChannel::Hdr },
89-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x5, channel: wgpu::AstcChannel::Unorm },
90-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x5, channel: wgpu::AstcChannel::UnormSrgb },
91-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x5, channel: wgpu::AstcChannel::Hdr },
92-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x6, channel: wgpu::AstcChannel::Unorm },
93-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x6, channel: wgpu::AstcChannel::UnormSrgb },
94-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B6x6, channel: wgpu::AstcChannel::Hdr },
95-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x5, channel: wgpu::AstcChannel::Unorm },
96-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x5, channel: wgpu::AstcChannel::UnormSrgb },
97-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x5, channel: wgpu::AstcChannel::Hdr },
98-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x6, channel: wgpu::AstcChannel::Unorm },
99-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x6, channel: wgpu::AstcChannel::UnormSrgb },
100-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x6, channel: wgpu::AstcChannel::Hdr },
101-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x8, channel: wgpu::AstcChannel::Unorm },
102-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x8, channel: wgpu::AstcChannel::UnormSrgb },
103-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B8x8, channel: wgpu::AstcChannel::Hdr },
104-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x5, channel: wgpu::AstcChannel::Unorm },
105-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x5, channel: wgpu::AstcChannel::UnormSrgb },
106-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x5, channel: wgpu::AstcChannel::Hdr },
107-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x6, channel: wgpu::AstcChannel::Unorm },
108-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x6, channel: wgpu::AstcChannel::UnormSrgb },
109-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x6, channel: wgpu::AstcChannel::Hdr },
110-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x8, channel: wgpu::AstcChannel::Unorm },
111-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x8, channel: wgpu::AstcChannel::UnormSrgb },
112-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x8, channel: wgpu::AstcChannel::Hdr },
113-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x10, channel: wgpu::AstcChannel::Unorm },
114-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x10, channel: wgpu::AstcChannel::UnormSrgb },
115-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B10x10, channel: wgpu::AstcChannel::Hdr },
116-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x10, channel: wgpu::AstcChannel::Unorm },
117-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x10, channel: wgpu::AstcChannel::UnormSrgb },
118-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x10, channel: wgpu::AstcChannel::Hdr },
119-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x12, channel: wgpu::AstcChannel::Unorm },
120-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x12, channel: wgpu::AstcChannel::UnormSrgb },
121-
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x12, channel: wgpu::AstcChannel::Hdr },
122-
];
123-
124-
#[test]
125-
fn test_uniqueness_in_texture_format_list() {
126-
use std::collections::HashSet;
127-
128-
let uniq: HashSet<wgpu::TextureFormat> = TEXTURE_FORMAT_LIST.into_iter().collect();
129-
let mut duplicated = TEXTURE_FORMAT_LIST.to_vec();
130-
uniq.iter().for_each(|u| {
131-
let first_occurrence = duplicated.iter().position(|el| u == el).unwrap();
132-
duplicated.remove(first_occurrence);
133-
});
134-
assert_eq!(duplicated, vec![]);
135-
}
1+
use exhaust::Exhaust;
1362

1373
#[test]
1384
fn test_compute_render_extent() {
139-
for format in TEXTURE_FORMAT_LIST {
5+
for format in wgpu::TextureFormat::exhaust() {
1406
let desc = wgpu::TextureDescriptor {
1417
label: None,
1428
size: wgpu::Extent3d {
@@ -211,8 +77,7 @@ fn test_compute_render_extent() {
21177
}
21278

21379
pub fn max_texture_format_string_size() -> usize {
214-
TEXTURE_FORMAT_LIST
215-
.into_iter()
80+
wgpu::TextureFormat::exhaust()
21681
.map(|f| texture_format_name(f).len())
21782
.max()
21883
.unwrap()

wgpu-types/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ counters = []
4747
trace = ["std"]
4848
# Enable web-specific dependencies for wasm.
4949
web = ["dep:js-sys", "dep:web-sys"]
50+
exhaust = ["dep:exhaust"]
5051

5152
[dependencies]
5253
bitflags.workspace = true
5354
bytemuck = { workspace = true, features = ["derive"] }
55+
exhaust = { workspace = true, optional = true }
5456
log.workspace = true
5557
raw-window-handle.workspace = true
5658
serde = { workspace = true, default-features = false, features = [
@@ -71,5 +73,7 @@ web-sys = { workspace = true, optional = true, default-features = false, feature
7173
] }
7274

7375
[dev-dependencies]
76+
exhaust.workspace = true
77+
hashbrown.workspace = true
7478
serde = { workspace = true, features = ["derive"] }
7579
serde_json.workspace = true

0 commit comments

Comments
 (0)