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:
parent
e299afa9ec
commit
3ded65e807
|
@ -29,9 +29,7 @@ void init() {
|
|||
queue = wgpuDeviceCreateQueue(device);
|
||||
|
||||
{
|
||||
WGPUSwapChainDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUSwapChainDescriptor descriptor = {};
|
||||
descriptor.implementation = GetSwapChainImplementation();
|
||||
swapchain = wgpuDeviceCreateSwapChain(device, nullptr, &descriptor);
|
||||
}
|
||||
|
@ -58,28 +56,23 @@ void init() {
|
|||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs).Release();
|
||||
|
||||
{
|
||||
WGPURenderPipelineDescriptor descriptor;
|
||||
descriptor.label = nullptr;
|
||||
descriptor.nextInChain = nullptr;
|
||||
WGPURenderPipelineDescriptor descriptor = {};
|
||||
|
||||
descriptor.vertexStage.nextInChain = nullptr;
|
||||
descriptor.vertexStage.module = vsModule;
|
||||
descriptor.vertexStage.entryPoint = "main";
|
||||
|
||||
WGPUProgrammableStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
WGPUProgrammableStageDescriptor fragmentStage = {};
|
||||
fragmentStage.module = fsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
descriptor.fragmentStage = &fragmentStage;
|
||||
|
||||
descriptor.sampleCount = 1;
|
||||
|
||||
WGPUBlendDescriptor blendDescriptor;
|
||||
WGPUBlendDescriptor blendDescriptor = {};
|
||||
blendDescriptor.operation = WGPUBlendOperation_Add;
|
||||
blendDescriptor.srcFactor = WGPUBlendFactor_One;
|
||||
blendDescriptor.dstFactor = WGPUBlendFactor_One;
|
||||
WGPUColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
WGPUColorStateDescriptor colorStateDescriptor = {};
|
||||
colorStateDescriptor.format = swapChainFormat;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
colorStateDescriptor.colorBlend = blendDescriptor;
|
||||
|
@ -88,22 +81,18 @@ void init() {
|
|||
descriptor.colorStateCount = 1;
|
||||
descriptor.colorStates = &colorStateDescriptor;
|
||||
|
||||
WGPUPipelineLayoutDescriptor pl;
|
||||
pl.nextInChain = nullptr;
|
||||
pl.label = nullptr;
|
||||
WGPUPipelineLayoutDescriptor pl = {};
|
||||
pl.bindGroupLayoutCount = 0;
|
||||
pl.bindGroupLayouts = nullptr;
|
||||
descriptor.layout = wgpuDeviceCreatePipelineLayout(device, &pl);
|
||||
|
||||
WGPUVertexStateDescriptor vertexState;
|
||||
vertexState.nextInChain = nullptr;
|
||||
WGPUVertexStateDescriptor vertexState = {};
|
||||
vertexState.indexFormat = WGPUIndexFormat_Uint32;
|
||||
vertexState.vertexBufferCount = 0;
|
||||
vertexState.vertexBuffers = nullptr;
|
||||
descriptor.vertexState = &vertexState;
|
||||
|
||||
WGPURasterizationStateDescriptor rasterizationState;
|
||||
rasterizationState.nextInChain = nullptr;
|
||||
WGPURasterizationStateDescriptor rasterizationState = {};
|
||||
rasterizationState.frontFace = WGPUFrontFace_CCW;
|
||||
rasterizationState.cullMode = WGPUCullMode_None;
|
||||
rasterizationState.depthBias = 0;
|
||||
|
@ -126,10 +115,8 @@ void init() {
|
|||
|
||||
void frame() {
|
||||
WGPUTextureView backbufferView = wgpuSwapChainGetCurrentTextureView(swapchain);
|
||||
WGPURenderPassDescriptor renderpassInfo;
|
||||
renderpassInfo.nextInChain = nullptr;
|
||||
renderpassInfo.label = nullptr;
|
||||
WGPURenderPassColorAttachmentDescriptor colorAttachment;
|
||||
WGPURenderPassDescriptor renderpassInfo = {};
|
||||
WGPURenderPassColorAttachmentDescriptor colorAttachment = {};
|
||||
{
|
||||
colorAttachment.attachment = backbufferView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
|
|
|
@ -52,9 +52,7 @@ namespace {
|
|||
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
|
||||
WGPUSurface surface,
|
||||
const WGPUSwapChainDescriptor*) {
|
||||
WGPUSwapChainDescriptor desc;
|
||||
desc.nextInChain = nullptr;
|
||||
desc.label = nullptr;
|
||||
WGPUSwapChainDescriptor desc = {};
|
||||
// A 0 implementation will trigger a swapchain creation error.
|
||||
desc.implementation = 0;
|
||||
return sOriginalDeviceCreateSwapChain(device, surface, &desc);
|
||||
|
|
|
@ -392,8 +392,7 @@ class CreateBufferMappedTests : public DawnTest {
|
|||
}
|
||||
|
||||
wgpu::CreateBufferMappedResult CreateBufferMapped(wgpu::BufferUsage usage, uint64_t size) {
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
wgpu::BufferDescriptor descriptor = {};
|
||||
descriptor.size = size;
|
||||
descriptor.usage = usage;
|
||||
|
||||
|
@ -414,8 +413,7 @@ class CreateBufferMappedTests : public DawnTest {
|
|||
template <WGPUBufferMapAsyncStatus expectedStatus = WGPUBufferMapAsyncStatus_Success>
|
||||
wgpu::CreateBufferMappedResult CreateBufferMappedAsyncAndWait(wgpu::BufferUsage usage,
|
||||
uint64_t size) {
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
wgpu::BufferDescriptor descriptor = {};
|
||||
descriptor.size = size;
|
||||
descriptor.usage = usage;
|
||||
|
||||
|
|
|
@ -178,10 +178,9 @@ TEST_P(DeviceLostTest, CreateRenderBundleEncoderFails) {
|
|||
TEST_P(DeviceLostTest, CreateComputePipelineFails) {
|
||||
SetCallbackAndLoseForTesting();
|
||||
|
||||
wgpu::ComputePipelineDescriptor descriptor;
|
||||
wgpu::ComputePipelineDescriptor descriptor = {};
|
||||
descriptor.layout = nullptr;
|
||||
descriptor.computeStage.module = nullptr;
|
||||
descriptor.nextInChain = nullptr;
|
||||
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&descriptor));
|
||||
}
|
||||
|
||||
|
@ -218,8 +217,7 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
|
|||
TEST_P(DeviceLostTest, CreateSwapChainFails) {
|
||||
SetCallbackAndLoseForTesting();
|
||||
|
||||
wgpu::SwapChainDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
wgpu::SwapChainDescriptor descriptor = {};
|
||||
ASSERT_DEVICE_ERROR(device.CreateSwapChain(nullptr, &descriptor));
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ TEST_F(WireArgumentTests, ValueArgument) {
|
|||
// Test that the wire is able to send arrays of numerical values
|
||||
TEST_F(WireArgumentTests, ValueArrayArgument) {
|
||||
// Create a bindgroup.
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.nextInChain = nullptr;
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
|
||||
bglDescriptor.bindingCount = 0;
|
||||
bglDescriptor.bindings = nullptr;
|
||||
|
||||
|
@ -57,8 +56,7 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
|
|||
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
|
||||
|
||||
WGPUBindGroupDescriptor bindGroupDescriptor;
|
||||
bindGroupDescriptor.nextInChain = nullptr;
|
||||
WGPUBindGroupDescriptor bindGroupDescriptor = {};
|
||||
bindGroupDescriptor.layout = bgl;
|
||||
bindGroupDescriptor.bindingCount = 0;
|
||||
bindGroupDescriptor.bindings = nullptr;
|
||||
|
@ -97,35 +95,31 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
|
|||
// Test that the wire is able to send C strings
|
||||
TEST_F(WireArgumentTests, CStringArgument) {
|
||||
// Create shader module
|
||||
WGPUShaderModuleDescriptor vertexDescriptor;
|
||||
vertexDescriptor.nextInChain = nullptr;
|
||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||
vertexDescriptor.codeSize = 0;
|
||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
|
||||
|
||||
// Create the color state descriptor
|
||||
WGPUBlendDescriptor blendDescriptor;
|
||||
WGPUBlendDescriptor blendDescriptor = {};
|
||||
blendDescriptor.operation = WGPUBlendOperation_Add;
|
||||
blendDescriptor.srcFactor = WGPUBlendFactor_One;
|
||||
blendDescriptor.dstFactor = WGPUBlendFactor_One;
|
||||
WGPUColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
WGPUColorStateDescriptor colorStateDescriptor = {};
|
||||
colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
colorStateDescriptor.colorBlend = blendDescriptor;
|
||||
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
|
||||
|
||||
// Create the input state
|
||||
WGPUVertexStateDescriptor vertexState;
|
||||
vertexState.nextInChain = nullptr;
|
||||
WGPUVertexStateDescriptor vertexState = {};
|
||||
vertexState.indexFormat = WGPUIndexFormat_Uint32;
|
||||
vertexState.vertexBufferCount = 0;
|
||||
vertexState.vertexBuffers = nullptr;
|
||||
|
||||
// Create the rasterization state
|
||||
WGPURasterizationStateDescriptor rasterizationState;
|
||||
rasterizationState.nextInChain = nullptr;
|
||||
WGPURasterizationStateDescriptor rasterizationState = {};
|
||||
rasterizationState.frontFace = WGPUFrontFace_CCW;
|
||||
rasterizationState.cullMode = WGPUCullMode_None;
|
||||
rasterizationState.depthBias = 0;
|
||||
|
@ -133,14 +127,13 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
rasterizationState.depthBiasClamp = 0.0;
|
||||
|
||||
// Create the depth-stencil state
|
||||
WGPUStencilStateFaceDescriptor stencilFace;
|
||||
WGPUStencilStateFaceDescriptor stencilFace = {};
|
||||
stencilFace.compare = WGPUCompareFunction_Always;
|
||||
stencilFace.failOp = WGPUStencilOperation_Keep;
|
||||
stencilFace.depthFailOp = WGPUStencilOperation_Keep;
|
||||
stencilFace.passOp = WGPUStencilOperation_Keep;
|
||||
|
||||
WGPUDepthStencilStateDescriptor depthStencilState;
|
||||
depthStencilState.nextInChain = nullptr;
|
||||
WGPUDepthStencilStateDescriptor depthStencilState = {};
|
||||
depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
|
||||
depthStencilState.depthWriteEnabled = false;
|
||||
depthStencilState.depthCompare = WGPUCompareFunction_Always;
|
||||
|
@ -150,8 +143,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
depthStencilState.stencilWriteMask = 0xff;
|
||||
|
||||
// Create the pipeline layout
|
||||
WGPUPipelineLayoutDescriptor layoutDescriptor;
|
||||
layoutDescriptor.nextInChain = nullptr;
|
||||
WGPUPipelineLayoutDescriptor layoutDescriptor = {};
|
||||
layoutDescriptor.bindGroupLayoutCount = 0;
|
||||
layoutDescriptor.bindGroupLayouts = nullptr;
|
||||
WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
|
@ -159,15 +151,12 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
|
||||
|
||||
// Create pipeline
|
||||
WGPURenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.nextInChain = nullptr;
|
||||
WGPURenderPipelineDescriptor pipelineDescriptor = {};
|
||||
|
||||
pipelineDescriptor.vertexStage.nextInChain = nullptr;
|
||||
pipelineDescriptor.vertexStage.module = vsModule;
|
||||
pipelineDescriptor.vertexStage.entryPoint = "main";
|
||||
|
||||
WGPUProgrammableStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
WGPUProgrammableStageDescriptor fragmentStage = {};
|
||||
fragmentStage.module = vsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||
|
@ -204,8 +193,7 @@ TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
|||
WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
|
||||
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = 8;
|
||||
descriptor.usage =
|
||||
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_F(WireArgumentTests, StructureOfValuesArgument) {
|
||||
WGPUSamplerDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
WGPUSamplerDescriptor descriptor = {};
|
||||
descriptor.magFilter = WGPUFilterMode_Linear;
|
||||
descriptor.minFilter = WGPUFilterMode_Nearest;
|
||||
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_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.nextInChain = nullptr;
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
|
||||
bglDescriptor.bindingCount = 0;
|
||||
bglDescriptor.bindings = nullptr;
|
||||
|
||||
|
@ -305,8 +291,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
|||
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
|
||||
|
||||
WGPUPipelineLayoutDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
WGPUPipelineLayoutDescriptor descriptor = {};
|
||||
descriptor.bindGroupLayoutCount = 1;
|
||||
descriptor.bindGroupLayouts = &bgl;
|
||||
|
||||
|
@ -337,7 +322,7 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
|
|||
WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
|
||||
WGPUTextureComponentType_Float},
|
||||
};
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor;
|
||||
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
|
||||
bglDescriptor.bindingCount = NUM_BINDINGS;
|
||||
bglDescriptor.bindings = bindings;
|
||||
|
||||
|
@ -366,8 +351,7 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
|
|||
TEST_F(WireArgumentTests, DISABLED_NullptrInArray) {
|
||||
WGPUBindGroupLayout nullBGL = nullptr;
|
||||
|
||||
WGPUPipelineLayoutDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
WGPUPipelineLayoutDescriptor descriptor = {};
|
||||
descriptor.bindGroupLayoutCount = 1;
|
||||
descriptor.bindGroupLayouts = &nullBGL;
|
||||
|
||||
|
|
|
@ -97,9 +97,7 @@ class WireBufferMappingTests : public WireTest {
|
|||
mockCreateBufferMappedCallback =
|
||||
std::make_unique<StrictMock<MockBufferCreateMappedCallback>>();
|
||||
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = kBufferSize;
|
||||
|
||||
apiBuffer = api.GetNewBuffer();
|
||||
|
@ -498,9 +496,7 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
|||
|
||||
// Test successful CreateBufferMapped
|
||||
TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = 4;
|
||||
|
||||
WGPUBuffer apiBuffer = api.GetNewBuffer();
|
||||
|
@ -526,9 +522,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
|
|||
|
||||
// Test that releasing after CreateBufferMapped does not call Unmap
|
||||
TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = 4;
|
||||
|
||||
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_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = 4;
|
||||
|
||||
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_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = 4;
|
||||
|
||||
WGPUBuffer apiBuffer = api.GetNewBuffer();
|
||||
|
@ -641,9 +631,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
|||
|
||||
// Test successful CreateBufferMappedAsync
|
||||
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = kBufferSize;
|
||||
|
||||
WGPUCreateBufferMappedResult apiResult;
|
||||
|
@ -686,9 +674,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
|
|||
|
||||
// Test CreateBufferMappedAsync with map error
|
||||
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
|
||||
WGPUCreateBufferMappedResult apiResult;
|
||||
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
|
||||
// callback
|
||||
TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = kBufferSize;
|
||||
|
||||
WGPUCreateBufferMappedResult apiResult;
|
||||
|
@ -759,9 +743,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
|
|||
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is deleted inside
|
||||
// the callback
|
||||
TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = kBufferSize;
|
||||
|
||||
WGPUCreateBufferMappedResult apiResult;
|
||||
|
@ -798,9 +780,7 @@ TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
|
|||
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is destroyed inside
|
||||
// the callback
|
||||
TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = kBufferSize;
|
||||
|
||||
WGPUCreateBufferMappedResult apiResult;
|
||||
|
|
|
@ -50,9 +50,7 @@ class WireFenceTests : public WireTest {
|
|||
FlushClient();
|
||||
}
|
||||
{
|
||||
WGPUFenceDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUFenceDescriptor descriptor = {};
|
||||
descriptor.initialValue = 1;
|
||||
|
||||
apiFence = api.GetNewFence();
|
||||
|
|
|
@ -155,9 +155,7 @@ class WireMemoryTransferServiceTests : public WireTest {
|
|||
using ServerWriteHandle = server::MockMemoryTransferService::MockWriteHandle;
|
||||
|
||||
std::pair<WGPUBuffer, WGPUBuffer> CreateBuffer() {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
WGPUBuffer apiBuffer = api.GetNewBuffer();
|
||||
|
@ -171,9 +169,7 @@ class WireMemoryTransferServiceTests : public WireTest {
|
|||
}
|
||||
|
||||
std::pair<WGPUCreateBufferMappedResult, WGPUCreateBufferMappedResult> CreateBufferMapped() {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
WGPUBuffer apiBuffer = api.GetNewBuffer();
|
||||
|
@ -193,9 +189,7 @@ class WireMemoryTransferServiceTests : public WireTest {
|
|||
}
|
||||
|
||||
WGPUCreateBufferMappedResult CreateBufferMappedAsync() {
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
|
||||
|
@ -879,9 +873,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncWriteHandleCreatio
|
|||
// Mock a WriteHandle creation failure
|
||||
MockWriteHandleCreationFailure();
|
||||
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
// 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
|
||||
MockWriteHandleCreationFailure();
|
||||
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
|
||||
|
@ -1081,9 +1071,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedHandleOpenFailure) {
|
|||
// Note: The handle is not serialized because sychronously opening it failed.
|
||||
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
|
||||
|
||||
WGPUBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.label = nullptr;
|
||||
WGPUBufferDescriptor descriptor = {};
|
||||
descriptor.size = sizeof(mBufferContent);
|
||||
|
||||
WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
|
||||
|
|
|
@ -26,9 +26,7 @@ class WireOptionalTests : public WireTest {
|
|||
|
||||
// Test passing nullptr instead of objects - object as value version
|
||||
TEST_F(WireOptionalTests, OptionalObjectValue) {
|
||||
WGPUBindGroupLayoutDescriptor bglDesc;
|
||||
bglDesc.nextInChain = nullptr;
|
||||
bglDesc.label = nullptr;
|
||||
WGPUBindGroupLayoutDescriptor bglDesc = {};
|
||||
bglDesc.bindingCount = 0;
|
||||
WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDesc);
|
||||
|
||||
|
@ -43,9 +41,7 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
|
|||
binding.textureView = nullptr;
|
||||
binding.buffer = nullptr;
|
||||
|
||||
WGPUBindGroupDescriptor bgDesc;
|
||||
bgDesc.nextInChain = nullptr;
|
||||
bgDesc.label = nullptr;
|
||||
WGPUBindGroupDescriptor bgDesc = {};
|
||||
bgDesc.layout = bgl;
|
||||
bgDesc.bindingCount = 1;
|
||||
bgDesc.bindings = &binding;
|
||||
|
@ -69,36 +65,31 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
|
|||
// Test that the wire is able to send optional pointers to structures
|
||||
TEST_F(WireOptionalTests, OptionalStructPointer) {
|
||||
// Create shader module
|
||||
WGPUShaderModuleDescriptor vertexDescriptor;
|
||||
vertexDescriptor.nextInChain = nullptr;
|
||||
vertexDescriptor.label = nullptr;
|
||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||
vertexDescriptor.codeSize = 0;
|
||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
|
||||
|
||||
// Create the color state descriptor
|
||||
WGPUBlendDescriptor blendDescriptor;
|
||||
WGPUBlendDescriptor blendDescriptor = {};
|
||||
blendDescriptor.operation = WGPUBlendOperation_Add;
|
||||
blendDescriptor.srcFactor = WGPUBlendFactor_One;
|
||||
blendDescriptor.dstFactor = WGPUBlendFactor_One;
|
||||
WGPUColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
WGPUColorStateDescriptor colorStateDescriptor = {};
|
||||
colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
colorStateDescriptor.colorBlend = blendDescriptor;
|
||||
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
|
||||
|
||||
// Create the input state
|
||||
WGPUVertexStateDescriptor vertexState;
|
||||
vertexState.nextInChain = nullptr;
|
||||
WGPUVertexStateDescriptor vertexState = {};
|
||||
vertexState.indexFormat = WGPUIndexFormat_Uint32;
|
||||
vertexState.vertexBufferCount = 0;
|
||||
vertexState.vertexBuffers = nullptr;
|
||||
|
||||
// Create the rasterization state
|
||||
WGPURasterizationStateDescriptor rasterizationState;
|
||||
rasterizationState.nextInChain = nullptr;
|
||||
WGPURasterizationStateDescriptor rasterizationState = {};
|
||||
rasterizationState.frontFace = WGPUFrontFace_CCW;
|
||||
rasterizationState.cullMode = WGPUCullMode_None;
|
||||
rasterizationState.depthBias = 0;
|
||||
|
@ -106,14 +97,13 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
rasterizationState.depthBiasClamp = 0.0;
|
||||
|
||||
// Create the depth-stencil state
|
||||
WGPUStencilStateFaceDescriptor stencilFace;
|
||||
WGPUStencilStateFaceDescriptor stencilFace = {};
|
||||
stencilFace.compare = WGPUCompareFunction_Always;
|
||||
stencilFace.failOp = WGPUStencilOperation_Keep;
|
||||
stencilFace.depthFailOp = WGPUStencilOperation_Keep;
|
||||
stencilFace.passOp = WGPUStencilOperation_Keep;
|
||||
|
||||
WGPUDepthStencilStateDescriptor depthStencilState;
|
||||
depthStencilState.nextInChain = nullptr;
|
||||
WGPUDepthStencilStateDescriptor depthStencilState = {};
|
||||
depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
|
||||
depthStencilState.depthWriteEnabled = false;
|
||||
depthStencilState.depthCompare = WGPUCompareFunction_Always;
|
||||
|
@ -123,9 +113,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
depthStencilState.stencilWriteMask = 0xff;
|
||||
|
||||
// Create the pipeline layout
|
||||
WGPUPipelineLayoutDescriptor layoutDescriptor;
|
||||
layoutDescriptor.nextInChain = nullptr;
|
||||
layoutDescriptor.label = nullptr;
|
||||
WGPUPipelineLayoutDescriptor layoutDescriptor = {};
|
||||
layoutDescriptor.bindGroupLayoutCount = 0;
|
||||
layoutDescriptor.bindGroupLayouts = nullptr;
|
||||
WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
|
@ -133,16 +121,12 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
|
||||
|
||||
// Create pipeline
|
||||
WGPURenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.nextInChain = nullptr;
|
||||
pipelineDescriptor.label = nullptr;
|
||||
WGPURenderPipelineDescriptor pipelineDescriptor = {};
|
||||
|
||||
pipelineDescriptor.vertexStage.nextInChain = nullptr;
|
||||
pipelineDescriptor.vertexStage.module = vsModule;
|
||||
pipelineDescriptor.vertexStage.entryPoint = "main";
|
||||
|
||||
WGPUProgrammableStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
WGPUProgrammableStageDescriptor fragmentStage = {};
|
||||
fragmentStage.module = vsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||
|
|
Loading…
Reference in New Issue