@babylonjs/core 7.0.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.d.ts +1 -1
- package/Animations/animationGroup.js +1 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.js +10 -3
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Compute/computeEffect.d.ts +3 -4
- package/Compute/computeEffect.js +40 -33
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.d.ts +2 -2
- package/Compute/computeShader.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +27 -3
- package/Engines/Extensions/engine.computeShader.js +1 -1
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +1 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +12 -2
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
- package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.d.ts +2 -2
- package/Engines/WebGPU/webgpuClearQuad.js +8 -3
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +1 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js +15 -0
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +10 -2
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +7 -7
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +14 -2
- package/Engines/renderTargetWrapper.js +23 -3
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +3 -7
- package/Engines/thinEngine.js +23 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -2
- package/Engines/webgpuEngine.js +19 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +6 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +2 -2
- package/Gizmos/boundingBoxGizmo.js +27 -17
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +6 -0
- package/Gizmos/scaleGizmo.js +10 -2
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +17 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +5 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.d.ts +2 -15
- package/Materials/Node/Blocks/addBlock.js +4 -32
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/baseMathBlock.d.ts +26 -0
- package/Materials/Node/Blocks/baseMathBlock.js +84 -0
- package/Materials/Node/Blocks/baseMathBlock.js.map +1 -0
- package/Materials/Node/Blocks/divideBlock.d.ts +2 -15
- package/Materials/Node/Blocks/divideBlock.js +4 -32
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.d.ts +2 -15
- package/Materials/Node/Blocks/multiplyBlock.js +4 -32
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.d.ts +2 -15
- package/Materials/Node/Blocks/subtractBlock.js +4 -32
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +7 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -5
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
- package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrSheenConfiguration.js +3 -12
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +0 -6
- package/Materials/Textures/baseTexture.js +0 -8
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +8 -24
- package/Materials/Textures/renderTargetTexture.js +13 -8
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +5 -8
- package/Materials/Textures/texture.js +10 -20
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +1 -0
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/effect.d.ts +3 -3
- package/Materials/effect.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +3 -3
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +12 -0
- package/Maths/math.vector.js +17 -2
- package/Maths/math.vector.js.map +1 -1
- package/Maths/tensor.d.ts +13 -11
- package/Maths/tensor.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +14 -0
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/ribbonBuilder.js +32 -28
- package/Meshes/Builders/ribbonBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +18 -6
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +17 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.d.ts +0 -2
- package/Meshes/GreasedLine/greasedLineMesh.js +84 -77
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +19 -4
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.d.ts +6 -0
- package/Meshes/Node/Blocks/mathBlock.js +95 -23
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +4 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +7 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +6 -0
- package/Misc/greasedLineTools.js +21 -0
- package/Misc/greasedLineTools.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
- package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
- package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +2 -0
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/greasedLine.vertex.js +3 -3
- package/Shaders/greasedLine.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +4 -4
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/clearQuad.fragment.js +11 -0
- package/ShadersWGSL/clearQuad.fragment.js.map +1 -0
- package/ShadersWGSL/clearQuad.vertex.js +22 -0
- package/ShadersWGSL/clearQuad.vertex.js.map +1 -0
- package/XR/features/WebXRHandTracking.d.ts +5 -0
- package/XR/features/WebXRHandTracking.js +6 -0
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/node.js +1 -6
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/Shaders/clearQuad.fragment.js +0 -10
- package/Shaders/clearQuad.fragment.js.map +0 -1
- package/Shaders/clearQuad.vertex.js +0 -19
- package/Shaders/clearQuad.vertex.js.map +0 -1
- /package/{Shaders → ShadersWGSL}/clearQuad.fragment.d.ts +0 -0
- /package/{Shaders → ShadersWGSL}/clearQuad.vertex.d.ts +0 -0
|
@@ -50,10 +50,9 @@ export declare class WebGLRenderTargetWrapper extends RenderTargetWrapper {
|
|
|
50
50
|
createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number, format?: number, label?: string): InternalTexture;
|
|
51
51
|
/**
|
|
52
52
|
* Shares the depth buffer of this render target with another render target.
|
|
53
|
-
* @internal
|
|
54
53
|
* @param renderTarget Destination renderTarget
|
|
55
54
|
*/
|
|
56
|
-
|
|
55
|
+
shareDepth(renderTarget: WebGLRenderTargetWrapper): void;
|
|
57
56
|
/**
|
|
58
57
|
* Binds a texture to this render target on a specific attachment
|
|
59
58
|
* @param texture The texture to bind to the framebuffer
|
|
@@ -85,11 +85,10 @@ export class WebGLRenderTargetWrapper extends RenderTargetWrapper {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Shares the depth buffer of this render target with another render target.
|
|
88
|
-
* @internal
|
|
89
88
|
* @param renderTarget Destination renderTarget
|
|
90
89
|
*/
|
|
91
|
-
|
|
92
|
-
super.
|
|
90
|
+
shareDepth(renderTarget) {
|
|
91
|
+
super.shareDepth(renderTarget);
|
|
93
92
|
const gl = this._context;
|
|
94
93
|
const depthbuffer = this._depthStencilBuffer;
|
|
95
94
|
const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;
|
|
@@ -1 +1 @@
|
|
|
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,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SACvF;IACL,CAAC;IAEM,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,wBAAwB;QAClE,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEzB,IAAI,CAAC,uBAAuB,EAAE;YAC1B,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBACrD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;aAClC;YACD,IAAI,IAAI,CAAC,yBAAyB,EAAE;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBAC5D,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;aACzC;SACJ;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;QAED,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { Engine } from \"../engine\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\nimport type { ThinEngine } from \"../thinEngine\";\r\n\r\n/** @internal */\r\nexport class WebGLRenderTargetWrapper extends RenderTargetWrapper {\r\n private _context: WebGLRenderingContext;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _framebuffer: Nullable<WebGLFramebuffer> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _MSAAFramebuffer: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Multiview\r\n /**\r\n * @internal\r\n */\r\n public _colorTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _disposeOnlyFramebuffers = false;\r\n /**\r\n * @internal\r\n */\r\n public _currentLOD = 0;\r\n\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine, context: WebGLRenderingContext) {\r\n super(isMulti, isCube, size, engine);\r\n\r\n this._context = context;\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._colorTextureArray && this._depthStencilTextureArray) {\r\n rtw = (this._engine as Engine).createMultiviewRenderTargetTexture(this.width, this.height);\r\n rtw.texture!.isReady = true;\r\n } else {\r\n rtw = super._cloneRenderTargetWrapper();\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: WebGLRenderTargetWrapper): void {\r\n super._swapRenderTargetWrapper(target);\r\n\r\n target._framebuffer = this._framebuffer;\r\n target._depthStencilBuffer = this._depthStencilBuffer;\r\n target._MSAAFramebuffer = this._MSAAFramebuffer;\r\n target._colorTextureArray = this._colorTextureArray;\r\n target._depthStencilTextureArray = this._depthStencilTextureArray;\r\n\r\n this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n if (this._depthStencilBuffer) {\r\n // Dispose previous depth/stencil render buffers and clear the corresponding attachment.\r\n // Next time this framebuffer is bound, the new depth/stencil texture will be attached.\r\n const currentFrameBuffer = this._engine._currentFramebuffer;\r\n const gl = this._context;\r\n\r\n this._engine._bindUnboundFramebuffer(this._framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n this._engine._bindUnboundFramebuffer(currentFrameBuffer);\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n return super.createDepthStencilTexture(comparisonFunction, bilinearFiltering, generateStencil, samples, format, label);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: WebGLRenderTargetWrapper): void {\r\n super._shareDepth(renderTarget);\r\n\r\n const gl = this._context;\r\n const depthbuffer = this._depthStencilBuffer;\r\n const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;\r\n\r\n if (renderTarget._depthStencilBuffer && renderTarget._depthStencilBuffer !== depthbuffer) {\r\n gl.deleteRenderbuffer(renderTarget._depthStencilBuffer);\r\n }\r\n renderTarget._depthStencilBuffer = depthbuffer;\r\n const attachment = renderTarget._generateStencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, depthbuffer);\r\n this._engine._bindUnboundFramebuffer(null);\r\n }\r\n\r\n /**\r\n * Binds a texture to this render target on a specific attachment\r\n * @param texture The texture to bind to the framebuffer\r\n * @param attachmentIndex Index of the attachment\r\n * @param faceIndexOrLayer The face or layer of the texture to render to in case of cube texture or array texture\r\n * @param lodLevel defines the lod level to bind to the frame buffer\r\n */\r\n private _bindTextureRenderTarget(texture: InternalTexture, attachmentIndex: number = 0, faceIndexOrLayer?: number, lodLevel: number = 0) {\r\n if (!texture._hardwareTexture) {\r\n return;\r\n }\r\n\r\n const framebuffer = this._framebuffer;\r\n\r\n const currentFB = this._engine._currentFramebuffer;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n\r\n if (this._engine.webGLVersion > 1) {\r\n const gl = this._context as WebGL2RenderingContext;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex];\r\n if (texture.is2DArray || texture.is3D) {\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.layerIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, texture._hardwareTexture.underlyingResource, lodLevel, faceIndexOrLayer);\r\n } else if (texture.isCube) {\r\n // if face index is not specified, try to query it from faceIndices\r\n // default is face 0\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.faceIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer, texture._hardwareTexture.underlyingResource, lodLevel);\r\n } else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n } else {\r\n // Default behavior (WebGL)\r\n const gl = this._context;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex + \"_WEBGL\"];\r\n const target = faceIndexOrLayer !== undefined ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer : gl.TEXTURE_2D;\r\n\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, target, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n\r\n this._engine._bindUnboundFramebuffer(currentFB);\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true) {\r\n super.setTexture(texture, index, disposePrevious);\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture\r\n * @param layers The layer of the texture to be set (make negative to not modify)\r\n * @param faces The face of the texture to be set (make negative to not modify)\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n super.setLayerAndFaceIndices(layers, faces);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n // the length of this._attachments is the right one as it does not count the depth texture, in case we generated it\r\n const textureCount = this._attachments?.length ?? this.textures.length;\r\n for (let index = 0; index < textureCount; index++) {\r\n const texture = this.textures[index];\r\n if (!texture) {\r\n // The target type was probably -1 at creation time and setTexture has not been called yet for this index\r\n continue;\r\n }\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(texture, index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(texture, index, this.faceIndices[index]);\r\n } else {\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the face and layer indices of a texture in the textures array\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n super.setLayerAndFaceIndex(index, layer, face);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n const texture = this.textures[index];\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.faceIndices[index]);\r\n }\r\n }\r\n\r\n public dispose(disposeOnlyFramebuffers = this._disposeOnlyFramebuffers): void {\r\n const gl = this._context;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n if (this._colorTextureArray) {\r\n this._context.deleteTexture(this._colorTextureArray);\r\n this._colorTextureArray = null;\r\n }\r\n if (this._depthStencilTextureArray) {\r\n this._context.deleteTexture(this._depthStencilTextureArray);\r\n this._depthStencilTextureArray = null;\r\n }\r\n }\r\n\r\n if (this._framebuffer) {\r\n gl.deleteFramebuffer(this._framebuffer);\r\n this._framebuffer = null;\r\n }\r\n\r\n if (this._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n if (this._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(this._MSAAFramebuffer);\r\n this._MSAAFramebuffer = null;\r\n }\r\n\r\n super.dispose(disposeOnlyFramebuffers);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webGLRenderTargetWrapper.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGL/webGLRenderTargetWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,gBAAgB;AAChB,MAAM,OAAO,wBAAyB,SAAQ,mBAAmB;IAoC7D,YAAY,OAAgB,EAAE,MAAe,EAAE,IAAiB,EAAE,MAAkB,EAAE,OAA8B;QAChH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAlCzC;;WAEG;QACI,iBAAY,GAA+B,IAAI,CAAC;QACvD;;WAEG;QACI,wBAAmB,GAAgC,IAAI,CAAC;QAC/D,gEAAgE;QAChE;;WAEG;QACH,gEAAgE;QACzD,qBAAgB,GAA+B,IAAI,CAAC;QAE3D,YAAY;QACZ;;WAEG;QACI,uBAAkB,GAA2B,IAAI,CAAC;QACzD;;WAEG;QACI,8BAAyB,GAA2B,IAAI,CAAC;QAChE;;WAEG;QACI,6BAAwB,GAAG,KAAK,CAAC;QACxC;;WAEG;QACI,gBAAW,GAAG,CAAC,CAAC;QAKnB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAES,yBAAyB;QAC/B,IAAI,GAAG,GAAkC,IAAI,CAAC;QAE9C,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAC3D,GAAG,GAAI,IAAI,CAAC,OAAkB,CAAC,kCAAkC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3F,GAAG,CAAC,OAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;SAC/B;aAAM;YACH,GAAG,GAAG,KAAK,CAAC,yBAAyB,EAAE,CAAC;SAC3C;QAED,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AAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SACvF;IACL,CAAC;IAEM,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,wBAAwB;QAClE,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEzB,IAAI,CAAC,uBAAuB,EAAE;YAC1B,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBACrD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;aAClC;YACD,IAAI,IAAI,CAAC,yBAAyB,EAAE;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBAC5D,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;aACzC;SACJ;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;QAED,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { Engine } from \"../engine\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\nimport type { ThinEngine } from \"../thinEngine\";\r\n\r\n/** @internal */\r\nexport class WebGLRenderTargetWrapper extends RenderTargetWrapper {\r\n private _context: WebGLRenderingContext;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _framebuffer: Nullable<WebGLFramebuffer> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _MSAAFramebuffer: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Multiview\r\n /**\r\n * @internal\r\n */\r\n public _colorTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _disposeOnlyFramebuffers = false;\r\n /**\r\n * @internal\r\n */\r\n public _currentLOD = 0;\r\n\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine, context: WebGLRenderingContext) {\r\n super(isMulti, isCube, size, engine);\r\n\r\n this._context = context;\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._colorTextureArray && this._depthStencilTextureArray) {\r\n rtw = (this._engine as Engine).createMultiviewRenderTargetTexture(this.width, this.height);\r\n rtw.texture!.isReady = true;\r\n } else {\r\n rtw = super._cloneRenderTargetWrapper();\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: WebGLRenderTargetWrapper): void {\r\n super._swapRenderTargetWrapper(target);\r\n\r\n target._framebuffer = this._framebuffer;\r\n target._depthStencilBuffer = this._depthStencilBuffer;\r\n target._MSAAFramebuffer = this._MSAAFramebuffer;\r\n target._colorTextureArray = this._colorTextureArray;\r\n target._depthStencilTextureArray = this._depthStencilTextureArray;\r\n\r\n this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n if (this._depthStencilBuffer) {\r\n // Dispose previous depth/stencil render buffers and clear the corresponding attachment.\r\n // Next time this framebuffer is bound, the new depth/stencil texture will be attached.\r\n const currentFrameBuffer = this._engine._currentFramebuffer;\r\n const gl = this._context;\r\n\r\n this._engine._bindUnboundFramebuffer(this._framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n this._engine._bindUnboundFramebuffer(currentFrameBuffer);\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n return super.createDepthStencilTexture(comparisonFunction, bilinearFiltering, generateStencil, samples, format, label);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: WebGLRenderTargetWrapper): void {\r\n super.shareDepth(renderTarget);\r\n\r\n const gl = this._context;\r\n const depthbuffer = this._depthStencilBuffer;\r\n const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;\r\n\r\n if (renderTarget._depthStencilBuffer && renderTarget._depthStencilBuffer !== depthbuffer) {\r\n gl.deleteRenderbuffer(renderTarget._depthStencilBuffer);\r\n }\r\n renderTarget._depthStencilBuffer = depthbuffer;\r\n const attachment = renderTarget._generateStencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, depthbuffer);\r\n this._engine._bindUnboundFramebuffer(null);\r\n }\r\n\r\n /**\r\n * Binds a texture to this render target on a specific attachment\r\n * @param texture The texture to bind to the framebuffer\r\n * @param attachmentIndex Index of the attachment\r\n * @param faceIndexOrLayer The face or layer of the texture to render to in case of cube texture or array texture\r\n * @param lodLevel defines the lod level to bind to the frame buffer\r\n */\r\n private _bindTextureRenderTarget(texture: InternalTexture, attachmentIndex: number = 0, faceIndexOrLayer?: number, lodLevel: number = 0) {\r\n if (!texture._hardwareTexture) {\r\n return;\r\n }\r\n\r\n const framebuffer = this._framebuffer;\r\n\r\n const currentFB = this._engine._currentFramebuffer;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n\r\n if (this._engine.webGLVersion > 1) {\r\n const gl = this._context as WebGL2RenderingContext;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex];\r\n if (texture.is2DArray || texture.is3D) {\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.layerIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, texture._hardwareTexture.underlyingResource, lodLevel, faceIndexOrLayer);\r\n } else if (texture.isCube) {\r\n // if face index is not specified, try to query it from faceIndices\r\n // default is face 0\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.faceIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer, texture._hardwareTexture.underlyingResource, lodLevel);\r\n } else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n } else {\r\n // Default behavior (WebGL)\r\n const gl = this._context;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex + \"_WEBGL\"];\r\n const target = faceIndexOrLayer !== undefined ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer : gl.TEXTURE_2D;\r\n\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, target, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n\r\n this._engine._bindUnboundFramebuffer(currentFB);\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true) {\r\n super.setTexture(texture, index, disposePrevious);\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture\r\n * @param layers The layer of the texture to be set (make negative to not modify)\r\n * @param faces The face of the texture to be set (make negative to not modify)\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n super.setLayerAndFaceIndices(layers, faces);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n // the length of this._attachments is the right one as it does not count the depth texture, in case we generated it\r\n const textureCount = this._attachments?.length ?? this.textures.length;\r\n for (let index = 0; index < textureCount; index++) {\r\n const texture = this.textures[index];\r\n if (!texture) {\r\n // The target type was probably -1 at creation time and setTexture has not been called yet for this index\r\n continue;\r\n }\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(texture, index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(texture, index, this.faceIndices[index]);\r\n } else {\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the face and layer indices of a texture in the textures array\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n super.setLayerAndFaceIndex(index, layer, face);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n const texture = this.textures[index];\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.faceIndices[index]);\r\n }\r\n }\r\n\r\n public dispose(disposeOnlyFramebuffers = this._disposeOnlyFramebuffers): void {\r\n const gl = this._context;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n if (this._colorTextureArray) {\r\n this._context.deleteTexture(this._colorTextureArray);\r\n this._colorTextureArray = null;\r\n }\r\n if (this._depthStencilTextureArray) {\r\n this._context.deleteTexture(this._depthStencilTextureArray);\r\n this._depthStencilTextureArray = null;\r\n }\r\n }\r\n\r\n if (this._framebuffer) {\r\n gl.deleteFramebuffer(this._framebuffer);\r\n this._framebuffer = null;\r\n }\r\n\r\n if (this._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n if (this._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(this._MSAAFramebuffer);\r\n this._MSAAFramebuffer = null;\r\n }\r\n\r\n super.dispose(disposeOnlyFramebuffers);\r\n }\r\n}\r\n"]}
|
|
@@ -99,6 +99,28 @@ WebGPUEngine.prototype._rebuildComputeEffects = function () {
|
|
|
99
99
|
effect._prepareEffect();
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
+
WebGPUEngine.prototype._executeWhenComputeStateIsCompiled = function (pipelineContext, action) {
|
|
103
|
+
pipelineContext.stage.module.getCompilationInfo().then((info) => {
|
|
104
|
+
const compilationMessages = {
|
|
105
|
+
numErrors: 0,
|
|
106
|
+
messages: [],
|
|
107
|
+
};
|
|
108
|
+
for (const message of info.messages) {
|
|
109
|
+
if (message.type === "error") {
|
|
110
|
+
compilationMessages.numErrors++;
|
|
111
|
+
}
|
|
112
|
+
compilationMessages.messages.push({
|
|
113
|
+
type: message.type,
|
|
114
|
+
text: message.message,
|
|
115
|
+
line: message.lineNum,
|
|
116
|
+
column: message.linePos,
|
|
117
|
+
length: message.length,
|
|
118
|
+
offset: message.offset,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
action(compilationMessages);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
102
124
|
WebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext) {
|
|
103
125
|
const webgpuPipelineContext = pipelineContext;
|
|
104
126
|
if (webgpuPipelineContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,eAAe,MAAM,oBAAoB,C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AChC,CAAC;QACF,UAAU;KACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport type { IComputeEffectCreationOptions, IComputeShaderPath } from \"../../../Compute/computeEffect\";\r\nimport { ComputeEffect } from \"../../../Compute/computeEffect\";\r\nimport type { IComputeContext } from \"../../../Compute/IComputeContext\";\r\nimport type { IComputePipelineContext } from \"../../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { ComputeBindingList, ComputeBindingMapping } from \"../../Extensions/engine.computeShader\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPUComputeContext } from \"../webgpuComputeContext\";\r\nimport { WebGPUComputePipelineContext } from \"../webgpuComputePipelineContext\";\r\nimport * as WebGPUConstants from \"../webgpuConstants\";\r\nimport type { WebGPUPerfCounter } from \"../webgpuPerfCounter\";\r\n\r\ndeclare module \"../../webgpuEngine\" {\r\n export interface WebGPUEngine {\r\n /** @internal */\r\n _createComputePipelineStageDescriptor(computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage;\r\n }\r\n}\r\n\r\nconst computePassDescriptor: GPUComputePassDescriptor = {};\r\n\r\nWebGPUEngine.prototype.createComputeContext = function (): IComputeContext | undefined {\r\n return new WebGPUComputeContext(this._device, this._cacheSampler);\r\n};\r\n\r\nWebGPUEngine.prototype.createComputeEffect = function (baseName: IComputeShaderPath & { computeToken?: string }, options: IComputeEffectCreationOptions): ComputeEffect {\r\n const compute = typeof baseName === \"string\" ? baseName : baseName.computeToken || baseName.computeSource || baseName.computeElement || baseName.compute;\r\n\r\n const name = compute + \"@\" + options.defines;\r\n if (this._compiledComputeEffects[name]) {\r\n const compiledEffect = <ComputeEffect>this._compiledComputeEffects[name];\r\n if (options.onCompiled && compiledEffect.isReady()) {\r\n options.onCompiled(compiledEffect);\r\n }\r\n\r\n return compiledEffect;\r\n }\r\n const effect = new ComputeEffect(baseName, options, this, name);\r\n this._compiledComputeEffects[name] = effect;\r\n\r\n return effect;\r\n};\r\n\r\nWebGPUEngine.prototype.createComputePipelineContext = function (): IComputePipelineContext {\r\n return new WebGPUComputePipelineContext(this);\r\n};\r\n\r\nWebGPUEngine.prototype.areAllComputeEffectsReady = function (): boolean {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nWebGPUEngine.prototype.computeDispatch = function (\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y = 1,\r\n z = 1,\r\n bindingsMapping?: ComputeBindingMapping,\r\n gpuPerfCounter?: WebGPUPerfCounter\r\n): void {\r\n this._endCurrentRenderPass();\r\n\r\n const contextPipeline = effect._pipelineContext as WebGPUComputePipelineContext;\r\n const computeContext = context as WebGPUComputeContext;\r\n\r\n if (!contextPipeline.computePipeline) {\r\n contextPipeline.computePipeline = this._device.createComputePipeline({\r\n layout: WebGPUConstants.AutoLayoutMode.Auto,\r\n compute: contextPipeline.stage!,\r\n });\r\n }\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.startPass(computePassDescriptor, this._timestampIndex);\r\n }\r\n\r\n const computePass = this._renderEncoder.beginComputePass(computePassDescriptor);\r\n\r\n computePass.setPipeline(contextPipeline.computePipeline);\r\n\r\n const bindGroups = computeContext.getBindGroups(bindings, contextPipeline.computePipeline, bindingsMapping);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n const bindGroup = bindGroups[i];\r\n if (!bindGroup) {\r\n continue;\r\n }\r\n computePass.setBindGroup(i, bindGroup);\r\n }\r\n\r\n if (x + y + z > 0) {\r\n computePass.dispatchWorkgroups(x, y, z);\r\n }\r\n computePass.end();\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.endPass(this._timestampIndex, gpuPerfCounter);\r\n this._timestampIndex += 2;\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.releaseComputeEffects = function () {\r\n for (const name in this._compiledComputeEffects) {\r\n const webGPUPipelineContextCompute = this._compiledComputeEffects[name].getPipelineContext() as WebGPUComputePipelineContext;\r\n this._deleteComputePipelineContext(webGPUPipelineContextCompute);\r\n }\r\n\r\n this._compiledComputeEffects = {};\r\n};\r\n\r\nWebGPUEngine.prototype._prepareComputePipelineContext = function (\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n): void {\r\n const webGpuContext = pipelineContext as WebGPUComputePipelineContext;\r\n\r\n if (this.dbgShowShaderCode) {\r\n Logger.Log(defines!);\r\n Logger.Log(computeSourceCode);\r\n }\r\n\r\n webGpuContext.sources = {\r\n compute: computeSourceCode,\r\n rawCompute: rawComputeSourceCode,\r\n };\r\n\r\n webGpuContext.stage = this._createComputePipelineStageDescriptor(computeSourceCode, defines, entryPoint);\r\n};\r\n\r\nWebGPUEngine.prototype._releaseComputeEffect = function (effect: ComputeEffect): void {\r\n if (this._compiledComputeEffects[effect._key]) {\r\n delete this._compiledComputeEffects[effect._key];\r\n\r\n this._deleteComputePipelineContext(effect.getPipelineContext() as WebGPUComputePipelineContext);\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._rebuildComputeEffects = function (): void {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n effect._pipelineContext = null;\r\n effect._wasPreviouslyReady = false;\r\n effect._prepareEffect();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext: IComputePipelineContext): void {\r\n const webgpuPipelineContext = pipelineContext as WebGPUComputePipelineContext;\r\n if (webgpuPipelineContext) {\r\n pipelineContext.dispose();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._createComputePipelineStageDescriptor = function (computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage {\r\n if (defines) {\r\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\r\n } else {\r\n defines = \"\";\r\n }\r\n return {\r\n module: this._device.createShaderModule({\r\n code: defines + computeShader,\r\n }),\r\n entryPoint,\r\n };\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AAUtD,MAAM,qBAAqB,GAA6B,EAAE,CAAC;AAE3D,YAAY,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAC1C,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;AACtE,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAU,QAAmE,EAAE,OAAsC;IAC9J,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC;IAEzJ,MAAM,IAAI,GAAG,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAC7C,IAAI,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE;QACpC,MAAM,cAAc,GAAkB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;QACzE,IAAI,OAAO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AAO;QACH,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;YACpC,IAAI,EAAE,OAAO,GAAG,aAAa;SAChC,CAAC;QACF,UAAU;KACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport type { IComputeEffectCreationOptions, IComputeShaderPath } from \"../../../Compute/computeEffect\";\r\nimport { ComputeEffect } from \"../../../Compute/computeEffect\";\r\nimport type { IComputeContext } from \"../../../Compute/IComputeContext\";\r\nimport type { IComputePipelineContext } from \"../../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { ComputeBindingList, ComputeBindingMapping, ComputeCompilationMessages } from \"../../Extensions/engine.computeShader\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPUComputeContext } from \"../webgpuComputeContext\";\r\nimport { WebGPUComputePipelineContext } from \"../webgpuComputePipelineContext\";\r\nimport * as WebGPUConstants from \"../webgpuConstants\";\r\nimport type { WebGPUPerfCounter } from \"../webgpuPerfCounter\";\r\n\r\ndeclare module \"../../webgpuEngine\" {\r\n export interface WebGPUEngine {\r\n /** @internal */\r\n _createComputePipelineStageDescriptor(computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage;\r\n }\r\n}\r\n\r\nconst computePassDescriptor: GPUComputePassDescriptor = {};\r\n\r\nWebGPUEngine.prototype.createComputeContext = function (): IComputeContext | undefined {\r\n return new WebGPUComputeContext(this._device, this._cacheSampler);\r\n};\r\n\r\nWebGPUEngine.prototype.createComputeEffect = function (baseName: string | (IComputeShaderPath & { computeToken?: string }), options: IComputeEffectCreationOptions): ComputeEffect {\r\n const compute = typeof baseName === \"string\" ? baseName : baseName.computeToken || baseName.computeSource || baseName.computeElement || baseName.compute;\r\n\r\n const name = compute + \"@\" + options.defines;\r\n if (this._compiledComputeEffects[name]) {\r\n const compiledEffect = <ComputeEffect>this._compiledComputeEffects[name];\r\n if (options.onCompiled && compiledEffect.isReady()) {\r\n options.onCompiled(compiledEffect);\r\n }\r\n\r\n return compiledEffect;\r\n }\r\n const effect = new ComputeEffect(baseName, options, this, name);\r\n this._compiledComputeEffects[name] = effect;\r\n\r\n return effect;\r\n};\r\n\r\nWebGPUEngine.prototype.createComputePipelineContext = function (): IComputePipelineContext {\r\n return new WebGPUComputePipelineContext(this);\r\n};\r\n\r\nWebGPUEngine.prototype.areAllComputeEffectsReady = function (): boolean {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nWebGPUEngine.prototype.computeDispatch = function (\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y = 1,\r\n z = 1,\r\n bindingsMapping?: ComputeBindingMapping,\r\n gpuPerfCounter?: WebGPUPerfCounter\r\n): void {\r\n this._endCurrentRenderPass();\r\n\r\n const contextPipeline = effect._pipelineContext as WebGPUComputePipelineContext;\r\n const computeContext = context as WebGPUComputeContext;\r\n\r\n if (!contextPipeline.computePipeline) {\r\n contextPipeline.computePipeline = this._device.createComputePipeline({\r\n layout: WebGPUConstants.AutoLayoutMode.Auto,\r\n compute: contextPipeline.stage!,\r\n });\r\n }\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.startPass(computePassDescriptor, this._timestampIndex);\r\n }\r\n\r\n const computePass = this._renderEncoder.beginComputePass(computePassDescriptor);\r\n\r\n computePass.setPipeline(contextPipeline.computePipeline);\r\n\r\n const bindGroups = computeContext.getBindGroups(bindings, contextPipeline.computePipeline, bindingsMapping);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n const bindGroup = bindGroups[i];\r\n if (!bindGroup) {\r\n continue;\r\n }\r\n computePass.setBindGroup(i, bindGroup);\r\n }\r\n\r\n if (x + y + z > 0) {\r\n computePass.dispatchWorkgroups(x, y, z);\r\n }\r\n computePass.end();\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.endPass(this._timestampIndex, gpuPerfCounter);\r\n this._timestampIndex += 2;\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.releaseComputeEffects = function () {\r\n for (const name in this._compiledComputeEffects) {\r\n const webGPUPipelineContextCompute = this._compiledComputeEffects[name].getPipelineContext() as WebGPUComputePipelineContext;\r\n this._deleteComputePipelineContext(webGPUPipelineContextCompute);\r\n }\r\n\r\n this._compiledComputeEffects = {};\r\n};\r\n\r\nWebGPUEngine.prototype._prepareComputePipelineContext = function (\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n): void {\r\n const webGpuContext = pipelineContext as WebGPUComputePipelineContext;\r\n\r\n if (this.dbgShowShaderCode) {\r\n Logger.Log(defines!);\r\n Logger.Log(computeSourceCode);\r\n }\r\n\r\n webGpuContext.sources = {\r\n compute: computeSourceCode,\r\n rawCompute: rawComputeSourceCode,\r\n };\r\n\r\n webGpuContext.stage = this._createComputePipelineStageDescriptor(computeSourceCode, defines, entryPoint);\r\n};\r\n\r\nWebGPUEngine.prototype._releaseComputeEffect = function (effect: ComputeEffect): void {\r\n if (this._compiledComputeEffects[effect._key]) {\r\n delete this._compiledComputeEffects[effect._key];\r\n\r\n this._deleteComputePipelineContext(effect.getPipelineContext() as WebGPUComputePipelineContext);\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._rebuildComputeEffects = function (): void {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n effect._pipelineContext = null;\r\n effect._wasPreviouslyReady = false;\r\n effect._prepareEffect();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._executeWhenComputeStateIsCompiled = function (\r\n pipelineContext: WebGPUComputePipelineContext,\r\n action: (messages: Nullable<ComputeCompilationMessages>) => void\r\n): void {\r\n pipelineContext.stage!.module.getCompilationInfo().then((info) => {\r\n const compilationMessages: ComputeCompilationMessages = {\r\n numErrors: 0,\r\n messages: [],\r\n };\r\n for (const message of info.messages) {\r\n if (message.type === \"error\") {\r\n compilationMessages.numErrors++;\r\n }\r\n compilationMessages.messages.push({\r\n type: message.type,\r\n text: message.message,\r\n line: message.lineNum,\r\n column: message.linePos,\r\n length: message.length,\r\n offset: message.offset,\r\n });\r\n }\r\n action(compilationMessages);\r\n });\r\n};\r\n\r\nWebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext: IComputePipelineContext): void {\r\n const webgpuPipelineContext = pipelineContext as WebGPUComputePipelineContext;\r\n if (webgpuPipelineContext) {\r\n pipelineContext.dispose();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._createComputePipelineStageDescriptor = function (computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage {\r\n if (defines) {\r\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\r\n } else {\r\n defines = \"\";\r\n }\r\n return {\r\n module: this._device.createShaderModule({\r\n code: defines + computeShader,\r\n }),\r\n entryPoint,\r\n };\r\n};\r\n"]}
|
|
@@ -11,7 +11,7 @@ WebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (rtWrapp
|
|
|
11
11
|
this._endCurrentRenderPass();
|
|
12
12
|
for (let i = 0; i < count; i++) {
|
|
13
13
|
const texture = rtWrapper.textures[i];
|
|
14
|
-
if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
|
|
14
|
+
if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube && !texture.is3D) {
|
|
15
15
|
this._generateMipmaps(texture);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CA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AoJ;AACxJ,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n this._endCurrentRenderPass();\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n const defaultTarget = Constants.TEXTURE_2D;\r\n\r\n let types: number[] = [];\r\n let samplingModes: number[] = [];\r\n let useSRGBBuffers: boolean[] = [];\r\n let formats: number[] = [];\r\n let targets: number[] = [];\r\n let faceIndex: number[] = [];\r\n let layerIndex: number[] = [];\r\n let layers: number[] = [];\r\n let labels: string[] = [];\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n if (options.targetTypes) {\r\n targets = options.targetTypes;\r\n }\r\n if (options.faceIndex) {\r\n faceIndex = options.faceIndex;\r\n }\r\n if (options.layerIndex) {\r\n layerIndex = options.layerIndex;\r\n }\r\n if (options.layerCounts) {\r\n layers = options.layerCounts;\r\n }\r\n\r\n labels = options.labels ?? labels;\r\n }\r\n\r\n rtWrapper.label = options?.label ?? \"MultiRenderTargetWrapper\";\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat, \"MultipleRenderTargetDepthStencil\");\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n\r\n const format = formats[i] || defaultFormat;\r\n const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;\r\n\r\n const target = targets[i] || defaultTarget;\r\n const layerCount = layers[i] ?? 1;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n if (target === -1) {\r\n continue;\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n textures[i] = texture;\r\n\r\n switch (target) {\r\n case Constants.TEXTURE_CUBE_MAP:\r\n texture.isCube = true;\r\n break;\r\n case Constants.TEXTURE_3D:\r\n texture.is3D = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n case Constants.TEXTURE_2D_ARRAY:\r\n texture.is2DArray = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n }\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n texture.label = labels[i];\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures[textureCount] = depthStencilTexture;\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n const gpuTextureWrapper = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n gpuTextureWrapper?.releaseMSAATexture();\r\n }\r\n\r\n // Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null\r\n const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,YAAY,CAAC,SAAS,CAAC,qCAAqC,GAAG,UAC3D,SAA8B,EAC9B,yBAAkC,KAAK,EACvC,cAA2B;IAE3B,IAAI,cAAc,EAAE;QAChB,cAAc,EAAE,CAAC;KACpB;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,YAAa,CAAC;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;IAEjC,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,QAAS,CA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C,kBAAkB,EAAE;QACzB,qHAAqH;QACrH,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;KAC5D;SAAM;QACH,uLAAuL;KAC1L;AACL,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,aAAwB;IAC1E,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;YAClB,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACtB;aAAM;YACH,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAClB;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,uBAAuB,GAAG;IAC7C,mKAAmK;AACvK,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,sCAAsC,GAAG;IAC5D,oJAAoJ;AACxJ,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n this._endCurrentRenderPass();\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube && !texture.is3D) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n const defaultTarget = Constants.TEXTURE_2D;\r\n\r\n let types: number[] = [];\r\n let samplingModes: number[] = [];\r\n let useSRGBBuffers: boolean[] = [];\r\n let formats: number[] = [];\r\n let targets: number[] = [];\r\n let faceIndex: number[] = [];\r\n let layerIndex: number[] = [];\r\n let layers: number[] = [];\r\n let labels: string[] = [];\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n if (options.targetTypes) {\r\n targets = options.targetTypes;\r\n }\r\n if (options.faceIndex) {\r\n faceIndex = options.faceIndex;\r\n }\r\n if (options.layerIndex) {\r\n layerIndex = options.layerIndex;\r\n }\r\n if (options.layerCounts) {\r\n layers = options.layerCounts;\r\n }\r\n\r\n labels = options.labels ?? labels;\r\n }\r\n\r\n rtWrapper.label = options?.label ?? \"MultiRenderTargetWrapper\";\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat, \"MultipleRenderTargetDepthStencil\");\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n\r\n const format = formats[i] || defaultFormat;\r\n const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;\r\n\r\n const target = targets[i] || defaultTarget;\r\n const layerCount = layers[i] ?? 1;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n if (target === -1) {\r\n continue;\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n textures[i] = texture;\r\n\r\n switch (target) {\r\n case Constants.TEXTURE_CUBE_MAP:\r\n texture.isCube = true;\r\n break;\r\n case Constants.TEXTURE_3D:\r\n texture.is3D = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n case Constants.TEXTURE_2D_ARRAY:\r\n texture.is2DArray = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n }\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n texture.label = labels[i];\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures[textureCount] = depthStencilTexture;\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n const gpuTextureWrapper = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n gpuTextureWrapper?.releaseMSAATexture();\r\n }\r\n\r\n // Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null\r\n const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
|
|
@@ -74,12 +74,14 @@ WebGPUEngine.prototype._setupDepthStencilTexture = function (internalTexture, si
|
|
|
74
74
|
const width = size.width || size;
|
|
75
75
|
const height = size.height || size;
|
|
76
76
|
const layers = size.layers || 0;
|
|
77
|
+
const depth = size.depth || 0;
|
|
77
78
|
internalTexture.baseWidth = width;
|
|
78
79
|
internalTexture.baseHeight = height;
|
|
79
80
|
internalTexture.width = width;
|
|
80
81
|
internalTexture.height = height;
|
|
81
82
|
internalTexture.is2DArray = layers > 0;
|
|
82
|
-
internalTexture.
|
|
83
|
+
internalTexture.is3D = depth > 0;
|
|
84
|
+
internalTexture.depth = layers || depth;
|
|
83
85
|
internalTexture.isReady = true;
|
|
84
86
|
internalTexture.samples = samples;
|
|
85
87
|
internalTexture.generateMipMaps = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,YAAY,CAAC,SAAS,CAAC,kCAAkC,GAAG,UAAU,OAAgB,EAAE,MAAe,EAAE,IAAiB;IACtH,MAAM,SAAS,GAAG,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,IAAiB,EAAE,OAA8C;IAC1H,MAAM,SAAS,GAA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,CAAC,OAAO,KAAK,OAAO,EAAE;QACnE,OAAO,OAAO,CAAC;KAClB;IAED,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;IAE3D,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAElE,IAAI,SAAS,CAAC,oBAAoB,EAAE;QAChC,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC/E,SAAS,CAAC,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC;KACpD;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n fullOptions.label = options.label;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper.label = fullOptions.label ?? \"RenderTargetWrapper\";\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n false, // force false as filtering is not supported for depth textures\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples,\r\n fullOptions.generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n fullOptions.label ? fullOptions.label + \"-DepthStencil\" : undefined\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, options.generateStencil ? InternalTextureSource.DepthStencil : InternalTextureSource.Depth);\r\n\r\n internalTexture.label = options.label;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\r\n const gpuTextureWrapper = internalTexture._hardwareTexture as WebGPUHardwareTexture;\r\n\r\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n const layers = (<{ width: number; height: number; layers?: number }>size).layers || 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.depth = layers;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],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;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n fullOptions.label = options.label;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper.label = fullOptions.label ?? \"RenderTargetWrapper\";\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n false, // force false as filtering is not supported for depth textures\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples,\r\n fullOptions.generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n fullOptions.label ? fullOptions.label + \"-DepthStencil\" : undefined\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, options.generateStencil ? InternalTextureSource.DepthStencil : InternalTextureSource.Depth);\r\n\r\n internalTexture.label = options.label;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\r\n const gpuTextureWrapper = internalTexture._hardwareTexture as WebGPUHardwareTexture;\r\n\r\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n const layers = (<{ width: number; height: number; depth?: number; layers?: number }>size).layers || 0;\r\n const depth = (<{ width: number; height: number; depth?: number; layers?: number }>size).depth || 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.is3D = depth > 0;\r\n internalTexture.depth = layers || depth;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
|
|
@@ -3,8 +3,8 @@ import type { IColor4Like } from "../../Maths/math.like";
|
|
|
3
3
|
import type { VertexBuffer } from "../../Buffers/buffer";
|
|
4
4
|
import type { Nullable } from "../../types";
|
|
5
5
|
import type { WebGPUEngine } from "../webgpuEngine";
|
|
6
|
-
import "../../
|
|
7
|
-
import "../../
|
|
6
|
+
import "../../ShadersWGSL/clearQuad.vertex";
|
|
7
|
+
import "../../ShadersWGSL/clearQuad.fragment";
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare class WebGPUClearQuad {
|
|
10
10
|
private _device;
|
|
@@ -3,8 +3,9 @@ import { WebGPUCacheRenderPipelineTree } from "./webgpuCacheRenderPipelineTree.j
|
|
|
3
3
|
import { WebGPUShaderProcessingContext } from "./webgpuShaderProcessingContext.js";
|
|
4
4
|
import { WebGPUTextureHelper } from "./webgpuTextureHelper.js";
|
|
5
5
|
import { renderableTextureFormatToIndex } from "./webgpuTextureManager.js";
|
|
6
|
-
import "../../
|
|
7
|
-
import "../../
|
|
6
|
+
import "../../ShadersWGSL/clearQuad.vertex.js";
|
|
7
|
+
import "../../ShadersWGSL/clearQuad.fragment.js";
|
|
8
|
+
import { ShaderLanguage } from "../../Materials/shaderLanguage.js";
|
|
8
9
|
/** @internal */
|
|
9
10
|
export class WebGPUClearQuad {
|
|
10
11
|
setDepthStencilFormat(format) {
|
|
@@ -27,7 +28,7 @@ export class WebGPUClearQuad {
|
|
|
27
28
|
this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);
|
|
28
29
|
this._cacheRenderPipeline.setDepthTestEnabled(false);
|
|
29
30
|
this._cacheRenderPipeline.setStencilReadMask(0xff);
|
|
30
|
-
this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"]);
|
|
31
|
+
this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"], undefined, undefined, undefined, undefined, undefined, undefined, ShaderLanguage.WGSL);
|
|
31
32
|
}
|
|
32
33
|
clear(renderPass, clearColor, clearDepth, clearStencil, sampleCount = 1) {
|
|
33
34
|
let renderPass2;
|
|
@@ -58,6 +59,7 @@ export class WebGPUClearQuad {
|
|
|
58
59
|
return bundle;
|
|
59
60
|
}
|
|
60
61
|
renderPass2 = this._device.createRenderBundleEncoder({
|
|
62
|
+
label: "clearQuadRenderBundle",
|
|
61
63
|
colorFormats: this._cacheRenderPipeline.colorFormats,
|
|
62
64
|
depthStencilFormat: this._depthTextureFormat,
|
|
63
65
|
sampleCount: WebGPUTextureHelper.GetSample(sampleCount),
|
|
@@ -84,16 +86,19 @@ export class WebGPUClearQuad {
|
|
|
84
86
|
const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];
|
|
85
87
|
bindGroups = this._bindGroups[key] = [];
|
|
86
88
|
bindGroups.push(this._device.createBindGroup({
|
|
89
|
+
label: `clearQuadBindGroup0-${key}`,
|
|
87
90
|
layout: bindGroupLayouts[0],
|
|
88
91
|
entries: [],
|
|
89
92
|
}));
|
|
90
93
|
if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {
|
|
91
94
|
bindGroups.push(this._device.createBindGroup({
|
|
95
|
+
label: `clearQuadBindGroup1-${key}`,
|
|
92
96
|
layout: bindGroupLayouts[1],
|
|
93
97
|
entries: [],
|
|
94
98
|
}));
|
|
95
99
|
}
|
|
96
100
|
bindGroups.push(this._device.createBindGroup({
|
|
101
|
+
label: `clearQuadBindGroup${WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2}-${key}`,
|
|
97
102
|
layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],
|
|
98
103
|
entries: [
|
|
99
104
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpuClearQuad.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuClearQuad.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,gCAAgC,CAAC;AACxC,OAAO,kCAAkC,CAAC;AAE1C,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAUjB,qBAAqB,CAAC,MAAoC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAEM,cAAc,CAAC,MAA+B;Q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,IAAI,CACX,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;oBACzB,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;oBAC3B,OAAO,EAAE,EAAE;iBACd,CAAC,CACL,CAAC;aACL;YACD,UAAU,CAAC,IAAI,CACX,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;gBACzB,MAAM,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxF,OAAO,EAAE;oBACL;wBACI,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE;4BACN,MAAM,EAAE,eAAe,CAAC,kBAAkB;4BAC1C,IAAI,EAAE,eAAe,CAAC,QAAQ;yBACjC;qBACJ;oBACD;wBACI,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE;4BACN,MAAM,EAAE,cAAc,CAAC,kBAAkB;4BACzC,IAAI,EAAE,cAAc,CAAC,QAAQ;yBAChC;qBACJ;iBACJ;aACJ,CAAC,CACL,CAAC;SACL;QAED,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACxC,WAAW,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAI,WAAsC,CAAC,MAAM,EAAE,CAAC;YAC1D,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC,GAAG,MAAM,CAAC;SAC1C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { IColor4Like } from \"../../Maths/math.like\";\r\nimport type { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { WebGPUCacheRenderPipelineTree } from \"./webgpuCacheRenderPipelineTree\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessingContext } from \"./webgpuShaderProcessingContext\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\nimport { renderableTextureFormatToIndex } from \"./webgpuTextureManager\";\r\n\r\nimport \"../../Shaders/clearQuad.vertex\";\r\nimport \"../../Shaders/clearQuad.fragment\";\r\n\r\n/** @internal */\r\nexport class WebGPUClearQuad {\r\n private _device: GPUDevice;\r\n private _engine: WebGPUEngine;\r\n private _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n private _effect: Effect;\r\n private _bindGroups: { [id: string]: GPUBindGroup[] } = {};\r\n private _depthTextureFormat: GPUTextureFormat | undefined;\r\n private _bundleCache: { [key: string]: GPURenderBundle } = {};\r\n private _keyTemp: number[] = [];\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._depthTextureFormat = format;\r\n this._cacheRenderPipeline.setDepthStencilFormat(format);\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._cacheRenderPipeline.setColorFormat(format);\r\n }\r\n\r\n public setMRTAttachments(attachments: number[], textureArray: InternalTexture[], textureCount: number): void {\r\n this._cacheRenderPipeline.setMRT(textureArray, textureCount);\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n }\r\n\r\n constructor(device: GPUDevice, engine: WebGPUEngine, emptyVertexBuffer: VertexBuffer) {\r\n this._device = device;\r\n this._engine = engine;\r\n\r\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);\r\n this._cacheRenderPipeline.setDepthTestEnabled(false);\r\n this._cacheRenderPipeline.setStencilReadMask(0xff);\r\n\r\n this._effect = engine.createEffect(\"clearQuad\", [], [\"color\", \"depthValue\"]);\r\n }\r\n\r\n public clear(\r\n renderPass: Nullable<GPURenderPassEncoder>,\r\n clearColor?: Nullable<IColor4Like>,\r\n clearDepth?: boolean,\r\n clearStencil?: boolean,\r\n sampleCount = 1\r\n ): Nullable<GPURenderBundle> {\r\n let renderPass2: GPURenderPassEncoder | GPURenderBundleEncoder;\r\n let bundle: Nullable<GPURenderBundle> = null;\r\n let bundleKey: string;\r\n\r\n const isRTTPass = !!this._engine._currentRenderTarget;\r\n\r\n if (renderPass) {\r\n renderPass2 = renderPass;\r\n } else {\r\n let idx = 0;\r\n this._keyTemp.length = 0;\r\n for (let i = 0; i < this._cacheRenderPipeline.colorFormats.length; ++i) {\r\n this._keyTemp[idx++] = renderableTextureFormatToIndex[this._cacheRenderPipeline.colorFormats[i] ?? \"\"];\r\n }\r\n\r\n const depthStencilFormatIndex = renderableTextureFormatToIndex[this._depthTextureFormat ?? 0];\r\n\r\n this._keyTemp[idx] =\r\n (clearColor ? clearColor.r + clearColor.g * 256 + clearColor.b * 256 * 256 + clearColor.a * 256 * 256 * 256 : 0) +\r\n (clearDepth ? 2 ** 32 : 0) +\r\n (clearStencil ? 2 ** 33 : 0) +\r\n (this._engine.useReverseDepthBuffer ? 2 ** 34 : 0) +\r\n (isRTTPass ? 2 ** 35 : 0) +\r\n (sampleCount > 1 ? 2 ** 36 : 0) +\r\n depthStencilFormatIndex * 2 ** 37;\r\n\r\n bundleKey = this._keyTemp.join(\"_\");\r\n bundle = this._bundleCache[bundleKey];\r\n\r\n if (bundle) {\r\n return bundle;\r\n }\r\n\r\n renderPass2 = this._device.createRenderBundleEncoder({\r\n colorFormats: this._cacheRenderPipeline.colorFormats,\r\n depthStencilFormat: this._depthTextureFormat,\r\n sampleCount: WebGPUTextureHelper.GetSample(sampleCount),\r\n });\r\n }\r\n\r\n this._cacheRenderPipeline.setDepthWriteEnabled(!!clearDepth);\r\n this._cacheRenderPipeline.setStencilEnabled(!!clearStencil && !!this._depthTextureFormat && WebGPUTextureHelper.HasStencilAspect(this._depthTextureFormat));\r\n this._cacheRenderPipeline.setStencilWriteMask(clearStencil ? 0xff : 0);\r\n this._cacheRenderPipeline.setStencilCompare(clearStencil ? Constants.ALWAYS : Constants.NEVER);\r\n this._cacheRenderPipeline.setStencilPassOp(clearStencil ? Constants.REPLACE : Constants.KEEP);\r\n this._cacheRenderPipeline.setWriteMask(clearColor ? 0xf : 0);\r\n\r\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(Constants.MATERIAL_TriangleStripDrawMode, this._effect, sampleCount);\r\n\r\n const webgpuPipelineContext = this._effect._pipelineContext as WebGPUPipelineContext;\r\n\r\n if (clearColor) {\r\n this._effect.setDirectColor4(\"color\", clearColor);\r\n }\r\n\r\n this._effect.setFloat(\"depthValue\", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue);\r\n\r\n webgpuPipelineContext.uniformBuffer!.update();\r\n\r\n const bufferInternals = isRTTPass ? this._engine._ubInvertY : this._engine._ubDontInvertY;\r\n const bufferLeftOver = webgpuPipelineContext.uniformBuffer!.getBuffer() as WebGPUDataBuffer;\r\n\r\n const key = bufferLeftOver.uniqueId + \"-\" + bufferInternals.uniqueId;\r\n\r\n let bindGroups = this._bindGroups[key];\r\n\r\n if (!bindGroups) {\r\n const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];\r\n bindGroups = this._bindGroups[key] = [];\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[0],\r\n entries: [],\r\n })\r\n );\r\n if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[1],\r\n entries: [],\r\n })\r\n );\r\n }\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],\r\n entries: [\r\n {\r\n binding: 0,\r\n resource: {\r\n buffer: bufferInternals.underlyingResource,\r\n size: bufferInternals.capacity,\r\n },\r\n },\r\n {\r\n binding: 1,\r\n resource: {\r\n buffer: bufferLeftOver.underlyingResource,\r\n size: bufferLeftOver.capacity,\r\n },\r\n },\r\n ],\r\n })\r\n );\r\n }\r\n\r\n renderPass2.setPipeline(pipeline);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n renderPass2.setBindGroup(i, bindGroups[i]);\r\n }\r\n renderPass2.draw(4, 1, 0, 0);\r\n\r\n if (!renderPass) {\r\n bundle = (renderPass2 as GPURenderBundleEncoder).finish();\r\n this._bundleCache[bundleKey!] = bundle;\r\n }\r\n\r\n return bundle;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webgpuClearQuad.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuClearQuad.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAUjB,qBAAqB,CAAC,MAAoC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAClC,IAAI,CA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,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAI,WAAsC,CAAC,MAAM,EAAE,CAAC;YAC1D,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC,GAAG,MAAM,CAAC;SAC1C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { IColor4Like } from \"../../Maths/math.like\";\r\nimport type { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { WebGPUCacheRenderPipelineTree } from \"./webgpuCacheRenderPipelineTree\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessingContext } from \"./webgpuShaderProcessingContext\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\nimport { renderableTextureFormatToIndex } from \"./webgpuTextureManager\";\r\n\r\nimport \"../../ShadersWGSL/clearQuad.vertex\";\r\nimport \"../../ShadersWGSL/clearQuad.fragment\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\n\r\n/** @internal */\r\nexport class WebGPUClearQuad {\r\n private _device: GPUDevice;\r\n private _engine: WebGPUEngine;\r\n private _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n private _effect: Effect;\r\n private _bindGroups: { [id: string]: GPUBindGroup[] } = {};\r\n private _depthTextureFormat: GPUTextureFormat | undefined;\r\n private _bundleCache: { [key: string]: GPURenderBundle } = {};\r\n private _keyTemp: number[] = [];\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._depthTextureFormat = format;\r\n this._cacheRenderPipeline.setDepthStencilFormat(format);\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._cacheRenderPipeline.setColorFormat(format);\r\n }\r\n\r\n public setMRTAttachments(attachments: number[], textureArray: InternalTexture[], textureCount: number): void {\r\n this._cacheRenderPipeline.setMRT(textureArray, textureCount);\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n }\r\n\r\n constructor(device: GPUDevice, engine: WebGPUEngine, emptyVertexBuffer: VertexBuffer) {\r\n this._device = device;\r\n this._engine = engine;\r\n\r\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);\r\n this._cacheRenderPipeline.setDepthTestEnabled(false);\r\n this._cacheRenderPipeline.setStencilReadMask(0xff);\r\n\r\n this._effect = engine.createEffect(\"clearQuad\", [], [\"color\", \"depthValue\"], undefined, undefined, undefined, undefined, undefined, undefined, ShaderLanguage.WGSL);\r\n }\r\n\r\n public clear(\r\n renderPass: Nullable<GPURenderPassEncoder>,\r\n clearColor?: Nullable<IColor4Like>,\r\n clearDepth?: boolean,\r\n clearStencil?: boolean,\r\n sampleCount = 1\r\n ): Nullable<GPURenderBundle> {\r\n let renderPass2: GPURenderPassEncoder | GPURenderBundleEncoder;\r\n let bundle: Nullable<GPURenderBundle> = null;\r\n let bundleKey: string;\r\n\r\n const isRTTPass = !!this._engine._currentRenderTarget;\r\n\r\n if (renderPass) {\r\n renderPass2 = renderPass;\r\n } else {\r\n let idx = 0;\r\n this._keyTemp.length = 0;\r\n for (let i = 0; i < this._cacheRenderPipeline.colorFormats.length; ++i) {\r\n this._keyTemp[idx++] = renderableTextureFormatToIndex[this._cacheRenderPipeline.colorFormats[i] ?? \"\"];\r\n }\r\n\r\n const depthStencilFormatIndex = renderableTextureFormatToIndex[this._depthTextureFormat ?? 0];\r\n\r\n this._keyTemp[idx] =\r\n (clearColor ? clearColor.r + clearColor.g * 256 + clearColor.b * 256 * 256 + clearColor.a * 256 * 256 * 256 : 0) +\r\n (clearDepth ? 2 ** 32 : 0) +\r\n (clearStencil ? 2 ** 33 : 0) +\r\n (this._engine.useReverseDepthBuffer ? 2 ** 34 : 0) +\r\n (isRTTPass ? 2 ** 35 : 0) +\r\n (sampleCount > 1 ? 2 ** 36 : 0) +\r\n depthStencilFormatIndex * 2 ** 37;\r\n\r\n bundleKey = this._keyTemp.join(\"_\");\r\n bundle = this._bundleCache[bundleKey];\r\n\r\n if (bundle) {\r\n return bundle;\r\n }\r\n\r\n renderPass2 = this._device.createRenderBundleEncoder({\r\n label: \"clearQuadRenderBundle\",\r\n colorFormats: this._cacheRenderPipeline.colorFormats,\r\n depthStencilFormat: this._depthTextureFormat,\r\n sampleCount: WebGPUTextureHelper.GetSample(sampleCount),\r\n });\r\n }\r\n\r\n this._cacheRenderPipeline.setDepthWriteEnabled(!!clearDepth);\r\n this._cacheRenderPipeline.setStencilEnabled(!!clearStencil && !!this._depthTextureFormat && WebGPUTextureHelper.HasStencilAspect(this._depthTextureFormat));\r\n this._cacheRenderPipeline.setStencilWriteMask(clearStencil ? 0xff : 0);\r\n this._cacheRenderPipeline.setStencilCompare(clearStencil ? Constants.ALWAYS : Constants.NEVER);\r\n this._cacheRenderPipeline.setStencilPassOp(clearStencil ? Constants.REPLACE : Constants.KEEP);\r\n this._cacheRenderPipeline.setWriteMask(clearColor ? 0xf : 0);\r\n\r\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(Constants.MATERIAL_TriangleStripDrawMode, this._effect, sampleCount);\r\n\r\n const webgpuPipelineContext = this._effect._pipelineContext as WebGPUPipelineContext;\r\n\r\n if (clearColor) {\r\n this._effect.setDirectColor4(\"color\", clearColor);\r\n }\r\n\r\n this._effect.setFloat(\"depthValue\", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue);\r\n\r\n webgpuPipelineContext.uniformBuffer!.update();\r\n\r\n const bufferInternals = isRTTPass ? this._engine._ubInvertY : this._engine._ubDontInvertY;\r\n const bufferLeftOver = webgpuPipelineContext.uniformBuffer!.getBuffer() as WebGPUDataBuffer;\r\n\r\n const key = bufferLeftOver.uniqueId + \"-\" + bufferInternals.uniqueId;\r\n\r\n let bindGroups = this._bindGroups[key];\r\n\r\n if (!bindGroups) {\r\n const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];\r\n bindGroups = this._bindGroups[key] = [];\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup0-${key}`,\r\n layout: bindGroupLayouts[0],\r\n entries: [],\r\n })\r\n );\r\n if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup1-${key}`,\r\n layout: bindGroupLayouts[1],\r\n entries: [],\r\n })\r\n );\r\n }\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup${WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2}-${key}`,\r\n layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],\r\n entries: [\r\n {\r\n binding: 0,\r\n resource: {\r\n buffer: bufferInternals.underlyingResource,\r\n size: bufferInternals.capacity,\r\n },\r\n },\r\n {\r\n binding: 1,\r\n resource: {\r\n buffer: bufferLeftOver.underlyingResource,\r\n size: bufferLeftOver.capacity,\r\n },\r\n },\r\n ],\r\n })\r\n );\r\n }\r\n\r\n renderPass2.setPipeline(pipeline);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n renderPass2.setBindGroup(i, bindGroups[i]);\r\n }\r\n renderPass2.draw(4, 1, 0, 0);\r\n\r\n if (!renderPass) {\r\n bundle = (renderPass2 as GPURenderBundleEncoder).finish();\r\n this._bundleCache[bundleKey!] = bundle;\r\n }\r\n\r\n return bundle;\r\n }\r\n}\r\n"]}
|
|
@@ -4,9 +4,11 @@ export class WebGPUComputePipelineContext {
|
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
6
|
get isReady() {
|
|
7
|
-
if (this.
|
|
8
|
-
return true
|
|
7
|
+
if (this.isAsync) {
|
|
8
|
+
// When async mode is implemented, this should return true if the pipeline is ready
|
|
9
|
+
return false;
|
|
9
10
|
}
|
|
11
|
+
// In synchronous mode, we return false, the readiness being determined by ComputeEffect
|
|
10
12
|
return false;
|
|
11
13
|
}
|
|
12
14
|
constructor(engine) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpuComputePipelineContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuComputePipelineContext.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAYrC,IAAW,OAAO;QACd,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAW,OAAO;QACd,IAAI,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"webgpuComputePipelineContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuComputePipelineContext.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAYrC,IAAW,OAAO;QACd,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAW,OAAO;QACd,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,mFAAmF;YACnF,OAAO,KAAK,CAAC;SAChB;QAED,wFAAwF;QACxF,OAAO,KAAK,CAAC;IACjB,CAAC;IAKD,YAAY,MAAoB;QAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,qBAAqB;QACxB,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;IACjC,CAAC;IAEM,OAAO,KAAU,CAAC;CAC5B","sourcesContent":["import type { IComputePipelineContext } from \"../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\n\r\n/** @internal */\r\nexport class WebGPUComputePipelineContext implements IComputePipelineContext {\r\n public engine: WebGPUEngine;\r\n\r\n public sources: {\r\n compute: string;\r\n rawCompute: string;\r\n };\r\n\r\n public stage: Nullable<GPUProgrammableStage>;\r\n\r\n public computePipeline: GPUComputePipeline;\r\n\r\n public get isAsync() {\r\n return false;\r\n }\r\n\r\n public get isReady(): boolean {\r\n if (this.isAsync) {\r\n // When async mode is implemented, this should return true if the pipeline is ready\r\n return false;\r\n }\r\n\r\n // In synchronous mode, we return false, the readiness being determined by ComputeEffect\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _name: string;\r\n\r\n constructor(engine: WebGPUEngine) {\r\n this._name = \"unnamed\";\r\n this.engine = engine;\r\n }\r\n\r\n public _getComputeShaderCode(): string | null {\r\n return this.sources?.compute;\r\n }\r\n\r\n public dispose(): void {}\r\n}\r\n"]}
|