From 9c4be585f323ad7c2767b6e150033bc2eb1f2290 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-core/src/command/bundle.rs | 2 +- wgpu-core/src/present.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 ++++++- wgpu/src/lib.rs | 2 +- 47 files changed, 76 insertions(+), 71 deletions(-) diff --git a/benches/benches/renderpass.rs b/benches/benches/renderpass.rs index 8ff6aff8ca..74dc566faa 100644 --- a/benches/benches/renderpass.rs +++ b/benches/benches/renderpass.rs @@ -85,7 +85,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, @@ -220,7 +220,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 26f8270876..a0dd74413f 100644 --- a/examples/src/bunnymark/mod.rs +++ b/examples/src/bunnymark/mod.rs @@ -243,7 +243,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 5da6f197e3..8eb5551aaa 100644 --- a/examples/src/conservative_raster/mod.rs +++ b/examples/src/conservative_raster/mod.rs @@ -30,7 +30,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 ae329331d5..bbb36e684a 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 3a616faa66..84382f41bb 100644 --- a/examples/src/framework.rs +++ b/examples/src/framework.rs @@ -555,7 +555,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 6261faf611..25b4f6cff8 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -232,7 +232,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 49c3279a1d..58ae160074 100644 --- a/examples/src/msaa_line/mod.rs +++ b/examples/src/msaa_line/mod.rs @@ -233,7 +233,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 f4ab3c0573..e0ac3de39f 100644 --- a/examples/src/render_to_texture/mod.rs +++ b/examples/src/render_to_texture/mod.rs @@ -42,7 +42,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 45a659c739..54f6d8c916 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 509600b9d9..b1289b190b 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, @@ -332,7 +332,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 29c4f1c411..27c95ee4cf 100644 --- a/examples/src/stencil_triangles/mod.rs +++ b/examples/src/stencil_triangles/mod.rs @@ -154,7 +154,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: &[], @@ -189,7 +189,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 f686b8b5e1..ae11567346 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 2578589269..5f9ac02bc0 100644 --- a/examples/src/texture_arrays/mod.rs +++ b/examples/src/texture_arrays/mod.rs @@ -156,7 +156,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 ae615b1c12..7f0d93a93d 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -377,7 +377,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 4d1ffde593..1602cc3555 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 @@ -626,7 +626,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 b322d2eaac..b900e01680 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 b2bd37081d..7448c67fd7 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 e45d51cd73..51f549a6e4 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -172,7 +172,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, @@ -184,7 +184,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, @@ -195,7 +195,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, @@ -333,7 +333,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, @@ -804,7 +804,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, @@ -903,7 +903,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 34af78dd13..bc16cd1ff2 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 0268695fd1..a05173e6a5 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 f081d456f4..ffc91d443f 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 b286ebcbd7..cf14036eaa 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 c1611126f5..a974d92d42 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 a7bf6f7ae4..fe9ae8f743 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 49f1f5e7ee..c8c4c1937c 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 d74e04612c..519e9203bd 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 cd77f64e9d..64785ee724 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 eccf7eb89f..7e6661b787 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 c874b6d4ac..e6b204c5e0 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 25f72326e2..16d7da897c 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 e4f456289b..a2773ac0ba 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 6a0021e286..e84766fd27 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, @@ -124,7 +124,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 4c24147373..4397719651 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 6b4cfdebce..4716a8bf1f 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -326,7 +326,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, @@ -431,7 +431,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 5532f5fcfc..091c41670e 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-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index d99cc6a133..122857e163 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -312,7 +312,7 @@ impl RenderBundleEncoder { resolves: ArrayVec::new(), depth_stencil: None, }, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), multiview: None, }, is_depth_read_only: false, diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index c943a81cf5..587c1464ef 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -169,7 +169,7 @@ impl Global { height: config.height, depth_or_array_layers: 1, }, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), mip_level_count: 1, format: config.format, dimension: wgt::TextureDimension::D2, diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 8a58d9ddc7..1a8ca98c61 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -309,7 +309,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, @@ -686,7 +686,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 6828ecd731..a9501a0e18 100644 --- a/wgpu-hal/examples/raw-gles.rs +++ b/wgpu-hal/examples/raw-gles.rs @@ -164,7 +164,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 26debebfe3..80f12d2205 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -543,7 +543,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 6a2f4c54a6..6e2b5f64e4 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -875,7 +875,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 2e80df9ff8..fad9c761f1 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -5866,7 +5866,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(), @@ -5931,6 +5931,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() diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 967fccdbc7..9c422d1b67 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -5610,7 +5610,7 @@ impl Surface<'_> { format: config.format, usage: config.usage, mip_level_count: 1, - sample_count: SampleCount::new(1), + sample_count: SampleCount::no_multisampling(), dimension: TextureDimension::D2, view_formats: &[], };