Skip to content

Commit ca3e10c

Browse files
authored
Update WebGPU to dawn @98f18d (#17507)
* Update WebGPU to dawn @98f18d * fix vertex step mode * fix closure 1 * fix maxDrawCount value * vertex step mode undefined and assert nextInChain === 0 * Fix vertex step mode undefined behavior * fix VertexStepMode.VertexBufferNotUsed * fix maxDrawCount undefined
1 parent 0e75ea8 commit ca3e10c

File tree

6 files changed

+461
-274
lines changed

6 files changed

+461
-274
lines changed

src/library_webgpu.js

Lines changed: 106 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@
141141
SurfaceDescriptorFromCanvasHTMLSelector: 4,
142142
ShaderModuleSPIRVDescriptor: 5,
143143
ShaderModuleWGSLDescriptor: 6,
144+
PrimitiveDepthClipControl: 7,
145+
RenderPassDescriptorMaxDrawCount: 15,
144146
},
145147
QueueWorkDoneStatus: {
146148
Success: 0,
@@ -149,6 +151,11 @@
149151
TextureFormat: {
150152
Undefined: 0,
151153
},
154+
VertexStepMode: {
155+
Vertex: 0,
156+
Instance: 1,
157+
VertexBufferNotUsed: 2,
158+
},
152159
};
153160
return null;
154161
})(); }}}
@@ -380,19 +387,17 @@ var LibraryWebGPU = {
380387
'validation',
381388
'out-of-memory',
382389
],
383-
FeatureName: {
384-
0: undefined,
385-
1: 'depth-clip-control',
386-
2: 'depth24unorm-stencil8',
387-
3: 'depth32float-stencil8',
388-
4: 'timestamp-query',
389-
5: 'pipeline-statistics-query',
390-
6: 'texture-compression-bc',
391-
7: 'texture-compression-etc2',
392-
8: 'texture-compression-astc',
393-
9: 'indirect-first-instance',
394-
1000: 'depth-clamping',
395-
},
390+
FeatureName: [
391+
undefined,
392+
'depth-clip-control',
393+
'depth32float-stencil8',
394+
'timestamp-query',
395+
'pipeline-statistics-query',
396+
'texture-compression-bc',
397+
'texture-compression-etc2',
398+
'texture-compression-astc',
399+
'indirect-first-instance',
400+
],
396401
FilterMode: [
397402
'nearest',
398403
'linear',
@@ -423,10 +428,6 @@ var LibraryWebGPU = {
423428
'low-power',
424429
'high-performance',
425430
],
426-
PredefinedColorSpace: [
427-
undefined,
428-
'srgb',
429-
],
430431
PrimitiveTopology: [
431432
'point-list',
432433
'line-list',
@@ -526,7 +527,6 @@ var LibraryWebGPU = {
526527
'depth16unorm',
527528
'depth24plus',
528529
'depth24plus-stencil8',
529-
'depth24unorm-stencil8',
530530
'depth32float',
531531
'depth32float-stencil8',
532532
'bc1-rgba-unorm',
@@ -635,6 +635,7 @@ var LibraryWebGPU = {
635635
VertexStepMode: [
636636
'vertex',
637637
'instance',
638+
undefined,
638639
],
639640
},
640641

@@ -725,6 +726,8 @@ var LibraryWebGPU = {
725726
setLimitValueU32('maxVertexAttributes', {{{ C_STRUCTS.WGPULimits.maxVertexAttributes }}});
726727
setLimitValueU32('maxVertexBufferArrayStride', {{{ C_STRUCTS.WGPULimits.maxVertexBufferArrayStride }}});
727728
setLimitValueU32('maxInterStageShaderComponents', {{{ C_STRUCTS.WGPULimits.maxInterStageShaderComponents }}});
729+
setLimitValueU32('maxInterStageShaderVariables', {{{ C_STRUCTS.WGPULimits.maxInterStageShaderVariables }}});
730+
setLimitValueU32('maxColorAttachments', {{{ C_STRUCTS.WGPULimits.maxColorAttachments }}});
728731
setLimitValueU32('maxComputeWorkgroupStorageSize', {{{ C_STRUCTS.WGPULimits.maxComputeWorkgroupStorageSize }}});
729732
setLimitValueU32('maxComputeInvocationsPerWorkgroup', {{{ C_STRUCTS.WGPULimits.maxComputeInvocationsPerWorkgroup }}});
730733
setLimitValueU32('maxComputeWorkgroupSizeX', {{{ C_STRUCTS.WGPULimits.maxComputeWorkgroupSizeX }}});
@@ -1314,11 +1317,10 @@ var LibraryWebGPU = {
13141317

13151318
function makeVertexBuffer(vbPtr) {
13161319
if (!vbPtr) return undefined;
1317-
1318-
return {
1320+
var stepModeInt = {{{ gpu.makeGetU32('vbPtr', C_STRUCTS.WGPUVertexBufferLayout.stepMode) }}};
1321+
return stepModeInt === {{{ gpu.VertexStepMode.VertexBufferNotUsed }}} ? null : {
13191322
"arrayStride": {{{ gpu.makeGetU64('vbPtr', C_STRUCTS.WGPUVertexBufferLayout.arrayStride) }}},
1320-
"stepMode": WebGPU.VertexStepMode[
1321-
{{{ gpu.makeGetU32('vbPtr', C_STRUCTS.WGPUVertexBufferLayout.stepMode) }}}],
1323+
"stepMode": WebGPU.VertexStepMode[stepModeInt],
13221324
"attributes": makeVertexAttributes(
13231325
{{{ gpu.makeGetU32('vbPtr', C_STRUCTS.WGPUVertexBufferLayout.attributeCount) }}},
13241326
{{{ makeGetValue('vbPtr', C_STRUCTS.WGPUVertexBufferLayout.attributes, '*') }}}),
@@ -1450,6 +1452,16 @@ var LibraryWebGPU = {
14501452

14511453
// wgpuQuerySet
14521454

1455+
wgpuQuerySetGetCount: function(querySetId) {
1456+
var querySet = WebGPU.mgrQuerySet.get(querySetId);
1457+
return querySet.count;
1458+
},
1459+
1460+
wgpuQuerySetGetType: function(querySetId, labelPtr) {
1461+
var querySet = WebGPU.mgrQuerySet.get(querySetId);
1462+
return querySet.type;
1463+
},
1464+
14531465
wgpuQuerySetSetLabel: function(querySetId, labelPtr) {
14541466
var querySet = WebGPU.mgrQuerySet.get(querySetId);
14551467
querySet.label = UTF8ToString(labelPtr);
@@ -1639,7 +1651,21 @@ var LibraryWebGPU = {
16391651
}
16401652

16411653
function makeRenderPassDescriptor(descriptor) {
1642-
{{{ gpu.makeCheckDescriptor('descriptor') }}}
1654+
{{{ gpu.makeCheck('descriptor') }}}
1655+
var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.nextInChain, '*') }}};
1656+
1657+
var maxDrawCount = undefined;
1658+
if (nextInChainPtr !== 0) {
1659+
var sType = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}};
1660+
#if ASSERTIONS
1661+
assert(sType === {{{ gpu.SType.RenderPassDescriptorMaxDrawCount }}});
1662+
assert(0 === {{{ makeGetValue('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next, '*') }}});
1663+
#endif
1664+
var renderPassDescriptorMaxDrawCount = nextInChainPtr;
1665+
{{{ gpu.makeCheckDescriptor('renderPassDescriptorMaxDrawCount') }}}
1666+
maxDrawCount = {{{ gpu.makeGetU64('renderPassDescriptorMaxDrawCount', C_STRUCTS.WGPURenderPassDescriptorMaxDrawCount.maxDrawCount) }}};
1667+
}
1668+
16431669
var desc = {
16441670
"label": undefined,
16451671
"colorAttachments": makeColorAttachments(
@@ -1649,6 +1675,7 @@ var LibraryWebGPU = {
16491675
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.depthStencilAttachment, '*') }}}),
16501676
"occlusionQuerySet": WebGPU.mgrQuerySet.get(
16511677
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.occlusionQuerySet, '*') }}}),
1678+
"maxDrawCount": maxDrawCount,
16521679
};
16531680
var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.label, '*') }}};
16541681
if (labelPtr) desc["label"] = UTF8ToString(labelPtr);
@@ -1659,6 +1686,7 @@ var LibraryWebGPU = {
16591686
timestampWriteCount,
16601687
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.timestampWrites, '*') }}});
16611688
}
1689+
16621690
return desc;
16631691
}
16641692

@@ -1917,6 +1945,17 @@ var LibraryWebGPU = {
19171945
});
19181946
},
19191947

1948+
wgpuBufferGetSize: function(bufferId) {
1949+
var buffer = WebGPU.mgrBuffer.get(bufferId);
1950+
// 64-bit
1951+
return buffer.size;
1952+
},
1953+
1954+
wgpuBufferGetUsage: function(bufferId) {
1955+
var buffer = WebGPU.mgrBuffer.get(bufferId);
1956+
return buffer.usage;
1957+
},
1958+
19201959
wgpuBufferSetLabel: function(bufferId, labelPtr) {
19211960
var buffer = WebGPU.mgrBuffer.get(bufferId);
19221961
buffer.label = UTF8ToString(labelPtr);
@@ -1941,6 +1980,46 @@ var LibraryWebGPU = {
19411980

19421981
// wgpuTexture
19431982

1983+
wgpuTextureGetDepthOrArrayLayers: function(textureId) {
1984+
var texture = WebGPU.mgrTexture.get(textureId);
1985+
return texture.depthOrArrayLayers;
1986+
},
1987+
1988+
wgpuTextureGetDimension: function(textureId) {
1989+
var texture = WebGPU.mgrTexture.get(textureId);
1990+
return texture.dimension;
1991+
},
1992+
1993+
wgpuTextureGetFormat: function(textureId) {
1994+
var texture = WebGPU.mgrTexture.get(textureId);
1995+
return texture.format;
1996+
},
1997+
1998+
wgpuTextureGetHeight: function(textureId) {
1999+
var texture = WebGPU.mgrTexture.get(textureId);
2000+
return texture.height;
2001+
},
2002+
2003+
wgpuTextureGetMipLevelCount: function(textureId) {
2004+
var texture = WebGPU.mgrTexture.get(textureId);
2005+
return texture.mipLevelCount;
2006+
},
2007+
2008+
wgpuTextureGetSampleCount: function(textureId) {
2009+
var texture = WebGPU.mgrTexture.get(textureId);
2010+
return texture.sampleCount;
2011+
},
2012+
2013+
wgpuTextureGetUsage: function(textureId) {
2014+
var texture = WebGPU.mgrTexture.get(textureId);
2015+
return texture.usage;
2016+
},
2017+
2018+
wgpuTextureGetWidth: function(textureId) {
2019+
var texture = WebGPU.mgrTexture.get(textureId);
2020+
return texture.width;
2021+
},
2022+
19442023
wgpuTextureSetLabel: function(textureId, labelPtr) {
19452024
var texture = WebGPU.mgrTexture.get(textureId);
19462025
texture.label = UTF8ToString(labelPtr);
@@ -2412,6 +2491,8 @@ var LibraryWebGPU = {
24122491
wgpuAdapterGetProperties: function(adapterId, properties) {
24132492
{{{ gpu.makeCheckDescriptor('properties') }}}
24142493
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.vendorID, '0', 'i32') }}};
2494+
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.vendorName, '0', 'i32') }}};
2495+
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.architecture, '0', 'i32') }}};
24152496
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.deviceID, '0', 'i32') }}};
24162497
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.name, '0', 'i32') }}};
24172498
{{{ makeSetValue('properties', C_STRUCTS.WGPUAdapterProperties.driverDescription, '0', 'i32') }}};
@@ -2483,6 +2564,8 @@ var LibraryWebGPU = {
24832564
setLimitU32IfDefined("maxVertexAttributes", {{{ C_STRUCTS.WGPULimits.maxVertexAttributes }}});
24842565
setLimitU32IfDefined("maxVertexBufferArrayStride", {{{ C_STRUCTS.WGPULimits.maxVertexBufferArrayStride }}});
24852566
setLimitU32IfDefined("maxInterStageShaderComponents", {{{ C_STRUCTS.WGPULimits.maxInterStageShaderComponents }}});
2567+
setLimitU32IfDefined("maxInterStageShaderVariables", {{{ C_STRUCTS.WGPULimits.maxInterStageShaderVariables }}});
2568+
setLimitU32IfDefined("maxColorAttachments", {{{ C_STRUCTS.WGPULimits.maxColorAttachments }}});
24862569
setLimitU32IfDefined("maxComputeWorkgroupStorageSize", {{{ C_STRUCTS.WGPULimits.maxComputeWorkgroupStorageSize }}});
24872570
setLimitU32IfDefined("maxComputeInvocationsPerWorkgroup", {{{ C_STRUCTS.WGPULimits.maxComputeInvocationsPerWorkgroup }}});
24882571
setLimitU32IfDefined("maxComputeWorkgroupSizeX", {{{ C_STRUCTS.WGPULimits.maxComputeWorkgroupSizeX }}});

src/struct_info.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,8 @@
10411041
"WGPUAdapterProperties": [
10421042
"nextInChain",
10431043
"vendorID",
1044+
"vendorName",
1045+
"architecture",
10441046
"deviceID",
10451047
"name",
10461048
"driverDescription",
@@ -1136,6 +1138,8 @@
11361138
"maxVertexAttributes",
11371139
"maxVertexBufferArrayStride",
11381140
"maxInterStageShaderComponents",
1141+
"maxInterStageShaderVariables",
1142+
"maxColorAttachments",
11391143
"maxComputeWorkgroupStorageSize",
11401144
"maxComputeInvocationsPerWorkgroup",
11411145
"maxComputeWorkgroupSizeX",
@@ -1160,10 +1164,6 @@
11601164
"bindGroupLayoutCount",
11611165
"bindGroupLayouts"
11621166
],
1163-
"WGPUPrimitiveDepthClampingState": [
1164-
"chain",
1165-
"clampDepth"
1166-
],
11671167
"WGPUPrimitiveDepthClipControl": [
11681168
"chain",
11691169
"unclippedDepth"
@@ -1212,6 +1212,10 @@
12121212
"stencilClearValue",
12131213
"stencilReadOnly"
12141214
],
1215+
"WGPURenderPassDescriptorMaxDrawCount": [
1216+
"chain",
1217+
"maxDrawCount"
1218+
],
12151219
"WGPURenderPassTimestampWrite": [
12161220
"querySet",
12171221
"queryIndex",

0 commit comments

Comments
 (0)