webgpu.h introduce a base struct for extension structures.

struct WGPUChainedStruct {
     WGPUChainedStruct const * nextInChain;
     WGPUSType sType;
 };

And changes all the nextInChain to point to such structures. This adds
more type safety to extension structs and requires less casting to check
sTypes and friends.

Bug: dawn:269

Change-Id: I443f363cdb55dbec7c7f6e897245d4a7ea0ebe70
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2020-01-15 09:54:42 +00:00
committed by Commit Bot service account
parent 7f078e7ebe
commit 2b24c3d92d
11 changed files with 77 additions and 10 deletions

View File

@@ -144,7 +144,9 @@ TEST_P(D3D12SharedHandleValidation, Success) {
// Test an error occurs if the texture descriptor is invalid
TEST_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) {
DAWN_SKIP_TEST_IF(UsesWire());
dawnDescriptor.nextInChain = this;
wgpu::ChainedStruct chainedDescriptor;
dawnDescriptor.nextInChain = &chainedDescriptor;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;

View File

@@ -136,7 +136,9 @@ TEST_P(IOSurfaceValidationTests, Success) {
// Test an error occurs if the texture descriptor is invalid
TEST_P(IOSurfaceValidationTests, InvalidTextureDescriptor) {
DAWN_SKIP_TEST_IF(UsesWire());
descriptor.nextInChain = this;
wgpu::ChainedStruct chainedDescriptor;
descriptor.nextInChain = &chainedDescriptor;
ASSERT_DEVICE_ERROR(wgpu::Texture texture =
WrapIOSurface(&descriptor, defaultIOSurface.get(), 0));

View File

@@ -75,7 +75,8 @@ TEST_F(BindGroupValidationTest, NextInChainNullptr) {
device.CreateBindGroup(&descriptor);
// Check that nextInChain != nullptr is an error.
descriptor.nextInChain = static_cast<void*>(&descriptor);
wgpu::ChainedStruct chainedDescriptor;
descriptor.nextInChain = &chainedDescriptor;
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
}

View File

@@ -256,7 +256,8 @@ TEST_P(VulkanImageWrappingValidationTests, MissingTextureDescriptor) {
// Test an error occurs if the texture descriptor is invalid
TEST_P(VulkanImageWrappingValidationTests, InvalidTextureDescriptor) {
DAWN_SKIP_TEST_IF(UsesWire());
defaultDescriptor.nextInChain = this;
wgpu::ChainedStruct chainedDescriptor;
defaultDescriptor.nextInChain = &chainedDescriptor;
ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapVulkanImage(
device, &defaultDescriptor, defaultFd, defaultAllocationSize,