diff --git a/.gitignore b/.gitignore index f4bd878..916a13d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /dist/ /out/ -/generated/webgpu.ts node_modules .DS_Store diff --git a/dist/index.d.ts b/dist/index.d.ts index 9a5bf5b..e2ea023 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -48,6 +48,53 @@ interface GPUExtent3DDictStrict depth?: undefined; } +/** @internal */ +interface __GPUDeviceEventMap { + uncapturederror: GPUUncapturedErrorEvent; +} + +// Extensions to the generated definition below. +interface GPUDevice { + addEventListener< + K extends keyof __GPUDeviceEventMap + >( + type: K, + listener: ( + this: GPUDevice, + ev: __GPUDeviceEventMap[K] + ) => any, + options?: + | boolean + | AddEventListenerOptions + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: + | boolean + | AddEventListenerOptions + ): void; + removeEventListener< + K extends keyof __GPUDeviceEventMap + >( + type: K, + listener: ( + this: GPUDevice, + ev: __GPUDeviceEventMap[K] + ) => any, + options?: + | boolean + | EventListenerOptions + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: + | boolean + | EventListenerOptions + ): void; +} + // ********************************************************************************************* // Semi-auto-generated (by manual diff with autogenerated types) // ********************************************************************************************* @@ -470,7 +517,7 @@ interface GPUBindGroupDescriptor interface GPUBindGroupEntry { /** * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a - * {@link GPUBindGroupLayoutEntry#binding|GPUBindGroupLayoutEntry.binding} and a @binding + * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding * attribute in the {@link GPUShaderModule}. */ binding: GPUIndex32; @@ -492,7 +539,7 @@ interface GPUBindGroupLayoutDescriptor interface GPUBindGroupLayoutEntry { /** * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding - * to a {@link GPUBindGroupEntry#binding|GPUBindGroupEntry.binding} and a @binding + * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding * attribute in the {@link GPUShaderModule}. */ binding: GPUIndex32; @@ -739,7 +786,7 @@ interface GPUComputePassDescriptor interface GPUComputePassTimestampWrites { /** - * The {@link GPUQuerySet}, of type {@link GPUQueryType#"timestamp"}, that the query results will be + * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be * written to. */ querySet: GPUQuerySet; @@ -767,12 +814,12 @@ interface GPUCopyExternalImageDestInfo extends GPUTexelCopyTextureInfo { /** * Describes the color space and encoding used to encode data into the destination texture. - * This [[#color-space-conversions|may result]] in values outside of the range [0, 1] + * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1] * being written to the target texture, if its format can represent them. * Otherwise, the results are clamped to the target texture format's range. * Note: * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, - * conversion may not be necessary. See [[#color-space-conversion-elision]]. + * conversion may not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. */ colorSpace?: PredefinedColorSpace; /** @@ -783,7 +830,7 @@ interface GPUCopyExternalImageDestInfo * corresponding alpha values. * Note: * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, - * conversion may not be necessary. See [[#color-space-conversion-elision]]. + * conversion may not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. */ premultipliedAlpha?: boolean; } @@ -872,7 +919,7 @@ interface GPUDeviceDescriptor * The request will fail if the adapter cannot provide these limits. * Each key with a non-`undefined` value must be the name of a member of supported limits. * API calls on the resulting device perform validation according to the exact limits of the - * device (not the adapter; see [[#limits]]). + * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). * */ depthClearValue?: number; /** * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s * depth component prior to executing the render pass. - * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details. + * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. */ depthLoadOp?: GPULoadOp; /** @@ -1225,7 +1272,7 @@ interface GPURenderPassDepthStencilAttachment { /** * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} - * is not {@link GPULoadOp#"clear"}. + * is not {@link GPULoadOp} `"clear"`. * The value will be converted to the type of the stencil aspect of `view` by taking the same * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. */ @@ -1233,7 +1280,7 @@ interface GPURenderPassDepthStencilAttachment { /** * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s * stencil component prior to executing the render pass. - * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details. + * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. */ stencilLoadOp?: GPULoadOp; /** @@ -1306,7 +1353,7 @@ interface GPURenderPassLayout interface GPURenderPassTimestampWrites { /** - * The {@link GPUQuerySet}, of type {@link GPUQueryType#"timestamp"}, that the query results will be + * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be * written to. */ querySet: GPUQuerySet; @@ -1342,7 +1389,7 @@ interface GPURenderPipelineDescriptor multisample?: GPUMultisampleState; /** * Describes the fragment shader entry point of the pipeline and its output colors. If - * not map/exist|provided, the [[#no-color-output]] mode is enabled. + * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. */ fragment?: GPUFragmentState; } @@ -1411,7 +1458,7 @@ interface GPUSamplerDescriptor */ addressModeV?: GPUAddressMode; /** - * Specifies the {{GPUAddressMode|address modes}} for the texture width, height, and depth + * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth * coordinates, respectively. */ addressModeW?: GPUAddressMode; @@ -1464,7 +1511,7 @@ interface GPUShaderModuleCompilationHint { /** * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. - * If set to {@link GPUAutoLayoutMode#"auto"} the layout will be the [$default pipeline layout$] + * If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] * for the entry point associated with this hint will be used. */ layout?: @@ -1496,7 +1543,7 @@ interface GPUShaderModuleDescriptor * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. * Hints are only applied to the entry points they explicitly name. - * Unlike {@link GPUProgrammableStage#entryPoint|GPUProgrammableStage.entryPoint}, + * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, * there is no default, even if only one entry point is present in the module. * * Note: @@ -1504,12 +1551,12 @@ interface GPUShaderModuleDescriptor * errors (like unknown entry point names or incompatible pipeline layouts) to developers, * for example in the browser developer console. */ - compilationHints?: Array; + compilationHints?: Iterable; } interface GPUStencilFaceState { /** - * The {@link GPUCompareFunction} used when testing the {@link RenderState#[[stencilReference]]} value + * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. */ compare?: GPUCompareFunction; @@ -1558,7 +1605,7 @@ interface GPUTexelCopyBufferInfo interface GPUTexelCopyBufferLayout { /** * The offset, in bytes, from the beginning of the texel data source (such as a - * {@link GPUTexelCopyBufferInfo#buffer|GPUTexelCopyBufferInfo.buffer}) to the start of the texel data + * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data * within that source. */ offset?: GPUSize64; @@ -1653,8 +1700,8 @@ interface GPUTextureDescriptor * test various systems to find out the impact on their particular application. * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or * {@link GPUTextureDescriptor#viewFormats} entry including - * {@link GPUTextureFormat#"rgba8unorm-srgb"} will perform less optimally than a - * {@link GPUTextureFormat#"rgba8unorm"} texture which does not. + * {@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a + * {@link GPUTextureFormat} `"rgba8unorm"` texture which does not. * Similar caveats exist for other formats and pairs of formats on other systems. * * Formats in this list must be texture view format compatible with the texture format. @@ -1689,7 +1736,7 @@ interface GPUTextureViewDescriptor */ dimension?: GPUTextureViewDimension; /** - * The allowed {@link GPUTextureUsage|usage(s)} for the texture view. Must be a subset of the + * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of * {@link GPUTexture#usage} flags of the texture. * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the @@ -1698,7 +1745,7 @@ interface GPUTextureViewDescriptor */ usage?: GPUTextureUsageFlags; /** - * Which {@link GPUTextureAspect|aspect(s)} of the texture are accessible to the texture view. + * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view. */ aspect?: GPUTextureAspect; /** @@ -1738,7 +1785,7 @@ interface GPUVertexAttribute { /** * The numeric location associated with this attribute, which will correspond with a * "@location" attribute - * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module|module}. + * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. */ shaderLocation: GPUIndex32; } @@ -1776,11 +1823,6 @@ interface GPUBindingCommandsMixin { * Sets the current {@link GPUBindGroup} for the given index. * @param index - The index to set the bind group at. * @param bindGroup - Bind group to use for subsequent render or compute commands. - * * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.--> */ @@ -1794,7 +1836,7 @@ interface GPUBindingCommandsMixin { ): undefined; /** * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset - * of a {@link Uint32Array}. + * of a Uint32Array. * @param index - The index to set the bind group at. * @param bindGroup - Bind group to use for subsequent render or compute commands. * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in @@ -1846,7 +1888,7 @@ interface GPUPipelineBase { /** * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s * {@link GPUBindGroupLayout} at `index`. - * @param index - Index into the pipeline layout's {@link GPUPipelineLayout#[[bindGroupLayouts]]} + * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` * sequence. */ getBindGroupLayout( @@ -1895,7 +1937,7 @@ interface GPURenderCommandsMixin { ): undefined; /** * Draws primitives. - * See [[#rendering-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. * @param vertexCount - The number of vertices to draw. * @param instanceCount - The number of instances to draw. * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from. @@ -1909,7 +1951,7 @@ interface GPURenderCommandsMixin { ): undefined; /** * Draws indexed primitives. - * See [[#rendering-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. * @param indexCount - The number of indices to draw. * @param instanceCount - The number of instances to draw. * @param firstIndex - Offset into the index buffer, in indices, begin drawing from. @@ -1925,9 +1967,9 @@ interface GPURenderCommandsMixin { ): undefined; /** * Draws primitives using parameters read from a {@link GPUBuffer}. - * See [[#rendering-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same - * order as the arguments for {@link GPURenderEncoderBase#draw}. For example: + * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: * @param indirectBuffer - Buffer containing the indirect draw parameters. * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. */ @@ -1937,9 +1979,9 @@ interface GPURenderCommandsMixin { ): undefined; /** * Draws indexed primitives using parameters read from a {@link GPUBuffer}. - * See [[#rendering-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in - * the same order as the arguments for {@link GPURenderEncoderBase#drawIndexed}. For example: + * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters. * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. */ @@ -1974,8 +2016,8 @@ interface GPU { ): Promise; /** * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range - * content on this system. Must only return {@link GPUTextureFormat#"rgba8unorm"} or - * {@link GPUTextureFormat#"bgra8unorm"}. + * content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or + * {@link GPUTextureFormat} `"bgra8unorm"`. * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated * canvas is able to display its contents efficiently. @@ -2138,14 +2180,14 @@ interface GPUBuffer readonly usage: GPUFlagsConstant; readonly mapState: GPUBufferMapState; /** - * Maps the given range of the {@link GPUBuffer} and resolves the returned {@link Promise} when the + * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. - * The resolution of the returned {@link Promise} **only** indicates that the buffer has been mapped. + * The resolution of the returned Promise **only** indicates that the buffer has been mapped. * It does not guarantee the completion of any other operations visible to the content timeline, - * and in particular does not imply that any other {@link Promise} returned from + * and in particular does not imply that any other Promise returned from * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s * have resolved. - * The resolution of the {@link Promise} returned from {@link GPUQueue#onSubmittedWorkDone} + * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} * **does** imply the completion of * {@link GPUBuffer#mapAsync} calls made prior to that call, * on {@link GPUBuffer}s last used exclusively on that queue. @@ -2159,9 +2201,9 @@ interface GPUBuffer size?: GPUSize64 ): Promise; /** - * Returns an {@link ArrayBuffer} with the contents of the {@link GPUBuffer} in the given mapped range. + * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range. * @param offset - Offset in bytes into the buffer to return buffer contents from. - * @param size - Size in bytes of the {@link ArrayBuffer} to return. + * @param size - Size in bytes of the ArrayBuffer to return. */ getMappedRange( offset?: GPUSize64, @@ -2266,7 +2308,7 @@ interface GPUCommandEncoder descriptor?: GPUComputePassDescriptor ): GPUComputePassEncoder; /** - * Shorthand, equivalent to {{GPUCommandEncoder/copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)|copyBufferToBuffer(source, 0, destination, 0, size)}}. + * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}. */ copyBufferToBuffer( source: GPUBuffer, @@ -2401,7 +2443,7 @@ interface GPUCompilationMessage { readonly message: string; /** * The severity level of the message. - * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType#"error"}, it + * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it * corresponds to a shader-creation error. */ readonly type: GPUCompilationMessageType; @@ -2466,7 +2508,7 @@ interface GPUComputePassEncoder ): undefined; /** * Dispatch work to be performed with the current {@link GPUComputePipeline}. - * See [[#computing-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. * @param workgroupCountX - X dimension of the grid of workgroups to dispatch. * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch. * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch. @@ -2479,7 +2521,7 @@ interface GPUComputePassEncoder /** * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read * from a {@link GPUBuffer}. - * See [[#computing-operations]] for the detailed specification. + * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. * packed block of **three 32-bit unsigned integer values (12 bytes total)**, * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. * For example: @@ -2517,11 +2559,6 @@ declare var GPUComputePipeline: { new (): never; }; -/** @internal */ -interface __GPUDeviceEventMap { - uncapturederror: GPUUncapturedErrorEvent; -} - interface GPUDevice extends EventTarget, GPUObjectBase { @@ -2633,9 +2670,9 @@ interface GPUDevice ): GPURenderPipeline; /** * Creates a {@link GPUComputePipeline} using async pipeline creation. - * The returned {@link Promise} resolves when the created pipeline + * The returned Promise resolves when the created pipeline * is ready to be used without additional delay. - * If pipeline creation fails, the returned {@link Promise} rejects with an {@link GPUPipelineError}. + * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. * (A {@link GPUError} is not dispatched to the device.) * Note: Use of this method is preferred whenever possible, as it prevents blocking the * queue timeline work on pipeline compilation. @@ -2646,9 +2683,9 @@ interface GPUDevice ): Promise; /** * Creates a {@link GPURenderPipeline} using async pipeline creation. - * The returned {@link Promise} resolves when the created pipeline + * The returned Promise resolves when the created pipeline * is ready to be used without additional delay. - * If pipeline creation fails, the returned {@link Promise} rejects with an {@link GPUPipelineError}. + * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. * (A {@link GPUError} is not dispatched to the device.) * Note: Use of this method is preferred whenever possible, as it prevents blocking the * queue timeline work on pipeline compilation. @@ -2685,20 +2722,20 @@ interface GPUDevice */ readonly lost: Promise; /** - * Pushes a new GPU error scope onto the {@link GPUDevice#[[errorScopeStack]]} for `this`. + * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`. * @param filter - Which class of errors this error scope observes. */ pushErrorScope( filter: GPUErrorFilter ): undefined; /** - * Pops a GPU error scope off the {@link GPUDevice#[[errorScopeStack]]} for `this` + * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. * There is no guarantee of the ordering of promise resolution. */ popErrorScope(): Promise; /** - * An event handler IDL attribute for the {@link GPUDevice#uncapturederror} event type. + * An event handler IDL attribute for the `uncapturederror` event type. */ onuncapturederror: | (( @@ -2706,45 +2743,6 @@ interface GPUDevice ev: GPUUncapturedErrorEvent ) => any) | null; - - addEventListener< - K extends keyof __GPUDeviceEventMap - >( - type: K, - listener: ( - this: GPUDevice, - ev: __GPUDeviceEventMap[K] - ) => any, - options?: - | boolean - | AddEventListenerOptions - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: - | boolean - | AddEventListenerOptions - ): void; - removeEventListener< - K extends keyof __GPUDeviceEventMap - >( - type: K, - listener: ( - this: GPUDevice, - ev: __GPUDeviceEventMap[K] - ) => any, - options?: - | boolean - | EventListenerOptions - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: - | boolean - | EventListenerOptions - ): void; } declare var GPUDevice: { @@ -2775,7 +2773,7 @@ interface GPUError { * Note: This message is generally intended for application developers to debug their * applications and capture information for debug reports, not to be surfaced to end-users. * Note: User agents should not include potentially machine-parsable details in this message, - * such as free system memory on {@link GPUErrorFilter#"out-of-memory"} or other details about the + * such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the * conditions under which memory was exhausted. * Note: The {@link GPUError#message} should follow the best practices for language and * direction information. This includes making use of any future standards which may emerge @@ -2929,9 +2927,9 @@ interface GPUQueue commandBuffers: Iterable ): undefined; /** - * Returns a {@link Promise} that resolves once this queue finishes processing all the work submitted + * Returns a Promise that resolves once this queue finishes processing all the work submitted * up to this moment. - * Resolution of this {@link Promise} implies the completion of + * Resolution of this Promise implies the completion of * {@link GPUBuffer#mapAsync} calls made prior to that call, * on {@link GPUBuffer}s last used exclusively on that queue. */ @@ -2969,7 +2967,7 @@ interface GPUQueue /** * Issues a copy operation of the contents of a platform image/canvas * into the destination texture. - * This operation performs [[#color-space-conversions|color encoding]] into the destination + * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}. * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded * values, as copying into the corresponding non-`-srgb` format. @@ -3079,16 +3077,16 @@ interface GPURenderPassEncoder height: GPUIntegerCoordinate ): undefined; /** - * Sets the constant blend color and alpha values used with {@link GPUBlendFactor#"constant"} - * and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s. + * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` + * and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. * @param color - The color to use when blending. */ setBlendConstant( color: GPUColor ): undefined; /** - * Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with - * the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}. + * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with + * the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. * @param reference - The new stencil reference value. */ setStencilReference( @@ -3111,7 +3109,7 @@ interface GPURenderPassEncoder * pass's pipeline, bind group, and vertex/index buffer state is cleared * (to the initial, empty values). * Note: The state is cleared, not restored to the previous state. - * This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed. + * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. * @param bundles - List of render bundles to execute. */ executeBundles( @@ -3357,7 +3355,7 @@ interface Navigator interface WorkerNavigator extends NavigatorGPU {} -declare var GPUBufferUsage: { +interface GPUBufferUsage { readonly MAP_READ: GPUFlagsConstant; readonly MAP_WRITE: GPUFlagsConstant; readonly COPY_SRC: GPUFlagsConstant; @@ -3368,34 +3366,44 @@ declare var GPUBufferUsage: { readonly STORAGE: GPUFlagsConstant; readonly INDIRECT: GPUFlagsConstant; readonly QUERY_RESOLVE: GPUFlagsConstant; -}; +} -declare var GPUColorWrite: { +declare var GPUBufferUsage: GPUBufferUsage; + +interface GPUColorWrite { readonly RED: GPUFlagsConstant; readonly GREEN: GPUFlagsConstant; readonly BLUE: GPUFlagsConstant; readonly ALPHA: GPUFlagsConstant; readonly ALL: GPUFlagsConstant; -}; +} + +declare var GPUColorWrite: GPUColorWrite; -declare var GPUMapMode: { +interface GPUMapMode { readonly READ: GPUFlagsConstant; readonly WRITE: GPUFlagsConstant; -}; +} + +declare var GPUMapMode: GPUMapMode; -declare var GPUShaderStage: { +interface GPUShaderStage { readonly VERTEX: GPUFlagsConstant; readonly FRAGMENT: GPUFlagsConstant; readonly COMPUTE: GPUFlagsConstant; -}; +} + +declare var GPUShaderStage: GPUShaderStage; -declare var GPUTextureUsage: { +interface GPUTextureUsage { readonly COPY_SRC: GPUFlagsConstant; readonly COPY_DST: GPUFlagsConstant; readonly TEXTURE_BINDING: GPUFlagsConstant; readonly STORAGE_BINDING: GPUFlagsConstant; readonly RENDER_ATTACHMENT: GPUFlagsConstant; -}; +} + +declare var GPUTextureUsage: GPUTextureUsage; /** @deprecated Use {@link GPUTexelCopyBufferLayout} */ type GPUImageDataLayout = diff --git a/fix-generated-comments.mjs b/fix-generated-comments.mjs new file mode 100644 index 0000000..0c3bb9d --- /dev/null +++ b/fix-generated-comments.mjs @@ -0,0 +1,39 @@ +import fs from 'fs'; + +async function main() { + let ts = fs.readFileSync('generated/index.d.ts', { encoding: 'utf-8' }); + ts = ts + // convert [[#anchor]] to {@link spec_url} + // convert [[#anchor|text]] to {@link spec_url|text} + .replace(/([^#])\[\[([^\[].*?)\]\]/g, '$1{@link https://www.w3.org/TR/webgpu/$2}') + + // convert {{ref}} to {@link ref} + // convert {{ref|text}} to {@link ref|text} + .replace(/\{\{(.*?)\}\}/g, '{@link $1}') + + // convert {@link foo/method(...)} to {@link foo#method} + .replace(/\{@link ([^[}]+)\/(.*?)\(.*?\)}/g, '{@link $1#$2}') + + // convert {@link foo#[[bar]]} to {@link foo}.`[[bar]]` + .replace(/\{@link ([^[}]+)#\[\[(.*?)]]}/g, '{@link $1}.`[[$2]]`') + + // convert {@link foo#"bar"} to {@link foo} `"bar"` + .replace(/\{@link ([^[}]+)#"(.*?)"}/g, '{@link $1} `"$2"`') + + // fix links of the form {@link foo|text} -> {@link foo | text} + .replace(/\{@link ([^}|]+)\|([^}|]+)\}/g, '{@link $1 | $2}') + + // remove items that are known not to be linkable + .replace(/{@link Promise}/g, 'Promise') + .replace(/{@link ArrayBuffer}/g, 'ArrayBuffer') + .replace(/{@link Uint32Array}/g, 'Uint32Array') + .replace(/{@link RenderState}/g, 'RenderState') + .replace(/{@link double}/g, '`double`') + + .replace(/
/g, '```$1')
+    .replace(/<\/pre>/g, '```');
+
+  fs.writeFileSync('generated/index.d.ts', ts);
+}
+
+main();
diff --git a/generated/index.d.ts b/generated/index.d.ts
index 8786701..464ba4d 100644
--- a/generated/index.d.ts
+++ b/generated/index.d.ts
@@ -415,7 +415,7 @@ interface GPUBindGroupDescriptor
 interface GPUBindGroupEntry {
   /**
    * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a
-   * {@link GPUBindGroupLayoutEntry#binding|GPUBindGroupLayoutEntry.binding} and a @binding
+   * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding
    * attribute in the {@link GPUShaderModule}.
    */
   binding: GPUIndex32;
@@ -437,7 +437,7 @@ interface GPUBindGroupLayoutDescriptor
 interface GPUBindGroupLayoutEntry {
   /**
    * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding
-   * to a {@link GPUBindGroupEntry#binding|GPUBindGroupEntry.binding} and a @binding
+   * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding
    * attribute in the {@link GPUShaderModule}.
    */
   binding: GPUIndex32;
@@ -669,7 +669,7 @@ interface GPUComputePassDescriptor
 
 interface GPUComputePassTimestampWrites {
   /**
-   * The {@link GPUQuerySet}, of type {@link GPUQueryType#"timestamp"}, that the query results will be
+   * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be
    * written to.
    */
   querySet: GPUQuerySet;
@@ -697,12 +697,12 @@ interface GPUCopyExternalImageDestInfo
   extends GPUTexelCopyTextureInfo {
   /**
    * Describes the color space and encoding used to encode data into the destination texture.
-   * This [[#color-space-conversions|may result]] in values outside of the range [0, 1]
+   * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1]
    * being written to the target texture, if its format can represent them.
    * Otherwise, the results are clamped to the target texture format's range.
    * Note:
    * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image,
-   * conversion may not be necessary. See [[#color-space-conversion-elision]].
+   * conversion may not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.
    */
   colorSpace?: PredefinedColorSpace;
   /**
@@ -713,7 +713,7 @@ interface GPUCopyExternalImageDestInfo
    * corresponding alpha values.
    * Note:
    * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image,
-   * conversion may not be necessary. See [[#color-space-conversion-elision]].
+   * conversion may not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.
    */
   premultipliedAlpha?: boolean;
 }
@@ -802,7 +802,7 @@ interface GPUDeviceDescriptor
    * The request will fail if the adapter cannot provide these limits.
    * Each key with a non-`undefined` value must be the name of a member of supported limits.
    * API calls on the resulting device perform validation according to the exact limits of the
-   * device (not the adapter; see [[#limits]]).
+   * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}).
    * 
    */
   depthClearValue?: number;
   /**
    * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
    * depth component prior to executing the render pass.
-   * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
+   * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details.
    */
   depthLoadOp?: GPULoadOp;
   /**
@@ -1147,7 +1147,7 @@ interface GPURenderPassDepthStencilAttachment {
   /**
    * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
    * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
-   * is not {@link GPULoadOp#"clear"}.
+   * is not {@link GPULoadOp} `"clear"`.
    * The value will be converted to the type of the stencil aspect of `view` by taking the same
    * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
    */
@@ -1155,7 +1155,7 @@ interface GPURenderPassDepthStencilAttachment {
   /**
    * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
    * stencil component prior to executing the render pass.
-   * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
+   * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details.
    */
   stencilLoadOp?: GPULoadOp;
   /**
@@ -1220,7 +1220,7 @@ interface GPURenderPassLayout
 
 interface GPURenderPassTimestampWrites {
   /**
-   * The {@link GPUQuerySet}, of type {@link GPUQueryType#"timestamp"}, that the query results will be
+   * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be
    * written to.
    */
   querySet: GPUQuerySet;
@@ -1256,7 +1256,7 @@ interface GPURenderPipelineDescriptor
   multisample?: GPUMultisampleState;
   /**
    * Describes the fragment shader entry point of the pipeline and its output colors. If
-   * not map/exist|provided, the [[#no-color-output]] mode is enabled.
+   * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled.
    */
   fragment?: GPUFragmentState;
 }
@@ -1296,7 +1296,7 @@ interface GPUSamplerDescriptor
    */
   addressModeV?: GPUAddressMode;
   /**
-   * Specifies the {{GPUAddressMode|address modes}} for the texture width, height, and depth
+   * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth
    * coordinates, respectively.
    */
   addressModeW?: GPUAddressMode;
@@ -1349,7 +1349,7 @@ interface GPUShaderModuleCompilationHint {
   /**
    * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future
    * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call.
-   * If set to {@link GPUAutoLayoutMode#"auto"} the layout will be the [$default pipeline layout$]
+   * If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$]
    * for the entry point associated with this hint will be used.
    */
   layout?:
@@ -1381,7 +1381,7 @@ interface GPUShaderModuleDescriptor
    * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to
    * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}.
    * Hints are only applied to the entry points they explicitly name.
-   * Unlike {@link GPUProgrammableStage#entryPoint|GPUProgrammableStage.entryPoint},
+   * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint},
    * there is no default, even if only one entry point is present in the module.
    * 
    * Note:
@@ -1394,7 +1394,7 @@ interface GPUShaderModuleDescriptor
 
 interface GPUStencilFaceState {
   /**
-   * The {@link GPUCompareFunction} used when testing the {@link RenderState#[[stencilReference]]} value
+   * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value
    * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values.
    */
   compare?: GPUCompareFunction;
@@ -1443,7 +1443,7 @@ interface GPUTexelCopyBufferInfo
 interface GPUTexelCopyBufferLayout {
   /**
    * The offset, in bytes, from the beginning of the texel data source (such as a
-   * {@link GPUTexelCopyBufferInfo#buffer|GPUTexelCopyBufferInfo.buffer}) to the start of the texel data
+   * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data
    * within that source.
    */
   offset?: GPUSize64;
@@ -1538,8 +1538,8 @@ interface GPUTextureDescriptor
    * test various systems to find out the impact on their particular application.
    * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or
    * {@link GPUTextureDescriptor#viewFormats} entry including
-   * {@link GPUTextureFormat#"rgba8unorm-srgb"} will perform less optimally than a
-   * {@link GPUTextureFormat#"rgba8unorm"} texture which does not.
+   * {@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a
+   * {@link GPUTextureFormat} `"rgba8unorm"` texture which does not.
    * Similar caveats exist for other formats and pairs of formats on other systems.
    * 
    * Formats in this list must be texture view format compatible with the texture format.
@@ -1564,7 +1564,7 @@ interface GPUTextureViewDescriptor
    */
   dimension?: GPUTextureViewDimension;
   /**
-   * The allowed {@link GPUTextureUsage|usage(s)} for the texture view. Must be a subset of the
+   * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the
    * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of
    * {@link GPUTexture#usage} flags of the texture.
    * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the
@@ -1573,7 +1573,7 @@ interface GPUTextureViewDescriptor
    */
   usage?: GPUTextureUsageFlags;
   /**
-   * Which {@link GPUTextureAspect|aspect(s)} of the texture are accessible to the texture view.
+   * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.
    */
   aspect?: GPUTextureAspect;
   /**
@@ -1613,7 +1613,7 @@ interface GPUVertexAttribute {
   /**
    * The numeric location associated with this attribute, which will correspond with a
    * "@location" attribute
-   * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module|module}.
+   * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}.
    */
   shaderLocation: GPUIndex32;
 }
@@ -1691,7 +1691,7 @@ interface GPUPipelineBase {
   /**
    * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s
    * {@link GPUBindGroupLayout} at `index`.
-   * @param index - Index into the pipeline layout's {@link GPUPipelineLayout#[[bindGroupLayouts]]}
+   * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]`
    * 	sequence.
    */
   getBindGroupLayout(
@@ -1737,7 +1737,7 @@ interface GPURenderCommandsMixin {
   ): undefined;
   /**
    * Draws primitives.
-   * See [[#rendering-operations]] for the detailed specification.
+   * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.
    * @param vertexCount - The number of vertices to draw.
    * @param instanceCount - The number of instances to draw.
    * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
@@ -1788,8 +1788,8 @@ interface GPU {
   ): Promise;
   /**
    * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range
-   * content on this system. Must only return {@link GPUTextureFormat#"rgba8unorm"} or
-   * {@link GPUTextureFormat#"bgra8unorm"}.
+   * content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or
+   * {@link GPUTextureFormat} `"bgra8unorm"`.
    * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to
    * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated
    * canvas is able to display its contents efficiently.
@@ -1889,14 +1889,14 @@ interface GPUBuffer
   readonly usage: GPUFlagsConstant;
   readonly mapState: GPUBufferMapState;
   /**
-   * Maps the given range of the {@link GPUBuffer} and resolves the returned {@link Promise} when the
+   * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the
    * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}.
-   * The resolution of the returned {@link Promise} **only** indicates that the buffer has been mapped.
+   * The resolution of the returned Promise **only** indicates that the buffer has been mapped.
    * It does not guarantee the completion of any other operations visible to the content timeline,
-   * and in particular does not imply that any other {@link Promise} returned from
+   * and in particular does not imply that any other Promise returned from
    * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s
    * have resolved.
-   * The resolution of the {@link Promise} returned from {@link GPUQueue#onSubmittedWorkDone}
+   * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone}
    * **does** imply the completion of
    * {@link GPUBuffer#mapAsync} calls made prior to that call,
    * on {@link GPUBuffer}s last used exclusively on that queue.
@@ -1910,9 +1910,9 @@ interface GPUBuffer
     size?: GPUSize64
   ): Promise;
   /**
-   * Returns an {@link ArrayBuffer} with the contents of the {@link GPUBuffer} in the given mapped range.
+   * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.
    * @param offset - Offset in bytes into the buffer to return buffer contents from.
-   * @param size - Size in bytes of the {@link ArrayBuffer} to return.
+   * @param size - Size in bytes of the ArrayBuffer to return.
    */
   getMappedRange(
     offset?: GPUSize64,
@@ -2011,7 +2011,7 @@ interface GPUCommandEncoder
     descriptor?: GPUComputePassDescriptor
   ): GPUComputePassEncoder;
   /**
-   * Shorthand, equivalent to {{GPUCommandEncoder/copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)|copyBufferToBuffer(source, 0, destination, 0, size)}}.
+   * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}.
    */
   copyBufferToBuffer(
     source: GPUBuffer,
@@ -2164,7 +2164,7 @@ interface GPUComputePassEncoder
   ): undefined;
   /**
    * Dispatch work to be performed with the current {@link GPUComputePipeline}.
-   * See [[#computing-operations]] for the detailed specification.
+   * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.
    * @param workgroupCountX - X dimension of the grid of workgroups to dispatch.
    * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch.
    * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch.
@@ -2177,7 +2177,7 @@ interface GPUComputePassEncoder
   /**
    * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read
    * from a {@link GPUBuffer}.
-   * See [[#computing-operations]] for the detailed specification.
+   * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.
    * packed block of **three 32-bit unsigned integer values (12 bytes total)**,
    * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}.
    * For example:
@@ -2307,9 +2307,9 @@ interface GPUDevice
   ): GPURenderPipeline;
   /**
    * Creates a {@link GPUComputePipeline} using async pipeline creation.
-   * The returned {@link Promise} resolves when the created pipeline
+   * The returned Promise resolves when the created pipeline
    * is ready to be used without additional delay.
-   * If pipeline creation fails, the returned {@link Promise} rejects with an {@link GPUPipelineError}.
+   * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.
    * (A {@link GPUError} is not dispatched to the device.)
    * Note: Use of this method is preferred whenever possible, as it prevents blocking the
    * queue timeline work on pipeline compilation.
@@ -2320,9 +2320,9 @@ interface GPUDevice
   ): Promise;
   /**
    * Creates a {@link GPURenderPipeline} using async pipeline creation.
-   * The returned {@link Promise} resolves when the created pipeline
+   * The returned Promise resolves when the created pipeline
    * is ready to be used without additional delay.
-   * If pipeline creation fails, the returned {@link Promise} rejects with an {@link GPUPipelineError}.
+   * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.
    * (A {@link GPUError} is not dispatched to the device.)
    * Note: Use of this method is preferred whenever possible, as it prevents blocking the
    * queue timeline work on pipeline compilation.
@@ -2359,14 +2359,14 @@ interface GPUDevice
    */
   readonly lost: Promise;
   /**
-   * Pushes a new GPU error scope onto the {@link GPUDevice#[[errorScopeStack]]} for `this`.
+   * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.
    * @param filter - Which class of errors this error scope observes.
    */
   pushErrorScope(
     filter: GPUErrorFilter
   ): undefined;
   /**
-   * Pops a GPU error scope off the {@link GPUDevice#[[errorScopeStack]]} for `this`
+   * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this`
    * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none.
    * There is no guarantee of the ordering of promise resolution.
    */
@@ -2552,7 +2552,7 @@ interface GPUQueue
   /**
    * Issues a copy operation of the contents of a platform image/canvas
    * into the destination texture.
-   * This operation performs [[#color-space-conversions|color encoding]] into the destination
+   * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination
    * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}.
    * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded
    * values, as copying into the corresponding non-`-srgb` format.
@@ -2659,16 +2659,16 @@ interface GPURenderPassEncoder
     height: GPUIntegerCoordinate
   ): undefined;
   /**
-   * Sets the constant blend color and alpha values used with {@link GPUBlendFactor#"constant"}
-   * and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s.
+   * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"`
+   * and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s.
    * @param color - The color to use when blending.
    */
   setBlendConstant(
     color: GPUColor
   ): undefined;
   /**
-   * Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with
-   * the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}.
+   * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with
+   * the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}.
    * @param reference - The new stencil reference value.
    */
   setStencilReference(
@@ -2691,7 +2691,7 @@ interface GPURenderPassEncoder
    * pass's pipeline, bind group, and vertex/index buffer state is cleared
    * (to the initial, empty values).
    * Note: The state is cleared, not restored to the previous state.
-   * This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed.
+   * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed.
    * @param bundles - List of render bundles to execute.
    */
   executeBundles(
diff --git a/package.json b/package.json
index 91a5b14..383337b 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
   "scripts": {
     "test": "for t in tests/*/ ; do (cd \"$t\" && npm i && npm test); done",
     "build-docs": "cd tsdoc-src && npm ci && npm run build",
-    "generate": "bikeshed-to-ts --in ./gpuweb/spec/index.bs --out ./generated/index.d.ts --forceGlobal --nominal && prettier -w generated/index.d.ts",
+    "generate": "bikeshed-to-ts --in ./gpuweb/spec/index.bs --out ./generated/index.d.ts --forceGlobal --nominal && node fix-generated-comments.mjs && prettier -w generated/index.d.ts",
     "format": "prettier -w dist/index.d.ts"
   },
   "devDependencies": {
diff --git a/tsdoc-src/.gitignore b/tsdoc-src/.gitignore
index 43f8971..e2e7327 100644
--- a/tsdoc-src/.gitignore
+++ b/tsdoc-src/.gitignore
@@ -1,2 +1 @@
 /out
-/webgpu.ts
diff --git a/tsdoc-src/generate-webgpu-ts.mjs b/tsdoc-src/generate-webgpu-ts.mjs
deleted file mode 100644
index e39ccdd..0000000
--- a/tsdoc-src/generate-webgpu-ts.mjs
+++ /dev/null
@@ -1,38 +0,0 @@
-import fs from 'fs';
-
-async function main() {
-  let ts = fs.readFileSync('../dist/index.d.ts', {encoding: 'utf-8'});
-  ts = ts
-    // export interfaces.
-    .replace(/\ninterface /g, '\nexport interface ')
-
-    // export types
-    .replace(/\ntype /g, '\nexport type ')
-
-    // {{ref|text}} => {@link ref | text}
-    .replace(/\{\{([^}|]+)\|([^}|]+)\}\}/g, '{@link $1 | $2}')
-
-    // fix links of the form {@link foo|caption} -> {@link foo | caption}
-    .replace(/\{@link([^}]+)\S\|\S(.*?)\}/g, `{@link $1 | $2}`)
-
-    // fix links of the form {@link foo[[#bar]]} -> {@link foo#bar}
-    .replace(/\{@link([^[}]+)\[\[(.*?)]]}/g, `{@link $1$2}`)
-
-    // convert [[link]] to {@link link}
-    .replace(/([^#])\[\[([^\[].*?)\]\]/g, '$1{@link https://www.w3.org/TR/webgpu/$2}')
-
-    .replace(/
/g, '```$1')
-    .replace(/<\/pre>/g, '```')
-
-    // remove __brand
-    .replace(new RegExp(`/\\*\\*
-   \\* Nominal type branding.
-   \\* https://github.com/microsoft/TypeScript/pull/33038
-   \\* @internal
-   \\*/
-  readonly __brand: ".*?";`.replace(/sss\*/g, '\\*').replace(/\s+/g, '\\s+'), 'g'), '');
-
-  fs.writeFileSync('./webgpu.ts', ts);
-}
-
-main();
diff --git a/tsdoc-src/package.json b/tsdoc-src/package.json
index c4d8402..e5e0beb 100644
--- a/tsdoc-src/package.json
+++ b/tsdoc-src/package.json
@@ -1,6 +1,6 @@
 {
   "scripts": {
-    "build": "node generate-webgpu-ts.mjs && typedoc --treatWarningsAsErrors ./webgpu.ts"
+    "build": "typedoc --treatWarningsAsErrors ../dist/index.d.ts"
   },
   "devDependencies": {
     "@types/dom-webcodecs": "0.1.3",
diff --git a/tsdoc-src/tsconfig.json b/tsdoc-src/tsconfig.json
index 99ffd6b..22aaacc 100644
--- a/tsdoc-src/tsconfig.json
+++ b/tsdoc-src/tsconfig.json
@@ -19,7 +19,7 @@
     ],
   },
   "include": [
-    "./webgpu.ts"
+    "../dist/index.d.ts"
   ],
   "exclude": [
     "node_modules",
diff --git a/tsdoc-src/typedoc.json b/tsdoc-src/typedoc.json
deleted file mode 100644
index e8a6222..0000000
--- a/tsdoc-src/typedoc.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "$schema": "https://typedoc.org/schema.json",
-    "entryPoints": ["./webgpu.ts"],
-    "out": "out",
-    "readme": "none",
-    "name": "WebGPU API reference",
-    "validation": false,
-    "disableSources": true
-}