From 929129ead9e251bf6dc33a04a39cd2d21383e156 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 4 Jul 2024 16:53:37 -0600 Subject: [PATCH] refactor: add and use `SampleCount::no_multisampling` ctor. --- benches/benches/renderpass.rs | 4 ++-- examples/src/bunnymark/mod.rs | 2 +- examples/src/conservative_raster/mod.rs | 2 +- examples/src/cube/mod.rs | 2 +- examples/src/framework.rs | 2 +- examples/src/mipmap/mod.rs | 2 +- examples/src/msaa_line/mod.rs | 2 +- examples/src/render_to_texture/mod.rs | 2 +- examples/src/shadow/mod.rs | 4 ++-- examples/src/skybox/mod.rs | 4 ++-- examples/src/stencil_triangles/mod.rs | 4 ++-- examples/src/storage_texture/mod.rs | 2 +- examples/src/texture_arrays/mod.rs | 2 +- examples/src/timestamp_queries/mod.rs | 2 +- examples/src/water/mod.rs | 6 +++--- tests/tests/bgra8unorm_storage.rs | 2 +- tests/tests/clear_texture.rs | 2 +- tests/tests/device.rs | 12 ++++++------ tests/tests/encoder.rs | 6 +++--- tests/tests/external_texture.rs | 2 +- tests/tests/float32_filterable.rs | 2 +- tests/tests/life_cycle.rs | 2 +- tests/tests/mem_leaks.rs | 2 +- tests/tests/nv12_texture/mod.rs | 12 ++++++------ tests/tests/occlusion_query/mod.rs | 2 +- tests/tests/partially_bounded_arrays/mod.rs | 2 +- tests/tests/queue_transfer.rs | 2 +- tests/tests/regression/issue_3349.rs | 2 +- tests/tests/regression/issue_3457.rs | 2 +- tests/tests/render_pass_ownership.rs | 2 +- tests/tests/scissor_tests/mod.rs | 2 +- tests/tests/shader_primitive_index/mod.rs | 2 +- tests/tests/shader_view_format/mod.rs | 4 ++-- tests/tests/texture_bounds.rs | 2 +- tests/tests/texture_view_creation.rs | 4 ++-- tests/tests/transfer.rs | 4 ++-- tests/tests/vertex_indices/mod.rs | 4 ++-- tests/tests/write_texture.rs | 4 ++-- tests/tests/zero_init_texture_after_discard.rs | 2 +- wgpu-hal/examples/halmark/main.rs | 4 ++-- wgpu-hal/examples/raw-gles.rs | 2 +- wgpu-hal/examples/ray-traced-triangle/main.rs | 2 +- wgpu-hal/src/dx12/mod.rs | 2 +- wgpu-types/src/lib.rs | 7 ++++++- 44 files changed, 73 insertions(+), 68 deletions(-) diff --git a/benches/benches/renderpass.rs b/benches/benches/renderpass.rs index 279b32bacc..f32cb032dc 100644 --- a/benches/benches/renderpass.rs +++ b/benches/benches/renderpass.rs @@ -95,7 +95,7 @@ impl RenderpassState { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::TEXTURE_BINDING, @@ -230,7 +230,7 @@ impl RenderpassState { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/examples/src/bunnymark/mod.rs b/examples/src/bunnymark/mod.rs index 88b27694ea..0a93a47b93 100644 --- a/examples/src/bunnymark/mod.rs +++ b/examples/src/bunnymark/mod.rs @@ -253,7 +253,7 @@ impl crate::framework::Example for Example { label: None, size, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::TEXTURE_BINDING, diff --git a/examples/src/conservative_raster/mod.rs b/examples/src/conservative_raster/mod.rs index c090fb9340..49fc94abd4 100644 --- a/examples/src/conservative_raster/mod.rs +++ b/examples/src/conservative_raster/mod.rs @@ -28,7 +28,7 @@ impl Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: RENDER_TARGET_FORMAT, usage: wgpu::TextureUsages::TEXTURE_BINDING diff --git a/examples/src/cube/mod.rs b/examples/src/cube/mod.rs index 7013bf6924..133d4f85f0 100644 --- a/examples/src/cube/mod.rs +++ b/examples/src/cube/mod.rs @@ -173,7 +173,7 @@ impl crate::framework::Example for Example { label: None, size: texture_extent, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::R8Uint, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, diff --git a/examples/src/framework.rs b/examples/src/framework.rs index f7e7373f42..d430ffe975 100644 --- a/examples/src/framework.rs +++ b/examples/src/framework.rs @@ -556,7 +556,7 @@ impl From> depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, diff --git a/examples/src/mipmap/mod.rs b/examples/src/mipmap/mod.rs index 3465267c7a..50d5c48edc 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -228,7 +228,7 @@ impl crate::framework::Example for Example { let texture = device.create_texture(&wgpu::TextureDescriptor { size: texture_extent, mip_level_count: MIP_LEVEL_COUNT, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: TEXTURE_FORMAT, usage: wgpu::TextureUsages::TEXTURE_BINDING diff --git a/examples/src/msaa_line/mod.rs b/examples/src/msaa_line/mod.rs index 0965d7f4ee..124b8ca41d 100644 --- a/examples/src/msaa_line/mod.rs +++ b/examples/src/msaa_line/mod.rs @@ -230,7 +230,7 @@ impl crate::framework::Example for Example { // supported sample counts to the user. Key::Named(NamedKey::ArrowLeft) => { if self.sample_count == self.max_sample_count { - self.sample_count = SampleCount::new(1); + self.sample_count = SampleCount::no_multisampling(); self.rebuild_bundle = true; } } diff --git a/examples/src/render_to_texture/mod.rs b/examples/src/render_to_texture/mod.rs index 180c57749e..2c39468438 100644 --- a/examples/src/render_to_texture/mod.rs +++ b/examples/src/render_to_texture/mod.rs @@ -40,7 +40,7 @@ async fn run(_path: Option) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, diff --git a/examples/src/shadow/mod.rs b/examples/src/shadow/mod.rs index 93aa2cc288..846cd20be1 100644 --- a/examples/src/shadow/mod.rs +++ b/examples/src/shadow/mod.rs @@ -192,7 +192,7 @@ impl Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: Self::DEPTH_FORMAT, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, @@ -381,7 +381,7 @@ impl crate::framework::Example for Example { let shadow_texture = device.create_texture(&wgpu::TextureDescriptor { size: Self::SHADOW_SIZE, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: Self::SHADOW_FORMAT, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING, diff --git a/examples/src/skybox/mod.rs b/examples/src/skybox/mod.rs index 34f139935a..31cfe82ad7 100644 --- a/examples/src/skybox/mod.rs +++ b/examples/src/skybox/mod.rs @@ -77,7 +77,7 @@ impl Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: Self::DEPTH_FORMAT, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, @@ -329,7 +329,7 @@ impl crate::framework::Example for Example { &wgpu::TextureDescriptor { size, mip_level_count: header.level_count, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: skybox_format, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, diff --git a/examples/src/stencil_triangles/mod.rs b/examples/src/stencil_triangles/mod.rs index c5c6130786..1613efab74 100644 --- a/examples/src/stencil_triangles/mod.rs +++ b/examples/src/stencil_triangles/mod.rs @@ -150,7 +150,7 @@ impl crate::framework::Example for Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Stencil8, view_formats: &[], @@ -185,7 +185,7 @@ impl crate::framework::Example for Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Stencil8, view_formats: &[], diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs index 1b67832bb3..87533e65c6 100644 --- a/examples/src/storage_texture/mod.rs +++ b/examples/src/storage_texture/mod.rs @@ -56,7 +56,7 @@ async fn run(_path: Option) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::COPY_SRC, diff --git a/examples/src/texture_arrays/mod.rs b/examples/src/texture_arrays/mod.rs index 2a3ceeeb34..50361517d9 100644 --- a/examples/src/texture_arrays/mod.rs +++ b/examples/src/texture_arrays/mod.rs @@ -159,7 +159,7 @@ impl crate::framework::Example for Example { let texture_descriptor = wgpu::TextureDescriptor { size: wgpu::Extent3d::default(), mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index 7f303b7702..c6be30399a 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -376,7 +376,7 @@ fn render_pass( depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/examples/src/water/mod.rs b/examples/src/water/mod.rs index 10cac2a746..0bbda44dfc 100644 --- a/examples/src/water/mod.rs +++ b/examples/src/water/mod.rs @@ -188,7 +188,7 @@ impl Example { label: Some("Reflection Render Texture"), size: texture_extent, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: config.view_formats[0], usage: wgpu::TextureUsages::TEXTURE_BINDING @@ -201,7 +201,7 @@ impl Example { label: Some("Depth Buffer"), size: texture_extent, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Depth32Float, usage: wgpu::TextureUsages::TEXTURE_BINDING @@ -620,7 +620,7 @@ impl crate::framework::Example for Example { depth_read_only: false, stencil_read_only: true, }), - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), multiview: None, }); encoder.set_pipeline(&terrain_pipeline); diff --git a/tests/tests/bgra8unorm_storage.rs b/tests/tests/bgra8unorm_storage.rs index 0688a249e0..5a3de0c9c9 100644 --- a/tests/tests/bgra8unorm_storage.rs +++ b/tests/tests/bgra8unorm_storage.rs @@ -33,7 +33,7 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new() depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Bgra8Unorm, usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::COPY_SRC, diff --git a/tests/tests/clear_texture.rs b/tests/tests/clear_texture.rs index bc8274e5fb..07789d193b 100644 --- a/tests/tests/clear_texture.rs +++ b/tests/tests/clear_texture.rs @@ -232,7 +232,7 @@ async fn single_texture_clear_test( // arbitrary value between 2 and max 3 }, - sample_count: wgpu::SampleCount::new(1), // multisampling is not supported for clear + sample_count: wgpu::SampleCount::no_multisampling(), // multisampling is not supported for clear dimension, format, usage: wgpu::TextureUsages::COPY_SRC | extra_usages, diff --git a/tests/tests/device.rs b/tests/tests/device.rs index ee316eb33d..f981ebd852 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -144,7 +144,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne label: None, size: texture_extent, mip_level_count: 2, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rg8Uint, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, @@ -156,7 +156,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne label: None, size: texture_extent, mip_level_count: 2, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rg8Uint, usage: wgpu::TextureUsages::COPY_SRC, @@ -167,7 +167,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne label: None, size: texture_extent, mip_level_count: 2, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rg8Uint, usage: wgpu::TextureUsages::COPY_DST, @@ -306,7 +306,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne depth_or_array_layers: 1, }, mip_level_count: 2, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rg8Uint, usage: wgpu::TextureUsages::COPY_SRC, @@ -757,7 +757,7 @@ static DIFFERENT_BGL_ORDER_BW_SHADER_AND_API: GpuTestConfiguration = GpuTestConf depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgt::TextureDimension::D2, format: wgt::TextureFormat::Rgba8Unorm, usage: wgt::TextureUsages::RENDER_ATTACHMENT | wgt::TextureUsages::TEXTURE_BINDING, @@ -856,7 +856,7 @@ static DEVICE_DESTROY_THEN_BUFFER_CLEANUP: GpuTestConfiguration = GpuTestConfigu label: None, size: texture_extent, mip_level_count: 2, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rg8Uint, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/tests/tests/encoder.rs b/tests/tests/encoder.rs index 04da545190..92f410dd23 100644 --- a/tests/tests/encoder.rs +++ b/tests/tests/encoder.rs @@ -41,7 +41,7 @@ static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::ne depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::R8Unorm, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, @@ -110,7 +110,7 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::COPY_DST, @@ -135,7 +135,7 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Bgra8UnormSrgb, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/tests/tests/external_texture.rs b/tests/tests/external_texture.rs index 60863eab76..fbf6a45429 100644 --- a/tests/tests/external_texture.rs +++ b/tests/tests/external_texture.rs @@ -255,7 +255,7 @@ static IMAGE_BITMAP_IMPORT: GpuTestConfiguration = depth_or_array_layers: dest_layers, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::RENDER_ATTACHMENT diff --git a/tests/tests/float32_filterable.rs b/tests/tests/float32_filterable.rs index 54e1277f60..8ac9610048 100644 --- a/tests/tests/float32_filterable.rs +++ b/tests/tests/float32_filterable.rs @@ -11,7 +11,7 @@ fn create_texture_binding(device: &wgpu::Device, format: wgpu::TextureFormat, fi depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, diff --git a/tests/tests/life_cycle.rs b/tests/tests/life_cycle.rs index b563c52604..2ea93d552a 100644 --- a/tests/tests/life_cycle.rs +++ b/tests/tests/life_cycle.rs @@ -88,7 +88,7 @@ static TEXTURE_DESTROY: GpuTestConfiguration = depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), // multisampling is not supported for clear + sample_count: wgpu::SampleCount::no_multisampling(), // multisampling is not supported for clear dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Snorm, usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::TEXTURE_BINDING, diff --git a/tests/tests/mem_leaks.rs b/tests/tests/mem_leaks.rs index 78445d6bc6..1fda0e38d4 100644 --- a/tests/tests/mem_leaks.rs +++ b/tests/tests/mem_leaks.rs @@ -145,7 +145,7 @@ async fn draw_test_with_reports( depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST, diff --git a/tests/tests/nv12_texture/mod.rs b/tests/tests/nv12_texture/mod.rs index f18d9ca688..783b438a96 100644 --- a/tests/tests/nv12_texture/mod.rs +++ b/tests/tests/nv12_texture/mod.rs @@ -51,7 +51,7 @@ static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfigurati format: wgpu::TextureFormat::NV12, usage: wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); let y_view = tex.create_view(&wgpu::TextureViewDescriptor { @@ -92,7 +92,7 @@ static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfigurati label: None, size, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: target_format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, @@ -138,7 +138,7 @@ static NV12_TEXTURE_VIEW_PLANE_ON_NON_PLANAR_FORMAT: GpuTestConfiguration = format: wgpu::TextureFormat::R8Unorm, usage: wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); fail( @@ -169,7 +169,7 @@ static NV12_TEXTURE_VIEW_PLANE_OUT_OF_BOUNDS: GpuTestConfiguration = GpuTestConf format: wgpu::TextureFormat::NV12, usage: wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); fail( @@ -201,7 +201,7 @@ static NV12_TEXTURE_BAD_FORMAT_VIEW_PLANE: GpuTestConfiguration = GpuTestConfigu format: wgpu::TextureFormat::NV12, usage: wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); fail( @@ -237,7 +237,7 @@ static NV12_TEXTURE_BAD_SIZE: GpuTestConfiguration = GpuTestConfiguration::new() format: wgpu::TextureFormat::NV12, usage: wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); }, diff --git a/tests/tests/occlusion_query/mod.rs b/tests/tests/occlusion_query/mod.rs index d120daa784..529b1ad71d 100644 --- a/tests/tests/occlusion_query/mod.rs +++ b/tests/tests/occlusion_query/mod.rs @@ -14,7 +14,7 @@ static OCCLUSION_QUERY: GpuTestConfiguration = GpuTestConfiguration::new() depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Depth32Float, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/tests/tests/partially_bounded_arrays/mod.rs b/tests/tests/partially_bounded_arrays/mod.rs index aa10653bd8..d13eb49cd6 100644 --- a/tests/tests/partially_bounded_arrays/mod.rs +++ b/tests/tests/partially_bounded_arrays/mod.rs @@ -26,7 +26,7 @@ static PARTIALLY_BOUNDED_ARRAY: GpuTestConfiguration = GpuTestConfiguration::new label: None, size: texture_extent, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba32Float, usage: wgpu::TextureUsages::TEXTURE_BINDING diff --git a/tests/tests/queue_transfer.rs b/tests/tests/queue_transfer.rs index dcdaecf901..21940fb9eb 100644 --- a/tests/tests/queue_transfer.rs +++ b/tests/tests/queue_transfer.rs @@ -13,7 +13,7 @@ static QUEUE_WRITE_TEXTURE_OVERFLOW: GpuTestConfiguration = depth_or_array_layers: 192, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba32Float, usage: wgpu::TextureUsages::COPY_DST, diff --git a/tests/tests/regression/issue_3349.rs b/tests/tests/regression/issue_3349.rs index 57f9207f3c..93a67fe234 100644 --- a/tests/tests/regression/issue_3349.rs +++ b/tests/tests/regression/issue_3349.rs @@ -130,7 +130,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, // Important: NOT srgb. format: wgpu::TextureFormat::Rgba8Unorm, diff --git a/tests/tests/regression/issue_3457.rs b/tests/tests/regression/issue_3457.rs index 605d63afe3..5b4d62fb4f 100644 --- a/tests/tests/regression/issue_3457.rs +++ b/tests/tests/regression/issue_3457.rs @@ -125,7 +125,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration = depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: TextureDimension::D2, format: TextureFormat::Rgba8Unorm, usage: TextureUsages::RENDER_ATTACHMENT, diff --git a/tests/tests/render_pass_ownership.rs b/tests/tests/render_pass_ownership.rs index e2e7138e81..f49baeff9e 100644 --- a/tests/tests/render_pass_ownership.rs +++ b/tests/tests/render_pass_ownership.rs @@ -468,7 +468,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup { let target_tex = ctx.device.create_texture(&target_desc); let target_tex_resolve = ctx.device.create_texture(&wgpu::TextureDescriptor { label: Some("target_resolve"), - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), ..target_desc }); diff --git a/tests/tests/scissor_tests/mod.rs b/tests/tests/scissor_tests/mod.rs index daa1ec5173..fd7889235e 100644 --- a/tests/tests/scissor_tests/mod.rs +++ b/tests/tests/scissor_tests/mod.rs @@ -24,7 +24,7 @@ async fn scissor_test_impl( depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::RENDER_ATTACHMENT, diff --git a/tests/tests/shader_primitive_index/mod.rs b/tests/tests/shader_primitive_index/mod.rs index 58fc5d6c35..99eaac430b 100644 --- a/tests/tests/shader_primitive_index/mod.rs +++ b/tests/tests/shader_primitive_index/mod.rs @@ -161,7 +161,7 @@ async fn pulling_common( label: None, size: texture_size, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, diff --git a/tests/tests/shader_view_format/mod.rs b/tests/tests/shader_view_format/mod.rs index 9bf08de36f..2fc4027c1c 100644 --- a/tests/tests/shader_view_format/mod.rs +++ b/tests/tests/shader_view_format/mod.rs @@ -75,7 +75,7 @@ async fn reinterpret( format: src_format, usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[reinterpret_to], }, wgpu::util::TextureDataOrder::LayerMajor, @@ -125,7 +125,7 @@ async fn reinterpret( label: None, size, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: src_format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, diff --git a/tests/tests/texture_bounds.rs b/tests/tests/texture_bounds.rs index 07bd22e6a5..d7bb862654 100644 --- a/tests/tests/texture_bounds.rs +++ b/tests/tests/texture_bounds.rs @@ -97,7 +97,7 @@ const TEXTURE_DESCRIPTOR: wgpu::TextureDescriptor = wgpu::TextureDescriptor { label: Some("CopyOrigin"), size: TEXTURE_SIZE, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, usage: wgpu::TextureUsages::COPY_DST.union(wgpu::TextureUsages::COPY_SRC), diff --git a/tests/tests/texture_view_creation.rs b/tests/tests/texture_view_creation.rs index 8d901d3ab5..eae0bcb684 100644 --- a/tests/tests/texture_view_creation.rs +++ b/tests/tests/texture_view_creation.rs @@ -18,7 +18,7 @@ static STENCIL_ONLY_VIEW_CREATION: GpuTestConfiguration = GpuTestConfiguration:: depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: TextureDimension::D2, format, usage: TextureUsages::COPY_DST @@ -49,7 +49,7 @@ static DEPTH_ONLY_VIEW_CREATION: GpuTestConfiguration = depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: TextureDimension::D2, format, usage: TextureUsages::COPY_DST diff --git a/tests/tests/transfer.rs b/tests/tests/transfer.rs index 9929c97598..6bc23c1753 100644 --- a/tests/tests/transfer.rs +++ b/tests/tests/transfer.rs @@ -17,7 +17,7 @@ static COPY_OVERFLOW_Z: GpuTestConfiguration = GpuTestConfiguration::new().run_s format: wgpu::TextureFormat::Rgba8Uint, usage: wgpu::TextureUsages::COPY_DST, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); let t2 = ctx.device.create_texture(&wgpu::TextureDescriptor { @@ -31,7 +31,7 @@ static COPY_OVERFLOW_Z: GpuTestConfiguration = GpuTestConfiguration::new().run_s format: wgpu::TextureFormat::Rgba8Uint, usage: wgpu::TextureUsages::COPY_DST, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index ef4d5de137..1cdf4ee767 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -307,7 +307,7 @@ async fn vertex_index_common(ctx: TestingContext) { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST, @@ -394,7 +394,7 @@ async fn vertex_index_common(ctx: TestingContext) { label: Some("test renderbundle encoder"), color_formats: &[Some(wgpu::TextureFormat::Rgba8Unorm)], depth_stencil: None, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), multiview: None, }, )), diff --git a/tests/tests/write_texture.rs b/tests/tests/write_texture.rs index 407173e7d4..99cda1f3b2 100644 --- a/tests/tests/write_texture.rs +++ b/tests/tests/write_texture.rs @@ -20,7 +20,7 @@ static WRITE_TEXTURE_SUBSET_2D: GpuTestConfiguration = | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); let data = vec![1u8; size as usize * 2]; @@ -115,7 +115,7 @@ static WRITE_TEXTURE_SUBSET_3D: GpuTestConfiguration = | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::TEXTURE_BINDING, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), view_formats: &[], }); let data = vec![1u8; (size * size) as usize * 2]; diff --git a/tests/tests/zero_init_texture_after_discard.rs b/tests/tests/zero_init_texture_after_discard.rs index 5444b47efc..9d0680fcfd 100644 --- a/tests/tests/zero_init_texture_after_discard.rs +++ b/tests/tests/zero_init_texture_after_discard.rs @@ -125,7 +125,7 @@ impl<'ctx> TestCase<'ctx> { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgpu::SampleCount::new(1), + sample_count: wgpu::SampleCount::no_multisampling(), dimension: TextureDimension::D2, format, usage: TextureUsages::COPY_DST diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 5f398b76dc..6f7b89ae40 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -313,7 +313,7 @@ impl Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgt::SampleCount::new(1), + sample_count: wgt::SampleCount::no_multisampling(), dimension: wgt::TextureDimension::D2, format: wgt::TextureFormat::Rgba8UnormSrgb, usage: hal::TextureUses::COPY_DST | hal::TextureUses::RESOURCE, @@ -690,7 +690,7 @@ impl Example { height: self.extent[1], depth_or_array_layers: 1, }, - sample_count: wgt::SampleCount::new(1), + sample_count: wgt::SampleCount::no_multisampling(), color_attachments: &[Some(hal::ColorAttachment { target: hal::Attachment { view: &surface_tex_view, diff --git a/wgpu-hal/examples/raw-gles.rs b/wgpu-hal/examples/raw-gles.rs index bcfe4b0a19..19aafaf7d4 100644 --- a/wgpu-hal/examples/raw-gles.rs +++ b/wgpu-hal/examples/raw-gles.rs @@ -312,7 +312,7 @@ fn fill_screen(exposed: &hal::ExposedAdapter, width: u32, height height, depth_or_array_layers: 1, }, - sample_count: wgt::SampleCount::new(1), + sample_count: wgt::SampleCount::no_multisampling(), color_attachments: &[Some(hal::ColorAttachment { target: hal::Attachment { view: &view, diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index 2f0badfe63..4df54d885c 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -578,7 +578,7 @@ impl Example { depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count: wgt::SampleCount::new(1), + sample_count: wgt::SampleCount::no_multisampling(), dimension: wgt::TextureDimension::D2, format: wgt::TextureFormat::Rgba8Unorm, usage: hal::TextureUses::STORAGE_READ_WRITE | hal::TextureUses::COPY_SRC, diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 9f098f9c08..7b47598545 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -1248,7 +1248,7 @@ impl crate::Surface for Surface { dimension: wgt::TextureDimension::D2, size: sc.size, mip_level_count: 1, - sample_count: wgt::SampleCount::new(1), + sample_count: wgt::SampleCount::no_multisampling(), allocation: None, }; Ok(Some(crate::AcquiredSurfaceTexture { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index cfeefd5a6c..d92001270e 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -6116,7 +6116,7 @@ impl TextureDescriptor { /// label: (), /// size: wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 }, /// mip_level_count: 7, - /// sample_count: wgpu::SampleCount::new(1), + /// sample_count: wgpu::SampleCount::no_multisampling(), /// dimension: wgpu::TextureDimension::D3, /// format: wgpu::TextureFormat::Rgba8Sint, /// usage: wgpu::TextureUsages::empty(), @@ -6184,6 +6184,11 @@ impl SampleCount { } } + /// Initializes with a count of 1. Implies no multisampling. + pub const fn no_multisampling() -> Self { + Self::new(1) + } + /// Retrieves the inner `u32` value of this count. pub const fn get(&self) -> u32 { self.0.get()