Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ Most or all of these should be fixed in the generator over time.

- `Array` changed to `Iterable` for WebIDL `sequence`s in argument positions (but not in return positions).
- `any` changed to `object` for WebIDL `object`.
- `| SharedArrayBuffer` added for `[AllowShared] BufferSource`.
- `| null` changed to `| null | undefined` for WebIDL nullable items (`T?`).

The following differences are TODO: should be changed in the final result.
Expand All @@ -109,6 +108,7 @@ The following differences are TODO: should be changed in the final result.
The following differences will remain.

- `onuncapturederror` strongly typed.
- `addEventListener('uncapturederror')` type support.
- `getContext` definitions.
- `GPUExtent3DStrict` and `GPUOrigin2DStrict`.

Expand Down
77 changes: 64 additions & 13 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ interface GPUBindGroupLayoutEntry {
storageTexture?: GPUStorageTextureBindingLayout;
/**
* When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUExternalTexture}.
* is either {@link GPUExternalTexture} or {@link GPUTextureView}.
* External textures use several binding slots: see Exceeds the binding slot limits.
*/
externalTexture?: GPUExternalTextureBindingLayout;
}
Expand Down Expand Up @@ -1069,6 +1070,48 @@ interface GPUProgrammableStage {
* Values are specified as <dfn typedef for="">GPUPipelineConstantValue</dfn>, which is a {@link double}.
* They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`).
* If conversion fails, a validation error is generated.
* <div class=example>
* Pipeline-overridable constants defined in WGSL:
* <pre highlight=wgsl>
* @id(0) override has_point_light: bool = true; // Algorithmic control.
* @id(1200) override specular_param: f32 = 2.3; // Numeric control.
* @id(1300) override gain: f32; // Must be overridden.
* override width: f32 = 0.0; // Specifed at the API level
* // using the name "width".
* override depth: f32; // Specifed at the API level
* // using the name "depth".
* // Must be overridden.
* override height = 2 * depth; // The default value
* // (if not set at the API level),
* // depends on another
* // overridable constant.
* </pre>
* Corresponding JavaScript code, providing only the overrides which are required
* (have no defaults):
* <pre highlight=js>
* {
* // ...
* constants: {
* 1300: 2.0, // "gain"
* depth: -1, // "depth"
* }
* }
* </pre>
* Corresponding JavaScript code, overriding all constants:
* <pre highlight=js>
* {
* // ...
* constants: {
* 0: false, // "has_point_light"
* 1200: 3.0, // "specular_param"
* 1300: 2.0, // "gain"
* width: 20, // "width"
* depth: -1, // "depth"
* height: 15, // "height"
* }
* }
* </pre>
* </div>
*/
constants?: Record<
string,
Expand Down Expand Up @@ -1307,10 +1350,11 @@ interface GPURenderPipelineDescriptor
interface GPURequestAdapterOptions {
/**
* "Feature level" for the adapter request.
* The allowed feature level string values are:
* - `"core"`
* The allowed <dfn dfn for="">feature level string</dfn> values are:
* <dl dfn-type=dfn dfn-for="feature level string">
* : <dfn noexport>"core"</dfn>
* No effect.
* - `"compatibility"`
* : <dfn noexport>"compatibility"</dfn>
* No effect.
* Note:
* This value is reserved for future use as a way to opt into additional validation restrictions.
Expand Down Expand Up @@ -1622,8 +1666,7 @@ interface GPUTextureDescriptor
*/
viewFormats?: Iterable<GPUTextureFormat>;
/**
* **PROPOSED** addition for Compatibility Mode:
* <https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md#1-texture-view-dimension-may-be-specified>
* **PROPOSED** in [Compatibility Mode](https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md).
*
* > [In compatibility mode,]
* > When specifying a texture, a textureBindingViewDimension property
Expand Down Expand Up @@ -1987,7 +2030,7 @@ interface GPUAdapter {
/**
* Requests a device from the adapter.
* This is a one-time action: if a device is returned successfully,
* the adapter becomes {@link adapter#[[state]]} "consumed".
* the adapter becomes {@link adapter#[[state]]#"consumed"}.
* @param descriptor - Description of the {@link GPUDevice} to request.
*/
requestDevice(
Expand Down Expand Up @@ -2222,6 +2265,14 @@ interface GPUCommandEncoder
beginComputePass(
descriptor?: GPUComputePassDescriptor
): GPUComputePassEncoder;
/**
* Shorthand, equivalent to {{GPUCommandEncoder/copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)|copyBufferToBuffer(source, 0, destination, 0, size)}}.
*/
copyBufferToBuffer(
source: GPUBuffer,
destination: GPUBuffer,
size?: GPUSize64
): undefined;
/**
* Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a
* {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}.
Expand Down Expand Up @@ -2898,9 +2949,7 @@ interface GPUQueue
writeBuffer(
buffer: GPUBuffer,
bufferOffset: GPUSize64,
data:
| BufferSource
| SharedArrayBuffer,
data: AllowSharedBufferSource,
dataOffset?: GPUSize64,
size?: GPUSize64
): undefined;
Expand All @@ -2913,9 +2962,7 @@ interface GPUQueue
*/
writeTexture(
destination: GPUTexelCopyTextureInfo,
data:
| BufferSource
| SharedArrayBuffer,
data: AllowSharedBufferSource,
dataLayout: GPUTexelCopyBufferLayout,
size: GPUExtent3DStrict
): undefined;
Expand Down Expand Up @@ -3174,9 +3221,13 @@ interface GPUSupportedLimits {
readonly maxComputeWorkgroupSizeY: number;
readonly maxComputeWorkgroupSizeZ: number;
readonly maxComputeWorkgroupsPerDimension: number;
/** **PROPOSED** in [Compatibility Mode](https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md). */
readonly maxStorageBuffersInVertexStage?: number;
/** **PROPOSED** in [Compatibility Mode](https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md). */
readonly maxStorageBuffersInFragmentStage?: number;
/** **PROPOSED** in [Compatibility Mode](https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md). */
readonly maxStorageTexturesInVertexStage?: number;
/** **PROPOSED** in [Compatibility Mode](https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md). */
readonly maxStorageTexturesInFragmentStage?: number;
}

Expand Down
15 changes: 12 additions & 3 deletions generated/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ interface GPUBindGroupLayoutEntry {
storageTexture?: GPUStorageTextureBindingLayout;
/**
* When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUExternalTexture}.
* is either {@link GPUExternalTexture} or {@link GPUTextureView}.
* External textures use several binding slots: see Exceeds the binding slot limits.
*/
externalTexture?: GPUExternalTextureBindingLayout;
}
Expand Down Expand Up @@ -1813,7 +1814,6 @@ interface GPUAdapter {
readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
readonly info: GPUAdapterInfo;
readonly isFallbackAdapter: boolean;
/**
* Requests a device from the adapter.
* This is a one-time action: if a device is returned successfully,
Expand Down Expand Up @@ -1842,6 +1842,7 @@ interface GPUAdapterInfo {
readonly description: string;
readonly subgroupMinSize: number;
readonly subgroupMaxSize: number;
readonly isFallbackAdapter: boolean;
}

declare var GPUAdapterInfo: {
Expand Down Expand Up @@ -2009,6 +2010,14 @@ interface GPUCommandEncoder
beginComputePass(
descriptor?: GPUComputePassDescriptor
): GPUComputePassEncoder;
/**
* Shorthand, equivalent to {{GPUCommandEncoder/copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)|copyBufferToBuffer(source, 0, destination, 0, size)}}.
*/
copyBufferToBuffer(
source: GPUBuffer,
destination: GPUBuffer,
size?: GPUSize64
): undefined;
/**
* Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a
* {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}.
Expand All @@ -2023,7 +2032,7 @@ interface GPUCommandEncoder
sourceOffset: GPUSize64,
destination: GPUBuffer,
destinationOffset: GPUSize64,
size: GPUSize64
size?: GPUSize64
): undefined;
/**
* Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/ts5.1/package.json → tests/ts5.2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"dependencies": {
"@webgpu/types": "file:../..",
"typescript": "~5.1.0"
"typescript": "~5.2.0"
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions tests/ts5.8/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@webgpu/types" />
9 changes: 9 additions & 0 deletions tests/ts5.8/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scripts": {
"test": "tsc --version && tsc"
},
"dependencies": {
"@webgpu/types": "file:../..",
"typescript": "~5.8.0"
}
}
4 changes: 4 additions & 0 deletions tests/ts5.8/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["index.ts"]
}
9 changes: 6 additions & 3 deletions tsdoc-src/generate-webgpu-ts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ async function main() {
// export types
.replace(/\ntype /g, '\nexport type ')

// {{GPUAddressMode|address modes}} => {@link GPUAddressMode | address modes}
.replace(/\{\{GPUAddressMode\|address modes\}\}/g, '{@link GPUAddressMode | address modes}')
// {{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}`)
Expand All @@ -19,7 +19,10 @@ async function main() {
.replace(/\{@link([^[}]+)\[\[(.*?)]]}/g, `{@link $1$2}`)

// convert [[link]] to {@link link}
.replace(/\[\[([^\[].*?)\]\]/g, '{@link https://www.w3.org/TR/webgpu/$1}')
.replace(/([^#])\[\[([^\[].*?)\]\]/g, '$1{@link https://www.w3.org/TR/webgpu/$2}')

.replace(/<pre highlight=['"]?(.*)['"]?>/g, '```$1')
.replace(/<\/pre>/g, '```')

// remove __brand
.replace(new RegExp(`/\\*\\*
Expand Down
Loading