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>
diff --git a/generator/templates/webgpu.h b/generator/templates/webgpu.h
index d1fcb32..aec3a18 100644
--- a/generator/templates/webgpu.h
+++ b/generator/templates/webgpu.h
@@ -73,10 +73,19 @@
{% endfor %}
+typedef struct WGPUChainedStruct {
+ struct WGPUChainedStruct const * nextInChain;
+ WGPUSType sType;
+} WGPUChainedStruct;
+
{% for type in by_category["structure"] %}
typedef struct {{as_cType(type.name)}} {
{% if type.extensible %}
- void const * nextInChain;
+ WGPUChainedStruct const * nextInChain;
+ {% endif %}
+ {% if type.chained %}
+ WGPUChainedStruct const * nextInChain;
+ WGPUSType sType;
{% endif %}
{% for member in type.members %}
{{as_annotated_cType(member)}};