You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param start - PrimitiveOffsetInfo pointing to the first dispatch parameter. If not provided, starts at offset 0. To obtain safe offsets, use `getOffsetInfoAt(...)`.
84
+
*/
85
+
dispatchWorkgroupsIndirect<TextendsAnyWgslData>(
86
+
indirectBuffer: TgpuBuffer<T>&IndirectFlag,
87
+
start?: PrimitiveOffsetInfo|number,
88
+
): void;
68
89
}
69
90
70
91
exportdeclarenamespaceTgpuComputePipeline{
@@ -101,6 +122,27 @@ type Memo = {
101
122
logResources: LogResources|undefined;
102
123
};
103
124
125
+
functionvalidateIndirectBufferSize(
126
+
bufferSize: number,
127
+
offset: number,
128
+
requiredBytes: number,
129
+
operation: string,
130
+
): void{
131
+
if(offset+requiredBytes>bufferSize){
132
+
thrownewError(
133
+
`Buffer too small for ${operation}. `+
134
+
`Required: ${requiredBytes} bytes at offset ${offset}, `+
135
+
`but buffer is only ${bufferSize} bytes.`,
136
+
);
137
+
}
138
+
139
+
if(offset%4!==0){
140
+
thrownewError(
141
+
`Indirect buffer offset must be a multiple of 4. Got: ${offset}`,
`dispatchWorkgroupsIndirect: Provided start offset ${offsetInfo} as a raw number. Use getOffsetInfoAt(...) to include contiguous padding info for safer validation.`,
255
+
);
256
+
// When only an offset is provided, assume we have at least 12 bytes contiguous.
257
+
offsetInfo={
258
+
offset: offsetInfo,
259
+
contiguous: DISPATCH_SIZE,
260
+
};
261
+
}
262
+
}
263
+
264
+
const{ offset, contiguous }=offsetInfo;
265
+
266
+
validateIndirectBufferSize(
267
+
sizeOf(indirectBuffer.dataType),
268
+
offset,
269
+
DISPATCH_SIZE,
270
+
'dispatchWorkgroupsIndirect',
271
+
);
272
+
273
+
if(contiguous<DISPATCH_SIZE){
274
+
console.warn(
275
+
`dispatchWorkgroupsIndirect: Starting at offset ${offset}, only ${contiguous} contiguous bytes are available before padding. Dispatch requires ${DISPATCH_SIZE} bytes (3 x u32). Reading across padding may result in undefined behavior.`,
0 commit comments