dawn.json: Add the "chain roots" data for chained structs.
This helps output in the headers information about which structure can be used to extend which. In the future it could also be used to generate helpers that validate that the chain for a root structure contains only allowed extension structs. Fixed: dawn:1486 Change-Id: I6134332d477503e242b3bec9f8e9bedeeb352351 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96000 Kokoro: Kokoro <noreply+kokoro@google.com> 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
e1bcb0b416
commit
a45561bb8c
21
dawn.json
21
dawn.json
|
@ -162,6 +162,7 @@
|
||||||
"tags": ["dawn", "native"],
|
"tags": ["dawn", "native"],
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["device descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "force enabled toggles count", "type": "uint32_t", "default": 0},
|
{"name": "force enabled toggles count", "type": "uint32_t", "default": 0},
|
||||||
{"name": "force enabled toggles", "type": "char", "annotation": "const*const*", "length": "force enabled toggles count"},
|
{"name": "force enabled toggles", "type": "char", "annotation": "const*const*", "length": "force enabled toggles count"},
|
||||||
|
@ -173,6 +174,7 @@
|
||||||
"tags": ["dawn", "native"],
|
"tags": ["dawn", "native"],
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["device descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "isolation key", "type": "char", "annotation": "const*", "length": "strlen", "default": "\"\""}
|
{"name": "isolation key", "type": "char", "annotation": "const*", "length": "strlen", "default": "\"\""}
|
||||||
]
|
]
|
||||||
|
@ -306,6 +308,7 @@
|
||||||
"external texture binding entry": {
|
"external texture binding entry": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["bind group entry"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "external texture", "type": "external texture"}
|
{"name": "external texture", "type": "external texture"}
|
||||||
|
@ -315,6 +318,7 @@
|
||||||
"external texture binding layout": {
|
"external texture binding layout": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["bind group layout entry"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": []
|
"members": []
|
||||||
},
|
},
|
||||||
|
@ -1445,6 +1449,7 @@
|
||||||
"tags": ["dawn", "native"],
|
"tags": ["dawn", "native"],
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["instance descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "additional runtime search paths count", "type": "uint32_t", "default": 0},
|
{"name": "additional runtime search paths count", "type": "uint32_t", "default": 0},
|
||||||
{"name": "additional runtime search paths", "type": "char", "annotation": "const*const*", "length": "additional runtime search paths count"}
|
{"name": "additional runtime search paths", "type": "char", "annotation": "const*const*", "length": "additional runtime search paths count"}
|
||||||
|
@ -1891,6 +1896,7 @@
|
||||||
"render pass descriptor max draw count": {
|
"render pass descriptor max draw count": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["render pass descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "max draw count", "type": "uint64_t", "default": 50000000}
|
{"name": "max draw count", "type": "uint64_t", "default": 50000000}
|
||||||
]
|
]
|
||||||
|
@ -2147,6 +2153,7 @@
|
||||||
"primitive depth clamping state": {
|
"primitive depth clamping state": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["primitive state"],
|
||||||
"tags": ["dawn", "emscripten"],
|
"tags": ["dawn", "emscripten"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "clamp depth", "type": "bool", "default": "false"}
|
{"name": "clamp depth", "type": "bool", "default": "false"}
|
||||||
|
@ -2156,6 +2163,7 @@
|
||||||
"primitive depth clip control": {
|
"primitive depth clip control": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["primitive state"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "unclipped depth", "type": "bool", "default": "false"}
|
{"name": "unclipped depth", "type": "bool", "default": "false"}
|
||||||
]
|
]
|
||||||
|
@ -2302,6 +2310,7 @@
|
||||||
"shader module SPIRV descriptor": {
|
"shader module SPIRV descriptor": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["shader module descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "code size", "type": "uint32_t"},
|
{"name": "code size", "type": "uint32_t"},
|
||||||
{"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size"}
|
{"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size"}
|
||||||
|
@ -2310,6 +2319,7 @@
|
||||||
"shader module WGSL descriptor": {
|
"shader module WGSL descriptor": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["shader module descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "source", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["dawn", "emscripten"]},
|
{"name": "source", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["dawn", "emscripten"]},
|
||||||
{"name": "code", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["upstream"]}
|
{"name": "code", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["upstream"]}
|
||||||
|
@ -2370,6 +2380,7 @@
|
||||||
"surface descriptor from android native window": {
|
"surface descriptor from android native window": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["native"],
|
"tags": ["native"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "window", "type": "void", "annotation": "*"}
|
{"name": "window", "type": "void", "annotation": "*"}
|
||||||
|
@ -2378,6 +2389,7 @@
|
||||||
"surface descriptor from canvas HTML selector": {
|
"surface descriptor from canvas HTML selector": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "selector", "type": "char", "annotation": "const*", "length": "strlen"}
|
{"name": "selector", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||||
]
|
]
|
||||||
|
@ -2385,6 +2397,7 @@
|
||||||
"surface descriptor from metal layer": {
|
"surface descriptor from metal layer": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["native"],
|
"tags": ["native"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "layer", "type": "void", "annotation": "*"}
|
{"name": "layer", "type": "void", "annotation": "*"}
|
||||||
|
@ -2393,6 +2406,7 @@
|
||||||
"surface descriptor from windows HWND": {
|
"surface descriptor from windows HWND": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["native"],
|
"tags": ["native"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "hinstance", "type": "void", "annotation": "*"},
|
{"name": "hinstance", "type": "void", "annotation": "*"},
|
||||||
|
@ -2402,6 +2416,7 @@
|
||||||
"surface descriptor from xcb window": {
|
"surface descriptor from xcb window": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["upstream"],
|
"tags": ["upstream"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "connection", "type": "void", "annotation": "*"},
|
{"name": "connection", "type": "void", "annotation": "*"},
|
||||||
|
@ -2411,6 +2426,7 @@
|
||||||
"surface descriptor from xlib window": {
|
"surface descriptor from xlib window": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["native"],
|
"tags": ["native"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "display", "type": "void", "annotation": "*"},
|
{"name": "display", "type": "void", "annotation": "*"},
|
||||||
|
@ -2420,6 +2436,7 @@
|
||||||
"surface descriptor from wayland surface": {
|
"surface descriptor from wayland surface": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["native"],
|
"tags": ["native"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "display", "type": "void", "annotation": "*"},
|
{"name": "display", "type": "void", "annotation": "*"},
|
||||||
|
@ -2429,6 +2446,7 @@
|
||||||
"surface descriptor from windows core window": {
|
"surface descriptor from windows core window": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "core window", "type": "void", "annotation": "*"}
|
{"name": "core window", "type": "void", "annotation": "*"}
|
||||||
|
@ -2437,6 +2455,7 @@
|
||||||
"surface descriptor from windows swap chain panel": {
|
"surface descriptor from windows swap chain panel": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["surface descriptor"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "swap chain panel", "type": "void", "annotation": "*"}
|
{"name": "swap chain panel", "type": "void", "annotation": "*"}
|
||||||
|
@ -2886,6 +2905,7 @@
|
||||||
"dawn texture internal usage descriptor": {
|
"dawn texture internal usage descriptor": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["texture descriptor"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "internal usage", "type": "texture usage", "default": "none"}
|
{"name": "internal usage", "type": "texture usage", "default": "none"}
|
||||||
|
@ -2894,6 +2914,7 @@
|
||||||
"dawn encoder internal usage descriptor": {
|
"dawn encoder internal usage descriptor": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
|
"chain roots": ["command encoder descriptor"],
|
||||||
"tags": ["dawn"],
|
"tags": ["dawn"],
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "use internal usages", "type": "bool", "default": "false"}
|
{"name": "use internal usages", "type": "bool", "default": "false"}
|
||||||
|
|
|
@ -68,7 +68,8 @@ A **record** is a list of **record members**, each of which is a dictionary with
|
||||||
**`"structure"`**
|
**`"structure"`**
|
||||||
- `"members"` a **record**, so an array of **record members**
|
- `"members"` a **record**, so an array of **record members**
|
||||||
- `"extensible"` (defaults to false) a boolean defining if this is an "extensible" WebGPU structure (i.e. has `nextInChain`). "descriptor" structures should usually have this set to true.
|
- `"extensible"` (defaults to false) a boolean defining if this is an "extensible" WebGPU structure (i.e. has `nextInChain`). "descriptor" structures should usually have this set to true.
|
||||||
- `"chained"` (defaults to false) a boolean defining if this is a structure that can be "chained" in a WebGPU structure (i.e. has `nextInChain` and `sType`)
|
- `"chained"` (defaults to None) a string defining if this is a structure that can be "chained" in a WebGPU structure (i.e. has `nextInChain` and `sType`) and in which direction ('in' for inputs to WebGPU, 'out' for outputs)
|
||||||
|
- `"chain roots"` (defaults to []) a list of strings that are the canonical names of structures that can be extended by this structure.
|
||||||
|
|
||||||
**`"object"`**
|
**`"object"`**
|
||||||
- `**methods**` an array of methods for this object. Note that "release" and "reference" don't need to be specified. Each method is a dictionary containing:
|
- `**methods**` an array of methods for this object. Note that "release" and "reference" don't need to be specified. Each method is a dictionary containing:
|
||||||
|
|
|
@ -237,12 +237,13 @@ class StructureType(Record, Type):
|
||||||
m for m in json_data['members'] if is_enabled(m)
|
m for m in json_data['members'] if is_enabled(m)
|
||||||
]
|
]
|
||||||
Type.__init__(self, name, dict(json_data, **json_data_override))
|
Type.__init__(self, name, dict(json_data, **json_data_override))
|
||||||
self.chained = json_data.get("chained", None)
|
self.chained = json_data.get('chained', None)
|
||||||
self.extensible = json_data.get("extensible", None)
|
self.extensible = json_data.get('extensible', None)
|
||||||
if self.chained:
|
if self.chained:
|
||||||
assert (self.chained == "in" or self.chained == "out")
|
assert self.chained == 'in' or self.chained == 'out'
|
||||||
|
assert 'chain roots' in json_data
|
||||||
if self.extensible:
|
if self.extensible:
|
||||||
assert (self.extensible == "in" or self.extensible == "out")
|
assert self.extensible == 'in' or self.extensible == 'out'
|
||||||
# Chained structs inherit from wgpu::ChainedStruct, which has
|
# Chained structs inherit from wgpu::ChainedStruct, which has
|
||||||
# nextInChain, so setting both extensible and chained would result in
|
# nextInChain, so setting both extensible and chained would result in
|
||||||
# two nextInChain members.
|
# two nextInChain members.
|
||||||
|
@ -348,6 +349,8 @@ def link_object(obj, types):
|
||||||
|
|
||||||
def link_structure(struct, types):
|
def link_structure(struct, types):
|
||||||
struct.members = linked_record_members(struct.json_data['members'], types)
|
struct.members = linked_record_members(struct.json_data['members'], types)
|
||||||
|
struct.chain_roots = [types[root] for root in struct.json_data.get('chain roots', [])]
|
||||||
|
assert all((root.category == 'structure' for root in struct.chain_roots))
|
||||||
|
|
||||||
|
|
||||||
def link_function_pointer(function_pointer, types):
|
def link_function_pointer(function_pointer, types):
|
||||||
|
|
|
@ -89,6 +89,9 @@ typedef struct {{c_prefix}}ChainedStructOut {
|
||||||
} {{c_prefix}}ChainedStructOut;
|
} {{c_prefix}}ChainedStructOut;
|
||||||
|
|
||||||
{% for type in by_category["structure"] %}
|
{% for type in by_category["structure"] %}
|
||||||
|
{% for root in type.chain_roots %}
|
||||||
|
// Can be chained in {{as_cType(root.name)}}
|
||||||
|
{% endfor %}
|
||||||
typedef struct {{as_cType(type.name)}} {
|
typedef struct {{as_cType(type.name)}} {
|
||||||
{% set Out = "Out" if type.output else "" %}
|
{% set Out = "Out" if type.output else "" %}
|
||||||
{% set const = "const " if not type.output else "" %}
|
{% set const = "const " if not type.output else "" %}
|
||||||
|
|
|
@ -225,6 +225,9 @@ namespace {{metadata.namespace}} {
|
||||||
{% set Out = "Out" if type.output else "" %}
|
{% set Out = "Out" if type.output else "" %}
|
||||||
{% set const = "const" if not type.output else "" %}
|
{% set const = "const" if not type.output else "" %}
|
||||||
{% if type.chained %}
|
{% if type.chained %}
|
||||||
|
{% for root in type.chain_roots %}
|
||||||
|
// Can be chained in {{as_cppType(root.name)}}
|
||||||
|
{% endfor %}
|
||||||
struct {{as_cppType(type.name)}} : ChainedStruct{{Out}} {
|
struct {{as_cppType(type.name)}} : ChainedStruct{{Out}} {
|
||||||
{{as_cppType(type.name)}}() {
|
{{as_cppType(type.name)}}() {
|
||||||
sType = SType::{{type.name.CamelCase()}};
|
sType = SType::{{type.name.CamelCase()}};
|
||||||
|
|
Loading…
Reference in New Issue