From 7d174a1effd8f74e13f8bb3184257bae4c9b99fc Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Tue, 21 Sep 2021 17:36:27 +0000 Subject: [PATCH] dawn.json changes to match upstream webgpu.h Bug: dawn:1080 Change-Id: Icc77f8ccd5a07162d0e7795d7160d936f9c33e49 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64620 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Kai Ninomiya --- dawn.json | 66 ++++++++++++++++++++++++++++++-- generator/dawn_json_generator.py | 2 +- generator/templates/webgpu.h | 4 +- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/dawn.json b/dawn.json index 60caac3117..51037464fc 100644 --- a/dawn.json +++ b/dawn.json @@ -22,7 +22,9 @@ "extensible": "in", "tags": ["upstream"], "members": [ - {"name": "compatible surface", "type": "surface"} + {"name": "compatible surface", "type": "surface"}, + {"name": "power preference", "type": "power preference", "tags": ["upstream"]}, + {"name": "force fallback adapter", "type": "bool", "tags": ["upstream"]} ] }, "request adapter status": { @@ -50,6 +52,14 @@ "category": "object", "tags": ["upstream"], "methods": [ + { + "name": "get limits", + "returns": "bool", + "tags": ["upstream"], + "args": [ + {"name": "limits", "type": "supported limits", "annotation": "*"} + ] + }, { "name": "get properties", "tags": ["upstream"], @@ -57,6 +67,14 @@ {"name": "properties", "type": "adapter properties", "annotation": "*"} ] }, + { + "name": "has feature", + "returns": "bool", + "tags": ["upstream"], + "args": [ + {"name": "feature", "type": "feature name"} + ] + }, { "name": "request device", "args": [ @@ -94,7 +112,11 @@ "extensible": "in", "tags": ["upstream"], "_TODO": "Add requiredFeatures and requiredLimits support", - "members": [] + "members": [ + {"name": "required features count", "type": "uint32_t"}, + {"name": "required features", "type": "feature name", "annotation": "const*", "length": "required features count"}, + {"name": "required limits", "type": "required limits", "annotation": "const*"} + ] }, "address mode": { "category": "enum", @@ -412,6 +434,14 @@ {"value": 15, "name": "all"} ] }, + "constant entry": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "key", "type": "char", "annotation": "const*"}, + {"name": "value", "type": "double"} + ] + }, "command buffer": { "category": "object" }, @@ -524,6 +554,7 @@ }, { "name": "write buffer", + "tags": ["dawn"], "args": [ {"name": "buffer", "type": "buffer"}, {"name": "buffer offset", "type": "uint64_t"}, @@ -1126,6 +1157,21 @@ {"name": "format", "type": "texture format"} ] }, + "feature name": { + "category": "enum", + "tags": ["upstream"], + "values": [ + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "depth clamping"}, + {"value": 2, "name": "depth24 unorm stencil8"}, + {"value": 3, "name": "depth32 float stencil8"}, + {"value": 4, "name": "timestamp query"}, + {"value": 5, "name": "pipeline statistics query"}, + {"value": 6, "name": "texture compression BC"}, + {"value": 7, "name": "texture compression ETC2"}, + {"value": 8, "name": "texture compression ASTC"} + ] + }, "filter mode": { "category": "enum", "values": [ @@ -1278,6 +1324,14 @@ {"value": 4, "name": "compute shader invocations"} ] }, + "power preference": { + "category": "enum", + "tags": ["upstream"], + "values": [ + {"value": 0, "name": "low power"}, + {"value": 1, "name": "high performance"} + ] + }, "present mode": { "category": "enum", "emscripten_no_enum_table": true, @@ -1292,7 +1346,9 @@ "extensible": "in", "members": [ {"name": "module", "type": "shader module"}, - {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"} + {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"}, + {"name": "constant count", "type": "uint32_t", "tags": ["upstream"]}, + {"name": "constants", "type": "constant entry", "annotation": "const*", "length": "constant count", "tags": ["upstream"]} ] }, "primitive topology": { @@ -1760,6 +1816,8 @@ "members": [ {"name": "module", "type": "shader module"}, {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"}, + {"name": "constant count", "type": "uint32_t", "tags": ["upstream"]}, + {"name": "constants", "type": "constant entry", "annotation": "const*", "length": "constant count", "tags": ["upstream"]}, {"name": "buffer count", "type": "uint32_t", "default": 0}, {"name": "buffers", "type": "vertex buffer layout", "annotation": "const*", "length": "buffer count"} ] @@ -1817,6 +1875,8 @@ "members": [ {"name": "module", "type": "shader module"}, {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"}, + {"name": "constant count", "type": "uint32_t", "tags": ["upstream"]}, + {"name": "constants", "type": "constant entry", "annotation": "const*", "length": "constant count", "tags": ["upstream"]}, {"name": "target count", "type": "uint32_t"}, {"name": "targets", "type": "color target state", "annotation": "const*", "length": "target count"} ] diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py index 3b138c8720..439eda1fb8 100644 --- a/generator/dawn_json_generator.py +++ b/generator/dawn_json_generator.py @@ -309,7 +309,7 @@ def link_typedef(typedef, types): # similar to the original order (though the sort isn't technically stable). # # It works by computing for each struct type what is the depth of its DAG of -# dependents, then resorting based on that depth using Python's stable sort. +# dependents, then re-sorting based on that depth using Python's stable sort. # This makes a toposort because if A depends on B then its depth will be bigger # than B's. It is also nice because all nodes with the same depth are kept in # the input order. diff --git a/generator/templates/webgpu.h b/generator/templates/webgpu.h index a0a6e3ee06..9630d1af03 100644 --- a/generator/templates/webgpu.h +++ b/generator/templates/webgpu.h @@ -116,9 +116,9 @@ typedef struct WGPUChainedStructOut { {% for type in by_category["structure"] %} typedef struct {{as_cType(type.name)}} { {% 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.extensible %} - WGPUChainedStruct{{Out}} {{const}} * nextInChain; + WGPUChainedStruct{{Out}} {{const}}* nextInChain; {% endif %} {% if type.chained %} WGPUChainedStruct{{Out}} chain;