diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-05-06 16:48:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 16:48:45 +0200 |
commit | f208e6a26f3c21c25dbfcfe29491a6f5660c999d (patch) | |
tree | 65dbbd45b2f36faab8ae585eb0d270356bcba33e /extensions/webgpu/01_webgpu.js | |
parent | ce76f8c3a97529c86d49c39c6d9a250f978b5430 (diff) |
chore: update wgpu and realign to spec (#9760)
Diffstat (limited to 'extensions/webgpu/01_webgpu.js')
-rw-r--r-- | extensions/webgpu/01_webgpu.js | 109 |
1 files changed, 39 insertions, 70 deletions
diff --git a/extensions/webgpu/01_webgpu.js b/extensions/webgpu/01_webgpu.js index a02262ccd..23beaf1cc 100644 --- a/extensions/webgpu/01_webgpu.js +++ b/extensions/webgpu/01_webgpu.js @@ -79,7 +79,7 @@ return { width: data[0], height: data[1], - depth: data[2], + depthOrArrayLayers: data[2], }; } else { return data; @@ -179,7 +179,7 @@ /** * @typedef InnerGPUAdapter * @property {number} rid - * @property {GPUAdapterFeatures} features + * @property {GPUSupportedFeatures} features * @property {GPUAdapterLimits} limits */ @@ -194,7 +194,7 @@ adapter[_name] = name; adapter[_adapter] = { ...inner, - features: createGPUAdapterFeatures(inner.features), + features: createGPUSupportedFeatures(inner.features), limits: createGPUAdapterLimits(inner.limits), }; return adapter; @@ -211,7 +211,7 @@ webidl.assertBranded(this, GPUAdapter); return this[_name]; } - /** @returns {GPUAdapterFeatures} */ + /** @returns {GPUSupportedFeatures} */ get features() { webidl.assertBranded(this, GPUAdapter); return this[_adapter].features; @@ -245,7 +245,7 @@ ); } } - const nonGuaranteedLimits = descriptor.nonGuaranteedLimits ?? []; + const nonGuaranteedLimits = descriptor.nonGuaranteedLimits; // TODO(lucacasonato): validate nonGuaranteedLimits const { rid, features, limits } = await core.opAsync( @@ -320,16 +320,20 @@ } get maxTextureDimension1D() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxTextureDimension1D; } get maxTextureDimension2D() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxTextureDimension2D; } get maxTextureDimension3D() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxTextureDimension3D; } get maxTextureArrayLayers() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxTextureArrayLayers; } get maxBindGroups() { webidl.assertBranded(this, GPUAdapterLimits); @@ -368,16 +372,20 @@ return this[_limits].maxUniformBufferBindingSize; } get maxStorageBufferBindingSize() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxStorageBufferBindingSize; } get maxVertexBuffers() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxVertexBuffers; } get maxVertexAttributes() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxVertexAttributes; } get maxVertexBufferArrayStride() { - throw new TypeError("Not yet implemented"); + webidl.assertBranded(this, GPUAdapterLimits); + return this[_limits].maxVertexBufferArrayStride; } [Symbol.for("Deno.customInspect")](inspect) { @@ -387,14 +395,14 @@ const _features = Symbol("[[features]]"); - function createGPUAdapterFeatures(features) { - /** @type {GPUAdapterFeatures} */ - const adapterFeatures = webidl.createBranded(GPUAdapterFeatures); + function createGPUSupportedFeatures(features) { + /** @type {GPUSupportedFeatures} */ + const adapterFeatures = webidl.createBranded(GPUSupportedFeatures); adapterFeatures[_features] = new Set(features); return adapterFeatures; } - class GPUAdapterFeatures { + class GPUSupportedFeatures { /** @type {Set<string>} */ [_features]; @@ -404,42 +412,42 @@ /** @return {IterableIterator<[string, string]>} */ entries() { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features].entries(); } /** @return {void} */ forEach(callbackfn, thisArg) { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); this[_features].forEach(callbackfn, thisArg); } /** @return {boolean} */ has(value) { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features].has(value); } /** @return {IterableIterator<string>} */ keys() { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features].keys(); } /** @return {IterableIterator<string>} */ values() { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features].values(); } /** @return {number} */ get size() { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features].size; } [Symbol.iterator]() { - webidl.assertBranded(this, GPUAdapterFeatures); + webidl.assertBranded(this, GPUSupportedFeatures); return this[_features][Symbol.iterator](); } @@ -661,10 +669,6 @@ } } - get adapter() { - webidl.assertBranded(this, GPUDevice); - return this[_device].adapter; - } get features() { webidl.assertBranded(this, GPUDevice); return this[_device].features; @@ -1291,7 +1295,6 @@ [Symbol.for("Deno.customInspect")](inspect) { return `${this.constructor.name} ${ inspect({ - adapter: this.adapter, features: this.features, label: this.label, limits: this.limits, @@ -1693,41 +1696,7 @@ if (size === undefined) { rangeSize = Math.max(0, this[_size] - offset); } else { - rangeSize = this[_size]; - } - if (this[_state] !== "mapped" && this[_state] !== "mapped at creation") { - throw new DOMException( - `${prefix}: buffer is not mapped.`, - "OperationError", - ); - } - if ((offset % 8) !== 0) { - throw new DOMException( - `${prefix}: offset must be a multiple of 8.`, - "OperationError", - ); - } - if ((rangeSize % 4) !== 0) { - throw new DOMException( - `${prefix}: rangeSize must be a multiple of 4.`, - "OperationError", - ); - } - const mappingRange = this[_mappingRange]; - if (!mappingRange) { - throw new DOMException(`${prefix}: invalid state.`, "OperationError"); - } - if (offset < mappingRange[0]) { - throw new DOMException( - `${prefix}: offset is out of bounds.`, - "OperationError", - ); - } - if ((offset + rangeSize) > mappingRange[1]) { - throw new DOMException( - `${prefix}: offset is out of bounds.`, - "OperationError", - ); + rangeSize = size; } const mappedRanges = this[_mappedRanges]; if (!mappedRanges) { @@ -1752,8 +1721,8 @@ "op_webgpu_buffer_get_mapped_range", { bufferRid, - offset: offset - mappingRange[0], - size: rangeSize, + offset, + size, }, new Uint8Array(buffer), ); @@ -3324,10 +3293,10 @@ /** * @param {GPUColor} color */ - setBlendColor(color) { + setBlendConstant(color) { webidl.assertBranded(this, GPURenderPassEncoder); const prefix = - "Failed to execute 'setBlendColor' on 'GPUComputePassEncoder'"; + "Failed to execute 'setBlendConstant' on 'GPUComputePassEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); color = webidl.converters.GPUColor(color, { prefix, @@ -3342,7 +3311,7 @@ context: "encoder referenced by this", }); const renderPassRid = assertResource(this, { prefix, context: "this" }); - core.opSync("op_webgpu_render_pass_set_blend_color", { + core.opSync("op_webgpu_render_pass_set_blend_constant", { renderPassRid, color: normalizeGPUColor(color), }); @@ -5017,7 +4986,7 @@ GPU, GPUAdapter, GPUAdapterLimits, - GPUAdapterFeatures, + GPUSupportedFeatures, GPUDevice, GPUQueue, GPUBuffer, |