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 <senorblanco@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2021-02-05 20:26:54 +00:00 committed by Commit Bot service account
parent 14a2398e71
commit fb2e77106a
12 changed files with 36 additions and 67 deletions

View File

@ -62,8 +62,7 @@ void initTextures() {
descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
texture = device.CreateTexture(&descriptor); texture = device.CreateTexture(&descriptor);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); sampler = device.CreateSampler();
sampler = device.CreateSampler(&samplerDesc);
// Initialize the texture with arbitrary data until we can load images // Initialize the texture with arbitrary data until we can load images
std::vector<uint8_t> data(4 * 1024 * 1024, 0); std::vector<uint8_t> data(4 * 1024 * 1024, 0);

View File

@ -117,7 +117,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
uint32_t baseMipLevel = 0) { uint32_t baseMipLevel = 0) {
ASSERT(IsBCFormatSupported()); ASSERT(IsBCFormatSupported());
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
samplerDesc.minFilter = wgpu::FilterMode::Nearest; samplerDesc.minFilter = wgpu::FilterMode::Nearest;
samplerDesc.magFilter = wgpu::FilterMode::Nearest; samplerDesc.magFilter = wgpu::FilterMode::Nearest;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);

View File

@ -307,8 +307,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
wgpu::TextureView textureView = wrappingTexture.CreateView(); wgpu::TextureView textureView = wrappingTexture.CreateView();
wgpu::SamplerDescriptor samplerDescriptor = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDescriptor);
bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{{0, sampler}, {1, textureView}}); {{0, sampler}, {1, textureView}});

View File

@ -311,45 +311,45 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
// Test that Samplers are correctly deduplicated. // Test that Samplers are correctly deduplicated.
TEST_P(ObjectCachingTest, SamplerDeduplication) { TEST_P(ObjectCachingTest, SamplerDeduplication) {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc); wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::SamplerDescriptor sameSamplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor sameSamplerDesc;
wgpu::Sampler sameSampler = device.CreateSampler(&sameSamplerDesc); wgpu::Sampler sameSampler = device.CreateSampler(&sameSamplerDesc);
wgpu::SamplerDescriptor otherSamplerDescAddressModeU = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescAddressModeU;
otherSamplerDescAddressModeU.addressModeU = wgpu::AddressMode::ClampToEdge; otherSamplerDescAddressModeU.addressModeU = wgpu::AddressMode::Repeat;
wgpu::Sampler otherSamplerAddressModeU = device.CreateSampler(&otherSamplerDescAddressModeU); wgpu::Sampler otherSamplerAddressModeU = device.CreateSampler(&otherSamplerDescAddressModeU);
wgpu::SamplerDescriptor otherSamplerDescAddressModeV = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescAddressModeV;
otherSamplerDescAddressModeV.addressModeV = wgpu::AddressMode::ClampToEdge; otherSamplerDescAddressModeV.addressModeV = wgpu::AddressMode::Repeat;
wgpu::Sampler otherSamplerAddressModeV = device.CreateSampler(&otherSamplerDescAddressModeV); wgpu::Sampler otherSamplerAddressModeV = device.CreateSampler(&otherSamplerDescAddressModeV);
wgpu::SamplerDescriptor otherSamplerDescAddressModeW = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescAddressModeW;
otherSamplerDescAddressModeW.addressModeW = wgpu::AddressMode::ClampToEdge; otherSamplerDescAddressModeW.addressModeW = wgpu::AddressMode::Repeat;
wgpu::Sampler otherSamplerAddressModeW = device.CreateSampler(&otherSamplerDescAddressModeW); wgpu::Sampler otherSamplerAddressModeW = device.CreateSampler(&otherSamplerDescAddressModeW);
wgpu::SamplerDescriptor otherSamplerDescMagFilter = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescMagFilter;
otherSamplerDescMagFilter.magFilter = wgpu::FilterMode::Nearest; otherSamplerDescMagFilter.magFilter = wgpu::FilterMode::Linear;
wgpu::Sampler otherSamplerMagFilter = device.CreateSampler(&otherSamplerDescMagFilter); wgpu::Sampler otherSamplerMagFilter = device.CreateSampler(&otherSamplerDescMagFilter);
wgpu::SamplerDescriptor otherSamplerDescMinFilter = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescMinFilter;
otherSamplerDescMinFilter.minFilter = wgpu::FilterMode::Nearest; otherSamplerDescMinFilter.minFilter = wgpu::FilterMode::Linear;
wgpu::Sampler otherSamplerMinFilter = device.CreateSampler(&otherSamplerDescMinFilter); wgpu::Sampler otherSamplerMinFilter = device.CreateSampler(&otherSamplerDescMinFilter);
wgpu::SamplerDescriptor otherSamplerDescMipmapFilter = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescMipmapFilter;
otherSamplerDescMipmapFilter.mipmapFilter = wgpu::FilterMode::Nearest; otherSamplerDescMipmapFilter.mipmapFilter = wgpu::FilterMode::Linear;
wgpu::Sampler otherSamplerMipmapFilter = device.CreateSampler(&otherSamplerDescMipmapFilter); wgpu::Sampler otherSamplerMipmapFilter = device.CreateSampler(&otherSamplerDescMipmapFilter);
wgpu::SamplerDescriptor otherSamplerDescLodMinClamp = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescLodMinClamp;
otherSamplerDescLodMinClamp.lodMinClamp += 1; otherSamplerDescLodMinClamp.lodMinClamp += 1;
wgpu::Sampler otherSamplerLodMinClamp = device.CreateSampler(&otherSamplerDescLodMinClamp); wgpu::Sampler otherSamplerLodMinClamp = device.CreateSampler(&otherSamplerDescLodMinClamp);
wgpu::SamplerDescriptor otherSamplerDescLodMaxClamp = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescLodMaxClamp;
otherSamplerDescLodMaxClamp.lodMaxClamp += 1; otherSamplerDescLodMaxClamp.lodMaxClamp += 1;
wgpu::Sampler otherSamplerLodMaxClamp = device.CreateSampler(&otherSamplerDescLodMaxClamp); wgpu::Sampler otherSamplerLodMaxClamp = device.CreateSampler(&otherSamplerDescLodMaxClamp);
wgpu::SamplerDescriptor otherSamplerDescCompareFunction = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor otherSamplerDescCompareFunction;
otherSamplerDescCompareFunction.compare = wgpu::CompareFunction::Always; otherSamplerDescCompareFunction.compare = wgpu::CompareFunction::Always;
wgpu::Sampler otherSamplerCompareFunction = wgpu::Sampler otherSamplerCompareFunction =
device.CreateSampler(&otherSamplerDescCompareFunction); device.CreateSampler(&otherSamplerDescCompareFunction);

View File

@ -853,8 +853,7 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat);
wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
@ -923,8 +922,7 @@ TEST_P(TextureZeroInitTest, TextureBothSampledAndAttachmentClear) {
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor);
// Create bindgroup // Create bindgroup
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0),
{{0, sampler}, {1, sampleView}}); {{0, sampler}, {1, sampleView}});
@ -972,8 +970,7 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
uint32_t data = 100; uint32_t data = 100;
queue.WriteBuffer(bufferTex, 0, &data, sizeof(data)); queue.WriteBuffer(bufferTex, 0, &data, sizeof(data));
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
// Create compute pipeline // Create compute pipeline
wgpu::ComputePipelineDescriptor computePipelineDescriptor; wgpu::ComputePipelineDescriptor computePipelineDescriptor;
@ -1131,8 +1128,7 @@ TEST_P(TextureZeroInitTest, RenderPassStoreOpClear) {
1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat);
wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
// Fill the sample texture with data // Fill the sample texture with data
std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 1); std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 1);
@ -1274,8 +1270,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedMip) {
kColorFormat); kColorFormat);
wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor); wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor( wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor(
1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat);
@ -1356,8 +1351,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) {
kColorFormat); kColorFormat);
wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor); wgpu::Texture sampleTexture = device.CreateTexture(&sampleTextureDescriptor);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor( wgpu::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor(
1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat); 1, 1, wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment, kColorFormat);

View File

@ -51,10 +51,7 @@ class BindGroupValidationTest : public ValidationTest {
descriptor.usage = wgpu::BufferUsage::Storage; descriptor.usage = wgpu::BufferUsage::Storage;
mSSBO = device.CreateBuffer(&descriptor); mSSBO = device.CreateBuffer(&descriptor);
} }
{ { mSampler = device.CreateSampler(); }
wgpu::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor();
mSampler = device.CreateSampler(&descriptor);
}
{ {
mSampledTexture = mSampledTexture =
CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::RGBA8Unorm, 1); 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. // Setting the sampler to an error sampler is an error.
{ {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
samplerDesc.minFilter = static_cast<wgpu::FilterMode>(0xFFFFFFFF); samplerDesc.minFilter = static_cast<wgpu::FilterMode>(0xFFFFFFFF);
wgpu::Sampler errorSampler; wgpu::Sampler errorSampler;

View File

@ -24,27 +24,24 @@ namespace {
// Test NaN and INFINITY values are not allowed // Test NaN and INFINITY values are not allowed
TEST_F(SamplerValidationTest, InvalidLOD) { TEST_F(SamplerValidationTest, InvalidLOD) {
{ device.CreateSampler(); }
{ {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
device.CreateSampler(&samplerDesc);
}
{
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMinClamp = NAN; samplerDesc.lodMinClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }
{ {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
samplerDesc.lodMaxClamp = NAN; samplerDesc.lodMaxClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }
{ {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
samplerDesc.lodMaxClamp = INFINITY; samplerDesc.lodMaxClamp = INFINITY;
device.CreateSampler(&samplerDesc); device.CreateSampler(&samplerDesc);
} }
{ {
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc;
samplerDesc.lodMaxClamp = INFINITY; samplerDesc.lodMaxClamp = INFINITY;
samplerDesc.lodMinClamp = INFINITY; samplerDesc.lodMinClamp = INFINITY;
device.CreateSampler(&samplerDesc); device.CreateSampler(&samplerDesc);

View File

@ -617,8 +617,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) {
// Samplers are not allowed to be used as storage textures in a bind group. // Samplers are not allowed to be used as storage textures in a bind group.
{ {
wgpu::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&descriptor);
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bindGroupLayout, {{0, sampler}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bindGroupLayout, {{0, sampler}}));
} }

View File

@ -187,8 +187,7 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
Device* d3dDevice = reinterpret_cast<Device*>(device.Get()); Device* d3dDevice = reinterpret_cast<Device*>(device.Get());
ShaderVisibleDescriptorAllocator* allocator = ShaderVisibleDescriptorAllocator* allocator =

View File

@ -357,8 +357,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
constexpr uint32_t kSize = 512; constexpr uint32_t kSize = 512;
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kSize, kSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kSize, kSize);
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
dawn_native::d3d12::Device* d3dDevice = dawn_native::d3d12::Device* d3dDevice =
reinterpret_cast<dawn_native::d3d12::Device*>(device.Get()); reinterpret_cast<dawn_native::d3d12::Device*>(device.Get());

View File

@ -303,19 +303,6 @@ namespace utils {
return textureDataLayout; 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, wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
const wgpu::BindGroupLayout* bindGroupLayout) { const wgpu::BindGroupLayout* bindGroupLayout) {
wgpu::PipelineLayoutDescriptor descriptor; wgpu::PipelineLayoutDescriptor descriptor;

View File

@ -98,7 +98,6 @@ namespace utils {
uint32_t width, uint32_t width,
uint32_t height); uint32_t height);
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor();
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device, wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
const wgpu::BindGroupLayout* bindGroupLayout); const wgpu::BindGroupLayout* bindGroupLayout);