gpuweb / types

TypeScript type definitions for WebGPU https://gpuweb.github.io/types/
https://www.npmjs.com/package/@webgpu/types
BSD 3-Clause "New" or "Revised" License
189 stars 38 forks source link

Add missing constructors, remove non-existent interfaces/prototypes/constructors #149

Closed kainino0x closed 5 months ago

kainino0x commented 5 months ago

A constructor is needed in GPUAdapterInfo for instanceof GPUAdapterInfo to work (https://github.com/gpuweb/cts/pull/3679/files#diff-b1c3098d2cfb3e28e1d76d21e07c37131894fe5eeb3f55f0646c15b0f3db2b02R25).

Also, after the spec switch from IDL interfaces to namespaces for bitflags, there are no longer prototypes or constructors on those objects, at least according to Chromium:

And they don't name types so I've removed the TS interfaces too. Associated CTS fixes in https://github.com/gpuweb/cts/pull/3770

kainino0x commented 5 months ago

Oh note: I did not update the generator, so these changes are in dist/ only. (Actually, this reduces the textual diff with the generator output, which was only generating one non-branded interface instead of a branded interface and a declare var.)

-interface GPUBufferUsage {
+declare var GPUBufferUsage: {
   readonly MAP_READ: GPUFlagsConstant;
   readonly MAP_WRITE: GPUFlagsConstant;
   readonly COPY_SRC: GPUFlagsConstant;
   readonly COPY_DST: GPUFlagsConstant;
   readonly INDEX: GPUFlagsConstant;
   readonly VERTEX: GPUFlagsConstant;
   readonly UNIFORM: GPUFlagsConstant;
   readonly STORAGE: GPUFlagsConstant;
   readonly INDIRECT: GPUFlagsConstant;
   readonly QUERY_RESOLVE: GPUFlagsConstant;
-}
+};

-interface GPUColorWrite {
+declare var GPUColorWrite: {
   readonly RED: GPUFlagsConstant;
   readonly GREEN: GPUFlagsConstant;
   readonly BLUE: GPUFlagsConstant;
   readonly ALPHA: GPUFlagsConstant;
   readonly ALL: GPUFlagsConstant;
-}
+};

-interface GPUMapMode {
+declare var GPUMapMode: {
   readonly READ: GPUFlagsConstant;
   readonly WRITE: GPUFlagsConstant;
-}
+};

-interface GPUShaderStage {
+declare var GPUShaderStage: {
   readonly VERTEX: GPUFlagsConstant;
   readonly FRAGMENT: GPUFlagsConstant;
   readonly COMPUTE: GPUFlagsConstant;
-}
+};

-interface GPUTextureUsage {
+declare var GPUTextureUsage: {
   readonly COPY_SRC: GPUFlagsConstant;
   readonly COPY_DST: GPUFlagsConstant;
   readonly TEXTURE_BINDING: GPUFlagsConstant;
   readonly STORAGE_BINDING: GPUFlagsConstant;
   readonly RENDER_ATTACHMENT: GPUFlagsConstant;
-}
+};