Fix examples when using the wire.
Previously the surface argument of CreateSwapChain was made un-optional to prevent a compilation error. This broke examples because the device-compatibility part of the wire would start dereferencing a null pointer. Instead of making the surface non-optional, make optional objects not produce = nullptr for method calls in webgpu_cpp.h. Bug: dawn:22 Change-Id: Icef357cc2b11ed452c78431dde514e4d497ae159 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31565 Reviewed-by: Shaobo Yan <shaobo.yan@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
bf1e9532c4
commit
9d6265bc07
|
@ -644,7 +644,7 @@
|
|||
"name": "create swap chain",
|
||||
"returns": "swap chain",
|
||||
"args": [
|
||||
{"name": "surface", "type": "surface"},
|
||||
{"name": "surface", "type": "surface", "optional": true},
|
||||
{"name": "descriptor", "type": "swap chain descriptor", "annotation": "const*"}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -140,10 +140,10 @@ namespace wgpu {
|
|||
CType mHandle = nullptr;
|
||||
};
|
||||
|
||||
{% macro render_cpp_default_value(member) -%}
|
||||
{% macro render_cpp_default_value(member, is_struct=True) -%}
|
||||
{%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%}
|
||||
{{" "}}= nullptr
|
||||
{%- elif member.type.category == "object" and member.optional -%}
|
||||
{%- elif member.type.category == "object" and member.optional and is_struct -%}
|
||||
{{" "}}= nullptr
|
||||
{%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%}
|
||||
{{" "}}= {{as_cppType(member.type.name)}}::{{as_cppEnum(Name(member.default_value))}}
|
||||
|
@ -164,7 +164,7 @@ namespace wgpu {
|
|||
{%- else -%}
|
||||
{{as_annotated_cppType(arg)}}
|
||||
{%- endif -%}
|
||||
{{render_cpp_default_value(arg)}}
|
||||
{{render_cpp_default_value(arg, False)}}
|
||||
{%- endfor -%}
|
||||
) const
|
||||
{%- endmacro %}
|
||||
|
|
Loading…
Reference in New Issue