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

WebGPU: texture width and height are undefined when descriptor size is an array. #22733

Closed
torelode opened this issue Mar 6, 2024 · 2 comments · Fixed by #23413
Closed

WebGPU: texture width and height are undefined when descriptor size is an array. #22733

torelode opened this issue Mar 6, 2024 · 2 comments · Fixed by #23413
Labels
bug Something isn't working ext/webgpu related to the ext/webgpu

Comments

@torelode
Copy link

torelode commented Mar 6, 2024

Version: Deno 1.41.1

This code fails:

const texture = device.createTexture({
  size: [256, 256],
  format: "rgba8unorm-srgb",
  usage: GPUTextureUsage.TEXTURE_BINDING,
});
console.assert(texture.width !== undefined);

This code works:

const texture = device.createTexture({
  size: { width: 256, height: 256 },
  format: "rgba8unorm-srgb",
  usage: GPUTextureUsage.TEXTURE_BINDING,
});
console.assert(texture.width !== undefined);
@littledivy littledivy added bug Something isn't working ext/webgpu related to the ext/webgpu labels Mar 6, 2024
@Hajime-san
Copy link
Contributor

Is this related?
gpuweb/types#147

@torelode
Copy link
Author

Not really. The values of width and height are undefined when initialized from array. If you look at the code, the bug is trivial. It simply fetches width and height from the description object, assuming width and height were defined using named properties and not an array. It should be easy to fix with a ternary and Array.isArray(). Or better yet, copy the description object and canonicalize the properties in the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ext/webgpu related to the ext/webgpu
Projects
None yet
3 participants