Declare nextInChain as ChainedStructOut when extensible is out This patch changes the type of the structure member nextInChain in AdapterProperties and SupportedLimits as "ChainedStructOut *" instead of "ChainedStruct * const" as all members of these structures should be writable when they are used as the outputs of Dawn APIs. Bug: dawn:1516 Change-Id: I185a0b5846ac6009717ac722df67bf7170354947 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101802 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/generator/templates/dawn/native/api_structs.h b/generator/templates/dawn/native/api_structs.h index 232d286..84a6404 100644 --- a/generator/templates/dawn/native/api_structs.h +++ b/generator/templates/dawn/native/api_structs.h
@@ -49,9 +49,15 @@ {{namespace}}::SType sType = {{namespace}}::SType::Invalid; }; + struct ChainedStructOut { + ChainedStructOut * nextInChain = nullptr; + {{namespace}}::SType sType = {{namespace}}::SType::Invalid; + }; + {% for type in by_category["structure"] %} {% if type.chained %} - struct {{as_cppType(type.name)}} : ChainedStruct { + {% set chainedStructType = "ChainedStructOut" if type.chained == "out" else "ChainedStruct" %} + struct {{as_cppType(type.name)}} : {{chainedStructType}} { {{as_cppType(type.name)}}() { sType = {{namespace}}::SType::{{type.name.CamelCase()}}; } @@ -59,7 +65,8 @@ struct {{as_cppType(type.name)}} { {% endif %} {% if type.extensible %} - ChainedStruct const * nextInChain = nullptr; + {% set chainedStructType = "ChainedStructOut" if type.output else "ChainedStruct const" %} + {{chainedStructType}} * nextInChain = nullptr; {% endif %} {% for member in type.members %} {% set member_declaration = as_annotated_frontendType(member) + render_cpp_default_value(member) %}