From b0789fde613183fa6d6950b7df77d4df729674cd Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 29 Oct 2020 13:09:12 +0000 Subject: [PATCH] Fix RPDesc::occlusionQuerySet not defaulting to nullptr The default value for optional object structure members wasn't set correctly for C++ structures. Bug: dawn:22 Change-Id: I09e7f3675f6e0b5990ddcf03601b3b91cd25f553 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31200 Reviewed-by: Austin Eng Reviewed-by: Shaobo Yan Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- dawn.json | 2 +- generator/templates/dawn_native/wgpu_structs.h | 2 ++ generator/templates/webgpu_cpp.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dawn.json b/dawn.json index 9bf733a0b9..31e7566585 100644 --- a/dawn.json +++ b/dawn.json @@ -644,7 +644,7 @@ "name": "create swap chain", "returns": "swap chain", "args": [ - {"name": "surface", "type": "surface", "optional": "true"}, + {"name": "surface", "type": "surface"}, {"name": "descriptor", "type": "swap chain descriptor", "annotation": "const*"} ] }, diff --git a/generator/templates/dawn_native/wgpu_structs.h b/generator/templates/dawn_native/wgpu_structs.h index 887de9e76f..3e267cb7fa 100644 --- a/generator/templates/dawn_native/wgpu_structs.h +++ b/generator/templates/dawn_native/wgpu_structs.h @@ -23,6 +23,8 @@ namespace dawn_native { {% macro render_cpp_default_value(member) -%} {%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%} {{" "}}= nullptr + {%- elif member.type.category == "object" and member.optional -%} + {{" "}}= nullptr {%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%} {{" "}}= wgpu::{{as_cppType(member.type.name)}}::{{as_cppEnum(Name(member.default_value))}} {%- elif member.type.category == "native" and member.default_value != None -%} diff --git a/generator/templates/webgpu_cpp.h b/generator/templates/webgpu_cpp.h index f72e1420a9..eb48a324ad 100644 --- a/generator/templates/webgpu_cpp.h +++ b/generator/templates/webgpu_cpp.h @@ -143,6 +143,8 @@ namespace wgpu { {% macro render_cpp_default_value(member) -%} {%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%} {{" "}}= nullptr + {%- elif member.type.category == "object" and member.optional -%} + {{" "}}= nullptr {%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%} {{" "}}= {{as_cppType(member.type.name)}}::{{as_cppEnum(Name(member.default_value))}} {%- elif member.type.category == "native" and member.default_value != None -%}