Renumber webgpu.h enums to reserve 0 except for undefined
Bug: 42241166
Change-Id: I3955c8c2ea92c584aeab5eb04edc5effe331a7be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/192867
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/generator/templates/dawn/wire/WireCmd.cpp b/generator/templates/dawn/wire/WireCmd.cpp
index 0c122d2..0ff5801 100644
--- a/generator/templates/dawn/wire/WireCmd.cpp
+++ b/generator/templates/dawn/wire/WireCmd.cpp
@@ -566,8 +566,6 @@
break;
}
{% endfor %}
- // Explicitly list the Invalid enum. MSVC complains about no case labels.
- case WGPUSType_Invalid:
default:
// Invalid enum. Reserve space just for the transfer header (sType and hasNext).
result += WireAlignSizeof<WGPUChainedStructTransfer>();
@@ -602,18 +600,16 @@
chainedStruct = chainedStruct->next;
} break;
{% endfor %}
- // Explicitly list the Invalid enum. MSVC complains about no case labels.
- case WGPUSType_Invalid:
default: {
// Invalid enum. Serialize just the transfer header with Invalid as the sType.
// TODO(crbug.com/dawn/369): Unknown sTypes are silently discarded.
- if (chainedStruct->sType != WGPUSType_Invalid) {
+ if (chainedStruct->sType != WGPUSType(0)) {
dawn::WarningLog() << "Unknown sType " << chainedStruct->sType << " discarded.";
}
WGPUChainedStructTransfer* transfer;
WIRE_TRY(buffer->Next(&transfer));
- transfer->sType = WGPUSType_Invalid;
+ transfer->sType = WGPUSType(0);
transfer->hasNext = chainedStruct->next != nullptr;
// Still move on in case there are valid structs after this.
@@ -658,12 +654,10 @@
hasNext = transfer->chain.hasNext;
} break;
{% endfor %}
- // Explicitly list the Invalid enum. MSVC complains about no case labels.
- case WGPUSType_Invalid:
default: {
// Invalid enum. Deserialize just the transfer header with Invalid as the sType.
// TODO(crbug.com/dawn/369): Unknown sTypes are silently discarded.
- if (sType != WGPUSType_Invalid) {
+ if (sType != WGPUSType(0)) {
dawn::WarningLog() << "Unknown sType " << sType << " discarded.";
}
@@ -672,7 +666,7 @@
{{ChainedStruct}}* outStruct;
WIRE_TRY(GetSpace(allocator, 1u, &outStruct));
- outStruct->sType = WGPUSType_Invalid;
+ outStruct->sType = WGPUSType(0);
outStruct->next = nullptr;
// Still move on in case there are valid structs after this.
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index d96372b..3f1bf5d 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -108,11 +108,11 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "unavailable"},
- {"value": 3, "name": "error"},
- {"value": 4, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "unavailable"},
+ {"value": 4, "name": "error"},
+ {"value": 5, "name": "unknown"}
]
},
"adapter": {
@@ -734,27 +734,27 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "validation error"},
- {"value": 3, "name": "unknown"},
- {"value": 4, "name": "device lost"},
- {"value": 5, "name": "destroyed before callback"},
- {"value": 6, "name": "unmapped before callback"},
- {"value": 7, "name": "mapping already pending"},
- {"value": 8, "name": "offset out of range"},
- {"value": 9, "name": "size out of range"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "validation error"},
+ {"value": 4, "name": "unknown"},
+ {"value": 5, "name": "device lost"},
+ {"value": 6, "name": "destroyed before callback"},
+ {"value": 7, "name": "unmapped before callback"},
+ {"value": 8, "name": "mapping already pending"},
+ {"value": 9, "name": "offset out of range"},
+ {"value": 10, "name": "size out of range"}
]
},
"map async status": {
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "error"},
- {"value": 3, "name": "aborted"},
- {"value": 4, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "error"},
+ {"value": 4, "name": "aborted"},
+ {"value": 5, "name": "unknown"}
]
},
"buffer map state": {
@@ -1019,11 +1019,11 @@
"compilation info request status": {
"category": "enum",
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "error"},
- {"value": 3, "name": "device lost"},
- {"value": 4, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "error"},
+ {"value": 4, "name": "device lost"},
+ {"value": 5, "name": "unknown"}
]
},
"compilation message": {
@@ -1131,11 +1131,11 @@
"composite alpha mode": {
"category": "enum",
"values": [
- {"value": 0, "name": "auto"},
- {"value": 1, "name": "opaque"},
- {"value": 2, "name": "premultiplied"},
- {"value": 3, "name": "unpremultiplied"},
- {"value": 4, "name": "inherit"}
+ {"value": 1, "name": "auto"},
+ {"value": 2, "name": "opaque"},
+ {"value": 3, "name": "premultiplied"},
+ {"value": 4, "name": "unpremultiplied"},
+ {"value": 5, "name": "inherit"}
]
},
"compute pass timestamp writes": {
@@ -1246,13 +1246,13 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "validation error"},
- {"value": 3, "name": "internal error"},
- {"value": 4, "name": "device lost"},
- {"value": 5, "name": "device destroyed"},
- {"value": 6, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "validation error"},
+ {"value": 4, "name": "internal error"},
+ {"value": 5, "name": "device lost"},
+ {"value": 6, "name": "device destroyed"},
+ {"value": 7, "name": "unknown"}
]
},
"create render pipeline async callback": {
@@ -1727,8 +1727,8 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"}
]
},
"pop error scope callback": {
@@ -1846,12 +1846,12 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "no error"},
- {"value": 1, "name": "validation"},
- {"value": 2, "name": "out of memory"},
- {"value": 3, "name": "internal"},
- {"value": 4, "name": "unknown"},
- {"value": 5, "name": "device lost"}
+ {"value": 1, "name": "no error"},
+ {"value": 2, "name": "validation"},
+ {"value": 3, "name": "out of memory"},
+ {"value": 4, "name": "internal"},
+ {"value": 5, "name": "unknown"},
+ {"value": 6, "name": "device lost"}
]
},
"logging type": {
@@ -1910,10 +1910,10 @@
"tags": ["dawn"],
"_comment": "ANGLEs are clockwise rotation degrees and not trigonometric.",
"values": [
- {"value": 0, "name": "rotate 0 degrees"},
- {"value": 1, "name": "rotate 90 degrees"},
- {"value": 2, "name": "rotate 180 degrees"},
- {"value": 3, "name": "rotate 270 degrees"}
+ {"value": 1, "name": "rotate 0 degrees"},
+ {"value": 2, "name": "rotate 90 degrees"},
+ {"value": 3, "name": "rotate 180 degrees"},
+ {"value": 4, "name": "rotate 270 degrees"}
]
},
"external texture descriptor": {
@@ -1943,8 +1943,8 @@
"status": {
"category": "enum",
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "error"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "error"}
]
},
"shared buffer memory": {
@@ -2629,12 +2629,12 @@
"_comment": "TODO(crbug.com/dawn/2053): This could possibly be [[nodiscard]].",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "timed out"},
- {"value": 2, "name": "unsupported timeout"},
- {"value": 3, "name": "unsupported count"},
- {"value": 4, "name": "unsupported mixed sources"},
- {"value": 5, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "timed out"},
+ {"value": 3, "name": "unsupported timeout"},
+ {"value": 4, "name": "unsupported count"},
+ {"value": 5, "name": "unsupported mixed sources"},
+ {"value": 6, "name": "unknown"}
]
},
"future wait info": {
@@ -2807,10 +2807,10 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "fifo"},
- {"value": 1, "name": "fifo relaxed"},
- {"value": 2, "name": "immediate"},
- {"value": 3, "name": "mailbox"}
+ {"value": 1, "name": "fifo"},
+ {"value": 2, "name": "fifo relaxed"},
+ {"value": 3, "name": "immediate"},
+ {"value": 4, "name": "mailbox"}
]
},
"programmable stage descriptor": {
@@ -3007,11 +3007,11 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "error"},
- {"value": 3, "name": "unknown"},
- {"value": 4, "name": "device lost"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "error"},
+ {"value": 4, "name": "unknown"},
+ {"value": 5, "name": "device lost"}
]
},
@@ -3458,10 +3458,10 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "instance dropped"},
- {"value": 2, "name": "error"},
- {"value": 3, "name": "unknown"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "instance dropped"},
+ {"value": 3, "name": "error"},
+ {"value": 4, "name": "unknown"}
]
},
@@ -3918,7 +3918,6 @@
"category": "enum",
"emscripten_no_enum_table": true,
"values": [
- {"value": 0, "name": "invalid", "valid": false},
{"value": 1, "name": "surface descriptor from metal layer", "tags": ["native"]},
{"value": 2, "name": "surface descriptor from windows HWND", "tags": ["native"]},
{"value": 3, "name": "surface descriptor from xlib window", "tags": ["native"]},
@@ -4058,13 +4057,13 @@
"surface get current texture status": {
"category": "enum",
"values": [
- {"value": 0, "name": "success"},
- {"value": 1, "name": "timeout"},
- {"value": 2, "name": "outdated"},
- {"value": 3, "name": "lost"},
- {"value": 4, "name": "out of memory"},
- {"value": 5, "name": "device lost"},
- {"value": 6, "name": "error"}
+ {"value": 1, "name": "success"},
+ {"value": 2, "name": "timeout"},
+ {"value": 3, "name": "outdated"},
+ {"value": 4, "name": "lost"},
+ {"value": 5, "name": "out of memory"},
+ {"value": 6, "name": "device lost"},
+ {"value": 7, "name": "error"}
]
},
"texture aspect": {
diff --git a/src/dawn/native/ChainUtils.h b/src/dawn/native/ChainUtils.h
index a22ceeb..7594137 100644
--- a/src/dawn/native/ChainUtils.h
+++ b/src/dawn/native/ChainUtils.h
@@ -308,7 +308,7 @@
ResultOrError<wgpu::SType> UnpackedPtr<T>::ValidateBranches() const {
using Validator = detail::BranchesValidator<UnpackedPtr<T>, Branches...>;
- wgpu::SType match = wgpu::SType::Invalid;
+ wgpu::SType match = wgpu::SType(0u);
if (Validator::Validate(*this, mBitset, match)) {
return match;
}
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index 719b7b2..5b62e47 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -1097,7 +1097,7 @@
(descriptor.ValidateBranches<
Branch<ShaderModuleWGSLDescriptor, ShaderModuleCompilationOptions>>()));
#endif
- DAWN_ASSERT(moduleType != wgpu::SType::Invalid);
+ DAWN_ASSERT(moduleType != wgpu::SType(0u));
ScopedTintICEHandler scopedICEHandler(device);
diff --git a/src/dawn/tests/end2end/WindowSurfaceTests.cpp b/src/dawn/tests/end2end/WindowSurfaceTests.cpp
index 0112f7c..5c03f04 100644
--- a/src/dawn/tests/end2end/WindowSurfaceTests.cpp
+++ b/src/dawn/tests/end2end/WindowSurfaceTests.cpp
@@ -119,7 +119,7 @@
// Test that a chained descriptor with a garbage sType produces an error.
TEST_F(WindowSurfaceInstanceTests, BadChainedDescriptors) {
wgpu::ChainedStruct chainedDescriptor;
- chainedDescriptor.sType = wgpu::SType::Invalid; // The default but we set it for clarity.
+ chainedDescriptor.sType = wgpu::SType(0u); // The default but we set it for clarity.
wgpu::SurfaceDescriptor descriptor;
descriptor.nextInChain = &chainedDescriptor;
diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
index 91dee40..8239de7 100644
--- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
@@ -154,7 +154,7 @@
// Check that nextInChain != nullptr is an error.
wgpu::ChainedStruct chainedDescriptor;
- chainedDescriptor.sType = wgpu::SType::Invalid;
+ chainedDescriptor.sType = wgpu::SType(0u);
descriptor.nextInChain = &chainedDescriptor;
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
}
diff --git a/src/dawn/tests/unittests/wire/WireExtensionTests.cpp b/src/dawn/tests/unittests/wire/WireExtensionTests.cpp
index f0215f1..6487eb6 100644
--- a/src/dawn/tests/unittests/wire/WireExtensionTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireExtensionTests.cpp
@@ -149,7 +149,7 @@
FlushClient();
WGPUPrimitiveDepthClipControl clientExt = {};
- clientExt.chain.sType = WGPUSType_Invalid;
+ clientExt.chain.sType = WGPUSType(0);
clientExt.chain.next = nullptr;
WGPURenderPipelineDescriptor renderPipelineDesc = {};
@@ -160,7 +160,7 @@
EXPECT_CALL(api, DeviceCreateRenderPipeline(apiDevice, NotNull()))
.WillOnce(Invoke(
[&](Unused, const WGPURenderPipelineDescriptor* serverDesc) -> WGPURenderPipeline {
- EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType_Invalid);
+ EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType(0));
EXPECT_EQ(serverDesc->primitive.nextInChain->next, nullptr);
return api.GetNewRenderPipeline();
}));
@@ -187,7 +187,7 @@
EXPECT_CALL(api, DeviceCreateRenderPipeline(apiDevice, NotNull()))
.WillOnce(Invoke(
[&](Unused, const WGPURenderPipelineDescriptor* serverDesc) -> WGPURenderPipeline {
- EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType_Invalid);
+ EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType(0));
EXPECT_EQ(serverDesc->primitive.nextInChain->next, nullptr);
return api.GetNewRenderPipeline();
}));
@@ -204,7 +204,7 @@
FlushClient();
WGPUPrimitiveDepthClipControl clientExt2 = {};
- clientExt2.chain.sType = WGPUSType_Invalid;
+ clientExt2.chain.sType = WGPUSType(0);
clientExt2.chain.next = nullptr;
WGPUPrimitiveDepthClipControl clientExt1 = {};
@@ -225,7 +225,7 @@
EXPECT_EQ(ext->chain.sType, clientExt1.chain.sType);
EXPECT_EQ(ext->unclippedDepth, true);
- EXPECT_EQ(ext->chain.next->sType, WGPUSType_Invalid);
+ EXPECT_EQ(ext->chain.next->sType, WGPUSType(0));
EXPECT_EQ(ext->chain.next->next, nullptr);
return api.GetNewRenderPipeline();
}));
@@ -240,7 +240,7 @@
EXPECT_CALL(api, DeviceCreateRenderPipeline(apiDevice, NotNull()))
.WillOnce(Invoke(
[&](Unused, const WGPURenderPipelineDescriptor* serverDesc) -> WGPURenderPipeline {
- EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType_Invalid);
+ EXPECT_EQ(serverDesc->primitive.nextInChain->sType, WGPUSType(0));
const auto* ext = reinterpret_cast<const WGPUPrimitiveDepthClipControl*>(
serverDesc->primitive.nextInChain->next);