Use webgpu.h's bitmask type definitions.

BUG=dawn:22

Change-Id: Ib7cf75a1411a6ed86cc5abb1218beb924dbb9001
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2019-10-17 08:46:07 +00:00 committed by Commit Bot service account
parent 31bde95857
commit 919812ed1c
4 changed files with 27 additions and 2 deletions

View File

@ -354,6 +354,11 @@ def as_cType(name):
else:
return 'Dawn' + name.CamelCase()
def as_cTypeEnumSpecialCase(typ):
if typ.category == 'bitmask':
return as_cType(typ.name) + 'Flags'
return as_cType(typ.name)
def as_cppType(name):
if name.native:
return name.concatcase()
@ -480,7 +485,7 @@ class MultiGeneratorFromDawnJSON(Generator):
base_params = {
'Name': lambda name: Name(name),
'as_annotated_cType': lambda arg: annotated(as_cType(arg.type.name), arg),
'as_annotated_cType': lambda arg: annotated(as_cTypeEnumSpecialCase(arg.type), arg),
'as_annotated_cppType': lambda arg: annotated(as_cppType(arg.type.name), arg),
'as_cEnum': as_cEnum,
'as_cppEnum': as_cppEnum,

View File

@ -23,6 +23,8 @@
const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
typedef uint32_t WGPUFlags;
{% for type in by_category["object"] %}
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
{% endfor %}
@ -34,6 +36,9 @@ const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
{% endfor %}
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
} {{as_cType(type.name)}};
{% if type.category == "bitmask" %}
typedef WGPUFlags {{as_cType(type.name)}}Flags;
{% endif %}
{% endfor %}

View File

@ -16,7 +16,7 @@
namespace dawn {
{% for type in by_category["enum"] + by_category["bitmask"] %}
{% for type in by_category["enum"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) %}
@ -29,6 +29,19 @@ namespace dawn {
{% endfor %}
{% for type in by_category["bitmask"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) + "Flags" %}
static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
{% for value in type.values %}
static_assert(static_cast<uint32_t>({{CppType}}::{{as_cppEnum(value.name)}}) == {{as_cEnum(type.name, value.name)}}, "value mismatch for {{CppType}}::{{as_cppEnum(value.name)}}");
{% endfor %}
{% endfor %}
{% for type in by_category["structure"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) %}

View File

@ -37,6 +37,8 @@
ObjectId
{%- elif member.type.category == "structure" -%}
{{as_cType(member.type.name)}}Transfer
{%- elif member.type.category == "bitmask" -%}
{{as_cType(member.type.name)}}Flags
{%- else -%}
{{as_cType(member.type.name)}}
{%- endif -%}