diff options
Diffstat (limited to 'ext/webgpu/src/01_webgpu.js')
-rw-r--r-- | ext/webgpu/src/01_webgpu.js | 352 |
1 files changed, 222 insertions, 130 deletions
diff --git a/ext/webgpu/src/01_webgpu.js b/ext/webgpu/src/01_webgpu.js index eb239bab8..23e8b24f0 100644 --- a/ext/webgpu/src/01_webgpu.js +++ b/ext/webgpu/src/01_webgpu.js @@ -57,7 +57,6 @@ const _architecture = Symbol("[[architecture]]"); const _description = Symbol("[[description]]"); const _limits = Symbol("[[limits]]"); - const _features = Symbol("[[features]]"); const _reason = Symbol("[[reason]]"); const _message = Symbol("[[message]]"); const _label = Symbol("[[label]]"); @@ -68,6 +67,15 @@ const _encoders = Symbol("[[encoders]]"); const _encoder = Symbol("[[encoder]]"); const _descriptor = Symbol("[[descriptor]]"); + const _width = Symbol("[[width]]"); + const _height = Symbol("[[height]]"); + const _depthOrArrayLayers = Symbol("[[depthOrArrayLayers]]"); + const _mipLevelCount = Symbol("[[mipLevelCount]]"); + const _sampleCount = Symbol("[[sampleCount]]"); + const _dimension = Symbol("[[dimension]]"); + const _format = Symbol("[[format]]"); + const _type = Symbol("[[type]]"); + const _count = Symbol("[[count]]"); /** * @param {any} self @@ -175,10 +183,13 @@ } } + const illegalConstructorKey = Symbol("illegalConstructorKey"); class GPUError extends Error { - constructor() { + constructor(key = null) { super(); - webidl.illegalConstructor(); + if (key !== illegalConstructorKey) { + webidl.illegalConstructor(); + } } [_message]; @@ -189,34 +200,38 @@ } const GPUErrorPrototype = GPUError.prototype; - class GPUOutOfMemoryError extends GPUError { - name = "GPUOutOfMemoryError"; + class GPUValidationError extends GPUError { + name = "GPUValidationError"; + /** @param {string} message */ constructor(message) { - const prefix = "Failed to construct 'GPUOutOfMemoryError'"; + const prefix = "Failed to construct 'GPUValidationError'"; webidl.requiredArguments(arguments.length, 1, { prefix }); message = webidl.converters.DOMString(message, { prefix, context: "Argument 1", }); - super(message); + super(illegalConstructorKey); + this[webidl.brand] = webidl.brand; + this[_message] = message; } } - const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype; + const GPUValidationErrorPrototype = GPUValidationError.prototype; - class GPUValidationError extends GPUError { - name = "GPUValidationError"; - /** @param {string} message */ + class GPUOutOfMemoryError extends GPUError { + name = "GPUOutOfMemoryError"; constructor(message) { - const prefix = "Failed to construct 'GPUValidationError'"; + const prefix = "Failed to construct 'GPUOutOfMemoryError'"; webidl.requiredArguments(arguments.length, 1, { prefix }); message = webidl.converters.DOMString(message, { prefix, context: "Argument 1", }); - super(message); + super(illegalConstructorKey); + this[webidl.brand] = webidl.brand; + this[_message] = message; } } - const GPUValidationErrorPrototype = GPUValidationError.prototype; + const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype; class GPU { [webidl.brand] = webidl.brand; @@ -314,27 +329,24 @@ const requiredFeatures = descriptor.requiredFeatures ?? []; for (let i = 0; i < requiredFeatures.length; ++i) { const feature = requiredFeatures[i]; - if (!SetPrototypeHas(this[_adapter].features[_features], feature)) { + if ( + !SetPrototypeHas( + this[_adapter].features[webidl.setlikeInner], + feature, + ) + ) { throw new TypeError( - `${prefix}: nonGuaranteedFeatures must be a subset of the adapter features.`, + `${prefix}: requiredFeatures must be a subset of the adapter features.`, ); } } - let requiredLimits = descriptor.requiredLimits; - if (requiredLimits) { - requiredLimits = { - ...this[_adapter].limits[_limits], - ...requiredLimits, - }; - } - // TODO(lucacasonato): validate requiredLimits const { rid, features, limits } = await core.opAsync( "op_webgpu_request_device", this[_adapter].rid, descriptor.label, requiredFeatures, - requiredLimits, + descriptor.requiredLimits, ); const inner = new InnerGPUDevice({ @@ -344,9 +356,9 @@ limits: createGPUSupportedLimits(limits), }); return createGPUDevice( - descriptor.label ?? null, + descriptor.label, inner, - createGPUQueue(descriptor.label ?? null, inner), + createGPUQueue(descriptor.label, inner), ); } @@ -441,10 +453,10 @@ } const GPUAdapterInfoPrototype = GPUAdapterInfo.prototype; - function createGPUSupportedLimits(features) { + function createGPUSupportedLimits(limits) { /** @type {GPUSupportedLimits} */ const adapterFeatures = webidl.createBranded(GPUSupportedLimits); - adapterFeatures[_limits] = features; + adapterFeatures[_limits] = limits; return adapterFeatures; } @@ -505,6 +517,14 @@ webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxBindGroups; } + get maxBindingsPerBindGroup() { + webidl.assertBranded(this, GPUSupportedLimitsPrototype); + return this[_limits].maxBindingsPerBindGroup; + } + get maxBufferSize() { + webidl.assertBranded(this, GPUSupportedLimitsPrototype); + return this[_limits].maxBufferSize; + } get maxDynamicUniformBuffersPerPipelineLayout() { webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxDynamicUniformBuffersPerPipelineLayout; @@ -611,7 +631,6 @@ constructor() { webidl.illegalConstructor(); } - [SymbolFor("Deno.privateCustomInspect")](inspect) { return `${this.constructor.name} ${ inspect([...new SafeArrayIterator(this.values())]) @@ -923,7 +942,7 @@ }; } const buffer = createGPUBuffer( - descriptor.label ?? null, + descriptor.label, device, rid, descriptor.size, @@ -955,7 +974,7 @@ device.pushError(err); const texture = createGPUTexture( - descriptor.label ?? null, + descriptor, device, rid, ); @@ -975,14 +994,14 @@ context: "Argument 1", }); const device = assertDevice(this, { prefix, context: "this" }); - const { rid, err } = ops.op_webgpu_create_sampler({ + const { rid, err } = ops.op_webgpu_create_texture({ deviceRid: device.rid, ...descriptor, }); device.pushError(err); const sampler = createGPUSampler( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1006,13 +1025,13 @@ for (let i = 0; i < descriptor.entries.length; ++i) { const entry = descriptor.entries[i]; - let count = 0; - if (entry.buffer) count++; - if (entry.sampler) count++; - if (entry.texture) count++; - if (entry.storageTexture) count++; + let j = 0; + if (entry.buffer) j++; + if (entry.sampler) j++; + if (entry.texture) j++; + if (entry.storageTexture) j++; - if (count !== 1) { + if (j !== 1) { throw new Error(); // TODO(@crowlKats): correct error } } @@ -1025,7 +1044,7 @@ device.pushError(err); const bindGroupLayout = createGPUBindGroupLayout( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1067,7 +1086,7 @@ device.pushError(err); const pipelineLayout = createGPUPipelineLayout( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1162,7 +1181,7 @@ device.pushError(err); const bindGroup = createGPUBindGroup( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1186,12 +1205,11 @@ device.rid, descriptor.label, descriptor.code, - descriptor.sourceMap, ); device.pushError(err); const shaderModule = createGPUShaderModule( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1245,7 +1263,7 @@ device.pushError(err); const computePipeline = createGPUComputePipeline( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1320,7 +1338,7 @@ device.pushError(err); const renderPipeline = createGPURenderPipeline( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1357,7 +1375,7 @@ device.pushError(err); const commandEncoder = createGPUCommandEncoder( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1382,16 +1400,14 @@ }, ); const device = assertDevice(this, { prefix, context: "this" }); - const { rid, err } = ops.op_webgpu_create_render_bundle_encoder( - { - deviceRid: device.rid, - ...descriptor, - }, - ); + const { rid, err } = ops.op_webgpu_create_render_bundle_encoder({ + deviceRid: device.rid, + ...descriptor, + }); device.pushError(err); const renderBundleEncoder = createGPURenderBundleEncoder( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -1422,7 +1438,7 @@ device.pushError(err); const querySet = createGPUQuerySet( - descriptor.label ?? null, + descriptor.label, device, rid, descriptor, @@ -1523,7 +1539,7 @@ * @param {GPUCommandBuffer[]} commandBuffers */ submit(commandBuffers) { - webidl.assertBranded(this, GPUQueue.prototype); + webidl.assertBranded(this, GPUQueuePrototype); const prefix = "Failed to execute 'submit' on 'GPUQueue'"; webidl.requiredArguments(arguments.length, 1, { prefix, @@ -1546,10 +1562,7 @@ return rid; }, ); - const { err } = ops.op_webgpu_queue_submit( - device.rid, - commandBufferRids, - ); + const { err } = ops.op_webgpu_queue_submit(device.rid, commandBufferRids); for (let i = 0; i < commandBuffers.length; ++i) { commandBuffers[i][_rid] = undefined; } @@ -1557,7 +1570,7 @@ } onSubmittedWorkDone() { - webidl.assertBranded(this, GPUQueue.prototype); + webidl.assertBranded(this, GPUQueuePrototype); return PromiseResolve(); } @@ -1569,7 +1582,7 @@ * @param {number} [size] */ writeBuffer(buffer, bufferOffset, data, dataOffset = 0, size) { - webidl.assertBranded(this, GPUQueue.prototype); + webidl.assertBranded(this, GPUQueuePrototype); const prefix = "Failed to execute 'writeBuffer' on 'GPUQueue'"; webidl.requiredArguments(arguments.length, 3, { prefix }); buffer = webidl.converters["GPUBuffer"](buffer, { @@ -1622,7 +1635,7 @@ * @param {GPUExtent3D} size */ writeTexture(destination, data, dataLayout, size) { - webidl.assertBranded(this, GPUQueue.prototype); + webidl.assertBranded(this, GPUQueuePrototype); const prefix = "Failed to execute 'writeTexture' on 'GPUQueue'"; webidl.requiredArguments(arguments.length, 4, { prefix }); destination = webidl.converters.GPUImageCopyTexture(destination, { @@ -1681,6 +1694,7 @@ } } GPUObjectBaseMixin("GPUQueue", GPUQueue); + const GPUQueuePrototype = GPUQueue.prototype; /** * @typedef CreateGPUBufferOptions @@ -1716,25 +1730,18 @@ class GPUBuffer { /** @type {InnerGPUDevice} */ [_device]; - /** @type {number} */ [_rid]; - /** @type {number} */ [_size]; - /** @type {number} */ [_usage]; - - /** @type {"mapped" | "mapped at creation" | "mapped pending" | "unmapped" | "destroy"} */ + /** @type {"mapped" | "mapped at creation" | "pending" | "unmapped" | "destroy"} */ [_state]; - /** @type {[number, number] | null} */ [_mappingRange]; - /** @type {[ArrayBuffer, number, number][] | null} */ [_mappedRanges]; - /** @type {number} */ [_mapMode]; @@ -1761,13 +1768,33 @@ webidl.illegalConstructor(); } + get size() { + webidl.assertBranded(this, GPUBufferPrototype); + return this[_size]; + } + + get usage() { + webidl.assertBranded(this, GPUBufferPrototype); + return this[_usage]; + } + + get mapState() { + webidl.assertBranded(this, GPUBufferPrototype); + const state = this[_state]; + if (state === "mapped at creation") { + return "mapped"; + } else { + return state; + } + } + /** * @param {number} mode * @param {number} offset * @param {number} [size] */ async mapAsync(mode, offset = 0, size) { - webidl.assertBranded(this, GPUBuffer.prototype); + webidl.assertBranded(this, GPUBufferPrototype); const prefix = "Failed to execute 'mapAsync' on 'GPUBuffer'"; webidl.requiredArguments(arguments.length, 1, { prefix }); mode = webidl.converters.GPUMapModeFlags(mode, { @@ -1839,7 +1866,7 @@ } this[_mapMode] = mode; - this[_state] = "mapping pending"; + this[_state] = "pending"; const promise = PromisePrototypeThen( core.opAsync( "op_webgpu_buffer_get_map_async", @@ -1867,7 +1894,7 @@ * @param {number} size */ getMappedRange(offset = 0, size) { - webidl.assertBranded(this, GPUBuffer.prototype); + webidl.assertBranded(this, GPUBufferPrototype); const prefix = "Failed to execute 'getMappedRange' on 'GPUBuffer'"; offset = webidl.converters.GPUSize64(offset, { prefix, @@ -1922,7 +1949,7 @@ } unmap() { - webidl.assertBranded(this, GPUBuffer.prototype); + webidl.assertBranded(this, GPUBufferPrototype); const prefix = "Failed to execute 'unmap' on 'GPUBuffer'"; const device = assertDevice(this, { prefix, context: "this" }); const bufferRid = assertResource(this, { prefix, context: "this" }); @@ -1932,7 +1959,7 @@ "OperationError", ); } - if (this[_state] === "mapping pending") { + if (this[_state] === "pending") { // TODO(lucacasonato): this is not spec compliant. throw new DOMException( `${prefix}: can not unmap while mapping. This is a Deno limitation.`, @@ -1980,7 +2007,7 @@ } destroy() { - webidl.assertBranded(this, GPUBuffer.prototype); + webidl.assertBranded(this, GPUBufferPrototype); this[_cleanup](); } @@ -1993,6 +2020,7 @@ } } GPUObjectBaseMixin("GPUBuffer", GPUBuffer); + const GPUBufferPrototype = GPUBuffer.prototype; class GPUBufferUsage { constructor() { @@ -2045,18 +2073,26 @@ } /** - * @param {string | null} label + * @param {GPUTextureDescriptor} descriptor * @param {InnerGPUDevice} device * @param {number} rid * @returns {GPUTexture} */ - function createGPUTexture(label, device, rid) { + function createGPUTexture(descriptor, device, rid) { /** @type {GPUTexture} */ const texture = webidl.createBranded(GPUTexture); - texture[_label] = label; + texture[_label] = descriptor.label; texture[_device] = device; texture[_rid] = rid; texture[_views] = []; + texture[_width] = descriptor.size.width; + texture[_height] = descriptor.size.height; + texture[_depthOrArrayLayers] = descriptor.size.depthOrArrayLayers; + texture[_mipLevelCount] = descriptor.mipLevelCount; + texture[_sampleCount] = descriptor.sampleCount; + texture[_dimension] = descriptor.dimension; + texture[_format] = descriptor.format; + texture[_usage] = descriptor.usage; return texture; } @@ -2068,6 +2104,23 @@ /** @type {WeakRef<GPUTextureView>[]} */ [_views]; + /** @type {number} */ + [_width]; + /** @type {number} */ + [_height]; + /** @type {number} */ + [_depthOrArrayLayers]; + /** @type {number} */ + [_mipLevelCount]; + /** @type {number} */ + [_sampleCount]; + /** @type {GPUTextureDimension} */ + [_dimension]; + /** @type {GPUTextureFormat} */ + [_format]; + /** @type {number} */ + [_usage]; + [_cleanup]() { const views = this[_views]; while (views.length > 0) { @@ -2092,7 +2145,7 @@ * @param {GPUTextureViewDescriptor} descriptor */ createView(descriptor = {}) { - webidl.assertBranded(this, GPUTexture.prototype); + webidl.assertBranded(this, GPUTexturePrototype); const prefix = "Failed to execute 'createView' on 'GPUTexture'"; webidl.requiredArguments(arguments.length, 0, { prefix }); descriptor = webidl.converters.GPUTextureViewDescriptor(descriptor, { @@ -2108,7 +2161,7 @@ device.pushError(err); const textureView = createGPUTextureView( - descriptor.label ?? null, + descriptor.label, this, rid, ); @@ -2117,10 +2170,50 @@ } destroy() { - webidl.assertBranded(this, GPUTexture.prototype); + webidl.assertBranded(this, GPUTexturePrototype); this[_cleanup](); } + get width() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_width]; + } + + get height() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_height]; + } + + get depthOrArrayLayers() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_depthOrArrayLayers]; + } + + get mipLevelCount() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_mipLevelCount]; + } + + get sampleCount() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_sampleCount]; + } + + get dimension() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_dimension]; + } + + get format() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_format]; + } + + get usage() { + webidl.assertBranded(this, GPUTexturePrototype); + return this[_usage]; + } + [SymbolFor("Deno.privateCustomInspect")](inspect) { return `${this.constructor.name} ${ inspect({ @@ -2130,6 +2223,7 @@ } } GPUObjectBaseMixin("GPUTexture", GPUTexture); + const GPUTexturePrototype = GPUTexture.prototype; class GPUTextureUsage { constructor() { @@ -2763,7 +2857,7 @@ ); const renderPassEncoder = createGPURenderPassEncoder( - descriptor.label ?? null, + descriptor.label, this, rid, ); @@ -2795,7 +2889,7 @@ ); const computePassEncoder = createGPUComputePassEncoder( - descriptor.label ?? null, + descriptor.label, this, rid, ); @@ -3310,7 +3404,7 @@ this[_rid] = undefined; const commandBuffer = createGPUCommandBuffer( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -3573,9 +3667,7 @@ context: "encoder referenced by this", }); const renderPassRid = assertResource(this, { prefix, context: "this" }); - ops.op_webgpu_render_pass_end_pipeline_statistics_query( - renderPassRid, - ); + ops.op_webgpu_render_pass_end_pipeline_statistics_query(renderPassRid); } /** @@ -3651,10 +3743,7 @@ }); return rid; }); - ops.op_webgpu_render_pass_execute_bundles( - renderPassRid, - bundleRids, - ); + ops.op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids); } end() { @@ -3747,10 +3836,7 @@ context: "encoder referenced by this", }); const renderPassRid = assertResource(this, { prefix, context: "this" }); - ops.op_webgpu_render_pass_push_debug_group( - renderPassRid, - groupLabel, - ); + ops.op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel); } popDebugGroup() { @@ -3790,10 +3876,7 @@ context: "encoder referenced by this", }); const renderPassRid = assertResource(this, { prefix, context: "this" }); - ops.op_webgpu_render_pass_insert_debug_marker( - renderPassRid, - markerLabel, - ); + ops.op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel); } /** @@ -3826,10 +3909,7 @@ resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_pass_set_pipeline( - renderPassRid, - pipelineRid, - ); + ops.op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid); } /** @@ -4205,10 +4285,7 @@ resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_compute_pass_set_pipeline( - computePassRid, - pipelineRid, - ); + ops.op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid); } /** @@ -4351,9 +4428,7 @@ context: "encoder referenced by this", }); const computePassRid = assertResource(this, { prefix, context: "this" }); - ops.op_webgpu_compute_pass_end_pipeline_statistics_query( - computePassRid, - ); + ops.op_webgpu_compute_pass_end_pipeline_statistics_query(computePassRid); } /** @@ -4488,10 +4563,7 @@ context: "encoder referenced by this", }); const computePassRid = assertResource(this, { prefix, context: "this" }); - ops.op_webgpu_compute_pass_push_debug_group( - computePassRid, - groupLabel, - ); + ops.op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel); } popDebugGroup() { @@ -4630,7 +4702,7 @@ * @param {GPURenderBundleDescriptor} descriptor */ finish(descriptor = {}) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'finish' on 'GPURenderBundleEncoder'"; descriptor = webidl.converters.GPURenderBundleDescriptor(descriptor, { prefix, @@ -4649,7 +4721,7 @@ this[_rid] = undefined; const renderBundle = createGPURenderBundle( - descriptor.label ?? null, + descriptor.label, device, rid, ); @@ -4665,7 +4737,7 @@ dynamicOffsetsDataStart, dynamicOffsetsDataLength, ) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'setBindGroup' on 'GPURenderBundleEncoder'"; const device = assertDevice(this, { prefix, context: "this" }); @@ -4706,7 +4778,7 @@ * @param {string} groupLabel */ pushDebugGroup(groupLabel) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'pushDebugGroup' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -4726,7 +4798,7 @@ } popDebugGroup() { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'"; assertDevice(this, { prefix, context: "this" }); @@ -4743,7 +4815,7 @@ * @param {string} markerLabel */ insertDebugMarker(markerLabel) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'insertDebugMarker' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -4766,7 +4838,7 @@ * @param {GPURenderPipeline} pipeline */ setPipeline(pipeline) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'setPipeline' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -4801,7 +4873,7 @@ * @param {number} size */ setIndexBuffer(buffer, indexFormat, offset = 0, size = 0) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'setIndexBuffer' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 2, { prefix }); @@ -4851,7 +4923,7 @@ * @param {number} size */ setVertexBuffer(slot, buffer, offset = 0, size = 0) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'setVertexBuffer' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 2, { prefix }); @@ -4901,7 +4973,7 @@ * @param {number} firstInstance */ draw(vertexCount, instanceCount = 1, firstVertex = 0, firstInstance = 0) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'draw' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); vertexCount = webidl.converters.GPUSize32(vertexCount, { @@ -4948,7 +5020,7 @@ baseVertex = 0, firstInstance = 0, ) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'drawIndexed' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -4992,7 +5064,7 @@ * @param {number} indirectOffset */ drawIndirect(indirectBuffer, indirectOffset) { - webidl.assertBranded(this, GPURenderBundleEncoder.prototype); + webidl.assertBranded(this, GPURenderBundleEncoderPrototype); const prefix = "Failed to execute 'drawIndirect' on 'GPURenderBundleEncoder'"; webidl.requiredArguments(arguments.length, 2, { prefix }); @@ -5038,6 +5110,7 @@ } } GPUObjectBaseMixin("GPURenderBundleEncoder", GPURenderBundleEncoder); + const GPURenderBundleEncoderPrototype = GPURenderBundleEncoder.prototype; /** * @param {string | null} label @@ -5106,6 +5179,10 @@ [_rid]; /** @type {GPUQuerySetDescriptor} */ [_descriptor]; + /** @type {GPUQueryType} */ + [_type]; + /** @type {number} */ + [_count]; [_cleanup]() { const rid = this[_rid]; @@ -5125,6 +5202,16 @@ this[_cleanup](); } + get type() { + webidl.assertBranded(this, GPUQuerySetPrototype); + return this[_type](); + } + + get count() { + webidl.assertBranded(this, GPUQuerySetPrototype); + return this[_count](); + } + [SymbolFor("Deno.privateCustomInspect")](inspect) { return `${this.constructor.name} ${ inspect({ @@ -5137,12 +5224,17 @@ const GPUQuerySetPrototype = GPUQuerySet.prototype; window.__bootstrap.webgpu = { + _device, + assertDevice, + createGPUTexture, gpu: webidl.createBranded(GPU), GPU, GPUAdapter, + GPUAdapterInfo, GPUSupportedLimits, GPUSupportedFeatures, GPUDevice, + GPUDeviceLostInfo, GPUQueue, GPUBuffer, GPUBufferUsage, @@ -5167,7 +5259,7 @@ GPURenderBundle, GPUQuerySet, GPUError, - GPUOutOfMemoryError, GPUValidationError, + GPUOutOfMemoryError, }; })(this); |