Skip to content

Commit 8f986f1

Browse files
authored
Update WebGPU headers (emscripten-core#16078)
* Update WebGPU to dawn a83c434cc785ea55fc9e76f055522378e32bf199 * fix reference_struct_info.json * Update dawn generator headers with 'upstream' tags; Fix power preference undefined * add depth clip control feature name * some library_webgpu.js implementation * check map size with uint32 * test_gen_struct_info rebaseline * add back some upstream only functions * update webgpu readme * map size check against -1
1 parent af4a408 commit 8f986f1

File tree

7 files changed

+337
-196
lines changed

7 files changed

+337
-196
lines changed

src/library_webgpu.js

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
// Must be in sync with webgpu.h.
9292
COPY_STRIDE_UNDEFINED: 0xFFFFFFFF,
9393
LIMIT_U32_UNDEFINED: 0xFFFFFFFF,
94+
WHOLE_MAP_SIZE: 0xFFFFFFFF, // use 32-bit uint max
9495
AdapterType: {
9596
Unknown: 3,
9697
},
@@ -349,6 +350,12 @@ var LibraryWebGPU = {
349350
'not-equal',
350351
'always',
351352
],
353+
CompilationInfoRequestStatus: [
354+
'success',
355+
'error',
356+
'device-lost',
357+
'unknown',
358+
],
352359
CullMode: [
353360
'none',
354361
'front',
@@ -358,17 +365,19 @@ var LibraryWebGPU = {
358365
'validation',
359366
'out-of-memory',
360367
],
361-
FeatureName: [
362-
undefined,
363-
'depth-clamping',
364-
'depth24unorm-stencil8',
365-
'depth32float-stencil8',
366-
'timestamp-query',
367-
'pipeline-statistics-query',
368-
'texture-compression-bc',
369-
'texture-compression-etc2',
370-
'texture-compression-astc',
371-
],
368+
FeatureName: {
369+
0: undefined,
370+
1: 'depth-clip-control',
371+
2: 'depth24unorm-stencil8',
372+
3: 'depth32float-stencil8',
373+
4: 'timestamp-query',
374+
5: 'pipeline-statistics-query',
375+
6: 'texture-compression-bc',
376+
7: 'texture-compression-etc2',
377+
8: 'texture-compression-astc',
378+
9: 'indirect-first-instance',
379+
1000: 'depth-clamping',
380+
},
372381
FilterMode: [
373382
'nearest',
374383
'linear',
@@ -390,6 +399,7 @@ var LibraryWebGPU = {
390399
'compute-shader-invocations',
391400
],
392401
PowerPreference: [
402+
undefined,
393403
'low-power',
394404
'high-performance',
395405
],
@@ -487,7 +497,9 @@ var LibraryWebGPU = {
487497
'depth16unorm',
488498
'depth24plus',
489499
'depth24plus-stencil8',
500+
'depth24unorm-stencil8',
490501
'depth32float',
502+
'depth32float-stencil8',
491503
'bc1-rgba-unorm',
492504
'bc1-rgba-unorm-srgb',
493505
'bc2-rgba-unorm',
@@ -1078,6 +1090,8 @@ var LibraryWebGPU = {
10781090
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.colorFormats, '*') }}}),
10791091
"depthStencilFormat": WebGPU.TextureFormat[{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.depthStencilFormat) }}}],
10801092
"sampleCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.sampleCount) }}},
1093+
"depthReadOnly": {{{ gpu.makeGetBool('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.depthReadOnly) }}},
1094+
"stencilReadOnly": {{{ gpu.makeGetBool('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.stencilReadOnly) }}},
10811095
};
10821096
var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderBundleEncoderDescriptor.label, '*') }}};
10831097
if (labelPtr) desc["label"] = UTF8ToString(labelPtr);
@@ -1598,6 +1612,10 @@ var LibraryWebGPU = {
15981612

15991613
// wgpuShaderModule
16001614

1615+
wgpuShaderModuleGetCompilationInfo: function(shaderModuleId, callback, userdata) {
1616+
var shaderModule = WebGPU.mgrShaderModule.get(shaderModuleId);
1617+
abort('TODO: wgpuShaderModuleGetCompilationInfo unimplemented');
1618+
},
16011619
wgpuShaderModuleSetLabel: function(shaderModuleId, labelPtr) {
16021620
var shaderModule = WebGPU.mgrShaderModule.get(shaderModuleId);
16031621
shaderModule.label = UTF8ToString(labelPtr);
@@ -1701,6 +1719,12 @@ var LibraryWebGPU = {
17011719
bufferWrapper.onUnmap = [];
17021720
var buffer = bufferWrapper.object;
17031721

1722+
// Handle the defaulting of size required by WebGPU
1723+
// We want to check against gpu.WHOLE_MAP_SIZE but the size seems to come in as int32_t
1724+
if (size === -1) {
1725+
size = undefined;
1726+
}
1727+
17041728
// `callback` takes (WGPUBufferMapAsyncStatus status, void * userdata)
17051729

17061730
{{{ runtimeKeepalivePush() }}}
@@ -2249,6 +2273,9 @@ var LibraryWebGPU = {
22492273
setLimitU32IfDefined("maxComputeWorkgroupsPerDimension", {{{ C_STRUCTS.WGPULimits.maxComputeWorkgroupsPerDimension }}});
22502274
desc["requiredLimits"] = requiredLimits;
22512275
}
2276+
2277+
var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUDeviceDescriptor.label, '*') }}};
2278+
if (labelPtr) desc["label"] = UTF8ToString(labelPtr);
22522279
}
22532280

22542281
{{{ runtimeKeepalivePush() }}}

src/struct_info.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@
11811181
"label"
11821182
],
11831183
"WGPUCompilationMessage": [
1184+
"nextInChain",
11841185
"message",
11851186
"type",
11861187
"lineNum",
@@ -1254,6 +1255,10 @@
12541255
"chain",
12551256
"clampDepth"
12561257
],
1258+
"WGPUPrimitiveDepthClipControl": [
1259+
"chain",
1260+
"unclippedDepth"
1261+
],
12571262
"WGPUPrimitiveState": [
12581263
"nextInChain",
12591264
"topology",
@@ -1279,7 +1284,9 @@
12791284
"colorFormatsCount",
12801285
"colorFormats",
12811286
"depthStencilFormat",
1282-
"sampleCount"
1287+
"sampleCount",
1288+
"depthReadOnly",
1289+
"stencilReadOnly"
12831290
],
12841291
"WGPURenderPassDepthStencilAttachment": [
12851292
"view",
@@ -1407,6 +1414,7 @@
14071414
"alpha"
14081415
],
14091416
"WGPUCompilationInfo": [
1417+
"nextInChain",
14101418
"messageCount",
14111419
"messages"
14121420
],
@@ -1493,6 +1501,7 @@
14931501
],
14941502
"WGPUDeviceDescriptor": [
14951503
"nextInChain",
1504+
"label",
14961505
"requiredFeaturesCount",
14971506
"requiredFeatures",
14981507
"requiredLimits"

system/include/webgpu/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ is included here because it is strongly tied to an exact `webgpu.h` revision.
1515
Dawn additionally autogenerates two "snippets" that are used in Emscripten:
1616
- `library_webgpu_enum_tables.js`, which is pasted into [`library_webgpu.js`](../../../src/library_webgpu.js)
1717
- `webgpu_struct_info.json`, which is pasted into [`struct_info.json`](../../../src/struct_info.json).
18+
19+
Once that's done, the following file also needs to be rebaselined:
20+
- [`reference_struct_info.json`](../../../tests/reference_struct_info.json): can be updated by running `tests/runner other.test_gen_struct_info --rebaseline`

0 commit comments

Comments
 (0)