From fb2e77106adcb1d52bdc0a718964ee02f507fb3e Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 5 Feb 2021 20:26:54 +0000 Subject: [PATCH] Remove utils::GetDefaultSamplerDescriptor This helper is no longer needed now that the descriptor has full defaults and is even optional in CreateSampler. Bug: dawn:599 Change-Id: I0d25233ebb1e817ad27f3ddaca988e01e2a5298c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40520 Commit-Queue: Stephen White Auto-Submit: Corentin Wallez Reviewed-by: Austin Eng Reviewed-by: Stephen White --- examples/CppHelloTriangle.cpp | 3 +- .../end2end/CompressedTextureFormatTests.cpp | 2 +- src/tests/end2end/IOSurfaceWrappingTests.cpp | 3 +- src/tests/end2end/ObjectCachingTests.cpp | 34 +++++++++---------- src/tests/end2end/TextureZeroInitTests.cpp | 18 ++++------ .../validation/BindGroupValidationTests.cpp | 7 ++-- .../validation/SamplerValidationTests.cpp | 13 +++---- .../StorageTextureValidationTests.cpp | 3 +- .../white_box/D3D12DescriptorHeapTests.cpp | 3 +- src/tests/white_box/D3D12ResidencyTests.cpp | 3 +- src/utils/WGPUHelpers.cpp | 13 ------- src/utils/WGPUHelpers.h | 1 - 12 files changed, 36 insertions(+), 67 deletions(-) diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp index 9c608c8fc1..bc1df72324 100644 --- a/examples/CppHelloTriangle.cpp +++ b/examples/CppHelloTriangle.cpp @@ -62,8 +62,7 @@ void initTextures() { descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled; texture = device.CreateTexture(&descriptor); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - sampler = device.CreateSampler(&samplerDesc); + sampler = device.CreateSampler(); // Initialize the texture with arbitrary data until we can load images std::vector data(4 * 1024 * 1024, 0); diff --git a/src/tests/end2end/CompressedTextureFormatTests.cpp b/src/tests/end2end/CompressedTextureFormatTests.cpp index a6b652350e..a9eb06f1c0 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -117,7 +117,7 @@ class CompressedTextureBCFormatTest : public DawnTest { uint32_t baseMipLevel = 0) { ASSERT(IsBCFormatSupported()); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.minFilter = wgpu::FilterMode::Nearest; samplerDesc.magFilter = wgpu::FilterMode::Nearest; wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index f0ebfe2bf3..58ebf6e177 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -307,8 +307,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { wgpu::TextureView textureView = wrappingTexture.CreateView(); - wgpu::SamplerDescriptor samplerDescriptor = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDescriptor); + wgpu::Sampler sampler = device.CreateSampler(); bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, sampler}, {1, textureView}}); diff --git a/src/tests/end2end/ObjectCachingTests.cpp b/src/tests/end2end/ObjectCachingTests.cpp index 1847bbd04a..47fff0aec7 100644 --- a/src/tests/end2end/ObjectCachingTests.cpp +++ b/src/tests/end2end/ObjectCachingTests.cpp @@ -311,45 +311,45 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) { // Test that Samplers are correctly deduplicated. TEST_P(ObjectCachingTest, SamplerDeduplication) { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); - wgpu::SamplerDescriptor sameSamplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor sameSamplerDesc; wgpu::Sampler sameSampler = device.CreateSampler(&sameSamplerDesc); - wgpu::SamplerDescriptor otherSamplerDescAddressModeU = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescAddressModeU.addressModeU = wgpu::AddressMode::ClampToEdge; + wgpu::SamplerDescriptor otherSamplerDescAddressModeU; + otherSamplerDescAddressModeU.addressModeU = wgpu::AddressMode::Repeat; wgpu::Sampler otherSamplerAddressModeU = device.CreateSampler(&otherSamplerDescAddressModeU); - wgpu::SamplerDescriptor otherSamplerDescAddressModeV = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescAddressModeV.addressModeV = wgpu::AddressMode::ClampToEdge; + wgpu::SamplerDescriptor otherSamplerDescAddressModeV; + otherSamplerDescAddressModeV.addressModeV = wgpu::AddressMode::Repeat; wgpu::Sampler otherSamplerAddressModeV = device.CreateSampler(&otherSamplerDescAddressModeV); - wgpu::SamplerDescriptor otherSamplerDescAddressModeW = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescAddressModeW.addressModeW = wgpu::AddressMode::ClampToEdge; + wgpu::SamplerDescriptor otherSamplerDescAddressModeW; + otherSamplerDescAddressModeW.addressModeW = wgpu::AddressMode::Repeat; wgpu::Sampler otherSamplerAddressModeW = device.CreateSampler(&otherSamplerDescAddressModeW); - wgpu::SamplerDescriptor otherSamplerDescMagFilter = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescMagFilter.magFilter = wgpu::FilterMode::Nearest; + wgpu::SamplerDescriptor otherSamplerDescMagFilter; + otherSamplerDescMagFilter.magFilter = wgpu::FilterMode::Linear; wgpu::Sampler otherSamplerMagFilter = device.CreateSampler(&otherSamplerDescMagFilter); - wgpu::SamplerDescriptor otherSamplerDescMinFilter = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescMinFilter.minFilter = wgpu::FilterMode::Nearest; + wgpu::SamplerDescriptor otherSamplerDescMinFilter; + otherSamplerDescMinFilter.minFilter = wgpu::FilterMode::Linear; wgpu::Sampler otherSamplerMinFilter = device.CreateSampler(&otherSamplerDescMinFilter); - wgpu::SamplerDescriptor otherSamplerDescMipmapFilter = utils::GetDefaultSamplerDescriptor(); - otherSamplerDescMipmapFilter.mipmapFilter = wgpu::FilterMode::Nearest; + wgpu::SamplerDescriptor otherSamplerDescMipmapFilter; + otherSamplerDescMipmapFilter.mipmapFilter = wgpu::FilterMode::Linear; wgpu::Sampler otherSamplerMipmapFilter = device.CreateSampler(&otherSamplerDescMipmapFilter); - wgpu::SamplerDescriptor otherSamplerDescLodMinClamp = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor otherSamplerDescLodMinClamp; otherSamplerDescLodMinClamp.lodMinClamp += 1; wgpu::Sampler otherSamplerLodMinClamp = device.CreateSampler(&otherSamplerDescLodMinClamp); - wgpu::SamplerDescriptor otherSamplerDescLodMaxClamp = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor otherSamplerDescLodMaxClamp; otherSamplerDescLodMaxClamp.lodMaxClamp += 1; wgpu::Sampler otherSamplerLodMaxClamp = device.CreateSampler(&otherSamplerDescLodMaxClamp); - wgpu::SamplerDescriptor otherSamplerDescCompareFunction = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor otherSamplerDescCompareFunction; otherSamplerDescCompareFunction.compare = wgpu::CompareFunction::Always; wgpu::Sampler otherSamplerCompareFunction = device.CreateSampler(&otherSamplerDescCompareFunction); diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp index 590d4956e1..ff8e3bedb0 100644 --- a/src/tests/end2end/TextureZeroInitTests.cpp +++ b/src/tests/end2end/TextureZeroInitTests.cpp @@ -853,8 +853,7 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) { 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); // Create render pipeline utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); @@ -923,8 +922,7 @@ TEST_P(TextureZeroInitTest, TextureBothSampledAndAttachmentClear) { wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); // Create bindgroup - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), {{0, sampler}, {1, sampleView}}); @@ -972,8 +970,7 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) { uint32_t data = 100; queue.WriteBuffer(bufferTex, 0, &data, sizeof(data)); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); // Create compute pipeline wgpu::ComputePipelineDescriptor computePipelineDescriptor; @@ -1131,8 +1128,7 @@ TEST_P(TextureZeroInitTest, RenderPassStoreOpClear) { 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); // Fill the sample texture with data std::vector data(kFormatBlockByteSize * kSize * kSize, 1); @@ -1274,8 +1270,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedMip) { kColorFormat); wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor( 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); @@ -1356,8 +1351,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) { kColorFormat); wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor( 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); diff --git a/src/tests/unittests/validation/BindGroupValidationTests.cpp b/src/tests/unittests/validation/BindGroupValidationTests.cpp index 8848fd9028..0f4a45466e 100644 --- a/src/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/tests/unittests/validation/BindGroupValidationTests.cpp @@ -51,10 +51,7 @@ class BindGroupValidationTest : public ValidationTest { descriptor.usage = wgpu::BufferUsage::Storage; mSSBO = device.CreateBuffer(&descriptor); } - { - wgpu::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor(); - mSampler = device.CreateSampler(&descriptor); - } + { mSampler = device.CreateSampler(); } { mSampledTexture = CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::RGBA8Unorm, 1); @@ -164,7 +161,7 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) { // Setting the sampler to an error sampler is an error. { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.minFilter = static_cast(0xFFFFFFFF); wgpu::Sampler errorSampler; diff --git a/src/tests/unittests/validation/SamplerValidationTests.cpp b/src/tests/unittests/validation/SamplerValidationTests.cpp index 00e202776c..83ca356ba0 100644 --- a/src/tests/unittests/validation/SamplerValidationTests.cpp +++ b/src/tests/unittests/validation/SamplerValidationTests.cpp @@ -24,27 +24,24 @@ namespace { // Test NaN and INFINITY values are not allowed TEST_F(SamplerValidationTest, InvalidLOD) { + { device.CreateSampler(); } { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - device.CreateSampler(&samplerDesc); - } - { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.lodMinClamp = NAN; ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); } { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.lodMaxClamp = NAN; ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); } { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.lodMaxClamp = INFINITY; device.CreateSampler(&samplerDesc); } { - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); + wgpu::SamplerDescriptor samplerDesc; samplerDesc.lodMaxClamp = INFINITY; samplerDesc.lodMinClamp = INFINITY; device.CreateSampler(&samplerDesc); diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp index bbfd21c9b6..81eec0d662 100644 --- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -617,8 +617,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) { // Samplers are not allowed to be used as storage textures in a bind group. { - wgpu::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&descriptor); + wgpu::Sampler sampler = device.CreateSampler(); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bindGroupLayout, {{0, sampler}})); } diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp index b9bc8f723b..623258d348 100644 --- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -187,8 +187,7 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) { wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); Device* d3dDevice = reinterpret_cast(device.Get()); ShaderVisibleDescriptorAllocator* allocator = diff --git a/src/tests/white_box/D3D12ResidencyTests.cpp b/src/tests/white_box/D3D12ResidencyTests.cpp index b9be954283..ee208bab23 100644 --- a/src/tests/white_box/D3D12ResidencyTests.cpp +++ b/src/tests/white_box/D3D12ResidencyTests.cpp @@ -357,8 +357,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { constexpr uint32_t kSize = 512; utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kSize, kSize); - wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); + wgpu::Sampler sampler = device.CreateSampler(); dawn_native::d3d12::Device* d3dDevice = reinterpret_cast(device.Get()); diff --git a/src/utils/WGPUHelpers.cpp b/src/utils/WGPUHelpers.cpp index b470dfc484..8ac5387308 100644 --- a/src/utils/WGPUHelpers.cpp +++ b/src/utils/WGPUHelpers.cpp @@ -303,19 +303,6 @@ namespace utils { return textureDataLayout; } - wgpu::SamplerDescriptor GetDefaultSamplerDescriptor() { - wgpu::SamplerDescriptor desc = {}; - - desc.minFilter = wgpu::FilterMode::Linear; - desc.magFilter = wgpu::FilterMode::Linear; - desc.mipmapFilter = wgpu::FilterMode::Linear; - desc.addressModeU = wgpu::AddressMode::Repeat; - desc.addressModeV = wgpu::AddressMode::Repeat; - desc.addressModeW = wgpu::AddressMode::Repeat; - - return desc; - } - wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device, const wgpu::BindGroupLayout* bindGroupLayout) { wgpu::PipelineLayoutDescriptor descriptor; diff --git a/src/utils/WGPUHelpers.h b/src/utils/WGPUHelpers.h index db3a3b30cd..86dbb4e154 100644 --- a/src/utils/WGPUHelpers.h +++ b/src/utils/WGPUHelpers.h @@ -98,7 +98,6 @@ namespace utils { uint32_t width, uint32_t height); - wgpu::SamplerDescriptor GetDefaultSamplerDescriptor(); wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device, const wgpu::BindGroupLayout* bindGroupLayout);