Skip to content

Commit 84406d7

Browse files
Align timestampWrites with WebGPU spec (#20411)
1 parent f97c348 commit 84406d7

File tree

7 files changed

+88
-167
lines changed

7 files changed

+88
-167
lines changed

src/generated_struct_info32.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,15 @@
891891
"utf16Offset": 56
892892
},
893893
"WGPUComputePassDescriptor": {
894-
"__size__": 16,
894+
"__size__": 12,
895895
"label": 4,
896896
"nextInChain": 0,
897-
"timestampWriteCount": 8,
898-
"timestampWrites": 12
897+
"timestampWrites": 8
899898
},
900-
"WGPUComputePassTimestampWrite": {
899+
"WGPUComputePassTimestampWrites": {
901900
"__size__": 12,
902-
"location": 8,
903-
"queryIndex": 4,
901+
"beginningOfPassWriteIndex": 4,
902+
"endOfPassWriteIndex": 8,
904903
"querySet": 0
905904
},
906905
"WGPUComputePipelineDescriptor": {
@@ -1103,25 +1102,24 @@
11031102
"view": 0
11041103
},
11051104
"WGPURenderPassDescriptor": {
1106-
"__size__": 32,
1105+
"__size__": 28,
11071106
"colorAttachmentCount": 8,
11081107
"colorAttachments": 12,
11091108
"depthStencilAttachment": 16,
11101109
"label": 4,
11111110
"nextInChain": 0,
11121111
"occlusionQuerySet": 20,
1113-
"timestampWriteCount": 24,
1114-
"timestampWrites": 28
1112+
"timestampWrites": 24
11151113
},
11161114
"WGPURenderPassDescriptorMaxDrawCount": {
11171115
"__size__": 16,
11181116
"chain": 0,
11191117
"maxDrawCount": 8
11201118
},
1121-
"WGPURenderPassTimestampWrite": {
1119+
"WGPURenderPassTimestampWrites": {
11221120
"__size__": 12,
1123-
"location": 8,
1124-
"queryIndex": 4,
1121+
"beginningOfPassWriteIndex": 4,
1122+
"endOfPassWriteIndex": 8,
11251123
"querySet": 0
11261124
},
11271125
"WGPURenderPipelineDescriptor": {

src/generated_struct_info64.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,15 @@
891891
"utf16Offset": 64
892892
},
893893
"WGPUComputePassDescriptor": {
894-
"__size__": 32,
894+
"__size__": 24,
895895
"label": 8,
896896
"nextInChain": 0,
897-
"timestampWriteCount": 16,
898-
"timestampWrites": 24
897+
"timestampWrites": 16
899898
},
900-
"WGPUComputePassTimestampWrite": {
899+
"WGPUComputePassTimestampWrites": {
901900
"__size__": 16,
902-
"location": 12,
903-
"queryIndex": 8,
901+
"beginningOfPassWriteIndex": 8,
902+
"endOfPassWriteIndex": 12,
904903
"querySet": 0
905904
},
906905
"WGPUComputePipelineDescriptor": {
@@ -1103,25 +1102,24 @@
11031102
"view": 0
11041103
},
11051104
"WGPURenderPassDescriptor": {
1106-
"__size__": 64,
1105+
"__size__": 56,
11071106
"colorAttachmentCount": 16,
11081107
"colorAttachments": 24,
11091108
"depthStencilAttachment": 32,
11101109
"label": 8,
11111110
"nextInChain": 0,
11121111
"occlusionQuerySet": 40,
1113-
"timestampWriteCount": 48,
1114-
"timestampWrites": 56
1112+
"timestampWrites": 48
11151113
},
11161114
"WGPURenderPassDescriptorMaxDrawCount": {
11171115
"__size__": 24,
11181116
"chain": 0,
11191117
"maxDrawCount": 16
11201118
},
1121-
"WGPURenderPassTimestampWrite": {
1119+
"WGPURenderPassTimestampWrites": {
11221120
"__size__": 16,
1123-
"location": 12,
1124-
"queryIndex": 8,
1121+
"beginningOfPassWriteIndex": 8,
1122+
"endOfPassWriteIndex": 12,
11251123
"querySet": 0
11261124
},
11271125
"WGPURenderPipelineDescriptor": {

src/library_webgpu.js

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,6 @@ var LibraryWebGPU = {
385385
'device-lost',
386386
'unknown',
387387
],
388-
ComputePassTimestampLocation: [
389-
'beginning',
390-
'end',
391-
],
392388
CullMode: [
393389
'none',
394390
'front',
@@ -460,10 +456,6 @@ var LibraryWebGPU = {
460456
'pipeline-statistics',
461457
'timestamp',
462458
],
463-
RenderPassTimestampLocation: [
464-
'beginning',
465-
'end',
466-
],
467459
SamplerBindingType: [
468460
undefined,
469461
'filtering',
@@ -1535,36 +1527,27 @@ var LibraryWebGPU = {
15351527
wgpuCommandEncoderBeginComputePass: (encoderId, descriptor) => {
15361528
var desc;
15371529

1538-
function makeComputePassTimestampWrite(twPtr) {
1530+
function makeComputePassTimestampWrites(twPtr) {
1531+
if (twPtr === 0) return undefined;
1532+
15391533
return {
15401534
"querySet": WebGPU.mgrQuerySet.get(
1541-
{{{ makeGetValue('twPtr', C_STRUCTS.WGPUComputePassTimestampWrite.querySet, '*') }}}),
1542-
"queryIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPUComputePassTimestampWrite.queryIndex) }}},
1543-
"location": WebGPU.ComputePassTimestampLocation[
1544-
{{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPUComputePassTimestampWrite.location) }}}],
1535+
{{{ makeGetValue('twPtr', C_STRUCTS.WGPUComputePassTimestampWrites.querySet, '*') }}}),
1536+
"beginningOfPassWriteIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPUComputePassTimestampWrites.beginningOfPassWriteIndex) }}},
1537+
"endOfPassWriteIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPUComputePassTimestampWrites.endOfPassWriteIndex) }}},
15451538
};
15461539
}
15471540

1548-
function makeComputePassTimestampWrites(count, twPtr) {
1549-
var timestampWrites = [];
1550-
for (var i = 0; i < count; ++i) {
1551-
timestampWrites.push(makeComputePassTimestampWrite(twPtr + {{{ C_STRUCTS.WGPUComputePassTimestampWrite.__size__ }}} * i));
1552-
}
1553-
return timestampWrites;
1554-
}
1555-
15561541
if (descriptor) {
15571542
{{{ gpu.makeCheckDescriptor('descriptor') }}}
1558-
desc = {};
1543+
desc = {
1544+
"label": undefined,
1545+
"timestampWrites": makeComputePassTimestampWrites(
1546+
{{{ makeGetValue('descriptor', C_STRUCTS.WGPUComputePassDescriptor.timestampWrites, '*') }}}),
1547+
};
15591548
var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUComputePassDescriptor.label, '*') }}};
15601549
if (labelPtr) desc["label"] = UTF8ToString(labelPtr);
15611550

1562-
var timestampWriteCount = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUComputePassDescriptor.timestampWriteCount) }}};
1563-
if (timestampWriteCount) {
1564-
desc["timestampWrites"] = makeComputePassTimestampWrites(
1565-
timestampWriteCount,
1566-
{{{ makeGetValue('descriptor', C_STRUCTS.WGPUComputePassDescriptor.timestampWrites, '*') }}});
1567-
}
15681551
}
15691552
var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId);
15701553
return WebGPU.mgrComputePassEncoder.create(commandEncoder["beginComputePass"](desc));
@@ -1631,24 +1614,17 @@ var LibraryWebGPU = {
16311614
};
16321615
}
16331616

1634-
function makeRenderPassTimestampWrite(twPtr) {
1617+
function makeRenderPassTimestampWrites(twPtr) {
1618+
if (twPtr === 0) return undefined;
1619+
16351620
return {
16361621
"querySet": WebGPU.mgrQuerySet.get(
1637-
{{{ makeGetValue('twPtr', C_STRUCTS.WGPURenderPassTimestampWrite.querySet, '*') }}}),
1638-
"queryIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPURenderPassTimestampWrite.queryIndex) }}},
1639-
"location": WebGPU.RenderPassTimestampLocation[
1640-
{{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPURenderPassTimestampWrite.location) }}}],
1622+
{{{ makeGetValue('twPtr', C_STRUCTS.WGPURenderPassTimestampWrites.querySet, '*') }}}),
1623+
"beginningOfPassWriteIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPURenderPassTimestampWrites.beginningOfPassWriteIndex) }}},
1624+
"endOfPassWriteIndex": {{{ gpu.makeGetU32('twPtr', C_STRUCTS.WGPURenderPassTimestampWrites.endOfPassWriteIndex) }}},
16411625
};
16421626
}
16431627

1644-
function makeRenderPassTimestampWrites(count, twPtr) {
1645-
var timestampWrites = [];
1646-
for (var i = 0; i < count; ++i) {
1647-
timestampWrites.push(makeRenderPassTimestampWrite(twPtr + {{{ C_STRUCTS.WGPURenderPassTimestampWrite.__size__ }}} * i));
1648-
}
1649-
return timestampWrites;
1650-
}
1651-
16521628
function makeRenderPassDescriptor(descriptor) {
16531629
{{{ gpu.makeCheck('descriptor') }}}
16541630
var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.nextInChain, '*') }}};
@@ -1674,18 +1650,13 @@ var LibraryWebGPU = {
16741650
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.depthStencilAttachment, '*') }}}),
16751651
"occlusionQuerySet": WebGPU.mgrQuerySet.get(
16761652
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.occlusionQuerySet, '*') }}}),
1677-
"maxDrawCount": maxDrawCount,
1653+
"timestampWrites": makeRenderPassTimestampWrites(
1654+
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.timestampWrites, '*') }}}),
1655+
"maxDrawCount": maxDrawCount,
16781656
};
16791657
var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.label, '*') }}};
16801658
if (labelPtr) desc["label"] = UTF8ToString(labelPtr);
16811659

1682-
var timestampWriteCount = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPURenderPassDescriptor.timestampWriteCount) }}};
1683-
if (timestampWriteCount) {
1684-
desc["timestampWrites"] = makeRenderPassTimestampWrites(
1685-
timestampWriteCount,
1686-
{{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.timestampWrites, '*') }}});
1687-
}
1688-
16891660
return desc;
16901661
}
16911662

src/struct_info.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,10 +1253,10 @@
12531253
"utf16Offset",
12541254
"utf16Length"
12551255
],
1256-
"WGPUComputePassTimestampWrite": [
1256+
"WGPUComputePassTimestampWrites": [
12571257
"querySet",
1258-
"queryIndex",
1259-
"location"
1258+
"beginningOfPassWriteIndex",
1259+
"endOfPassWriteIndex"
12601260
],
12611261
"WGPUConstantEntry": [
12621262
"nextInChain",
@@ -1374,10 +1374,10 @@
13741374
"chain",
13751375
"maxDrawCount"
13761376
],
1377-
"WGPURenderPassTimestampWrite": [
1377+
"WGPURenderPassTimestampWrites": [
13781378
"querySet",
1379-
"queryIndex",
1380-
"location"
1379+
"beginningOfPassWriteIndex",
1380+
"endOfPassWriteIndex"
13811381
],
13821382
"WGPURequestAdapterOptions": [
13831383
"nextInChain",
@@ -1503,7 +1503,6 @@
15031503
"WGPUComputePassDescriptor": [
15041504
"nextInChain",
15051505
"label",
1506-
"timestampWriteCount",
15071506
"timestampWrites"
15081507
],
15091508
"WGPUDepthStencilState": [
@@ -1607,7 +1606,6 @@
16071606
"colorAttachments",
16081607
"depthStencilAttachment",
16091608
"occlusionQuerySet",
1610-
"timestampWriteCount",
16111609
"timestampWrites"
16121610
],
16131611
"WGPUVertexState": [

system/include/webgpu/webgpu.h

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL)
7474
#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL)
7575
#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL)
76+
#define WGPU_QUERY_SET_INDEX_UNDEFINED (0xffffffffUL)
7677
#define WGPU_WHOLE_MAP_SIZE SIZE_MAX
7778
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)
7879

@@ -112,7 +113,7 @@ struct WGPUColor;
112113
struct WGPUCommandBufferDescriptor;
113114
struct WGPUCommandEncoderDescriptor;
114115
struct WGPUCompilationMessage;
115-
struct WGPUComputePassTimestampWrite;
116+
struct WGPUComputePassTimestampWrites;
116117
struct WGPUConstantEntry;
117118
struct WGPUExtent3D;
118119
struct WGPUInstanceDescriptor;
@@ -128,7 +129,7 @@ struct WGPURenderBundleDescriptor;
128129
struct WGPURenderBundleEncoderDescriptor;
129130
struct WGPURenderPassDepthStencilAttachment;
130131
struct WGPURenderPassDescriptorMaxDrawCount;
131-
struct WGPURenderPassTimestampWrite;
132+
struct WGPURenderPassTimestampWrites;
132133
struct WGPURequestAdapterOptions;
133134
struct WGPUSamplerBindingLayout;
134135
struct WGPUSamplerDescriptor;
@@ -277,12 +278,6 @@ typedef enum WGPUCompilationMessageType {
277278
WGPUCompilationMessageType_Force32 = 0x7FFFFFFF
278279
} WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE;
279280

280-
typedef enum WGPUComputePassTimestampLocation {
281-
WGPUComputePassTimestampLocation_Beginning = 0x00000000,
282-
WGPUComputePassTimestampLocation_End = 0x00000001,
283-
WGPUComputePassTimestampLocation_Force32 = 0x7FFFFFFF
284-
} WGPUComputePassTimestampLocation WGPU_ENUM_ATTRIBUTE;
285-
286281
typedef enum WGPUCreatePipelineAsyncStatus {
287282
WGPUCreatePipelineAsyncStatus_Success = 0x00000000,
288283
WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001,
@@ -419,12 +414,6 @@ typedef enum WGPUQueueWorkDoneStatus {
419414
WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF
420415
} WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE;
421416

422-
typedef enum WGPURenderPassTimestampLocation {
423-
WGPURenderPassTimestampLocation_Beginning = 0x00000000,
424-
WGPURenderPassTimestampLocation_End = 0x00000001,
425-
WGPURenderPassTimestampLocation_Force32 = 0x7FFFFFFF
426-
} WGPURenderPassTimestampLocation WGPU_ENUM_ATTRIBUTE;
427-
428417
typedef enum WGPURequestAdapterStatus {
429418
WGPURequestAdapterStatus_Success = 0x00000000,
430419
WGPURequestAdapterStatus_Unavailable = 0x00000001,
@@ -809,11 +798,11 @@ typedef struct WGPUCompilationMessage {
809798
uint64_t utf16Length;
810799
} WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE;
811800

812-
typedef struct WGPUComputePassTimestampWrite {
801+
typedef struct WGPUComputePassTimestampWrites {
813802
WGPUQuerySet querySet;
814-
uint32_t queryIndex;
815-
WGPUComputePassTimestampLocation location;
816-
} WGPUComputePassTimestampWrite WGPU_STRUCTURE_ATTRIBUTE;
803+
uint32_t beginningOfPassWriteIndex;
804+
uint32_t endOfPassWriteIndex;
805+
} WGPUComputePassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE;
817806

818807
typedef struct WGPUConstantEntry {
819808
WGPUChainedStruct const * nextInChain;
@@ -948,11 +937,11 @@ typedef struct WGPURenderPassDescriptorMaxDrawCount {
948937
uint64_t maxDrawCount;
949938
} WGPURenderPassDescriptorMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE;
950939

951-
typedef struct WGPURenderPassTimestampWrite {
940+
typedef struct WGPURenderPassTimestampWrites {
952941
WGPUQuerySet querySet;
953-
uint32_t queryIndex;
954-
WGPURenderPassTimestampLocation location;
955-
} WGPURenderPassTimestampWrite WGPU_STRUCTURE_ATTRIBUTE;
942+
uint32_t beginningOfPassWriteIndex;
943+
uint32_t endOfPassWriteIndex;
944+
} WGPURenderPassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE;
956945

957946
typedef struct WGPURequestAdapterOptions {
958947
WGPUChainedStruct const * nextInChain;
@@ -1100,8 +1089,7 @@ typedef struct WGPUCompilationInfo {
11001089
typedef struct WGPUComputePassDescriptor {
11011090
WGPUChainedStruct const * nextInChain;
11021091
WGPU_NULLABLE char const * label;
1103-
size_t timestampWriteCount;
1104-
WGPUComputePassTimestampWrite const * timestampWrites;
1092+
WGPU_NULLABLE WGPUComputePassTimestampWrites const * timestampWrites;
11051093
} WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE;
11061094

11071095
typedef struct WGPUDepthStencilState {
@@ -1218,8 +1206,7 @@ typedef struct WGPURenderPassDescriptor {
12181206
WGPURenderPassColorAttachment const * colorAttachments;
12191207
WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment;
12201208
WGPU_NULLABLE WGPUQuerySet occlusionQuerySet;
1221-
size_t timestampWriteCount;
1222-
WGPURenderPassTimestampWrite const * timestampWrites;
1209+
WGPU_NULLABLE WGPURenderPassTimestampWrites const * timestampWrites;
12231210
} WGPURenderPassDescriptor WGPU_STRUCTURE_ATTRIBUTE;
12241211

12251212
typedef struct WGPUVertexState {

0 commit comments

Comments
 (0)