Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 30, 2024

Conversation

kainino0x
Copy link
Collaborator

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:

  • GPUBufferUsage instanceof Function is false
  • 'prototype' in GPUBufferUsage is false
  • GPUBufferUsage.__proto__ === ({}).__proto__

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

@kainino0x kainino0x requested a review from toji May 29, 2024 22:50
@kainino0x
Copy link
Collaborator Author

kainino0x commented May 29, 2024

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;
-}
+};

Copy link
Member

@toji toji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kainino0x kainino0x merged commit 7556dfe into gpuweb:main May 30, 2024
1 check passed
@kainino0x kainino0x deleted the constructors branch May 30, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants