Skip to content

Commit f9509bc

Browse files
authored
[d3d12] use plane 1 for stencil only views (#5100)
* [d3d12] use plane 1 for stencil only views * add test * skip stencil only view creation on WebGL
1 parent 101e9a5 commit f9509bc

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

tests/tests/root.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod shader;
3434
mod shader_primitive_index;
3535
mod shader_view_format;
3636
mod texture_bounds;
37+
mod texture_view_creation;
3738
mod transfer;
3839
mod vertex_indices;
3940
mod write_texture;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use wgpu::*;
2+
use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters};
3+
4+
#[gpu_test]
5+
static STENCIL_ONLY_VIEW_CREATION: GpuTestConfiguration = GpuTestConfiguration::new()
6+
.parameters(
7+
TestParameters::default()
8+
.skip(FailureCase::webgl2()) // WebGL doesn't have stencil only views
9+
.limits(wgpu::Limits::downlevel_defaults()),
10+
)
11+
.run_async(|ctx| async move {
12+
for format in [TextureFormat::Stencil8, TextureFormat::Depth24PlusStencil8] {
13+
let texture = ctx.device.create_texture(&TextureDescriptor {
14+
label: None,
15+
size: Extent3d {
16+
width: 256,
17+
height: 256,
18+
depth_or_array_layers: 1,
19+
},
20+
mip_level_count: 1,
21+
sample_count: 1,
22+
dimension: TextureDimension::D2,
23+
format,
24+
usage: TextureUsages::COPY_DST
25+
| TextureUsages::COPY_SRC
26+
| TextureUsages::TEXTURE_BINDING,
27+
view_formats: &[],
28+
});
29+
let _view = texture.create_view(&TextureViewDescriptor {
30+
aspect: TextureAspect::StencilOnly,
31+
..Default::default()
32+
});
33+
}
34+
});
35+
36+
#[gpu_test]
37+
static DEPTH_ONLY_VIEW_CREATION: GpuTestConfiguration =
38+
GpuTestConfiguration::new().run_async(|ctx| async move {
39+
for format in [
40+
TextureFormat::Depth16Unorm,
41+
TextureFormat::Depth24Plus,
42+
TextureFormat::Depth24PlusStencil8,
43+
] {
44+
let texture = ctx.device.create_texture(&TextureDescriptor {
45+
label: None,
46+
size: Extent3d {
47+
width: 256,
48+
height: 256,
49+
depth_or_array_layers: 1,
50+
},
51+
mip_level_count: 1,
52+
sample_count: 1,
53+
dimension: TextureDimension::D2,
54+
format,
55+
usage: TextureUsages::COPY_DST
56+
| TextureUsages::COPY_SRC
57+
| TextureUsages::TEXTURE_BINDING,
58+
view_formats: &[],
59+
});
60+
let _view = texture.create_view(&TextureViewDescriptor {
61+
aspect: TextureAspect::DepthOnly,
62+
..Default::default()
63+
});
64+
}
65+
});

wgpu-hal/src/dx12/view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl crate::TextureViewDescriptor<'_> {
3636

3737
fn aspects_to_plane(aspects: crate::FormatAspects) -> u32 {
3838
match aspects {
39+
crate::FormatAspects::STENCIL => 1,
3940
crate::FormatAspects::PLANE_1 => 1,
4041
crate::FormatAspects::PLANE_2 => 2,
4142
_ => 0,

0 commit comments

Comments
 (0)