Fix MSVC compilation.

Add missing includes:
- Add missing vector include WGPUHelper.h
- Add missing algorithm include as there is a std::transform used in DawnPerfTestPlatform.cpp

Remove c++20 designated initializers from tests.
Removing these as we target c++14 and they trigger warnings in MSVC.

Bug: dawn:394
Change-Id: Id7aea9ef953cc9baa5b7633a036dd09a96aca130
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20460
Commit-Queue: Felix Maier <xilefmai@gmail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Felix Maier 2020-04-27 20:29:01 +00:00 committed by Commit Bot service account
parent c05a0e1aac
commit f70db58dce
9 changed files with 259 additions and 281 deletions

View File

@ -896,17 +896,16 @@ TEST_P(BindGroupTests, LastReferenceToBindGroupLayout) {
TEST_P(BindGroupTests, EmptyLayout) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(device, {});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {});
wgpu::ComputePipelineDescriptor pipelineDesc = {
.layout = utils::MakeBasicPipelineLayout(device, &bgl),
.computeStage =
{
.module = utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
wgpu::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.layout = utils::MakeBasicPipelineLayout(device, &bgl);
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450
void main() {
})"),
.entryPoint = "main",
},
};
})");
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -61,31 +61,28 @@ class ComparisonSamplerTest : public DawnTest {
mRenderPipeline = device.CreateRenderPipeline(&pipelineDescriptor);
wgpu::BufferDescriptor uniformBufferDesc = {
.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst,
.size = sizeof(float),
};
wgpu::BufferDescriptor uniformBufferDesc;
uniformBufferDesc.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst;
uniformBufferDesc.size = sizeof(float);
mUniformBuffer = device.CreateBuffer(&uniformBufferDesc);
wgpu::BufferDescriptor textureUploadDesc = {
.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst,
.size = sizeof(float),
};
wgpu::BufferDescriptor textureUploadDesc;
textureUploadDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
textureUploadDesc.size = sizeof(float);
mTextureUploadBuffer = device.CreateBuffer(&textureUploadDesc);
wgpu::TextureDescriptor inputTextureDesc = {
.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled |
wgpu::TextureUsage::OutputAttachment,
.size = {1, 1, 1},
.format = wgpu::TextureFormat::Depth32Float,
};
wgpu::TextureDescriptor inputTextureDesc;
inputTextureDesc.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled |
wgpu::TextureUsage::OutputAttachment;
inputTextureDesc.size = {1, 1, 1};
inputTextureDesc.format = wgpu::TextureFormat::Depth32Float;
mInputTexture = device.CreateTexture(&inputTextureDesc);
wgpu::TextureDescriptor outputTextureDesc = {
.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc,
.size = {1, 1, 1},
.format = wgpu::TextureFormat::RGBA8Unorm,
};
wgpu::TextureDescriptor outputTextureDesc;
outputTextureDesc.usage =
wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
outputTextureDesc.size = {1, 1, 1};
outputTextureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
mOutputTexture = device.CreateTexture(&outputTextureDesc);
}
@ -94,9 +91,8 @@ class ComparisonSamplerTest : public DawnTest {
std::vector<float> textureValues) {
mUniformBuffer.SetSubData(0, sizeof(float), &compareRef);
wgpu::SamplerDescriptor samplerDesc = {
.compare = compare,
};
wgpu::SamplerDescriptor samplerDesc;
samplerDesc.compare = compare;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup =
@ -155,16 +151,14 @@ class ComparisonSamplerTest : public DawnTest {
return;
}
mTextureUploadBuffer.SetSubData(0, sizeof(float), &textureValue);
wgpu::BufferCopyView bufferCopyView = {
.buffer = mTextureUploadBuffer,
.offset = 0,
.rowPitch = kTextureBytesPerRowAlignment,
.imageHeight = 1,
};
wgpu::TextureCopyView textureCopyView = {
.texture = mInputTexture,
.origin = {0, 0, 0},
};
wgpu::BufferCopyView bufferCopyView;
bufferCopyView.buffer = mTextureUploadBuffer;
bufferCopyView.offset = 0;
bufferCopyView.rowPitch = kTextureBytesPerRowAlignment;
bufferCopyView.imageHeight = 1;
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = mInputTexture;
textureCopyView.origin = {0, 0, 0};
wgpu::Extent3D copySize = {1, 1, 1};
commandEncoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
}

View File

@ -75,74 +75,80 @@ TEST_P(DeprecationTests, CreateQueueReturnsFunctionalQueue) {
// Test that creating a BGL with textureDimension produces a deprecation warning.
TEST_P(DeprecationTests, BGLEntryTextureDimensionIsDeprecated) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::e2D,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::SampledTexture;
entryDesc.textureDimension = wgpu::TextureViewDimension::e2D;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 0;
bglDesc.bindings = nullptr;
bglDesc.entryCount = 1;
bglDesc.entries = &entryDesc;
EXPECT_DEPRECATION_WARNING(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with default viewDimension and textureDimension doesn't emit a warning
TEST_P(DeprecationTests, BGLEntryTextureDimensionAndViewUndefinedEmitsNoWarning) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::Sampler,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::Sampler;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 0;
bglDesc.bindings = nullptr;
bglDesc.entryCount = 1;
bglDesc.entries = &entryDesc;
device.CreateBindGroupLayout(&bglDesc);
}
// Test that creating a BGL with both textureDimension and viewDimension is an error
TEST_P(DeprecationTests, BGLEntryTextureAndViewDimensionIsInvalid) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::e2D,
.viewDimension = wgpu::TextureViewDimension::e2D,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::SampledTexture;
entryDesc.textureDimension = wgpu::TextureViewDimension::e2D;
entryDesc.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 0;
bglDesc.bindings = nullptr;
bglDesc.entryCount = 1;
bglDesc.entries = &entryDesc;
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with both textureDimension still does correct state tracking
TEST_P(DeprecationTests, BGLEntryTextureDimensionStateTracking) {
// Create a BGL that expects a cube map
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::Cube,
};
wgpu::BindGroupLayoutEntry entryDesc = {};
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::SampledTexture;
entryDesc.textureDimension = wgpu::TextureViewDimension::Cube;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc = {};
bglDesc.bindingCount = 0;
bglDesc.bindings = nullptr;
bglDesc.entryCount = 1;
bglDesc.entries = &entryDesc;
wgpu::BindGroupLayout layout;
EXPECT_DEPRECATION_WARNING(layout = device.CreateBindGroupLayout(&bglDesc));
// Create a 2D array view and a cube view
wgpu::TextureDescriptor textureDesc = {
.usage = wgpu::TextureUsage::Sampled,
.size = {1, 1, 1},
.arrayLayerCount = 6,
.format = wgpu::TextureFormat::RGBA8Unorm,
};
wgpu::TextureDescriptor textureDesc = {};
textureDesc.usage = wgpu::TextureUsage::Sampled;
textureDesc.size = {1, 1, 1};
textureDesc.arrayLayerCount = 6;
textureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
wgpu::Texture texture = device.CreateTexture(&textureDesc);
wgpu::TextureViewDescriptor viewDesc = {
.dimension = wgpu::TextureViewDimension::e2DArray,
.baseArrayLayer = 0,
.arrayLayerCount = 6,
};
wgpu::TextureViewDescriptor viewDesc = {};
viewDesc.dimension = wgpu::TextureViewDimension::e2DArray;
viewDesc.baseArrayLayer = 0;
viewDesc.arrayLayerCount = 6;
wgpu::TextureView arrayView = texture.CreateView(&viewDesc);
viewDesc.dimension = wgpu::TextureViewDimension::Cube;
@ -158,64 +164,67 @@ TEST_P(DeprecationTests, BGLEntryTextureDimensionStateTracking) {
// Test that creating a BGL with bindings emits a deprecation warning.
TEST_P(DeprecationTests, BGLDescBindingIsDeprecated) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::Sampler,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::Sampler;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 1;
bglDesc.bindings = &entryDesc;
bglDesc.entryCount = 0;
bglDesc.entries = nullptr;
EXPECT_DEPRECATION_WARNING(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with both entries and bindings is an error
TEST_P(DeprecationTests, BGLDescBindingAndEntriesIsInvalid) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::Sampler,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.visibility = wgpu::ShaderStage::None;
entryDesc.type = wgpu::BindingType::Sampler;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 1;
bglDesc.bindings = &entryDesc;
bglDesc.entryCount = 1;
bglDesc.entries = &entryDesc;
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with both entries and bindings to 0 doesn't emit warnings
TEST_P(DeprecationTests, BGLDescBindingAndEntriesBothZeroEmitsNoWarning) {
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 0,
.bindings = nullptr,
.entryCount = 0,
.entries = nullptr,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 0;
bglDesc.bindings = nullptr;
bglDesc.entryCount = 0;
bglDesc.entries = nullptr;
device.CreateBindGroupLayout(&bglDesc);
}
// Test that creating a BGL with bindings still does correct state tracking
TEST_P(DeprecationTests, BGLDescBindingStateTracking) {
wgpu::BindGroupLayoutEntry entryDesc = {
.binding = 0,
.type = wgpu::BindingType::Sampler,
};
wgpu::BindGroupLayoutEntry entryDesc;
entryDesc.binding = 0;
entryDesc.type = wgpu::BindingType::Sampler;
entryDesc.visibility = wgpu::ShaderStage::None;
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
wgpu::BindGroupLayoutDescriptor bglDesc;
bglDesc.bindingCount = 1;
bglDesc.bindings = &entryDesc;
bglDesc.entryCount = 0;
bglDesc.entries = nullptr;
wgpu::BindGroupLayout layout;
EXPECT_DEPRECATION_WARNING(layout = device.CreateBindGroupLayout(&bglDesc));
// Test a case where if |bindings| wasn't taken into account, no validation error would happen
// because the layout would be empty
wgpu::BindGroupDescriptor badBgDesc = {
.layout = layout,
.entryCount = 0,
.entries = nullptr,
};
wgpu::BindGroupDescriptor badBgDesc;
badBgDesc.layout = layout;
badBgDesc.bindingCount = 0;
badBgDesc.bindings = nullptr;
badBgDesc.entryCount = 0;
badBgDesc.entries = nullptr;
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&badBgDesc));
}
@ -229,16 +238,16 @@ TEST_P(DeprecationTests, BGDescBindingIsDeprecated) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
wgpu::BindGroupEntry entryDesc = {
.binding = 0,
.sampler = sampler,
};
wgpu::BindGroupEntry entryDesc;
entryDesc.binding = 0;
entryDesc.sampler = sampler;
wgpu::BindGroupDescriptor bgDesc = {
.layout = layout,
.bindingCount = 1,
.bindings = &entryDesc,
};
wgpu::BindGroupDescriptor bgDesc;
bgDesc.layout = layout;
bgDesc.bindingCount = 1;
bgDesc.bindings = &entryDesc;
bgDesc.entryCount = 0;
bgDesc.entries = nullptr;
EXPECT_DEPRECATION_WARNING(device.CreateBindGroup(&bgDesc));
}
@ -250,18 +259,16 @@ TEST_P(DeprecationTests, BGDescBindingAndEntriesIsInvalid) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
wgpu::BindGroupEntry entryDesc = {
.binding = 0,
.sampler = sampler,
};
wgpu::BindGroupEntry entryDesc = {};
entryDesc.binding = 0;
entryDesc.sampler = sampler;
wgpu::BindGroupDescriptor bgDesc = {
.layout = layout,
.bindingCount = 1,
.bindings = &entryDesc,
.entryCount = 1,
.entries = &entryDesc,
};
wgpu::BindGroupDescriptor bgDesc;
bgDesc.layout = layout;
bgDesc.bindingCount = 1;
bgDesc.bindings = &entryDesc;
bgDesc.entryCount = 1;
bgDesc.entries = &entryDesc;
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&bgDesc));
}
@ -269,13 +276,12 @@ TEST_P(DeprecationTests, BGDescBindingAndEntriesIsInvalid) {
TEST_P(DeprecationTests, BGDescBindingAndEntriesBothZeroEmitsNoWarning) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
wgpu::BindGroupDescriptor bgDesc = {
.layout = layout,
.bindingCount = 0,
.bindings = nullptr,
.entryCount = 0,
.entries = nullptr,
};
wgpu::BindGroupDescriptor bgDesc;
bgDesc.layout = layout;
bgDesc.bindingCount = 0;
bgDesc.bindings = nullptr;
bgDesc.entryCount = 0;
bgDesc.entries = nullptr;
device.CreateBindGroup(&bgDesc);
}
@ -288,16 +294,16 @@ TEST_P(DeprecationTests, BGDescBindingStateTracking) {
wgpu::SamplerDescriptor samplerDesc = {};
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroupEntry entryDesc = {
.binding = 0,
.sampler = sampler,
};
wgpu::BindGroupEntry entryDesc = {};
entryDesc.binding = 0;
entryDesc.sampler = sampler;
wgpu::BindGroupDescriptor bgDesc = {
.layout = layout,
.bindingCount = 1,
.bindings = &entryDesc,
};
wgpu::BindGroupDescriptor bgDesc;
bgDesc.layout = layout;
bgDesc.bindingCount = 1;
bgDesc.bindings = &entryDesc;
bgDesc.entryCount = 0;
bgDesc.entries = nullptr;
EXPECT_DEPRECATION_WARNING(ASSERT_DEVICE_ERROR(device.CreateBindGroup(&bgDesc)));
}
@ -312,10 +318,9 @@ TEST_P(DeprecationTests, ShaderModuleNoSubDescriptorIsDeprecated) {
std::vector<uint32_t> spirv =
CompileGLSLToSpirv(utils::SingleShaderStage::Compute, kEmptyShader);
wgpu::ShaderModuleDescriptor descriptor = {
.codeSize = static_cast<uint32_t>(spirv.size()),
.code = spirv.data(),
};
wgpu::ShaderModuleDescriptor descriptor;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
EXPECT_DEPRECATION_WARNING(device.CreateShaderModule(&descriptor));
}
@ -328,11 +333,10 @@ TEST_P(DeprecationTests, ShaderModuleBothInlinedAndChainedIsInvalid) {
spirvDesc.codeSize = static_cast<uint32_t>(spirv.size());
spirvDesc.code = spirv.data();
wgpu::ShaderModuleDescriptor descriptor = {
.nextInChain = &spirvDesc,
.codeSize = static_cast<uint32_t>(spirv.size()),
.code = spirv.data(),
};
wgpu::ShaderModuleDescriptor descriptor;
descriptor.nextInChain = &spirvDesc;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
ASSERT_DEVICE_ERROR(device.CreateShaderModule(&descriptor));
}
@ -341,21 +345,17 @@ TEST_P(DeprecationTests, ShaderModuleInlinedCodeStateTracking) {
std::vector<uint32_t> spirv =
CompileGLSLToSpirv(utils::SingleShaderStage::Compute, kEmptyShader);
wgpu::ShaderModuleDescriptor descriptor = {
.codeSize = static_cast<uint32_t>(spirv.size()),
.code = spirv.data(),
};
wgpu::ShaderModuleDescriptor descriptor;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
wgpu::ShaderModule module;
EXPECT_DEPRECATION_WARNING(module = device.CreateShaderModule(&descriptor));
// Creating a compute pipeline works, because it is a compute module.
wgpu::ComputePipelineDescriptor computePipelineDesc = {
.computeStage =
{
.module = module,
.entryPoint = "main",
},
};
wgpu::ComputePipelineDescriptor computePipelineDesc;
computePipelineDesc.layout = nullptr;
computePipelineDesc.computeStage.module = module;
computePipelineDesc.computeStage.entryPoint = "main";
device.CreateComputePipeline(&computePipelineDesc);
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device);
@ -372,17 +372,15 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
void TestSetUp() override {
DeprecationTests::TestSetUp();
wgpu::BufferDescriptor bufferDesc = {
.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst,
.size = kTextureBytesPerRowAlignment * 2,
};
wgpu::BufferDescriptor bufferDesc;
bufferDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
bufferDesc.size = kTextureBytesPerRowAlignment * 2;
buffer = device.CreateBuffer(&bufferDesc);
wgpu::TextureDescriptor textureDesc = {
.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst,
.size = {2, 2, 1},
.format = wgpu::TextureFormat::RGBA8Unorm,
};
wgpu::TextureDescriptor textureDesc;
textureDesc.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
textureDesc.size = {2, 2, 1};
textureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
texture = device.CreateTexture(&textureDesc);
}
@ -391,12 +389,11 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
T2B,
};
void DoCopy(CopyType type, const wgpu::BufferCopyView& bufferView) {
wgpu::TextureCopyView textureCopyView = {
.texture = texture,
.mipLevel = 0,
.arrayLayer = 0,
.origin = {0, 0},
};
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = texture;
textureCopyView.mipLevel = 0;
textureCopyView.arrayLayer = 0;
textureCopyView.origin = {0, 0};
wgpu::Extent3D copySize = {2, 2, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -417,54 +414,49 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
// Test that using rowPitch produces a deprecation warning.
TEST_P(BufferCopyViewDeprecationTests, RowPitchIsDeprecated) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.rowPitch = 256,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.rowPitch = 256;
EXPECT_DEPRECATION_WARNING(DoCopy(B2T, view));
EXPECT_DEPRECATION_WARNING(DoCopy(T2B, view));
}
// Test that using imageHeight produces a deprecation warning.
TEST_P(BufferCopyViewDeprecationTests, ImageHeightIsDeprecated) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.imageHeight = 2,
.bytesPerRow = 256,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.imageHeight = 2;
view.bytesPerRow = 256;
EXPECT_DEPRECATION_WARNING(DoCopy(B2T, view));
EXPECT_DEPRECATION_WARNING(DoCopy(T2B, view));
}
// Test that using both rowPitch and bytesPerRow produces a validation error.
TEST_P(BufferCopyViewDeprecationTests, BothRowPitchAndBytesPerRowIsInvalid) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.rowPitch = 256,
.bytesPerRow = 256,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.rowPitch = 256;
view.bytesPerRow = 256;
ASSERT_DEVICE_ERROR(DoCopy(B2T, view));
ASSERT_DEVICE_ERROR(DoCopy(T2B, view));
}
// Test that using both imageHeight and rowsPerImage produces a validation error.
TEST_P(BufferCopyViewDeprecationTests, BothImageHeightAndRowsPerImageIsInvalid) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.imageHeight = 2,
.bytesPerRow = 256,
.rowsPerImage = 2,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.imageHeight = 2;
view.bytesPerRow = 256;
view.rowsPerImage = 2;
ASSERT_DEVICE_ERROR(DoCopy(B2T, view));
ASSERT_DEVICE_ERROR(DoCopy(T2B, view));
}
// Test that rowPitch is correctly taken into account for validation
TEST_P(BufferCopyViewDeprecationTests, RowPitchTakenIntoAccountForValidation) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.rowPitch = 256,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.rowPitch = 256;
EXPECT_DEPRECATION_WARNING(DoCopy(B2T, view));
EXPECT_DEPRECATION_WARNING(DoCopy(T2B, view));
@ -475,11 +467,10 @@ TEST_P(BufferCopyViewDeprecationTests, RowPitchTakenIntoAccountForValidation) {
// Test that imageHeight is correctly taken into account for validation
TEST_P(BufferCopyViewDeprecationTests, ImageHeightTakenIntoAccountForValidation) {
wgpu::BufferCopyView view = {
.buffer = buffer,
.imageHeight = 2,
.bytesPerRow = 256,
};
wgpu::BufferCopyView view;
view.buffer = buffer;
view.imageHeight = 2;
view.bytesPerRow = 256;
EXPECT_DEPRECATION_WARNING(DoCopy(B2T, view));
EXPECT_DEPRECATION_WARNING(DoCopy(T2B, view));

View File

@ -14,15 +14,16 @@
#include "tests/perf_tests/DawnPerfTest.h"
#include <algorithm>
#include <fstream>
#include <limits>
#include "common/Assert.h"
#include "common/Log.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include "tests/perf_tests/DawnPerfTestPlatform.h"
#include "utils/Timer.h"
#include <fstream>
#include <limits>
namespace {
DawnPerfTestEnvironment* gTestEnv = nullptr;

View File

@ -14,12 +14,13 @@
#include "tests/perf_tests/DawnPerfTestPlatform.h"
#include <algorithm>
#include "common/Assert.h"
#include "common/HashUtils.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include "tests/perf_tests/DawnPerfTest.h"
#include "utils/Timer.h"
namespace {
struct TraceCategoryInfo {

View File

@ -1601,9 +1601,8 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}});
wgpu::SamplerDescriptor desc = {
.compare = wgpu::CompareFunction::Never,
};
wgpu::SamplerDescriptor desc = {};
desc.compare = wgpu::CompareFunction::Never;
utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}});
}
@ -1612,9 +1611,8 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
wgpu::SamplerDescriptor desc = {
.compare = wgpu::CompareFunction::Never,
};
wgpu::SamplerDescriptor desc;
desc.compare = wgpu::CompareFunction::Never;
ASSERT_DEVICE_ERROR(
utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}}));
}

View File

@ -20,10 +20,9 @@ class IndexBufferValidationTest : public ValidationTest {};
// Test that for OOB validation of index buffer offset and size.
TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
wgpu::BufferDescriptor bufferDesc = {
.usage = wgpu::BufferUsage::Index,
.size = 256,
};
wgpu::BufferDescriptor bufferDesc;
bufferDesc.usage = wgpu::BufferUsage::Index;
bufferDesc.size = 256;
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
DummyRenderPass renderPass(device);

View File

@ -876,11 +876,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureInRenderPass) {
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) {
// Create a bind group that contains a storage texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Fragment,
.type = storageTextureType,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroupWithStorageTexture =
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
@ -910,15 +909,14 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneRender
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) {
// Create a bind group that binds the same texture as both storage texture and sampled
// texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Fragment,
.type = storageTextureType,
.storageTextureFormat = kFormat},
{.binding = 1,
.visibility = wgpu::ShaderStage::Fragment,
.type = wgpu::BindingType::SampledTexture,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Fragment, storageTextureType, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -954,11 +952,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndOutputAttachmentInOneRend
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) {
// Create a bind group that contains a storage texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Fragment,
.type = storageTextureType,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroupWithStorageTexture =
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
@ -980,15 +977,14 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneRen
// Create a bind group that uses the same texture as both read-only and write-only storage
// texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Fragment,
.type = wgpu::BindingType::ReadonlyStorageTexture,
.storageTextureFormat = kFormat},
{.binding = 1,
.visibility = wgpu::ShaderStage::Fragment,
.type = wgpu::BindingType::WriteonlyStorageTexture,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -1014,15 +1010,14 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneComput
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) {
// Create a bind group that binds the same texture as both storage texture and sampled
// texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Compute,
.type = storageTextureType,
.storageTextureFormat = kFormat},
{.binding = 1,
.visibility = wgpu::ShaderStage::Compute,
.type = wgpu::BindingType::SampledTexture,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Compute, storageTextureType, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -1045,15 +1040,14 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneCom
// Create a bind group that uses the same texture as both read-only and write-only storage
// texture.
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {{.binding = 0,
.visibility = wgpu::ShaderStage::Compute,
.type = wgpu::BindingType::ReadonlyStorageTexture,
.storageTextureFormat = kFormat},
{.binding = 1,
.visibility = wgpu::ShaderStage::Compute,
.type = wgpu::BindingType::WriteonlyStorageTexture,
.storageTextureFormat = kFormat}});
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, false, false,
wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});

View File

@ -19,6 +19,7 @@
#include <array>
#include <initializer_list>
#include <vector>
#include "common/Constants.h"