From 92ca0f02587822871311602f699b509c0e84b3a3 Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 00:59:19 +0800 Subject: [PATCH 1/7] GPUDeviceYouHua --- src/WebGPU.ts | 10 ++- src/youhua/GPUDeviceYouHua.ts | 122 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/youhua/GPUDeviceYouHua.ts diff --git a/src/WebGPU.ts b/src/WebGPU.ts index 1efe9ed..6922d3e 100644 --- a/src/WebGPU.ts +++ b/src/WebGPU.ts @@ -15,6 +15,7 @@ import { copyDepthTexture } from "./utils/copyDepthTexture"; import { quitIfWebGPUNotAvailable } from "./utils/quitIfWebGPUNotAvailable"; import { readPixels } from "./utils/readPixels"; import { textureInvertYPremultiplyAlpha } from "./utils/textureInvertYPremultiplyAlpha"; +import { GPUDeviceYouHua } from "./youhua/GPUDeviceYouHua"; /** * WebGPU 对象。 @@ -23,6 +24,13 @@ import { textureInvertYPremultiplyAlpha } from "./utils/textureInvertYPremultipl */ export class WebGPU { + private _是否优化: boolean; + + constructor(是否优化 = true) + { + this._是否优化 = 是否优化; + } + /** * 初始化 WebGPU 获取 GPUDevice 。 */ @@ -44,7 +52,7 @@ export class WebGPU } }); - this.device = device; + this.device = this._是否优化 ? new GPUDeviceYouHua(device) : device; return this; } diff --git a/src/youhua/GPUDeviceYouHua.ts b/src/youhua/GPUDeviceYouHua.ts new file mode 100644 index 0000000..96862cc --- /dev/null +++ b/src/youhua/GPUDeviceYouHua.ts @@ -0,0 +1,122 @@ +((configure) => +{ + GPUCanvasContext.prototype.configure = function (configuration: GPUCanvasConfiguration) + { + if (configuration.device.constructor.name !== "GPUDevice") + { + configuration.device = configuration.device['_device']; + console.assert(configuration.device.constructor.name === "GPUDevice"); + } + + configure.call(this, configuration); + }; +})(GPUCanvasContext.prototype.configure); + +/** + * 优化性能 + */ +export class GPUDeviceYouHua implements GPUDevice +{ + get __brand() { return this._device.__brand; } + get features() { return this._device.features; } + get limits() { return this._device.limits; } + get queue() { return this._device.queue; } + get label() { return this._device.label; } + get lost() { return this._device.lost; } + + get onuncapturederror() { return this._device.onuncapturederror; } + set onuncapturederror(v) { this._device.onuncapturederror = v; } + + // + private _device: GPUDevice; + + constructor(device: GPUDevice) + { + this._device = device; + } + + destroy(): undefined + { + return this._device.destroy(); + } + createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer + { + return this._device.createBuffer(descriptor); + } + createTexture(descriptor: GPUTextureDescriptor): GPUTexture + { + return this._device.createTexture(descriptor); + } + createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler + { + return this._device.createSampler(descriptor); + } + importExternalTexture(descriptor: GPUExternalTextureDescriptor): GPUExternalTexture + { + return this._device.importExternalTexture(descriptor); + } + createBindGroupLayout(descriptor: GPUBindGroupLayoutDescriptor): GPUBindGroupLayout + { + return this._device.createBindGroupLayout(descriptor); + } + createPipelineLayout(descriptor: GPUPipelineLayoutDescriptor): GPUPipelineLayout + { + return this._device.createPipelineLayout(descriptor); + } + createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup + { + return this._device.createBindGroup(descriptor); + } + createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule + { + return this._device.createShaderModule(descriptor); + } + createComputePipeline(descriptor: GPUComputePipelineDescriptor): GPUComputePipeline + { + return this._device.createComputePipeline(descriptor); + } + createRenderPipeline(descriptor: GPURenderPipelineDescriptor): GPURenderPipeline + { + return this._device.createRenderPipeline(descriptor); + } + createComputePipelineAsync(descriptor: GPUComputePipelineDescriptor): Promise + { + return this._device.createComputePipelineAsync(descriptor); + } + createRenderPipelineAsync(descriptor: GPURenderPipelineDescriptor): Promise + { + return this._device.createRenderPipelineAsync(descriptor); + } + createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): GPUCommandEncoder + { + return this._device.createCommandEncoder(descriptor); + } + createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): GPURenderBundleEncoder + { + return this._device.createRenderBundleEncoder(descriptor); + } + createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet + { + return this._device.createQuerySet(descriptor); + } + pushErrorScope(filter: GPUErrorFilter): undefined + { + return this._device.pushErrorScope(filter); + } + popErrorScope(): Promise + { + return this._device.popErrorScope(); + } + addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void + { + return this._device.addEventListener(type, callback, options); + } + dispatchEvent(event: Event): boolean + { + return this._device.dispatchEvent(event); + } + removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void + { + return this._device.removeEventListener(type, callback, options); + } +} \ No newline at end of file -- Gitee From d615904538697664bd6420b6ca65f5cb1deb3421 Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 01:00:33 +0800 Subject: [PATCH 2/7] GPUDeviceYouHua --- src/youhua/GPUDeviceYouHua.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/youhua/GPUDeviceYouHua.ts b/src/youhua/GPUDeviceYouHua.ts index 96862cc..e8d8d6d 100644 --- a/src/youhua/GPUDeviceYouHua.ts +++ b/src/youhua/GPUDeviceYouHua.ts @@ -1,17 +1,3 @@ -((configure) => -{ - GPUCanvasContext.prototype.configure = function (configuration: GPUCanvasConfiguration) - { - if (configuration.device.constructor.name !== "GPUDevice") - { - configuration.device = configuration.device['_device']; - console.assert(configuration.device.constructor.name === "GPUDevice"); - } - - configure.call(this, configuration); - }; -})(GPUCanvasContext.prototype.configure); - /** * 优化性能 */ @@ -119,4 +105,19 @@ export class GPUDeviceYouHua implements GPUDevice { return this._device.removeEventListener(type, callback, options); } -} \ No newline at end of file +} + +// 处理 configure 函数,兼容 GPUDeviceYouHua +((configure) => +{ + GPUCanvasContext.prototype.configure = function (configuration: GPUCanvasConfiguration) + { + if (configuration.device.constructor.name !== "GPUDevice") + { + configuration.device = configuration.device['_device']; + console.assert(configuration.device.constructor.name === "GPUDevice"); + } + + configure.call(this, configuration); + }; +})(GPUCanvasContext.prototype.configure); -- Gitee From 11b52abe1d59667ba5d03ad00eb47c4e882d5512 Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 03:04:22 +0800 Subject: [PATCH 3/7] getGPURenderPassDescriptor --- src/caches/getGPURenderPassDescriptor.ts | 199 ++++++++++++++--------- src/caches/getGPUTexture.ts | 9 +- src/eventnames.ts | 1 + 3 files changed, 125 insertions(+), 84 deletions(-) diff --git a/src/caches/getGPURenderPassDescriptor.ts b/src/caches/getGPURenderPassDescriptor.ts index b8cc512..440fef3 100644 --- a/src/caches/getGPURenderPassDescriptor.ts +++ b/src/caches/getGPURenderPassDescriptor.ts @@ -1,9 +1,11 @@ +import { anyEmitter } from "@feng3d/event"; import { watcher } from "@feng3d/watcher"; import { IGPURenderPassColorAttachment } from "../data/IGPURenderPassColorAttachment"; import { IGPURenderPassDepthStencilAttachment } from "../data/IGPURenderPassDepthStencilAttachment"; import { IGPURenderPassDescriptor } from "../data/IGPURenderPassDescriptor"; import { IGPUTexture, IGPUTextureBase, IGPUTextureFromContext } from "../data/IGPUTexture"; import { IGPUTextureView } from "../data/IGPUTextureView"; +import { IGPUTexture_resize } from "../eventnames"; import { getGPUTextureFormat } from "./getGPUTextureFormat"; import { getGPUTextureSize } from "./getGPUTextureSize"; import { getGPUTextureView } from "./getGPUTextureView"; @@ -17,48 +19,89 @@ import { getGPUTextureView } from "./getGPUTextureView"; */ export function getGPURenderPassDescriptor(device: GPUDevice, descriptor: IGPURenderPassDescriptor): GPURenderPassDescriptor { + const renderPassDescriptorMap: Map = device["_RenderPassDescriptorMap"] = device["_RenderPassDescriptorMap"] || new Map(); + let renderPassDescriptor = renderPassDescriptorMap.get(descriptor); + if (renderPassDescriptor) + { + // 执行更新函数。 + (renderPassDescriptor["_updates"] as Function[]).forEach((v) => v()); + return renderPassDescriptor; + } + + renderPassDescriptor = { colorAttachments: [], }; + renderPassDescriptorMap.set(descriptor, renderPassDescriptor); + + const _updates: Function[] = renderPassDescriptor["_updates"] = []; + descriptor = getIGPURenderPassDescriptor(descriptor); - const renderPassDescriptor: GPURenderPassDescriptor = { - colorAttachments: [], - }; if (descriptor.colorAttachments) { descriptor.colorAttachments.forEach((v, i) => { if (!v) return; - const view = getGPUTextureView(device, v.view); + const { clearValue, loadOp, storeOp } = v; - let resolveTarget: GPUTextureView; - if (v.resolveTarget) - { - resolveTarget = getGPUTextureView(device, v.resolveTarget); - } - const loadOp = v.loadOp; - const storeOp = v.storeOp; const attachment: GPURenderPassColorAttachment = { ...v, - view, - resolveTarget, + view: undefined, + resolveTarget: undefined, + clearValue, loadOp, storeOp, }; + const updateView = () => + { + attachment.view = getGPUTextureView(device, v.view); + }; + updateView(); + + // + if ((v.view.texture as IGPUTextureFromContext).context) + { + _updates.push(updateView); + } + anyEmitter.on(v.view.texture, IGPUTexture_resize, updateView); + + // + if (v.resolveTarget) + { + const updateResolveTarget = () => + { + attachment.resolveTarget = getGPUTextureView(device, v.resolveTarget); + }; + updateResolveTarget(); + // + if ((v.resolveTarget?.texture as IGPUTextureFromContext)?.context) + { + _updates.push(updateResolveTarget); + } + anyEmitter.on(v.resolveTarget.texture, IGPUTexture_resize, updateResolveTarget); + } + + // renderPassDescriptor.colorAttachments[i] = attachment; }); } if (descriptor.depthStencilAttachment) { - const depthStencilAttachment = descriptor.depthStencilAttachment; - - const view = getGPUTextureView(device, depthStencilAttachment.view); + const v = descriptor.depthStencilAttachment; renderPassDescriptor.depthStencilAttachment = { - ...depthStencilAttachment, - view, + ...v, + view: undefined, }; + + const updateView = () => + { + renderPassDescriptor.depthStencilAttachment.view = getGPUTextureView(device, v.view); + }; + updateView(); + + anyEmitter.on(v.view.texture, IGPUTexture_resize, updateView); } return renderPassDescriptor; @@ -73,38 +116,37 @@ export function getGPURenderPassDescriptor(device: GPUDevice, descriptor: IGPURe function getIGPURenderPassDescriptor(renderPass: IGPURenderPassDescriptor) { let iGPURenderPass = renderPassMap.get(renderPass); - if (!iGPURenderPass) - { - // 更新渲染通道附件尺寸,使得附件上纹理尺寸一致。 - updateAttachmentSize(renderPass); + if (iGPURenderPass) return iGPURenderPass; - // 获取颜色附件完整描述列表。 - const colorAttachments = getIGPURenderPassColorAttachments(renderPass.colorAttachments, renderPass.multisample); + // 更新渲染通道附件尺寸,使得附件上纹理尺寸一致。 + updateAttachmentSize(renderPass); - // 获取深度模板附件 - const depthStencilAttachment = getIGPURenderPassDepthStencilAttachment(renderPass.depthStencilAttachment, renderPass.attachmentSize, renderPass.multisample); + // 获取颜色附件完整描述列表。 + const colorAttachments = getIGPURenderPassColorAttachments(renderPass.colorAttachments, renderPass.multisample); - // 附件尺寸变化时,渲染通道描述失效。 - const watchProperty = { attachmentSize: { width: 0, height: 0 } }; // 被监听的属性 - watcher.watchobject(renderPass, watchProperty, () => - { - // 更新所有纹理描述中的尺寸 - updateAttachmentSize(renderPass); - // 更新所有纹理尺寸 - const iGPURenderPass = renderPassMap.get(renderPass); - // 由于深度纹理与多重采样纹理可能是引擎自动生成的,这部分纹理需要更新。 - updateIGPURenderPassAttachmentSize(iGPURenderPass, renderPass.attachmentSize); - }); + // 获取深度模板附件 + const depthStencilAttachment = getIGPURenderPassDepthStencilAttachment(renderPass.depthStencilAttachment, renderPass.attachmentSize, renderPass.multisample); - // - iGPURenderPass = { - ...renderPass, - colorAttachments, - depthStencilAttachment, - }; + // 附件尺寸变化时,渲染通道描述失效。 + const watchProperty = { attachmentSize: { width: 0, height: 0 } }; // 被监听的属性 + watcher.watchobject(renderPass, watchProperty, () => + { + // 更新所有纹理描述中的尺寸 + updateAttachmentSize(renderPass); + // 更新所有纹理尺寸 + const iGPURenderPass = renderPassMap.get(renderPass); + // 由于深度纹理与多重采样纹理可能是引擎自动生成的,这部分纹理需要更新。 + updateIGPURenderPassAttachmentSize(iGPURenderPass, renderPass.attachmentSize); + }); - renderPassMap.set(renderPass, iGPURenderPass); - } + // + iGPURenderPass = { + ...renderPass, + colorAttachments, + depthStencilAttachment, + }; + + renderPassMap.set(renderPass, iGPURenderPass); return iGPURenderPass; } @@ -275,43 +317,42 @@ const multisampleTextureMap = new WeakMap(); function getIGPURenderPassDepthStencilAttachment(depthStencilAttachment: IGPURenderPassDepthStencilAttachment, attachmentSize: { width: number, height: number }, multisample: number) { let gpuDepthStencilAttachment: IGPURenderPassDepthStencilAttachment; - if (depthStencilAttachment) - { - let view = depthStencilAttachment.view; - if (!view) - { - view = { - texture: { - label: `自动生成的深度纹理`, - size: [attachmentSize.width, attachmentSize.height], - format: "depth24plus", - usage: GPUTextureUsage.RENDER_ATTACHMENT, - } - }; - } + if (!depthStencilAttachment) return undefined; - let resolveTarget = depthStencilAttachment.resolveTarget; - if (multisample && !resolveTarget) - { - resolveTarget = view; - view = getMultisampleTextureView(view.texture, multisample); - } - - const depthClearValue = depthStencilAttachment.depthClearValue; - const depthLoadOp = depthStencilAttachment.depthLoadOp; - const depthStoreOp = depthStencilAttachment.depthStoreOp; - - // - gpuDepthStencilAttachment = { - ...depthStencilAttachment, - view, - resolveTarget, - depthClearValue, - depthLoadOp, - depthStoreOp, + let view = depthStencilAttachment.view; + if (!view) + { + view = { + texture: { + label: `自动生成的深度纹理`, + size: [attachmentSize.width, attachmentSize.height], + format: "depth24plus", + usage: GPUTextureUsage.RENDER_ATTACHMENT, + } }; } + let resolveTarget = depthStencilAttachment.resolveTarget; + if (multisample && !resolveTarget) + { + resolveTarget = view; + view = getMultisampleTextureView(view.texture, multisample); + } + + const depthClearValue = depthStencilAttachment.depthClearValue; + const depthLoadOp = depthStencilAttachment.depthLoadOp; + const depthStoreOp = depthStencilAttachment.depthStoreOp; + + // + gpuDepthStencilAttachment = { + ...depthStencilAttachment, + view, + resolveTarget, + depthClearValue, + depthLoadOp, + depthStoreOp, + }; + return gpuDepthStencilAttachment; } @@ -371,7 +412,7 @@ function updateAttachmentSize(renderPass: IGPURenderPassDescriptor) * @param texture 纹理描述。 * @param attachmentSize 附件尺寸。 */ -function setITextureSize(texture: IGPUTexture, attachmentSize: {width: number, height: number}) +function setITextureSize(texture: IGPUTexture, attachmentSize: { width: number, height: number }) { if ((texture as IGPUTextureFromContext).context) { diff --git a/src/caches/getGPUTexture.ts b/src/caches/getGPUTexture.ts index 3a73fec..61c9db8 100644 --- a/src/caches/getGPUTexture.ts +++ b/src/caches/getGPUTexture.ts @@ -1,9 +1,9 @@ import { anyEmitter } from "@feng3d/event"; import { watcher } from "@feng3d/watcher"; import { IGPUTexture, IGPUTextureBase, IGPUTextureFromContext } from "../data/IGPUTexture"; +import { GPUTexture_destroy, IGPUTexture_resize } from "../eventnames"; import { generateMipmap } from "../utils/generate-mipmap"; import { getGPUCanvasContext } from "./getGPUCanvasContext"; -import { GPUTexture_destroy } from "../eventnames"; /** * 获取GPU纹理 {@link GPUTexture} 。 @@ -16,10 +16,7 @@ export function getGPUTexture(device: GPUDevice, texture: IGPUTexture, autoCreat { const textureMap: Map = device["textureMap"] = device["textureMap"] || new Map(); let gpuTexture = textureMap.get(texture); - if (gpuTexture) - { - return gpuTexture; - } + if (gpuTexture) return gpuTexture; if ((texture as IGPUTextureFromContext).context) { @@ -120,6 +117,8 @@ export function getGPUTexture(device: GPUDevice, texture: IGPUTexture, autoCreat } gpuTexture.destroy(); + // + anyEmitter.emit(texture, IGPUTexture_resize); }; watcher.watch(iGPUTextureBase, "size", resize); diff --git a/src/eventnames.ts b/src/eventnames.ts index bbdee60..9eed9cb 100644 --- a/src/eventnames.ts +++ b/src/eventnames.ts @@ -10,3 +10,4 @@ export const GPUTextureView_destroy = "GPUTextureView_destroy"; export const GPUQueue_submit = "GPUQueue_submit"; +export const IGPUTexture_resize = "IGPUTexture_resize"; \ No newline at end of file -- Gitee From 6fbbfc1c9cc42cf61aa72e02d8dabceebcb695eb Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 15:15:40 +0800 Subject: [PATCH 4/7] GPURenderPassEncoderYouHua --- src/youhua/GPUCommandEncoderYouHua.ts | 67 +++++++++++++++++ src/youhua/GPUDeviceYouHua.ts | 5 +- src/youhua/GPURenderPassEncoderYouHua.ts | 92 ++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/youhua/GPUCommandEncoderYouHua.ts create mode 100644 src/youhua/GPURenderPassEncoderYouHua.ts diff --git a/src/youhua/GPUCommandEncoderYouHua.ts b/src/youhua/GPUCommandEncoderYouHua.ts new file mode 100644 index 0000000..88033df --- /dev/null +++ b/src/youhua/GPUCommandEncoderYouHua.ts @@ -0,0 +1,67 @@ +import { GPURenderPassEncoderYouHua } from "./GPURenderPassEncoderYouHua"; + +export class GPUCommandEncoderYouHua implements GPUCommandEncoder +{ + get __brand() { return this._commandEncoder.__brand; } + get label() { return this._commandEncoder.label; } + set label(v) { this._commandEncoder.label = v; } + + private _commandEncoder: GPUCommandEncoder; + + constructor(commandEncoder: GPUCommandEncoder) + { + this._commandEncoder = commandEncoder; + } + + beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder + { + const renderPassEncoder = this._commandEncoder.beginRenderPass(descriptor); + + return new GPURenderPassEncoderYouHua(renderPassEncoder); + } + + beginComputePass(descriptor?: GPUComputePassDescriptor): GPUComputePassEncoder + { + return this._commandEncoder.beginComputePass(descriptor); + } + copyBufferToBuffer(source: GPUBuffer, sourceOffset: GPUSize64, destination: GPUBuffer, destinationOffset: GPUSize64, size: GPUSize64): undefined + { + return this._commandEncoder.copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size); + } + copyBufferToTexture(source: GPUImageCopyBuffer, destination: GPUImageCopyTexture, copySize: GPUExtent3DStrict): undefined + { + return this._commandEncoder.copyBufferToTexture(source, destination, copySize); + } + copyTextureToBuffer(source: GPUImageCopyTexture, destination: GPUImageCopyBuffer, copySize: GPUExtent3DStrict): undefined + { + return this._commandEncoder.copyTextureToBuffer(source, destination, copySize); + } + copyTextureToTexture(source: GPUImageCopyTexture, destination: GPUImageCopyTexture, copySize: GPUExtent3DStrict): undefined + { + return this._commandEncoder.copyTextureToTexture(source, destination, copySize); + } + clearBuffer(buffer: GPUBuffer, offset?: GPUSize64, size?: GPUSize64): undefined + { + return this._commandEncoder.clearBuffer(buffer, offset, size); + } + resolveQuerySet(querySet: GPUQuerySet, firstQuery: GPUSize32, queryCount: GPUSize32, destination: GPUBuffer, destinationOffset: GPUSize64): undefined + { + return this._commandEncoder.resolveQuerySet(querySet, firstQuery, queryCount, destination, destinationOffset); + } + finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer + { + return this._commandEncoder.finish(descriptor); + } + pushDebugGroup(groupLabel: string): undefined + { + return this._commandEncoder.pushDebugGroup(groupLabel); + } + popDebugGroup(): undefined + { + return this._commandEncoder.popDebugGroup(); + } + insertDebugMarker(markerLabel: string): undefined + { + return this._commandEncoder.insertDebugMarker(markerLabel); + } +} \ No newline at end of file diff --git a/src/youhua/GPUDeviceYouHua.ts b/src/youhua/GPUDeviceYouHua.ts index e8d8d6d..d73f3c1 100644 --- a/src/youhua/GPUDeviceYouHua.ts +++ b/src/youhua/GPUDeviceYouHua.ts @@ -1,3 +1,5 @@ +import { GPUCommandEncoderYouHua } from "./GPUCommandEncoderYouHua"; + /** * 优化性能 */ @@ -75,7 +77,8 @@ export class GPUDeviceYouHua implements GPUDevice } createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): GPUCommandEncoder { - return this._device.createCommandEncoder(descriptor); + const commandEncoder = this._device.createCommandEncoder(descriptor); + return new GPUCommandEncoderYouHua(commandEncoder); } createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): GPURenderBundleEncoder { diff --git a/src/youhua/GPURenderPassEncoderYouHua.ts b/src/youhua/GPURenderPassEncoderYouHua.ts new file mode 100644 index 0000000..ecfc44e --- /dev/null +++ b/src/youhua/GPURenderPassEncoderYouHua.ts @@ -0,0 +1,92 @@ +export class GPURenderPassEncoderYouHua implements GPURenderPassEncoder +{ + get __brand() { return this._renderPassEncoder.__brand; } + get label() { return this._renderPassEncoder.label; } + set label(v) { this._renderPassEncoder.label = v; } + + private _renderPassEncoder: GPURenderPassEncoder; + + constructor(renderPassEncoder: GPURenderPassEncoder) + { + this._renderPassEncoder = renderPassEncoder; + } + + setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): undefined + { + return this._renderPassEncoder.setViewport(x, y, width, height, minDepth, maxDepth); + } + setScissorRect(x: GPUIntegerCoordinate, y: GPUIntegerCoordinate, width: GPUIntegerCoordinate, height: GPUIntegerCoordinate): undefined + { + return this._renderPassEncoder.setScissorRect(x, y, width, height); + } + setBlendConstant(color: GPUColor): undefined + { + return this._renderPassEncoder.setBlendConstant(color); + } + setStencilReference(reference: GPUStencilValue): undefined + { + return this._renderPassEncoder.setStencilReference(reference); + } + beginOcclusionQuery(queryIndex: GPUSize32): undefined + { + return this._renderPassEncoder.beginOcclusionQuery(queryIndex); + } + endOcclusionQuery(): undefined + { + return this._renderPassEncoder.endOcclusionQuery(); + } + executeBundles(bundles: Iterable): undefined + { + return this._renderPassEncoder.executeBundles(bundles); + } + end(): undefined + { + return this._renderPassEncoder.end(); + } + pushDebugGroup(groupLabel: string): undefined + { + return this._renderPassEncoder.pushDebugGroup(groupLabel); + } + popDebugGroup(): undefined + { + return this._renderPassEncoder.popDebugGroup(); + } + insertDebugMarker(markerLabel: string): undefined + { + return this._renderPassEncoder.insertDebugMarker(markerLabel); + } + setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsets?: Iterable): undefined; + setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsetsData: Uint32Array, dynamicOffsetsDataStart: GPUSize64, dynamicOffsetsDataLength: GPUSize32): undefined; + setBindGroup(...args: any[]): undefined + { + return this._renderPassEncoder.setBindGroup.apply(this._renderPassEncoder, args); + } + setPipeline(pipeline: GPURenderPipeline): undefined + { + return this._renderPassEncoder.setPipeline(pipeline); + } + setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): undefined + { + return this._renderPassEncoder.setIndexBuffer(buffer, indexFormat, offset, size); + } + setVertexBuffer(slot: GPUIndex32, buffer: GPUBuffer | null, offset?: GPUSize64, size?: GPUSize64): undefined + { + return this._renderPassEncoder.setVertexBuffer(slot, buffer, offset, size); + } + draw(vertexCount: GPUSize32, instanceCount?: GPUSize32, firstVertex?: GPUSize32, firstInstance?: GPUSize32): undefined + { + return this._renderPassEncoder.draw(vertexCount, instanceCount, firstVertex, firstInstance); + } + drawIndexed(indexCount: GPUSize32, instanceCount?: GPUSize32, firstIndex?: GPUSize32, baseVertex?: GPUSignedOffset32, firstInstance?: GPUSize32): undefined + { + return this._renderPassEncoder.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined + { + return this._renderPassEncoder.drawIndirect(indirectBuffer, indirectOffset); + } + drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined + { + return this._renderPassEncoder.drawIndexedIndirect(indirectBuffer, indirectOffset) + } +} \ No newline at end of file -- Gitee From a123d15a779f55b1018b719fc980110374ff5574 Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 15:22:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=94=BE=E5=BC=83=E5=A5=97=E5=A3=B3?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WebGPU.ts | 10 +- src/youhua/GPUCommandEncoderYouHua.ts | 67 ------------ src/youhua/GPUDeviceYouHua.ts | 126 ----------------------- src/youhua/GPURenderPassEncoderYouHua.ts | 92 ----------------- 4 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 src/youhua/GPUCommandEncoderYouHua.ts delete mode 100644 src/youhua/GPUDeviceYouHua.ts delete mode 100644 src/youhua/GPURenderPassEncoderYouHua.ts diff --git a/src/WebGPU.ts b/src/WebGPU.ts index 6922d3e..1efe9ed 100644 --- a/src/WebGPU.ts +++ b/src/WebGPU.ts @@ -15,7 +15,6 @@ import { copyDepthTexture } from "./utils/copyDepthTexture"; import { quitIfWebGPUNotAvailable } from "./utils/quitIfWebGPUNotAvailable"; import { readPixels } from "./utils/readPixels"; import { textureInvertYPremultiplyAlpha } from "./utils/textureInvertYPremultiplyAlpha"; -import { GPUDeviceYouHua } from "./youhua/GPUDeviceYouHua"; /** * WebGPU 对象。 @@ -24,13 +23,6 @@ import { GPUDeviceYouHua } from "./youhua/GPUDeviceYouHua"; */ export class WebGPU { - private _是否优化: boolean; - - constructor(是否优化 = true) - { - this._是否优化 = 是否优化; - } - /** * 初始化 WebGPU 获取 GPUDevice 。 */ @@ -52,7 +44,7 @@ export class WebGPU } }); - this.device = this._是否优化 ? new GPUDeviceYouHua(device) : device; + this.device = device; return this; } diff --git a/src/youhua/GPUCommandEncoderYouHua.ts b/src/youhua/GPUCommandEncoderYouHua.ts deleted file mode 100644 index 88033df..0000000 --- a/src/youhua/GPUCommandEncoderYouHua.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { GPURenderPassEncoderYouHua } from "./GPURenderPassEncoderYouHua"; - -export class GPUCommandEncoderYouHua implements GPUCommandEncoder -{ - get __brand() { return this._commandEncoder.__brand; } - get label() { return this._commandEncoder.label; } - set label(v) { this._commandEncoder.label = v; } - - private _commandEncoder: GPUCommandEncoder; - - constructor(commandEncoder: GPUCommandEncoder) - { - this._commandEncoder = commandEncoder; - } - - beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder - { - const renderPassEncoder = this._commandEncoder.beginRenderPass(descriptor); - - return new GPURenderPassEncoderYouHua(renderPassEncoder); - } - - beginComputePass(descriptor?: GPUComputePassDescriptor): GPUComputePassEncoder - { - return this._commandEncoder.beginComputePass(descriptor); - } - copyBufferToBuffer(source: GPUBuffer, sourceOffset: GPUSize64, destination: GPUBuffer, destinationOffset: GPUSize64, size: GPUSize64): undefined - { - return this._commandEncoder.copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size); - } - copyBufferToTexture(source: GPUImageCopyBuffer, destination: GPUImageCopyTexture, copySize: GPUExtent3DStrict): undefined - { - return this._commandEncoder.copyBufferToTexture(source, destination, copySize); - } - copyTextureToBuffer(source: GPUImageCopyTexture, destination: GPUImageCopyBuffer, copySize: GPUExtent3DStrict): undefined - { - return this._commandEncoder.copyTextureToBuffer(source, destination, copySize); - } - copyTextureToTexture(source: GPUImageCopyTexture, destination: GPUImageCopyTexture, copySize: GPUExtent3DStrict): undefined - { - return this._commandEncoder.copyTextureToTexture(source, destination, copySize); - } - clearBuffer(buffer: GPUBuffer, offset?: GPUSize64, size?: GPUSize64): undefined - { - return this._commandEncoder.clearBuffer(buffer, offset, size); - } - resolveQuerySet(querySet: GPUQuerySet, firstQuery: GPUSize32, queryCount: GPUSize32, destination: GPUBuffer, destinationOffset: GPUSize64): undefined - { - return this._commandEncoder.resolveQuerySet(querySet, firstQuery, queryCount, destination, destinationOffset); - } - finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer - { - return this._commandEncoder.finish(descriptor); - } - pushDebugGroup(groupLabel: string): undefined - { - return this._commandEncoder.pushDebugGroup(groupLabel); - } - popDebugGroup(): undefined - { - return this._commandEncoder.popDebugGroup(); - } - insertDebugMarker(markerLabel: string): undefined - { - return this._commandEncoder.insertDebugMarker(markerLabel); - } -} \ No newline at end of file diff --git a/src/youhua/GPUDeviceYouHua.ts b/src/youhua/GPUDeviceYouHua.ts deleted file mode 100644 index d73f3c1..0000000 --- a/src/youhua/GPUDeviceYouHua.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { GPUCommandEncoderYouHua } from "./GPUCommandEncoderYouHua"; - -/** - * 优化性能 - */ -export class GPUDeviceYouHua implements GPUDevice -{ - get __brand() { return this._device.__brand; } - get features() { return this._device.features; } - get limits() { return this._device.limits; } - get queue() { return this._device.queue; } - get label() { return this._device.label; } - get lost() { return this._device.lost; } - - get onuncapturederror() { return this._device.onuncapturederror; } - set onuncapturederror(v) { this._device.onuncapturederror = v; } - - // - private _device: GPUDevice; - - constructor(device: GPUDevice) - { - this._device = device; - } - - destroy(): undefined - { - return this._device.destroy(); - } - createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer - { - return this._device.createBuffer(descriptor); - } - createTexture(descriptor: GPUTextureDescriptor): GPUTexture - { - return this._device.createTexture(descriptor); - } - createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler - { - return this._device.createSampler(descriptor); - } - importExternalTexture(descriptor: GPUExternalTextureDescriptor): GPUExternalTexture - { - return this._device.importExternalTexture(descriptor); - } - createBindGroupLayout(descriptor: GPUBindGroupLayoutDescriptor): GPUBindGroupLayout - { - return this._device.createBindGroupLayout(descriptor); - } - createPipelineLayout(descriptor: GPUPipelineLayoutDescriptor): GPUPipelineLayout - { - return this._device.createPipelineLayout(descriptor); - } - createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup - { - return this._device.createBindGroup(descriptor); - } - createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule - { - return this._device.createShaderModule(descriptor); - } - createComputePipeline(descriptor: GPUComputePipelineDescriptor): GPUComputePipeline - { - return this._device.createComputePipeline(descriptor); - } - createRenderPipeline(descriptor: GPURenderPipelineDescriptor): GPURenderPipeline - { - return this._device.createRenderPipeline(descriptor); - } - createComputePipelineAsync(descriptor: GPUComputePipelineDescriptor): Promise - { - return this._device.createComputePipelineAsync(descriptor); - } - createRenderPipelineAsync(descriptor: GPURenderPipelineDescriptor): Promise - { - return this._device.createRenderPipelineAsync(descriptor); - } - createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): GPUCommandEncoder - { - const commandEncoder = this._device.createCommandEncoder(descriptor); - return new GPUCommandEncoderYouHua(commandEncoder); - } - createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): GPURenderBundleEncoder - { - return this._device.createRenderBundleEncoder(descriptor); - } - createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet - { - return this._device.createQuerySet(descriptor); - } - pushErrorScope(filter: GPUErrorFilter): undefined - { - return this._device.pushErrorScope(filter); - } - popErrorScope(): Promise - { - return this._device.popErrorScope(); - } - addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void - { - return this._device.addEventListener(type, callback, options); - } - dispatchEvent(event: Event): boolean - { - return this._device.dispatchEvent(event); - } - removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void - { - return this._device.removeEventListener(type, callback, options); - } -} - -// 处理 configure 函数,兼容 GPUDeviceYouHua -((configure) => -{ - GPUCanvasContext.prototype.configure = function (configuration: GPUCanvasConfiguration) - { - if (configuration.device.constructor.name !== "GPUDevice") - { - configuration.device = configuration.device['_device']; - console.assert(configuration.device.constructor.name === "GPUDevice"); - } - - configure.call(this, configuration); - }; -})(GPUCanvasContext.prototype.configure); diff --git a/src/youhua/GPURenderPassEncoderYouHua.ts b/src/youhua/GPURenderPassEncoderYouHua.ts deleted file mode 100644 index ecfc44e..0000000 --- a/src/youhua/GPURenderPassEncoderYouHua.ts +++ /dev/null @@ -1,92 +0,0 @@ -export class GPURenderPassEncoderYouHua implements GPURenderPassEncoder -{ - get __brand() { return this._renderPassEncoder.__brand; } - get label() { return this._renderPassEncoder.label; } - set label(v) { this._renderPassEncoder.label = v; } - - private _renderPassEncoder: GPURenderPassEncoder; - - constructor(renderPassEncoder: GPURenderPassEncoder) - { - this._renderPassEncoder = renderPassEncoder; - } - - setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): undefined - { - return this._renderPassEncoder.setViewport(x, y, width, height, minDepth, maxDepth); - } - setScissorRect(x: GPUIntegerCoordinate, y: GPUIntegerCoordinate, width: GPUIntegerCoordinate, height: GPUIntegerCoordinate): undefined - { - return this._renderPassEncoder.setScissorRect(x, y, width, height); - } - setBlendConstant(color: GPUColor): undefined - { - return this._renderPassEncoder.setBlendConstant(color); - } - setStencilReference(reference: GPUStencilValue): undefined - { - return this._renderPassEncoder.setStencilReference(reference); - } - beginOcclusionQuery(queryIndex: GPUSize32): undefined - { - return this._renderPassEncoder.beginOcclusionQuery(queryIndex); - } - endOcclusionQuery(): undefined - { - return this._renderPassEncoder.endOcclusionQuery(); - } - executeBundles(bundles: Iterable): undefined - { - return this._renderPassEncoder.executeBundles(bundles); - } - end(): undefined - { - return this._renderPassEncoder.end(); - } - pushDebugGroup(groupLabel: string): undefined - { - return this._renderPassEncoder.pushDebugGroup(groupLabel); - } - popDebugGroup(): undefined - { - return this._renderPassEncoder.popDebugGroup(); - } - insertDebugMarker(markerLabel: string): undefined - { - return this._renderPassEncoder.insertDebugMarker(markerLabel); - } - setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsets?: Iterable): undefined; - setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsetsData: Uint32Array, dynamicOffsetsDataStart: GPUSize64, dynamicOffsetsDataLength: GPUSize32): undefined; - setBindGroup(...args: any[]): undefined - { - return this._renderPassEncoder.setBindGroup.apply(this._renderPassEncoder, args); - } - setPipeline(pipeline: GPURenderPipeline): undefined - { - return this._renderPassEncoder.setPipeline(pipeline); - } - setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): undefined - { - return this._renderPassEncoder.setIndexBuffer(buffer, indexFormat, offset, size); - } - setVertexBuffer(slot: GPUIndex32, buffer: GPUBuffer | null, offset?: GPUSize64, size?: GPUSize64): undefined - { - return this._renderPassEncoder.setVertexBuffer(slot, buffer, offset, size); - } - draw(vertexCount: GPUSize32, instanceCount?: GPUSize32, firstVertex?: GPUSize32, firstInstance?: GPUSize32): undefined - { - return this._renderPassEncoder.draw(vertexCount, instanceCount, firstVertex, firstInstance); - } - drawIndexed(indexCount: GPUSize32, instanceCount?: GPUSize32, firstIndex?: GPUSize32, baseVertex?: GPUSignedOffset32, firstInstance?: GPUSize32): undefined - { - return this._renderPassEncoder.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance); - } - drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined - { - return this._renderPassEncoder.drawIndirect(indirectBuffer, indirectOffset); - } - drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined - { - return this._renderPassEncoder.drawIndexedIndirect(indirectBuffer, indirectOffset) - } -} \ No newline at end of file -- Gitee From c62d131859aebac325c4373670280e7c8697dcdf Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 15:44:49 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/runs/runBindGroup.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/runs/runBindGroup.ts b/src/runs/runBindGroup.ts index bce95ae..733f564 100644 --- a/src/runs/runBindGroup.ts +++ b/src/runs/runBindGroup.ts @@ -12,10 +12,8 @@ import { getIGPUBuffer } from "./getIGPUIndexBuffer"; export function runBindGroup(device: GPUDevice, passEncoder: GPUBindingCommandsMixin, pipeline: IGPUComputePipeline | IGPURenderPipeline, bindingResources: IGPUBindingResources) { - const gpuPipelineLayout = getIGPUPipelineLayout(pipeline); - // 计算 bindGroups - const setBindGroups = getIGPUSetBindGroups(gpuPipelineLayout, bindingResources); + const setBindGroups = getIGPUSetBindGroups(pipeline, bindingResources); setBindGroups?.forEach((setBindGroup, index) => { @@ -24,14 +22,17 @@ export function runBindGroup(device: GPUDevice, passEncoder: GPUBindingCommandsM }); } -function getIGPUSetBindGroups(layout: IGPUPipelineLayoutDescriptor, bindingResources: IGPUBindingResources) +function getIGPUSetBindGroups(pipeline: IGPUComputePipeline | IGPURenderPipeline, bindingResources: IGPUBindingResources) { // - let gpuSetBindGroups = bindGroupsMap.get([layout, bindingResources]); + let gpuSetBindGroups = bindGroupsMap.get([pipeline, bindingResources]); if (gpuSetBindGroups) return gpuSetBindGroups; gpuSetBindGroups = []; + bindGroupsMap.set([pipeline, bindingResources], gpuSetBindGroups); + // + const layout = getIGPUPipelineLayout(pipeline); layout.bindGroupLayouts.forEach((bindGroupLayout, group) => { const entries: IGPUBindGroupEntry[] = []; @@ -84,12 +85,10 @@ function getIGPUSetBindGroups(layout: IGPUPipelineLayoutDescriptor, bindingResou }); }); - bindGroupsMap.set([layout, bindingResources], gpuSetBindGroups); - return gpuSetBindGroups; } -const bindGroupsMap = new ChainMap<[IGPUPipelineLayoutDescriptor, IGPUBindingResources], IGPUSetBindGroup[]>(); +const bindGroupsMap = new ChainMap<[IGPUComputePipeline | IGPURenderPipeline, IGPUBindingResources], IGPUSetBindGroup[]>(); /** * -- Gitee From 2e76cbd3cb4a9b1a064f3c8fe1f2e71f4f0be1e8 Mon Sep 17 00:00:00 2001 From: feng <908087098@qq.com> Date: Mon, 25 Nov 2024 16:14:45 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/caches/getGPUBindGroup.ts | 6 +++--- src/caches/getGPUComputePipeline.ts | 3 ++- src/caches/getIGPUComputePipeline.ts | 4 ++-- src/runs/runBindGroup.ts | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/caches/getGPUBindGroup.ts b/src/caches/getGPUBindGroup.ts index d5624e4..743b819 100644 --- a/src/caches/getGPUBindGroup.ts +++ b/src/caches/getGPUBindGroup.ts @@ -4,15 +4,17 @@ import { IGPUBindGroupDescriptor, IGPUBufferBinding, IGPUExternalTexture } from import { IGPUSampler } from "../data/IGPUSampler"; import { IGPUTextureFromContext } from "../data/IGPUTexture"; import { IGPUTextureView } from "../data/IGPUTextureView"; +import { GPUTextureView_destroy } from "../eventnames"; import { getGPUBindGroupLayout } from "./getGPUBindGroupLayout"; import { getGPUBufferBinding } from "./getGPUBufferBinding"; import { getGPUExternalTexture } from "./getGPUExternalTexture"; import { getGPUSampler } from "./getGPUSampler"; import { getGPUTextureView } from "./getGPUTextureView"; -import { GPUTextureView_destroy } from "../eventnames"; export function getGPUBindGroup(device: GPUDevice, bindGroup: IGPUBindGroupDescriptor) { + const bindGroupMap: WeakMap = device["_bindGroupMap"] = device["_bindGroupMap"] || new WeakMap(); + let gBindGroup = bindGroupMap.get(bindGroup); if (gBindGroup) return gBindGroup; @@ -103,5 +105,3 @@ export function getGPUBindGroup(device: GPUDevice, bindGroup: IGPUBindGroupDescr return gBindGroup; } - -const bindGroupMap = new WeakMap(); diff --git a/src/caches/getGPUComputePipeline.ts b/src/caches/getGPUComputePipeline.ts index a2003a6..d52b27e 100644 --- a/src/caches/getGPUComputePipeline.ts +++ b/src/caches/getGPUComputePipeline.ts @@ -4,6 +4,8 @@ import { getGPUShaderModule } from "./getGPUShaderModule"; export function getGPUComputePipeline(device: GPUDevice, descriptor: IGPUComputePipeline) { + const computePipelineMap: WeakMap = device["_computePipelineMap"] = device["_computePipelineMap"] || new WeakMap(); + let pipeline = computePipelineMap.get(descriptor); if (pipeline) return pipeline; @@ -21,4 +23,3 @@ export function getGPUComputePipeline(device: GPUDevice, descriptor: IGPUCompute return pipeline; } -const computePipelineMap = new WeakMap(); diff --git a/src/caches/getIGPUComputePipeline.ts b/src/caches/getIGPUComputePipeline.ts index 47b881b..edc0254 100644 --- a/src/caches/getIGPUComputePipeline.ts +++ b/src/caches/getIGPUComputePipeline.ts @@ -1,5 +1,5 @@ import { FunctionInfo } from "wgsl_reflect"; -import { IGPUComputePipeline, IGPUProgrammableStage } from "../data/IGPUComputeObject"; +import { IGPUComputePipeline, IGPUComputeStage, IGPUProgrammableStage } from "../data/IGPUComputeObject"; import { getIGPUPipelineLayout } from "./getIGPUPipelineLayout"; import { getWGSLReflectInfo } from "./getWGSLReflectInfo"; @@ -39,7 +39,7 @@ const computePipelineMap = new Map(); * @param computeStage 计算阶段描述。 * @returns 计算阶段完整描述。 */ -function getIGPUComputeStage(computeStage: IGPUProgrammableStage) +function getIGPUComputeStage(computeStage: IGPUComputeStage) { const reflect = getWGSLReflectInfo(computeStage.code); let compute: FunctionInfo; diff --git a/src/runs/runBindGroup.ts b/src/runs/runBindGroup.ts index 733f564..ca71e5f 100644 --- a/src/runs/runBindGroup.ts +++ b/src/runs/runBindGroup.ts @@ -6,7 +6,6 @@ import { IGPUBindGroupEntry, IGPUBufferBinding } from "../data/IGPUBindGroupDesc import { IGPUBindingResources } from "../data/IGPUBindingResources"; import { IGPUComputePipeline } from "../data/IGPUComputeObject"; import { IGPURenderPipeline, IGPUSetBindGroup } from "../data/IGPURenderObject"; -import { IGPUPipelineLayoutDescriptor } from "../internal/IGPUPipelineLayoutDescriptor"; import { ChainMap } from "../utils/ChainMap"; import { getIGPUBuffer } from "./getIGPUIndexBuffer"; -- Gitee