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

fix(ext/webgpu): GPUDevice.createTexture works when the argument descriptor.size is an Array #23413

Merged
merged 20 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion ext/webgpu/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,10 +1126,11 @@ class GPUDevice extends EventTarget {
"Argument 1",
);
const device = assertDevice(this, prefix, "this");
// assign normalized size to descriptor due to createGPUTexture needs it
descriptor.size = normalizeGPUExtent3D(descriptor.size);
const { rid, err } = op_webgpu_create_texture({
deviceRid: device.rid,
...descriptor,
size: normalizeGPUExtent3D(descriptor.size),
});
device.pushError(err);

Expand Down Expand Up @@ -5301,6 +5302,18 @@ webidl.converters["GPUExtent3D"] = (V, opts) => {
return webidl.converters["GPUExtent3DDict"](V, opts);
}
if (typeof V === "object") {
// validate GPUExtent3D when its an Array
if (ArrayIsArray(V)) {
const min = 1;
const max = 3;
if (V.length < min || V.length > max) {
throw webidl.makeException(
TypeError,
`A sequence of number used as a GPUExtent3D must have between ${min} and ${max} elements.`,
opts,
);
crowlKats marked this conversation as resolved.
Show resolved Hide resolved
}
}
const method = V[SymbolIterator];
if (method !== undefined) {
return webidl.converters["sequence<GPUIntegerCoordinate>"](V, opts);
Expand Down
1 change: 0 additions & 1 deletion tests/wpt/suite
Submodule suite deleted from daa07c