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:
parent
31bde95857
commit
919812ed1c
|
@ -354,6 +354,11 @@ def as_cType(name):
|
||||||
else:
|
else:
|
||||||
return 'Dawn' + name.CamelCase()
|
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):
|
def as_cppType(name):
|
||||||
if name.native:
|
if name.native:
|
||||||
return name.concatcase()
|
return name.concatcase()
|
||||||
|
@ -480,7 +485,7 @@ class MultiGeneratorFromDawnJSON(Generator):
|
||||||
base_params = {
|
base_params = {
|
||||||
'Name': lambda name: Name(name),
|
'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_annotated_cppType': lambda arg: annotated(as_cppType(arg.type.name), arg),
|
||||||
'as_cEnum': as_cEnum,
|
'as_cEnum': as_cEnum,
|
||||||
'as_cppEnum': as_cppEnum,
|
'as_cppEnum': as_cppEnum,
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
||||||
|
|
||||||
|
typedef uint32_t WGPUFlags;
|
||||||
|
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
|
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -34,6 +36,9 @@ const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
||||||
} {{as_cType(type.name)}};
|
} {{as_cType(type.name)}};
|
||||||
|
{% if type.category == "bitmask" %}
|
||||||
|
typedef WGPUFlags {{as_cType(type.name)}}Flags;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace dawn {
|
namespace dawn {
|
||||||
|
|
||||||
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
{% for type in by_category["enum"] %}
|
||||||
{% set CppType = as_cppType(type.name) %}
|
{% set CppType = as_cppType(type.name) %}
|
||||||
{% set CType = as_cType(type.name) %}
|
{% set CType = as_cType(type.name) %}
|
||||||
|
|
||||||
|
@ -29,6 +29,19 @@ namespace dawn {
|
||||||
|
|
||||||
{% endfor %}
|
{% 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"] %}
|
{% for type in by_category["structure"] %}
|
||||||
{% set CppType = as_cppType(type.name) %}
|
{% set CppType = as_cppType(type.name) %}
|
||||||
{% set CType = as_cType(type.name) %}
|
{% set CType = as_cType(type.name) %}
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
ObjectId
|
ObjectId
|
||||||
{%- elif member.type.category == "structure" -%}
|
{%- elif member.type.category == "structure" -%}
|
||||||
{{as_cType(member.type.name)}}Transfer
|
{{as_cType(member.type.name)}}Transfer
|
||||||
|
{%- elif member.type.category == "bitmask" -%}
|
||||||
|
{{as_cType(member.type.name)}}Flags
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{{as_cType(member.type.name)}}
|
{{as_cType(member.type.name)}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
Loading…
Reference in New Issue