Default initialize all descriptors

Some dawn_unittests crash on some configurations because the
uninitialized |label| member crashed string serialization.
Default initialize all descriptors to avoid this problem.

Bug: none
Change-Id: I6ea1851ebb6f54690a28ba396e0beaa85d8670cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16260
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2020-02-28 22:29:15 +00:00 committed by Commit Bot service account
parent e299afa9ec
commit 3ded65e807
9 changed files with 62 additions and 147 deletions

View File

@ -29,9 +29,7 @@ void init() {
queue = wgpuDeviceCreateQueue(device); queue = wgpuDeviceCreateQueue(device);
{ {
WGPUSwapChainDescriptor descriptor; WGPUSwapChainDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.implementation = GetSwapChainImplementation(); descriptor.implementation = GetSwapChainImplementation();
swapchain = wgpuDeviceCreateSwapChain(device, nullptr, &descriptor); swapchain = wgpuDeviceCreateSwapChain(device, nullptr, &descriptor);
} }
@ -58,28 +56,23 @@ void init() {
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs).Release(); utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs).Release();
{ {
WGPURenderPipelineDescriptor descriptor; WGPURenderPipelineDescriptor descriptor = {};
descriptor.label = nullptr;
descriptor.nextInChain = nullptr;
descriptor.vertexStage.nextInChain = nullptr;
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.vertexStage.entryPoint = "main"; descriptor.vertexStage.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage; WGPUProgrammableStageDescriptor fragmentStage = {};
fragmentStage.nextInChain = nullptr;
fragmentStage.module = fsModule; fragmentStage.module = fsModule;
fragmentStage.entryPoint = "main"; fragmentStage.entryPoint = "main";
descriptor.fragmentStage = &fragmentStage; descriptor.fragmentStage = &fragmentStage;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
WGPUBlendDescriptor blendDescriptor; WGPUBlendDescriptor blendDescriptor = {};
blendDescriptor.operation = WGPUBlendOperation_Add; blendDescriptor.operation = WGPUBlendOperation_Add;
blendDescriptor.srcFactor = WGPUBlendFactor_One; blendDescriptor.srcFactor = WGPUBlendFactor_One;
blendDescriptor.dstFactor = WGPUBlendFactor_One; blendDescriptor.dstFactor = WGPUBlendFactor_One;
WGPUColorStateDescriptor colorStateDescriptor; WGPUColorStateDescriptor colorStateDescriptor = {};
colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = swapChainFormat; colorStateDescriptor.format = swapChainFormat;
colorStateDescriptor.alphaBlend = blendDescriptor; colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor; colorStateDescriptor.colorBlend = blendDescriptor;
@ -88,22 +81,18 @@ void init() {
descriptor.colorStateCount = 1; descriptor.colorStateCount = 1;
descriptor.colorStates = &colorStateDescriptor; descriptor.colorStates = &colorStateDescriptor;
WGPUPipelineLayoutDescriptor pl; WGPUPipelineLayoutDescriptor pl = {};
pl.nextInChain = nullptr;
pl.label = nullptr;
pl.bindGroupLayoutCount = 0; pl.bindGroupLayoutCount = 0;
pl.bindGroupLayouts = nullptr; pl.bindGroupLayouts = nullptr;
descriptor.layout = wgpuDeviceCreatePipelineLayout(device, &pl); descriptor.layout = wgpuDeviceCreatePipelineLayout(device, &pl);
WGPUVertexStateDescriptor vertexState; WGPUVertexStateDescriptor vertexState = {};
vertexState.nextInChain = nullptr;
vertexState.indexFormat = WGPUIndexFormat_Uint32; vertexState.indexFormat = WGPUIndexFormat_Uint32;
vertexState.vertexBufferCount = 0; vertexState.vertexBufferCount = 0;
vertexState.vertexBuffers = nullptr; vertexState.vertexBuffers = nullptr;
descriptor.vertexState = &vertexState; descriptor.vertexState = &vertexState;
WGPURasterizationStateDescriptor rasterizationState; WGPURasterizationStateDescriptor rasterizationState = {};
rasterizationState.nextInChain = nullptr;
rasterizationState.frontFace = WGPUFrontFace_CCW; rasterizationState.frontFace = WGPUFrontFace_CCW;
rasterizationState.cullMode = WGPUCullMode_None; rasterizationState.cullMode = WGPUCullMode_None;
rasterizationState.depthBias = 0; rasterizationState.depthBias = 0;
@ -126,10 +115,8 @@ void init() {
void frame() { void frame() {
WGPUTextureView backbufferView = wgpuSwapChainGetCurrentTextureView(swapchain); WGPUTextureView backbufferView = wgpuSwapChainGetCurrentTextureView(swapchain);
WGPURenderPassDescriptor renderpassInfo; WGPURenderPassDescriptor renderpassInfo = {};
renderpassInfo.nextInChain = nullptr; WGPURenderPassColorAttachmentDescriptor colorAttachment = {};
renderpassInfo.label = nullptr;
WGPURenderPassColorAttachmentDescriptor colorAttachment;
{ {
colorAttachment.attachment = backbufferView; colorAttachment.attachment = backbufferView;
colorAttachment.resolveTarget = nullptr; colorAttachment.resolveTarget = nullptr;

View File

@ -52,9 +52,7 @@ namespace {
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device, WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
WGPUSurface surface, WGPUSurface surface,
const WGPUSwapChainDescriptor*) { const WGPUSwapChainDescriptor*) {
WGPUSwapChainDescriptor desc; WGPUSwapChainDescriptor desc = {};
desc.nextInChain = nullptr;
desc.label = nullptr;
// A 0 implementation will trigger a swapchain creation error. // A 0 implementation will trigger a swapchain creation error.
desc.implementation = 0; desc.implementation = 0;
return sOriginalDeviceCreateSwapChain(device, surface, &desc); return sOriginalDeviceCreateSwapChain(device, surface, &desc);

View File

@ -392,8 +392,7 @@ class CreateBufferMappedTests : public DawnTest {
} }
wgpu::CreateBufferMappedResult CreateBufferMapped(wgpu::BufferUsage usage, uint64_t size) { wgpu::CreateBufferMappedResult CreateBufferMapped(wgpu::BufferUsage usage, uint64_t size) {
wgpu::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.size = size; descriptor.size = size;
descriptor.usage = usage; descriptor.usage = usage;
@ -414,8 +413,7 @@ class CreateBufferMappedTests : public DawnTest {
template <WGPUBufferMapAsyncStatus expectedStatus = WGPUBufferMapAsyncStatus_Success> template <WGPUBufferMapAsyncStatus expectedStatus = WGPUBufferMapAsyncStatus_Success>
wgpu::CreateBufferMappedResult CreateBufferMappedAsyncAndWait(wgpu::BufferUsage usage, wgpu::CreateBufferMappedResult CreateBufferMappedAsyncAndWait(wgpu::BufferUsage usage,
uint64_t size) { uint64_t size) {
wgpu::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.size = size; descriptor.size = size;
descriptor.usage = usage; descriptor.usage = usage;

View File

@ -178,10 +178,9 @@ TEST_P(DeviceLostTest, CreateRenderBundleEncoderFails) {
TEST_P(DeviceLostTest, CreateComputePipelineFails) { TEST_P(DeviceLostTest, CreateComputePipelineFails) {
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
wgpu::ComputePipelineDescriptor descriptor; wgpu::ComputePipelineDescriptor descriptor = {};
descriptor.layout = nullptr; descriptor.layout = nullptr;
descriptor.computeStage.module = nullptr; descriptor.computeStage.module = nullptr;
descriptor.nextInChain = nullptr;
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&descriptor));
} }
@ -218,8 +217,7 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
TEST_P(DeviceLostTest, CreateSwapChainFails) { TEST_P(DeviceLostTest, CreateSwapChainFails) {
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
wgpu::SwapChainDescriptor descriptor; wgpu::SwapChainDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
ASSERT_DEVICE_ERROR(device.CreateSwapChain(nullptr, &descriptor)); ASSERT_DEVICE_ERROR(device.CreateSwapChain(nullptr, &descriptor));
} }

View File

@ -48,8 +48,7 @@ TEST_F(WireArgumentTests, ValueArgument) {
// Test that the wire is able to send arrays of numerical values // Test that the wire is able to send arrays of numerical values
TEST_F(WireArgumentTests, ValueArrayArgument) { TEST_F(WireArgumentTests, ValueArrayArgument) {
// Create a bindgroup. // Create a bindgroup.
WGPUBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.nextInChain = nullptr;
bglDescriptor.bindingCount = 0; bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr; bglDescriptor.bindings = nullptr;
@ -57,8 +56,7 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl)); EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
WGPUBindGroupDescriptor bindGroupDescriptor; WGPUBindGroupDescriptor bindGroupDescriptor = {};
bindGroupDescriptor.nextInChain = nullptr;
bindGroupDescriptor.layout = bgl; bindGroupDescriptor.layout = bgl;
bindGroupDescriptor.bindingCount = 0; bindGroupDescriptor.bindingCount = 0;
bindGroupDescriptor.bindings = nullptr; bindGroupDescriptor.bindings = nullptr;
@ -97,35 +95,31 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
// Test that the wire is able to send C strings // Test that the wire is able to send C strings
TEST_F(WireArgumentTests, CStringArgument) { TEST_F(WireArgumentTests, CStringArgument) {
// Create shader module // Create shader module
WGPUShaderModuleDescriptor vertexDescriptor; WGPUShaderModuleDescriptor vertexDescriptor = {};
vertexDescriptor.nextInChain = nullptr;
vertexDescriptor.codeSize = 0; vertexDescriptor.codeSize = 0;
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor); WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the color state descriptor // Create the color state descriptor
WGPUBlendDescriptor blendDescriptor; WGPUBlendDescriptor blendDescriptor = {};
blendDescriptor.operation = WGPUBlendOperation_Add; blendDescriptor.operation = WGPUBlendOperation_Add;
blendDescriptor.srcFactor = WGPUBlendFactor_One; blendDescriptor.srcFactor = WGPUBlendFactor_One;
blendDescriptor.dstFactor = WGPUBlendFactor_One; blendDescriptor.dstFactor = WGPUBlendFactor_One;
WGPUColorStateDescriptor colorStateDescriptor; WGPUColorStateDescriptor colorStateDescriptor = {};
colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm; colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
colorStateDescriptor.alphaBlend = blendDescriptor; colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor; colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.writeMask = WGPUColorWriteMask_All; colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state // Create the input state
WGPUVertexStateDescriptor vertexState; WGPUVertexStateDescriptor vertexState = {};
vertexState.nextInChain = nullptr;
vertexState.indexFormat = WGPUIndexFormat_Uint32; vertexState.indexFormat = WGPUIndexFormat_Uint32;
vertexState.vertexBufferCount = 0; vertexState.vertexBufferCount = 0;
vertexState.vertexBuffers = nullptr; vertexState.vertexBuffers = nullptr;
// Create the rasterization state // Create the rasterization state
WGPURasterizationStateDescriptor rasterizationState; WGPURasterizationStateDescriptor rasterizationState = {};
rasterizationState.nextInChain = nullptr;
rasterizationState.frontFace = WGPUFrontFace_CCW; rasterizationState.frontFace = WGPUFrontFace_CCW;
rasterizationState.cullMode = WGPUCullMode_None; rasterizationState.cullMode = WGPUCullMode_None;
rasterizationState.depthBias = 0; rasterizationState.depthBias = 0;
@ -133,14 +127,13 @@ TEST_F(WireArgumentTests, CStringArgument) {
rasterizationState.depthBiasClamp = 0.0; rasterizationState.depthBiasClamp = 0.0;
// Create the depth-stencil state // Create the depth-stencil state
WGPUStencilStateFaceDescriptor stencilFace; WGPUStencilStateFaceDescriptor stencilFace = {};
stencilFace.compare = WGPUCompareFunction_Always; stencilFace.compare = WGPUCompareFunction_Always;
stencilFace.failOp = WGPUStencilOperation_Keep; stencilFace.failOp = WGPUStencilOperation_Keep;
stencilFace.depthFailOp = WGPUStencilOperation_Keep; stencilFace.depthFailOp = WGPUStencilOperation_Keep;
stencilFace.passOp = WGPUStencilOperation_Keep; stencilFace.passOp = WGPUStencilOperation_Keep;
WGPUDepthStencilStateDescriptor depthStencilState; WGPUDepthStencilStateDescriptor depthStencilState = {};
depthStencilState.nextInChain = nullptr;
depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8; depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
depthStencilState.depthWriteEnabled = false; depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = WGPUCompareFunction_Always; depthStencilState.depthCompare = WGPUCompareFunction_Always;
@ -150,8 +143,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
depthStencilState.stencilWriteMask = 0xff; depthStencilState.stencilWriteMask = 0xff;
// Create the pipeline layout // Create the pipeline layout
WGPUPipelineLayoutDescriptor layoutDescriptor; WGPUPipelineLayoutDescriptor layoutDescriptor = {};
layoutDescriptor.nextInChain = nullptr;
layoutDescriptor.bindGroupLayoutCount = 0; layoutDescriptor.bindGroupLayoutCount = 0;
layoutDescriptor.bindGroupLayouts = nullptr; layoutDescriptor.bindGroupLayouts = nullptr;
WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor); WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
@ -159,15 +151,12 @@ TEST_F(WireArgumentTests, CStringArgument) {
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout)); EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
// Create pipeline // Create pipeline
WGPURenderPipelineDescriptor pipelineDescriptor; WGPURenderPipelineDescriptor pipelineDescriptor = {};
pipelineDescriptor.nextInChain = nullptr;
pipelineDescriptor.vertexStage.nextInChain = nullptr;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertexStage.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage; WGPUProgrammableStageDescriptor fragmentStage = {};
fragmentStage.nextInChain = nullptr;
fragmentStage.module = vsModule; fragmentStage.module = vsModule;
fragmentStage.entryPoint = "main"; fragmentStage.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragmentStage = &fragmentStage;
@ -204,8 +193,7 @@ TEST_F(WireArgumentTests, ObjectAsValueArgument) {
WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.size = 8; descriptor.size = 8;
descriptor.usage = descriptor.usage =
static_cast<WGPUBufferUsage>(WGPUBufferUsage_CopySrc | WGPUBufferUsage_CopyDst); static_cast<WGPUBufferUsage>(WGPUBufferUsage_CopySrc | WGPUBufferUsage_CopyDst);
@ -262,8 +250,7 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
// Test that the wire is able to send structures that contain pure values (non-objects) // Test that the wire is able to send structures that contain pure values (non-objects)
TEST_F(WireArgumentTests, StructureOfValuesArgument) { TEST_F(WireArgumentTests, StructureOfValuesArgument) {
WGPUSamplerDescriptor descriptor; WGPUSamplerDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.magFilter = WGPUFilterMode_Linear; descriptor.magFilter = WGPUFilterMode_Linear;
descriptor.minFilter = WGPUFilterMode_Nearest; descriptor.minFilter = WGPUFilterMode_Nearest;
descriptor.mipmapFilter = WGPUFilterMode_Linear; descriptor.mipmapFilter = WGPUFilterMode_Linear;
@ -296,8 +283,7 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
// Test that the wire is able to send structures that contain objects // Test that the wire is able to send structures that contain objects
TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) { TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
WGPUBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.nextInChain = nullptr;
bglDescriptor.bindingCount = 0; bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr; bglDescriptor.bindings = nullptr;
@ -305,8 +291,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl)); EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
WGPUPipelineLayoutDescriptor descriptor; WGPUPipelineLayoutDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.bindGroupLayoutCount = 1; descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = &bgl; descriptor.bindGroupLayouts = &bgl;
@ -337,7 +322,7 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D, WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float}, WGPUTextureComponentType_Float},
}; };
WGPUBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = NUM_BINDINGS; bglDescriptor.bindingCount = NUM_BINDINGS;
bglDescriptor.bindings = bindings; bglDescriptor.bindings = bindings;
@ -366,8 +351,7 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
TEST_F(WireArgumentTests, DISABLED_NullptrInArray) { TEST_F(WireArgumentTests, DISABLED_NullptrInArray) {
WGPUBindGroupLayout nullBGL = nullptr; WGPUBindGroupLayout nullBGL = nullptr;
WGPUPipelineLayoutDescriptor descriptor; WGPUPipelineLayoutDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.bindGroupLayoutCount = 1; descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = &nullBGL; descriptor.bindGroupLayouts = &nullBGL;

View File

@ -97,9 +97,7 @@ class WireBufferMappingTests : public WireTest {
mockCreateBufferMappedCallback = mockCreateBufferMappedCallback =
std::make_unique<StrictMock<MockBufferCreateMappedCallback>>(); std::make_unique<StrictMock<MockBufferCreateMappedCallback>>();
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
apiBuffer = api.GetNewBuffer(); apiBuffer = api.GetNewBuffer();
@ -498,9 +496,7 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
// Test successful CreateBufferMapped // Test successful CreateBufferMapped
TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -526,9 +522,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
// Test that releasing after CreateBufferMapped does not call Unmap // Test that releasing after CreateBufferMapped does not call Unmap
TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) { TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -554,9 +548,7 @@ TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
// Test that it is valid to map a buffer after CreateBufferMapped and Unmap // Test that it is valid to map a buffer after CreateBufferMapped and Unmap
TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -599,9 +591,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
// Test that it is invalid to map a buffer after CreateBufferMapped before Unmap // Test that it is invalid to map a buffer after CreateBufferMapped before Unmap
TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) { TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -641,9 +631,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
// Test successful CreateBufferMappedAsync // Test successful CreateBufferMappedAsync
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
WGPUCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
@ -686,9 +674,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
// Test CreateBufferMappedAsync with map error // Test CreateBufferMappedAsync with map error
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) { TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
WGPUCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
@ -720,9 +706,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
// Test that the CreateBufferMappedCallback isn't fired twice when unmap() is called inside the // Test that the CreateBufferMappedCallback isn't fired twice when unmap() is called inside the
// callback // callback
TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
WGPUCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
@ -759,9 +743,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is deleted inside // Test that the CreateBufferMappedCallback isn't fired twice when the buffer is deleted inside
// the callback // the callback
TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
WGPUCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
@ -798,9 +780,7 @@ TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is destroyed inside // Test that the CreateBufferMappedCallback isn't fired twice when the buffer is destroyed inside
// the callback // the callback
TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
WGPUCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;

View File

@ -50,9 +50,7 @@ class WireFenceTests : public WireTest {
FlushClient(); FlushClient();
} }
{ {
WGPUFenceDescriptor descriptor; WGPUFenceDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.initialValue = 1; descriptor.initialValue = 1;
apiFence = api.GetNewFence(); apiFence = api.GetNewFence();

View File

@ -155,9 +155,7 @@ class WireMemoryTransferServiceTests : public WireTest {
using ServerWriteHandle = server::MockMemoryTransferService::MockWriteHandle; using ServerWriteHandle = server::MockMemoryTransferService::MockWriteHandle;
std::pair<WGPUBuffer, WGPUBuffer> CreateBuffer() { std::pair<WGPUBuffer, WGPUBuffer> CreateBuffer() {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -171,9 +169,7 @@ class WireMemoryTransferServiceTests : public WireTest {
} }
std::pair<WGPUCreateBufferMappedResult, WGPUCreateBufferMappedResult> CreateBufferMapped() { std::pair<WGPUCreateBufferMappedResult, WGPUCreateBufferMappedResult> CreateBufferMapped() {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
WGPUBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
@ -193,9 +189,7 @@ class WireMemoryTransferServiceTests : public WireTest {
} }
WGPUCreateBufferMappedResult CreateBufferMappedAsync() { WGPUCreateBufferMappedResult CreateBufferMappedAsync() {
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
@ -879,9 +873,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncWriteHandleCreatio
// Mock a WriteHandle creation failure // Mock a WriteHandle creation failure
MockWriteHandleCreationFailure(); MockWriteHandleCreationFailure();
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
// Failed creation of a WriteHandle is a fatal failure. The client synchronously receives // Failed creation of a WriteHandle is a fatal failure. The client synchronously receives
@ -1035,9 +1027,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedWriteHandleCreationFail
// Mock a WriteHandle creation failure // Mock a WriteHandle creation failure
MockWriteHandleCreationFailure(); MockWriteHandleCreationFailure();
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
@ -1081,9 +1071,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedHandleOpenFailure) {
// Note: The handle is not serialized because sychronously opening it failed. // Note: The handle is not serialized because sychronously opening it failed.
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
WGPUBufferDescriptor descriptor; WGPUBufferDescriptor descriptor = {};
descriptor.nextInChain = nullptr;
descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);

View File

@ -26,9 +26,7 @@ class WireOptionalTests : public WireTest {
// Test passing nullptr instead of objects - object as value version // Test passing nullptr instead of objects - object as value version
TEST_F(WireOptionalTests, OptionalObjectValue) { TEST_F(WireOptionalTests, OptionalObjectValue) {
WGPUBindGroupLayoutDescriptor bglDesc; WGPUBindGroupLayoutDescriptor bglDesc = {};
bglDesc.nextInChain = nullptr;
bglDesc.label = nullptr;
bglDesc.bindingCount = 0; bglDesc.bindingCount = 0;
WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDesc); WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDesc);
@ -43,9 +41,7 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
binding.textureView = nullptr; binding.textureView = nullptr;
binding.buffer = nullptr; binding.buffer = nullptr;
WGPUBindGroupDescriptor bgDesc; WGPUBindGroupDescriptor bgDesc = {};
bgDesc.nextInChain = nullptr;
bgDesc.label = nullptr;
bgDesc.layout = bgl; bgDesc.layout = bgl;
bgDesc.bindingCount = 1; bgDesc.bindingCount = 1;
bgDesc.bindings = &binding; bgDesc.bindings = &binding;
@ -69,36 +65,31 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
// Test that the wire is able to send optional pointers to structures // Test that the wire is able to send optional pointers to structures
TEST_F(WireOptionalTests, OptionalStructPointer) { TEST_F(WireOptionalTests, OptionalStructPointer) {
// Create shader module // Create shader module
WGPUShaderModuleDescriptor vertexDescriptor; WGPUShaderModuleDescriptor vertexDescriptor = {};
vertexDescriptor.nextInChain = nullptr;
vertexDescriptor.label = nullptr;
vertexDescriptor.codeSize = 0; vertexDescriptor.codeSize = 0;
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor); WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the color state descriptor // Create the color state descriptor
WGPUBlendDescriptor blendDescriptor; WGPUBlendDescriptor blendDescriptor = {};
blendDescriptor.operation = WGPUBlendOperation_Add; blendDescriptor.operation = WGPUBlendOperation_Add;
blendDescriptor.srcFactor = WGPUBlendFactor_One; blendDescriptor.srcFactor = WGPUBlendFactor_One;
blendDescriptor.dstFactor = WGPUBlendFactor_One; blendDescriptor.dstFactor = WGPUBlendFactor_One;
WGPUColorStateDescriptor colorStateDescriptor; WGPUColorStateDescriptor colorStateDescriptor = {};
colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm; colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
colorStateDescriptor.alphaBlend = blendDescriptor; colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor; colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.writeMask = WGPUColorWriteMask_All; colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state // Create the input state
WGPUVertexStateDescriptor vertexState; WGPUVertexStateDescriptor vertexState = {};
vertexState.nextInChain = nullptr;
vertexState.indexFormat = WGPUIndexFormat_Uint32; vertexState.indexFormat = WGPUIndexFormat_Uint32;
vertexState.vertexBufferCount = 0; vertexState.vertexBufferCount = 0;
vertexState.vertexBuffers = nullptr; vertexState.vertexBuffers = nullptr;
// Create the rasterization state // Create the rasterization state
WGPURasterizationStateDescriptor rasterizationState; WGPURasterizationStateDescriptor rasterizationState = {};
rasterizationState.nextInChain = nullptr;
rasterizationState.frontFace = WGPUFrontFace_CCW; rasterizationState.frontFace = WGPUFrontFace_CCW;
rasterizationState.cullMode = WGPUCullMode_None; rasterizationState.cullMode = WGPUCullMode_None;
rasterizationState.depthBias = 0; rasterizationState.depthBias = 0;
@ -106,14 +97,13 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
rasterizationState.depthBiasClamp = 0.0; rasterizationState.depthBiasClamp = 0.0;
// Create the depth-stencil state // Create the depth-stencil state
WGPUStencilStateFaceDescriptor stencilFace; WGPUStencilStateFaceDescriptor stencilFace = {};
stencilFace.compare = WGPUCompareFunction_Always; stencilFace.compare = WGPUCompareFunction_Always;
stencilFace.failOp = WGPUStencilOperation_Keep; stencilFace.failOp = WGPUStencilOperation_Keep;
stencilFace.depthFailOp = WGPUStencilOperation_Keep; stencilFace.depthFailOp = WGPUStencilOperation_Keep;
stencilFace.passOp = WGPUStencilOperation_Keep; stencilFace.passOp = WGPUStencilOperation_Keep;
WGPUDepthStencilStateDescriptor depthStencilState; WGPUDepthStencilStateDescriptor depthStencilState = {};
depthStencilState.nextInChain = nullptr;
depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8; depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
depthStencilState.depthWriteEnabled = false; depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = WGPUCompareFunction_Always; depthStencilState.depthCompare = WGPUCompareFunction_Always;
@ -123,9 +113,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
depthStencilState.stencilWriteMask = 0xff; depthStencilState.stencilWriteMask = 0xff;
// Create the pipeline layout // Create the pipeline layout
WGPUPipelineLayoutDescriptor layoutDescriptor; WGPUPipelineLayoutDescriptor layoutDescriptor = {};
layoutDescriptor.nextInChain = nullptr;
layoutDescriptor.label = nullptr;
layoutDescriptor.bindGroupLayoutCount = 0; layoutDescriptor.bindGroupLayoutCount = 0;
layoutDescriptor.bindGroupLayouts = nullptr; layoutDescriptor.bindGroupLayouts = nullptr;
WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor); WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
@ -133,16 +121,12 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout)); EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
// Create pipeline // Create pipeline
WGPURenderPipelineDescriptor pipelineDescriptor; WGPURenderPipelineDescriptor pipelineDescriptor = {};
pipelineDescriptor.nextInChain = nullptr;
pipelineDescriptor.label = nullptr;
pipelineDescriptor.vertexStage.nextInChain = nullptr;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertexStage.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage; WGPUProgrammableStageDescriptor fragmentStage = {};
fragmentStage.nextInChain = nullptr;
fragmentStage.module = vsModule; fragmentStage.module = vsModule;
fragmentStage.entryPoint = "main"; fragmentStage.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragmentStage = &fragmentStage;