Add new items for Emscripten/webgpu-headers

Generates the exact upstream headers, except for a few Dawn and upstream
changes that have landed since I started this CL, and the "_TODO"s about
extensibility of compilation info/message.

Bug: dawn:1080
Change-Id: I2a6128a3e78cfef7b9f8feae84b7c7c207eb2826
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62861
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/dawn.json b/dawn.json
index 363d6aa..45db3e2 100644
--- a/dawn.json
+++ b/dawn.json
@@ -17,6 +17,56 @@
 
     "_doc": "See docs/codegen.md",
 
+    "request adapter options": {
+        "category": "structure",
+        "extensible": true,
+        "tags": ["upstream"],
+        "members": [
+            {"name": "compatible surface", "type": "surface"}
+        ]
+    },
+    "request adapter status": {
+        "category": "enum",
+        "tags": ["upstream"],
+        "emscripten_no_enum_table": true,
+        "values": [
+            {"value": 0, "name": "success"},
+            {"value": 1, "name": "unavailable"},
+            {"value": 2, "name": "error"},
+            {"value": 3, "name": "unknown"}
+        ]
+    },
+    "request adapter callback": {
+        "category": "callback",
+        "tags": ["upstream"],
+        "args": [
+            {"name": "status", "type": "request adapter status"},
+            {"name": "adapter", "type": "adapter"},
+            {"name": "message", "type": "char", "annotation": "const*"},
+            {"name": "userdata", "type": "void", "annotation": "*"}
+        ]
+    },
+    "adapter": {
+        "category": "object",
+        "tags": ["upstream"],
+        "methods": [
+            {
+                "name": "get properties",
+                "tags": ["upstream"],
+                "args": [
+                    {"name": "properties", "type": "adapter properties", "annotation": "*"}
+                ]
+            },
+            {
+                "name": "request device",
+                "args": [
+                    {"name": "descriptor", "type": "device descriptor", "annotation": "const*"},
+                    {"name": "callback", "type": "request device callback"},
+                    {"name": "userdata", "type": "void", "annotation": "*"}
+                ]
+            }
+        ]
+    },
     "adapter properties": {
         "category": "structure",
         "extensible": true,
@@ -40,6 +90,13 @@
             {"value": 3, "name": "unknown"}
         ]
     },
+    "device descriptor": {
+        "category": "structure",
+        "extensible": true,
+        "tags": ["upstream"],
+        "_TODO": "Add requiredFeatures and requiredLimits support",
+        "members": []
+    },
     "address mode": {
         "category": "enum",
         "values": [
@@ -53,12 +110,13 @@
         "emscripten_no_enum_table": true,
         "values": [
             {"value": 0, "name": "null"},
-            {"value": 1, "name": "D3D11"},
-            {"value": 2, "name": "D3D12"},
-            {"value": 3, "name": "metal"},
-            {"value": 4, "name": "vulkan"},
-            {"value": 5, "name": "openGL"},
-            {"value": 6, "name": "openGLES"}
+            {"value": 1, "name": "WebGPU"},
+            {"value": 2, "name": "D3D11"},
+            {"value": 3, "name": "D3D12"},
+            {"value": 4, "name": "metal"},
+            {"value": 5, "name": "vulkan"},
+            {"value": 6, "name": "openGL"},
+            {"value": 7, "name": "openGLES"}
         ]
     },
     "bind group": {
@@ -96,7 +154,7 @@
             {"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false},
             {"value": 1, "name": "uniform"},
             {"value": 2, "name": "storage"},
-            {"value": 3, "name": "read only storage", "jsrepr": "readonly-storage"}
+            {"value": 3, "name": "read only storage"}
         ]
     },
     "buffer binding layout": {
@@ -498,6 +556,7 @@
     "compilation info": {
         "category": "structure",
         "extensible": false,
+        "_TODO": "should be extensible, but need to make that work in wire: https://github.com/webgpu-native/webgpu-headers/issues/82",
         "members": [
             {"name": "message count", "type": "uint32_t"},
             {"name": "messages", "type": "compilation message", "annotation": "const*", "length": "message count"}
@@ -525,6 +584,7 @@
     "compilation message": {
         "category": "structure",
         "extensible": false,
+        "_TODO": "should be extensible, but need to make that work in wire: https://github.com/webgpu-native/webgpu-headers/issues/82",
         "members": [
             {"name": "message", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
             {"name": "type", "type": "compilation message type"},
@@ -592,6 +652,14 @@
                 ]
             },
             {
+                "name": "begin pipeline statistics query",
+                "tags": ["upstream"],
+                "args": [
+                    {"name": "query set", "type": "query set"},
+                    {"name": "query index", "type": "uint32_t"}
+                ]
+            },
+            {
                 "name": "dispatch",
                 "args": [
                     {"name": "x", "type": "uint32_t"},
@@ -608,6 +676,10 @@
             },
             {
                 "name": "end pass"
+            },
+            {
+                "name": "end pipeline statistics query",
+                "tags": ["upstream"]
             }
         ]
     },
@@ -821,6 +893,11 @@
                 ]
             },
             {
+                "name": "destroy",
+                "_TODO": "crbug.com/dawn/628: Implement in Dawn",
+                "tags": ["upstream"]
+            },
+            {
                 "name": "get limits",
                 "returns": "bool",
                 "args": [
@@ -892,6 +969,14 @@
             {"name": "userdata", "type": "void", "annotation": "*"}
         ]
     },
+    "device lost reason": {
+        "category": "enum",
+        "emscripten_no_enum_table": true,
+        "values": [
+            {"name": "undefined", "value": 0, "jsrepr": "undefined"},
+            {"name": "destroyed", "value": 1}
+        ]
+    },
     "device properties": {
         "category": "structure",
         "extensible": false,
@@ -1086,6 +1171,19 @@
                 "args": [
                     {"name": "descriptor", "type": "surface descriptor", "annotation": "const*"}
                 ]
+            },
+            {
+                "name": "process events",
+                "tags": ["upstream"]
+            },
+            {
+                "name": "request adapter",
+                "tags": ["upstream"],
+                "args": [
+                    {"name": "options", "type": "request adapter options", "annotation": "const*"},
+                    {"name": "callback", "type": "request adapter callback"},
+                    {"name": "userdata", "type": "void", "annotation": "*"}
+                ]
             }
         ]
     },
@@ -1582,6 +1680,14 @@
                 ]
             },
             {
+                "name": "begin pipeline statistics query",
+                "tags": ["upstream"],
+                "args": [
+                    {"name": "query set", "type": "query set"},
+                    {"name": "query index", "type": "uint32_t"}
+                ]
+            },
+            {
                 "name": "end occlusion query"
             },
             {
@@ -1593,6 +1699,10 @@
             },
             {
                 "name": "end pass"
+            },
+            {
+                "name": "end pipeline statistics query",
+                "tags": ["upstream"]
             }
         ]
     },
@@ -1831,7 +1941,17 @@
         ]
     },
     "surface": {
-        "category": "object"
+        "category": "object",
+        "methods": [
+            {
+                "name": "get preferred format",
+                "returns": "texture format",
+                "tags": ["upstream"],
+                "args": [
+                    {"name": "adapter", "type": "adapter"}
+                ]
+            }
+        ]
     },
     "surface descriptor": {
         "category": "structure",
diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp
index 73d238e..172ece93 100644
--- a/src/dawn_native/DawnNative.cpp
+++ b/src/dawn_native/DawnNative.cpp
@@ -76,6 +76,7 @@
                 return BackendType::OpenGLES;
 
             case wgpu::BackendType::D3D11:
+            case wgpu::BackendType::WebGPU:
                 UNREACHABLE();
         }
     }