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

@@ -42,6 +42,15 @@ namespace wgpu {
{% endfor %}
static_assert(sizeof(ChainedStruct) == sizeof(WGPUChainedStruct),
"sizeof mismatch for ChainedStruct");
static_assert(alignof(ChainedStruct) == alignof(WGPUChainedStruct),
"alignof mismatch for ChainedStruct");
static_assert(offsetof(ChainedStruct, nextInChain) == offsetof(WGPUChainedStruct, nextInChain),
"offsetof mismatch for ChainedStruct::nextInChain");
static_assert(offsetof(ChainedStruct, sType) == offsetof(WGPUChainedStruct, sType),
"offsetof mismatch for ChainedStruct::sType");
{% for type in by_category["structure"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) %}