[webgpu] Bump version of Dawn to b9b4a370 (#23494)

### Description

This PR updates the version of Dawn to
`b9b4a37041dec3dd62ac92014a6cc1aece48d9f3` (ref:
[chromium](67f86f01dd/DEPS (399)))
in the `deps.txt` file.

The newer version of Dawn includes the previous changes from dawn.patch
so that we can remove the patch file.

There is a little interface changes and code is updated correspondingly.
This commit is contained in:
Yulong Wang 2025-01-27 14:02:06 -08:00 committed by GitHub
parent fdde2e25e1
commit 8db97a68f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 15 additions and 133 deletions

View file

@ -346,7 +346,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "12a3b24c456cebd9fd11f23ac0164f78129b00c6",
"commitHash": "b9b4a37041dec3dd62ac92014a6cc1aece48d9f3",
"repositoryUrl": "https://github.com/google/dawn.git"
},
"comments": "dawn"

View file

@ -58,5 +58,5 @@ extensions;https://github.com/microsoft/onnxruntime-extensions/archive/f3f6caa6e
composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/204da9c522cebec5220bba52cd3542ebcaf99e7a.zip;1827348efd47831c13074245274d41b7cae8a557
directx_headers;https://github.com/microsoft/DirectX-Headers/archive/refs/tags/v1.613.1.zip;47653509a3371eabb156360f42faf582f314bf2e
cudnn_frontend;https://github.com/NVIDIA/cudnn-frontend/archive/refs/tags/v1.7.0.zip;d0753d8d5b39947ca0729d7773cb84653a129eb1
dawn;https://github.com/google/dawn/archive/12a3b24c456cebd9fd11f23ac0164f78129b00c6.zip;ad428f6dc16f1336d584f7bad5714e1097dafc43
dawn;https://github.com/google/dawn/archive/b9b4a37041dec3dd62ac92014a6cc1aece48d9f3.zip;e8b8c2ebabdedb7c57d931fc4a19ae22146d31e1
kleidiai;https://gitlab.arm.com/kleidi/kleidiai/-/archive/d15722976120710080ca098fe8ddabf4556cb40f/kleidiai-d15722976120710080ca098fe8ddabf4556cb40f.zip;d6c840d00c3b05aedf06e957ddaece1013d1f40b

View file

@ -631,7 +631,7 @@ if (onnxruntime_USE_WEBGPU)
URL_HASH SHA1=${DEP_SHA1_dawn}
# All previous patches are merged into the upstream dawn project. We don't need to apply any patches right now.
# if we need to apply patches in the future, we can uncomment the following line.
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/dawn.patch
# PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/dawn.patch
)
endif()

View file

@ -1,118 +0,0 @@
diff --git a/src/emdawnwebgpu/CMakeLists.txt b/src/emdawnwebgpu/CMakeLists.txt
index de673537d3..c98dc46de7 100644
--- a/src/emdawnwebgpu/CMakeLists.txt
+++ b/src/emdawnwebgpu/CMakeLists.txt
@@ -78,6 +78,7 @@ if (${DAWN_ENABLE_EMSCRIPTEN})
endif()
set(ARGS
+ ${Python3_EXECUTABLE}
"${DAWN_EMSCRIPTEN_TOOLCHAIN}/tools/maint/gen_struct_info.py"
-q
"${EM_BUILD_GEN_DIR}/struct_info_webgpu.json"
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index d1835cb090..df03ea2f94 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -16,10 +16,19 @@
throw new Error("To use Dawn's library_webgpu.js, disable -sUSE_WEBGPU and first include Dawn's library_webgpu_struct_info.js and library_webgpu_enum_tables.js (before library_webgpu.js)");
}
+ if (MEMORY64) {
+ throw new Error("The current implementation of Dawn's library_webgpu.js does not support MEMORY64 yet");
+ }
+
// Helper functions for code generation
globalThis.gpu = {
- convertSentinelToUndefined: function(name) {
- return `if (${name} == -1) ${name} = undefined;`;
+ convertSentinelToUndefined: function(name, isPtr = false) {
+ // When `CAN_ADDRESS_2GB` is true, value `-1` is normalized to `0xFFFFFFFF` for pointer.
+ if (CAN_ADDRESS_2GB && isPtr) {
+ return `if (${name} == 0xFFFFFFFF) ${name} = undefined;`;
+ } else {
+ return `if (${name} == -1) ${name} = undefined;`;
+ }
},
makeGetBool: function(struct, offset) {
@@ -700,6 +709,7 @@ var LibraryWebGPU = {
{{{ makeSetValue('info', C_STRUCTS.WGPUAdapterInfo.adapterType, 'adapterType', 'i32') }}};
{{{ makeSetValue('info', C_STRUCTS.WGPUAdapterInfo.vendorID, '0', 'i32') }}};
{{{ makeSetValue('info', C_STRUCTS.WGPUAdapterInfo.deviceID, '0', 'i32') }}};
+ return 1;
},
wgpuAdapterGetLimits: (adapterPtr, limitsOutPtr) => {
@@ -882,7 +892,7 @@ var LibraryWebGPU = {
if (size === 0) warnOnce('getMappedRange size=0 no longer means WGPU_WHOLE_MAP_SIZE');
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
var mapped;
try {
@@ -909,7 +919,7 @@ var LibraryWebGPU = {
if (size === 0) warnOnce('getMappedRange size=0 no longer means WGPU_WHOLE_MAP_SIZE');
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
var mapped;
try {
@@ -950,7 +960,7 @@ var LibraryWebGPU = {
var buffer = WebGPU.getJsObject(bufferPtr);
WebGPU.Internals.bufferOnUnmaps[bufferPtr] = [];
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
{{{ runtimeKeepalivePush() }}}
WebGPU.Internals.futureInsert(futureId, buffer.mapAsync(mode, offset, size).then(() => {
@@ -1145,7 +1155,7 @@ var LibraryWebGPU = {
wgpuCommandEncoderClearBuffer: (encoderPtr, bufferPtr, offset, size) => {
var commandEncoder = WebGPU.getJsObject(encoderPtr);
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
var buffer = WebGPU.getJsObject(bufferPtr);
commandEncoder.clearBuffer(buffer, offset, size);
@@ -2103,7 +2113,7 @@ var LibraryWebGPU = {
wgpuRenderBundleEncoderSetIndexBuffer: (passPtr, bufferPtr, format, offset, size) => {
var pass = WebGPU.getJsObject(passPtr);
var buffer = WebGPU.getJsObject(bufferPtr);
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
pass.setIndexBuffer(buffer, WebGPU.IndexFormat[format], offset, size);
},
@@ -2116,7 +2126,7 @@ var LibraryWebGPU = {
wgpuRenderBundleEncoderSetVertexBuffer: (passPtr, slot, bufferPtr, offset, size) => {
var pass = WebGPU.getJsObject(passPtr);
var buffer = WebGPU.getJsObject(bufferPtr);
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
pass.setVertexBuffer(slot, buffer, offset, size);
},
@@ -2211,7 +2221,7 @@ var LibraryWebGPU = {
wgpuRenderPassEncoderSetIndexBuffer: (passPtr, bufferPtr, format, offset, size) => {
var pass = WebGPU.getJsObject(passPtr);
var buffer = WebGPU.getJsObject(bufferPtr);
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
pass.setIndexBuffer(buffer, WebGPU.IndexFormat[format], offset, size);
},
@@ -2234,7 +2244,7 @@ var LibraryWebGPU = {
wgpuRenderPassEncoderSetVertexBuffer: (passPtr, slot, bufferPtr, offset, size) => {
var pass = WebGPU.getJsObject(passPtr);
var buffer = WebGPU.getJsObject(bufferPtr);
- {{{ gpu.convertSentinelToUndefined('size') }}}
+ {{{ gpu.convertSentinelToUndefined('size', true) }}}
pass.setVertexBuffer(slot, buffer, offset, size);
},

View file

@ -147,16 +147,16 @@ Status ProgramManager::Build(const ProgramBase& program,
}
}
wgpu::ProgrammableStageDescriptor compute_stage{};
compute_stage.module = shader_module;
compute_stage.entryPoint = "main";
wgpu::ComputeState compute_state{};
compute_state.module = shader_module;
compute_state.entryPoint = "main";
if (!constant_entries.empty()) {
compute_stage.constants = constant_entries.data();
compute_stage.constantCount = constant_entries.size();
compute_state.constants = constant_entries.data();
compute_state.constantCount = constant_entries.size();
}
wgpu::ComputePipelineDescriptor pipeline_descriptor{};
pipeline_descriptor.compute = compute_stage;
pipeline_descriptor.compute = compute_state;
#ifndef NDEBUG // if debug build
pipeline_descriptor.label = program.Name().c_str();
#endif

View file

@ -115,12 +115,12 @@ void WebGpuContext::Initialize(const WebGpuBufferCacheConfig& buffer_cache_confi
device_desc.requiredLimits = &required_limits;
// TODO: revise temporary error handling
device_desc.SetUncapturedErrorCallback([](const wgpu::Device& /*device*/, wgpu::ErrorType type, const char* message) {
LOGS_DEFAULT(ERROR) << "WebGPU device error(" << int(type) << "): " << message;
device_desc.SetUncapturedErrorCallback([](const wgpu::Device& /*device*/, wgpu::ErrorType type, wgpu::StringView message) {
LOGS_DEFAULT(ERROR) << "WebGPU device error(" << int(type) << "): " << std::string_view{message};
});
// TODO: revise temporary device lost handling
device_desc.SetDeviceLostCallback(wgpu::CallbackMode::AllowSpontaneous, [](const wgpu::Device& /*device*/, wgpu::DeviceLostReason reason, const char* message) {
LOGS_DEFAULT(INFO) << "WebGPU device lost (" << int(reason) << "): " << message;
device_desc.SetDeviceLostCallback(wgpu::CallbackMode::AllowSpontaneous, [](const wgpu::Device& /*device*/, wgpu::DeviceLostReason reason, wgpu::StringView message) {
LOGS_DEFAULT(INFO) << "WebGPU device lost (" << int(reason) << "): " << std::string_view{message};
});
ORT_ENFORCE(wgpu::WaitStatus::Success == instance_.WaitAny(adapter_.RequestDevice(

View file

@ -11,7 +11,7 @@ steps:
packageType: upack
feed: '/7424c8e4-5c62-490e-95c4-79446f31017c'
definition: '517c4f6f-5437-4392-a70d-4f15ec5be2f0'
version: 1.0.208
version: 1.0.213
downloadPath: $(Build.BinariesDirectory)/deps
# The private ADO project
@ -22,7 +22,7 @@ steps:
packageType: upack
feed: '/4c7631f5-24c0-4307-8822-1aa8f180c325'
definition: 'fd9dd5ad-b73e-4678-890e-edcf680dbc1a'
version: 1.0.208
version: 1.0.213
downloadPath: $(Build.BinariesDirectory)/deps
# You can add more ADO accounts at here.