@babylonjs/core 6.3.0 → 6.4.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/Audio/audioSceneComponent.js +2 -2
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +10 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Culling/ray.d.ts +1 -1
- package/Culling/ray.js +1 -1
- package/Culling/ray.js.map +1 -1
- package/Debug/physicsViewer.d.ts +17 -0
- package/Debug/physicsViewer.js +153 -2
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +28 -9
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/engine.d.ts +5 -0
- package/Engines/engine.js +0 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.js +25 -1
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js +16 -3
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +11 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.d.ts +1 -0
- package/Materials/Textures/htmlElementTexture.js +1 -0
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/texture.js +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +16 -8
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/material.js +0 -5
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginManager.js +7 -0
- package/Materials/materialPluginManager.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +146 -114
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +3 -0
- package/Meshes/mesh.js +3 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +6 -3
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Misc/dumpTools.js +2 -1
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.js +9 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/perfCounter.d.ts +5 -0
- package/Misc/perfCounter.js +7 -0
- package/Misc/perfCounter.js.map +1 -1
- package/Morph/morphTargetManager.js +3 -0
- package/Morph/morphTargetManager.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +12 -2
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.d.ts +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
- package/Sprites/spriteManager.js +5 -9
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/webXRSessionManager.d.ts +6 -0
- package/XR/webXRSessionManager.js +9 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +1 -0
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpuCacheRenderPipeline.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuCacheRenderPipeline.ts"],"names":[],"mappings":"AAAA,yDA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AC,CAAC,SAAS;gBACX,CAAC,CAAC;oBACI,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;oBAC1C,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,eAAe,CAAC,MAAM;oBACjJ,MAAM,EAAE,IAAI,CAAC,yBAAyB;oBACtC,YAAY,EAAE,IAAI,CAAC,eAAe,IAAI,4BAA4B,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;oBACjG,WAAW,EAAE,IAAI,CAAC,eAAe,IAAI,4BAA4B,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;oBAChG,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;oBACzG,gBAAgB,EAAE,IAAI,CAAC,eAAe,IAAI,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;oBAC3G,SAAS,EAAE,IAAI,CAAC,UAAU;oBAC1B,cAAc,EAAE,IAAI,CAAC,eAAe;oBACpC,mBAAmB,EAAE,IAAI,CAAC,oBAAoB;iBACjD;SACd,CAAC,CAAC;IACP,CAAC;;AA59Ba,gDAAsB,GAAG,CAAC,CAAC;AAC3B,6CAAmB,GAAG,CAAC,CAAC;AACxB,sCAAY,GAAG,CAAC,CAAC;AACjB,sDAA4B,GAAG,CAAC,CAAC;AAIhC,0DAAgC,GAAG,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Constants } from \"../constants\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebGPUHardwareTexture } from \"./webgpuHardwareTexture\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessor } from \"./webgpuShaderProcessor\";\r\nimport { renderableTextureFormatToIndex, WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\n\r\nenum StatePosition {\r\n StencilReadMask = 0,\r\n StencilWriteMask = 1,\r\n //DepthBiasClamp = 1, // not used, so remove it to improve perf\r\n DepthBias = 2,\r\n DepthBiasSlopeScale = 3,\r\n DepthStencilState = 4,\r\n MRTAttachments1 = 5,\r\n MRTAttachments2 = 6,\r\n RasterizationState = 7,\r\n ColorStates = 8,\r\n ShaderStage = 9,\r\n TextureStage = 10,\r\n VertexState = 11, // vertex state will consume positions 11, 12, ... depending on the number of vertex inputs\r\n\r\n NumStates = 12,\r\n}\r\n\r\nconst alphaBlendFactorToIndex: { [name: number]: number } = {\r\n 0: 1, // Zero\r\n 1: 2, // One\r\n 0x0300: 3, // SrcColor\r\n 0x0301: 4, // OneMinusSrcColor\r\n 0x0302: 5, // SrcAlpha\r\n 0x0303: 6, // OneMinusSrcAlpha\r\n 0x0304: 7, // DstAlpha\r\n 0x0305: 8, // OneMinusDstAlpha\r\n 0x0306: 9, // DstColor\r\n 0x0307: 10, // OneMinusDstColor\r\n 0x0308: 11, // SrcAlphaSaturated\r\n 0x8001: 12, // BlendColor\r\n 0x8002: 13, // OneMinusBlendColor\r\n 0x8003: 12, // BlendColor (alpha)\r\n 0x8004: 13, // OneMinusBlendColor (alpha)\r\n};\r\n\r\nconst stencilOpToIndex: { [name: number]: number } = {\r\n 0x0000: 0, // ZERO\r\n 0x1e00: 1, // KEEP\r\n 0x1e01: 2, // REPLACE\r\n 0x1e02: 3, // INCR\r\n 0x1e03: 4, // DECR\r\n 0x150a: 5, // INVERT\r\n 0x8507: 6, // INCR_WRAP\r\n 0x8508: 7, // DECR_WRAP\r\n};\r\n\r\n/** @internal */\r\nexport abstract class WebGPUCacheRenderPipeline {\r\n public static NumCacheHitWithoutHash = 0;\r\n public static NumCacheHitWithHash = 0;\r\n public static NumCacheMiss = 0;\r\n public static NumPipelineCreationLastFrame = 0;\r\n\r\n public disabled: boolean;\r\n\r\n private static _NumPipelineCreationCurrentFrame = 0;\r\n\r\n protected _states: number[];\r\n protected _statesLength: number;\r\n protected _stateDirtyLowestIndex: number;\r\n public lastStateDirtyLowestIndex: number; // for stats only\r\n\r\n private _device: GPUDevice;\r\n private _isDirty: boolean;\r\n private _emptyVertexBuffer: VertexBuffer;\r\n private _parameter: { token: any; pipeline: Nullable<GPURenderPipeline> };\r\n private _kMaxVertexBufferStride;\r\n\r\n private _shaderId: number;\r\n private _alphaToCoverageEnabled: boolean;\r\n private _frontFace: number;\r\n private _cullEnabled: boolean;\r\n private _cullFace: number;\r\n private _clampDepth: boolean;\r\n private _rasterizationState: number;\r\n private _depthBias: number;\r\n private _depthBiasClamp: number;\r\n private _depthBiasSlopeScale: number;\r\n private _colorFormat: number;\r\n private _webgpuColorFormat: (GPUTextureFormat | null)[];\r\n private _mrtAttachments1: number;\r\n private _mrtAttachments2: number;\r\n private _mrtFormats: (GPUTextureFormat | null)[];\r\n private _mrtEnabledMask: number;\r\n private _alphaBlendEnabled: boolean;\r\n private _alphaBlendFuncParams: Array<Nullable<number>>;\r\n private _alphaBlendEqParams: Array<Nullable<number>>;\r\n private _writeMask: number;\r\n private _colorStates: number;\r\n private _depthStencilFormat: number;\r\n private _webgpuDepthStencilFormat: GPUTextureFormat | undefined;\r\n private _depthTestEnabled: boolean;\r\n private _depthWriteEnabled: boolean;\r\n private _depthCompare: number;\r\n private _stencilEnabled: boolean;\r\n private _stencilFrontCompare: number;\r\n private _stencilFrontDepthFailOp: number;\r\n private _stencilFrontPassOp: number;\r\n private _stencilFrontFailOp: number;\r\n private _stencilReadMask: number;\r\n private _stencilWriteMask: number;\r\n private _depthStencilState: number;\r\n private _vertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>;\r\n private _overrideVertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>;\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _textureState: number;\r\n private _useTextureStage: boolean;\r\n\r\n constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer, useTextureStage: boolean) {\r\n this._device = device;\r\n this._useTextureStage = useTextureStage;\r\n this._states = new Array(30); // pre-allocate enough room so that no new allocation will take place afterwards\r\n this._statesLength = 0;\r\n this._stateDirtyLowestIndex = 0;\r\n this._emptyVertexBuffer = emptyVertexBuffer;\r\n this._mrtFormats = [];\r\n this._parameter = { token: undefined, pipeline: null };\r\n this.disabled = false;\r\n this.vertexBuffers = [];\r\n this._kMaxVertexBufferStride = device.limits.maxVertexBufferArrayStride || 2048;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this._isDirty = true;\r\n this.vertexBuffers.length = 0;\r\n this.setAlphaToCoverage(false);\r\n this.resetDepthCullingState();\r\n this.setClampDepth(false);\r\n this.setDepthBias(0);\r\n //this.setDepthBiasClamp(0);\r\n this._webgpuColorFormat = [WebGPUConstants.TextureFormat.BGRA8Unorm];\r\n this.setColorFormat(WebGPUConstants.TextureFormat.BGRA8Unorm);\r\n this.setMRT([]);\r\n this.setAlphaBlendEnabled(false);\r\n this.setAlphaBlendFactors([null, null, null, null], [null, null]);\r\n this.setWriteMask(0xf);\r\n this.setDepthStencilFormat(WebGPUConstants.TextureFormat.Depth24PlusStencil8);\r\n this.setStencilEnabled(false);\r\n this.resetStencilState();\r\n this.setBuffers(null, null, null);\r\n this._setTextureState(0);\r\n }\r\n\r\n protected abstract _getRenderPipeline(param: { token: any; pipeline: Nullable<GPURenderPipeline> }): void;\r\n protected abstract _setRenderPipeline(param: { token: any; pipeline: Nullable<GPURenderPipeline> }): void;\r\n\r\n public readonly vertexBuffers: VertexBuffer[];\r\n\r\n public get colorFormats(): (GPUTextureFormat | null)[] {\r\n return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat;\r\n }\r\n\r\n public readonly mrtAttachments: number[];\r\n public readonly mrtTextureArray: InternalTexture[];\r\n public readonly mrtTextureCount: number = 0;\r\n\r\n public getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number, textureState = 0): GPURenderPipeline {\r\n if (sampleCount > 1) {\r\n // WebGPU only supports 1 or 4\r\n sampleCount = 4;\r\n }\r\n if (this.disabled) {\r\n const topology = WebGPUCacheRenderPipeline._GetTopology(fillMode);\r\n\r\n this._setVertexState(effect); // to fill this.vertexBuffers with correct data\r\n\r\n this._parameter.pipeline = this._createRenderPipeline(effect, topology, sampleCount);\r\n\r\n WebGPUCacheRenderPipeline.NumCacheMiss++;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame++;\r\n\r\n return this._parameter.pipeline;\r\n }\r\n\r\n this._setShaderStage(effect.uniqueId);\r\n this._setRasterizationState(fillMode, sampleCount);\r\n this._setColorStates();\r\n this._setDepthStencilState();\r\n this._setVertexState(effect);\r\n this._setTextureState(textureState);\r\n\r\n this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex;\r\n\r\n if (!this._isDirty && this._parameter.pipeline) {\r\n this._stateDirtyLowestIndex = this._statesLength;\r\n WebGPUCacheRenderPipeline.NumCacheHitWithoutHash++;\r\n return this._parameter.pipeline;\r\n }\r\n\r\n this._getRenderPipeline(this._parameter);\r\n\r\n this._isDirty = false;\r\n this._stateDirtyLowestIndex = this._statesLength;\r\n\r\n if (this._parameter.pipeline) {\r\n WebGPUCacheRenderPipeline.NumCacheHitWithHash++;\r\n return this._parameter.pipeline;\r\n }\r\n\r\n const topology = WebGPUCacheRenderPipeline._GetTopology(fillMode);\r\n\r\n this._parameter.pipeline = this._createRenderPipeline(effect, topology, sampleCount);\r\n this._setRenderPipeline(this._parameter);\r\n\r\n WebGPUCacheRenderPipeline.NumCacheMiss++;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame++;\r\n\r\n return this._parameter.pipeline;\r\n }\r\n\r\n public endFrame(): void {\r\n WebGPUCacheRenderPipeline.NumPipelineCreationLastFrame = WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame = 0;\r\n }\r\n\r\n public setAlphaToCoverage(enabled: boolean): void {\r\n this._alphaToCoverageEnabled = enabled;\r\n }\r\n\r\n public setFrontFace(frontFace: number): void {\r\n this._frontFace = frontFace;\r\n }\r\n\r\n public setCullEnabled(enabled: boolean): void {\r\n this._cullEnabled = enabled;\r\n }\r\n\r\n public setCullFace(cullFace: number): void {\r\n this._cullFace = cullFace;\r\n }\r\n\r\n public setClampDepth(clampDepth: boolean): void {\r\n this._clampDepth = clampDepth;\r\n }\r\n\r\n public resetDepthCullingState(): void {\r\n this.setDepthCullingState(false, 2, 1, 0, 0, true, true, Constants.ALWAYS);\r\n }\r\n\r\n public setDepthCullingState(\r\n cullEnabled: boolean,\r\n frontFace: number,\r\n cullFace: number,\r\n zOffset: number,\r\n zOffsetUnits: number,\r\n depthTestEnabled: boolean,\r\n depthWriteEnabled: boolean,\r\n depthCompare: Nullable<number>\r\n ): void {\r\n this._depthWriteEnabled = depthWriteEnabled;\r\n this._depthTestEnabled = depthTestEnabled;\r\n this._depthCompare = (depthCompare ?? Constants.ALWAYS) - 0x0200;\r\n this._cullFace = cullFace;\r\n this._cullEnabled = cullEnabled;\r\n this._frontFace = frontFace;\r\n this.setDepthBiasSlopeScale(zOffset);\r\n this.setDepthBias(zOffsetUnits);\r\n }\r\n\r\n public setDepthBias(depthBias: number): void {\r\n if (this._depthBias !== depthBias) {\r\n this._depthBias = depthBias;\r\n this._states[StatePosition.DepthBias] = depthBias;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBias);\r\n }\r\n }\r\n\r\n /*public setDepthBiasClamp(depthBiasClamp: number): void {\r\n if (this._depthBiasClamp !== depthBiasClamp) {\r\n this._depthBiasClamp = depthBiasClamp;\r\n this._states[StatePosition.DepthBiasClamp] = depthBiasClamp.toString();\r\n this._isDirty = true;\r\n }\r\n }*/\r\n\r\n public setDepthBiasSlopeScale(depthBiasSlopeScale: number): void {\r\n if (this._depthBiasSlopeScale !== depthBiasSlopeScale) {\r\n this._depthBiasSlopeScale = depthBiasSlopeScale;\r\n this._states[StatePosition.DepthBiasSlopeScale] = depthBiasSlopeScale;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBiasSlopeScale);\r\n }\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._webgpuColorFormat[0] = format;\r\n this._colorFormat = renderableTextureFormatToIndex[format ?? \"\"];\r\n }\r\n\r\n public setMRTAttachments(attachments: number[]): void {\r\n (this.mrtAttachments as any) = attachments;\r\n let mask = 0;\r\n for (let i = 0; i < attachments.length; ++i) {\r\n if (attachments[i] !== 0) {\r\n mask += 1 << i;\r\n }\r\n }\r\n if (this._mrtEnabledMask !== mask) {\r\n this._mrtEnabledMask = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1);\r\n }\r\n }\r\n\r\n public setMRT(textureArray: InternalTexture[], textureCount?: number): void {\r\n textureCount = textureCount ?? textureArray.length;\r\n if (textureCount > 10) {\r\n // If we want more than 10 attachments we need to change this method (and the StatePosition enum) but 10 seems plenty: note that WebGPU only supports 8 at the time (2021/12/13)!\r\n // As we need 39 different values we are using 6 bits to encode a texture format, meaning we can encode 5 texture formats in 32 bits\r\n // We are using 2x32 bit values to handle 10 textures\r\n throw \"Can't handle more than 10 attachments for a MRT in cache render pipeline!\";\r\n }\r\n (this.mrtTextureArray as any) = textureArray;\r\n (this.mrtTextureCount as any) = textureCount;\r\n\r\n this._mrtEnabledMask = 0xffff; // all textures are enabled at start (meaning we can write to them). Calls to setMRTAttachments may disable some\r\n\r\n const bits: number[] = [0, 0];\r\n let indexBits = 0,\r\n mask = 0,\r\n numRT = 0;\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n const gpuWrapper = texture?._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n this._mrtFormats[numRT] = gpuWrapper?.format ?? this._webgpuColorFormat[0];\r\n\r\n bits[indexBits] += renderableTextureFormatToIndex[this._mrtFormats[numRT] ?? \"\"] << mask;\r\n mask += 6;\r\n numRT++;\r\n\r\n if (mask >= 32) {\r\n mask = 0;\r\n indexBits++;\r\n }\r\n }\r\n this._mrtFormats.length = numRT;\r\n if (this._mrtAttachments1 !== bits[0] || this._mrtAttachments2 !== bits[1]) {\r\n this._mrtAttachments1 = bits[0];\r\n this._mrtAttachments2 = bits[1];\r\n this._states[StatePosition.MRTAttachments1] = bits[0];\r\n this._states[StatePosition.MRTAttachments2] = bits[1];\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1);\r\n }\r\n }\r\n\r\n public setAlphaBlendEnabled(enabled: boolean): void {\r\n this._alphaBlendEnabled = enabled;\r\n }\r\n\r\n public setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void {\r\n this._alphaBlendFuncParams = factors;\r\n this._alphaBlendEqParams = operations;\r\n }\r\n\r\n public setWriteMask(mask: number): void {\r\n this._writeMask = mask;\r\n }\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._webgpuDepthStencilFormat = format;\r\n this._depthStencilFormat = format === undefined ? 0 : renderableTextureFormatToIndex[format];\r\n }\r\n\r\n public setDepthTestEnabled(enabled: boolean): void {\r\n this._depthTestEnabled = enabled;\r\n }\r\n\r\n public setDepthWriteEnabled(enabled: boolean): void {\r\n this._depthWriteEnabled = enabled;\r\n }\r\n\r\n public setDepthCompare(func: Nullable<number>): void {\r\n this._depthCompare = (func ?? Constants.ALWAYS) - 0x0200;\r\n }\r\n\r\n public setStencilEnabled(enabled: boolean): void {\r\n this._stencilEnabled = enabled;\r\n }\r\n\r\n public setStencilCompare(func: Nullable<number>): void {\r\n this._stencilFrontCompare = (func ?? Constants.ALWAYS) - 0x0200;\r\n }\r\n\r\n public setStencilDepthFailOp(op: Nullable<number>): void {\r\n this._stencilFrontDepthFailOp = op === null ? 1 /* KEEP */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilPassOp(op: Nullable<number>): void {\r\n this._stencilFrontPassOp = op === null ? 2 /* REPLACE */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilFailOp(op: Nullable<number>): void {\r\n this._stencilFrontFailOp = op === null ? 1 /* KEEP */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilReadMask(mask: number): void {\r\n if (this._stencilReadMask !== mask) {\r\n this._stencilReadMask = mask;\r\n this._states[StatePosition.StencilReadMask] = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilReadMask);\r\n }\r\n }\r\n\r\n public setStencilWriteMask(mask: number): void {\r\n if (this._stencilWriteMask !== mask) {\r\n this._stencilWriteMask = mask;\r\n this._states[StatePosition.StencilWriteMask] = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilWriteMask);\r\n }\r\n }\r\n\r\n public resetStencilState(): void {\r\n this.setStencilState(false, Constants.ALWAYS, Constants.KEEP, Constants.REPLACE, Constants.KEEP, 0xff, 0xff);\r\n }\r\n\r\n public setStencilState(\r\n stencilEnabled: boolean,\r\n compare: Nullable<number>,\r\n depthFailOp: Nullable<number>,\r\n passOp: Nullable<number>,\r\n failOp: Nullable<number>,\r\n readMask: number,\r\n writeMask: number\r\n ): void {\r\n this._stencilEnabled = stencilEnabled;\r\n this._stencilFrontCompare = (compare ?? Constants.ALWAYS) - 0x0200;\r\n this._stencilFrontDepthFailOp = depthFailOp === null ? 1 /* KEEP */ : stencilOpToIndex[depthFailOp];\r\n this._stencilFrontPassOp = passOp === null ? 2 /* REPLACE */ : stencilOpToIndex[passOp];\r\n this._stencilFrontFailOp = failOp === null ? 1 /* KEEP */ : stencilOpToIndex[failOp];\r\n this.setStencilReadMask(readMask);\r\n this.setStencilWriteMask(writeMask);\r\n }\r\n\r\n public setBuffers(\r\n vertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>,\r\n indexBuffer: Nullable<DataBuffer>,\r\n overrideVertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>\r\n ): void {\r\n this._vertexBuffers = vertexBuffers;\r\n this._overrideVertexBuffers = overrideVertexBuffers;\r\n this._indexBuffer = indexBuffer;\r\n }\r\n\r\n private static _GetTopology(fillMode: number): GPUPrimitiveTopology {\r\n switch (fillMode) {\r\n // Triangle views\r\n case Constants.MATERIAL_TriangleFillMode:\r\n return WebGPUConstants.PrimitiveTopology.TriangleList;\r\n case Constants.MATERIAL_PointFillMode:\r\n return WebGPUConstants.PrimitiveTopology.PointList;\r\n case Constants.MATERIAL_WireFrameFillMode:\r\n return WebGPUConstants.PrimitiveTopology.LineList;\r\n // Draw modes\r\n case Constants.MATERIAL_PointListDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.PointList;\r\n case Constants.MATERIAL_LineListDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.LineList;\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n // return this._gl.LINE_LOOP;\r\n // TODO WEBGPU. Line Loop Mode Fallback at buffer load time.\r\n throw \"LineLoop is an unsupported fillmode in WebGPU\";\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.LineStrip;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.TriangleStrip;\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n // return this._gl.TRIANGLE_FAN;\r\n // TODO WEBGPU. Triangle Fan Mode Fallback at buffer load time.\r\n throw \"TriangleFan is an unsupported fillmode in WebGPU\";\r\n default:\r\n return WebGPUConstants.PrimitiveTopology.TriangleList;\r\n }\r\n }\r\n\r\n private static _GetAphaBlendOperation(operation: Nullable<number>): GPUBlendOperation {\r\n switch (operation) {\r\n case Constants.GL_ALPHA_EQUATION_ADD:\r\n return WebGPUConstants.BlendOperation.Add;\r\n case Constants.GL_ALPHA_EQUATION_SUBTRACT:\r\n return WebGPUConstants.BlendOperation.Subtract;\r\n case Constants.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:\r\n return WebGPUConstants.BlendOperation.ReverseSubtract;\r\n case Constants.GL_ALPHA_EQUATION_MIN:\r\n return WebGPUConstants.BlendOperation.Min;\r\n case Constants.GL_ALPHA_EQUATION_MAX:\r\n return WebGPUConstants.BlendOperation.Max;\r\n default:\r\n return WebGPUConstants.BlendOperation.Add;\r\n }\r\n }\r\n\r\n private static _GetAphaBlendFactor(factor: Nullable<number>): GPUBlendFactor {\r\n switch (factor) {\r\n case 0:\r\n return WebGPUConstants.BlendFactor.Zero;\r\n case 1:\r\n return WebGPUConstants.BlendFactor.One;\r\n case Constants.GL_ALPHA_FUNCTION_SRC:\r\n return WebGPUConstants.BlendFactor.Src;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusSrc;\r\n case Constants.GL_ALPHA_FUNCTION_SRC_ALPHA:\r\n return WebGPUConstants.BlendFactor.SrcAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusSrcAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_DST_ALPHA:\r\n return WebGPUConstants.BlendFactor.DstAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusDstAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_DST_COLOR:\r\n return WebGPUConstants.BlendFactor.Dst;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusDst;\r\n case Constants.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:\r\n return WebGPUConstants.BlendFactor.SrcAlphaSaturated;\r\n case Constants.GL_ALPHA_FUNCTION_CONSTANT_COLOR:\r\n return WebGPUConstants.BlendFactor.Constant;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusConstant;\r\n case Constants.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:\r\n return WebGPUConstants.BlendFactor.Constant;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusConstant;\r\n default:\r\n return WebGPUConstants.BlendFactor.One;\r\n }\r\n }\r\n\r\n private static _GetCompareFunction(compareFunction: number): GPUCompareFunction {\r\n switch (compareFunction) {\r\n case 0: // NEVER\r\n return WebGPUConstants.CompareFunction.Never;\r\n case 1: // LESS\r\n return WebGPUConstants.CompareFunction.Less;\r\n case 2: // EQUAL\r\n return WebGPUConstants.CompareFunction.Equal;\r\n case 3: // LEQUAL\r\n return WebGPUConstants.CompareFunction.LessEqual;\r\n case 4: // GREATER\r\n return WebGPUConstants.CompareFunction.Greater;\r\n case 5: // NOTEQUAL\r\n return WebGPUConstants.CompareFunction.NotEqual;\r\n case 6: // GEQUAL\r\n return WebGPUConstants.CompareFunction.GreaterEqual;\r\n case 7: // ALWAYS\r\n return WebGPUConstants.CompareFunction.Always;\r\n }\r\n return WebGPUConstants.CompareFunction.Never;\r\n }\r\n\r\n private static _GetStencilOpFunction(operation: number): GPUStencilOperation {\r\n switch (operation) {\r\n case 0:\r\n return WebGPUConstants.StencilOperation.Zero;\r\n case 1:\r\n return WebGPUConstants.StencilOperation.Keep;\r\n case 2:\r\n return WebGPUConstants.StencilOperation.Replace;\r\n case 3:\r\n return WebGPUConstants.StencilOperation.IncrementClamp;\r\n case 4:\r\n return WebGPUConstants.StencilOperation.DecrementClamp;\r\n case 5:\r\n return WebGPUConstants.StencilOperation.Invert;\r\n case 6:\r\n return WebGPUConstants.StencilOperation.IncrementWrap;\r\n case 7:\r\n return WebGPUConstants.StencilOperation.DecrementWrap;\r\n }\r\n return WebGPUConstants.StencilOperation.Keep;\r\n }\r\n\r\n private static _GetVertexInputDescriptorFormat(vertexBuffer: VertexBuffer): GPUVertexFormat {\r\n const type = vertexBuffer.type;\r\n const normalized = vertexBuffer.normalized;\r\n const size = vertexBuffer.getSize();\r\n\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm8x2 : WebGPUConstants.VertexFormat.Sint8x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm8x4 : WebGPUConstants.VertexFormat.Sint8x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm8x2 : WebGPUConstants.VertexFormat.Uint8x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm8x4 : WebGPUConstants.VertexFormat.Uint8x4;\r\n }\r\n break;\r\n case VertexBuffer.SHORT:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm16x2 : WebGPUConstants.VertexFormat.Sint16x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm16x4 : WebGPUConstants.VertexFormat.Sint16x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm16x2 : WebGPUConstants.VertexFormat.Uint16x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm16x4 : WebGPUConstants.VertexFormat.Uint16x4;\r\n }\r\n break;\r\n case VertexBuffer.INT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Sint32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Sint32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Sint32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Sint32x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Uint32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Uint32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Uint32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Uint32x4;\r\n }\r\n break;\r\n case VertexBuffer.FLOAT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Float32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Float32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Float32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Float32x4;\r\n }\r\n break;\r\n }\r\n\r\n throw new Error(`Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size}`);\r\n }\r\n\r\n private _getAphaBlendState(): Nullable<GPUBlendComponent> {\r\n if (!this._alphaBlendEnabled) {\r\n return null;\r\n }\r\n\r\n return {\r\n srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),\r\n dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),\r\n operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[1]),\r\n };\r\n }\r\n\r\n private _getColorBlendState(): Nullable<GPUBlendComponent> {\r\n if (!this._alphaBlendEnabled) {\r\n return null;\r\n }\r\n\r\n return {\r\n srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),\r\n dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),\r\n operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[0]),\r\n };\r\n }\r\n\r\n private _setShaderStage(id: number): void {\r\n if (this._shaderId !== id) {\r\n this._shaderId = id;\r\n this._states[StatePosition.ShaderStage] = id;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ShaderStage);\r\n }\r\n }\r\n\r\n private _setRasterizationState(topology: number, sampleCount: number): void {\r\n const frontFace = this._frontFace;\r\n const cullMode = this._cullEnabled ? this._cullFace : 0;\r\n const clampDepth = this._clampDepth ? 1 : 0;\r\n const alphaToCoverage = this._alphaToCoverageEnabled ? 1 : 0;\r\n const rasterizationState = frontFace - 1 + (cullMode << 1) + (clampDepth << 3) + (alphaToCoverage << 4) + (topology << 5) + (sampleCount << 8);\r\n\r\n if (this._rasterizationState !== rasterizationState) {\r\n this._rasterizationState = rasterizationState;\r\n this._states[StatePosition.RasterizationState] = this._rasterizationState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.RasterizationState);\r\n }\r\n }\r\n\r\n private _setColorStates(): void {\r\n let colorStates = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29); // this state has been moved from depthStencilState here because alpha and depth are related (generally when alpha is on, depth write is off and the other way around)\r\n\r\n if (this._alphaBlendEnabled) {\r\n colorStates +=\r\n ((this._alphaBlendFuncParams[0] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[0]]) << 0) +\r\n ((this._alphaBlendFuncParams[1] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[1]]) << 4) +\r\n ((this._alphaBlendFuncParams[2] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[2]]) << 8) +\r\n ((this._alphaBlendFuncParams[3] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[3]]) << 12) +\r\n ((this._alphaBlendEqParams[0] === null ? 1 : this._alphaBlendEqParams[0] - 0x8005) << 16) +\r\n ((this._alphaBlendEqParams[1] === null ? 1 : this._alphaBlendEqParams[1] - 0x8005) << 19);\r\n }\r\n\r\n if (colorStates !== this._colorStates) {\r\n this._colorStates = colorStates;\r\n this._states[StatePosition.ColorStates] = this._colorStates;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ColorStates);\r\n }\r\n }\r\n\r\n private _setDepthStencilState(): void {\r\n const stencilState = !this._stencilEnabled\r\n ? 7 /* ALWAYS */ + (1 /* KEEP */ << 3) + (1 /* KEEP */ << 6) + (1 /* KEEP */ << 9)\r\n : this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9);\r\n\r\n const depthStencilState = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) /* ALWAYS */ << 6) + (stencilState << 10); // stencil front - stencil back is the same\r\n\r\n if (this._depthStencilState !== depthStencilState) {\r\n this._depthStencilState = depthStencilState;\r\n this._states[StatePosition.DepthStencilState] = this._depthStencilState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthStencilState);\r\n }\r\n }\r\n\r\n private _setVertexState(effect: Effect): void {\r\n const currStateLen = this._statesLength;\r\n let newNumStates = StatePosition.VertexState;\r\n\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const attributes = webgpuPipelineContext.shaderProcessingContext.attributeNamesFromEffect;\r\n const locations = webgpuPipelineContext.shaderProcessingContext.attributeLocationsFromEffect;\r\n\r\n let currentGPUBuffer;\r\n let numVertexBuffers = 0;\r\n for (let index = 0; index < attributes.length; index++) {\r\n const location = locations[index];\r\n let vertexBuffer = (this._overrideVertexBuffers && this._overrideVertexBuffers[attributes[index]]) ?? this._vertexBuffers![attributes[index]];\r\n if (!vertexBuffer) {\r\n // In WebGL it's valid to not bind a vertex buffer to an attribute, but it's not valid in WebGPU\r\n // So we must bind a dummy buffer when we are not given one for a specific attribute\r\n vertexBuffer = this._emptyVertexBuffer;\r\n }\r\n\r\n const buffer = vertexBuffer.getBuffer()?.underlyingResource;\r\n\r\n // We optimize usage of GPUVertexBufferLayout: we will create a single GPUVertexBufferLayout for all the attributes which follow each other and which use the same GPU buffer\r\n // However, there are some constraints in the attribute.offset value range, so we must check for them before being able to reuse the same GPUVertexBufferLayout\r\n // See _getVertexInputDescriptor() below\r\n if (vertexBuffer._validOffsetRange === undefined) {\r\n const offset = vertexBuffer.byteOffset;\r\n const formatSize = vertexBuffer.getSize(true);\r\n const byteStride = vertexBuffer.byteStride;\r\n vertexBuffer._validOffsetRange = offset <= this._kMaxVertexBufferStride - formatSize && (byteStride === 0 || offset + formatSize <= byteStride);\r\n }\r\n\r\n if (!(currentGPUBuffer && currentGPUBuffer === buffer && vertexBuffer._validOffsetRange)) {\r\n // we can't combine the previous vertexBuffer with the current one\r\n this.vertexBuffers[numVertexBuffers++] = vertexBuffer;\r\n currentGPUBuffer = vertexBuffer._validOffsetRange ? buffer : null;\r\n }\r\n\r\n const vid = vertexBuffer.hashCode + (location << 7);\r\n\r\n this._isDirty = this._isDirty || this._states[newNumStates] !== vid;\r\n this._states[newNumStates++] = vid;\r\n }\r\n\r\n this.vertexBuffers.length = numVertexBuffers;\r\n\r\n this._statesLength = newNumStates;\r\n this._isDirty = this._isDirty || newNumStates !== currStateLen;\r\n if (this._isDirty) {\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.VertexState);\r\n }\r\n }\r\n\r\n private _setTextureState(textureState: number): void {\r\n if (this._textureState !== textureState) {\r\n this._textureState = textureState;\r\n this._states[StatePosition.TextureStage] = this._textureState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.TextureStage);\r\n }\r\n }\r\n\r\n private _createPipelineLayout(webgpuPipelineContext: WebGPUPipelineContext): GPUPipelineLayout {\r\n if (this._useTextureStage) {\r\n return this._createPipelineLayoutWithTextureStage(webgpuPipelineContext);\r\n }\r\n\r\n const bindGroupLayouts: GPUBindGroupLayout[] = [];\r\n const bindGroupLayoutEntries = webgpuPipelineContext.shaderProcessingContext.bindGroupLayoutEntries;\r\n\r\n for (let i = 0; i < bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = bindGroupLayoutEntries[i];\r\n\r\n bindGroupLayouts[i] = this._device.createBindGroupLayout({\r\n entries: setDefinition,\r\n });\r\n }\r\n\r\n webgpuPipelineContext.bindGroupLayouts = bindGroupLayouts;\r\n\r\n return this._device.createPipelineLayout({ bindGroupLayouts });\r\n }\r\n\r\n private _createPipelineLayoutWithTextureStage(webgpuPipelineContext: WebGPUPipelineContext): GPUPipelineLayout {\r\n const shaderProcessingContext = webgpuPipelineContext.shaderProcessingContext;\r\n const bindGroupLayoutEntries = shaderProcessingContext.bindGroupLayoutEntries;\r\n\r\n let bitVal = 1;\r\n for (let i = 0; i < bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = bindGroupLayoutEntries[i];\r\n\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = bindGroupLayoutEntries[i][j];\r\n\r\n if (entry.texture) {\r\n const name = shaderProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].name;\r\n const textureInfo = shaderProcessingContext.availableTextures[name];\r\n const samplerInfo = textureInfo.autoBindSampler ? shaderProcessingContext.availableSamplers[name + WebGPUShaderProcessor.AutoSamplerSuffix] : null;\r\n\r\n let sampleType = textureInfo.sampleType;\r\n let samplerType = samplerInfo?.type ?? WebGPUConstants.SamplerBindingType.Filtering;\r\n\r\n if (this._textureState & bitVal && sampleType !== WebGPUConstants.TextureSampleType.Depth) {\r\n // The texture is a 32 bits float texture but the system does not support linear filtering for them:\r\n // we set the sampler to \"non-filtering\" and the texture sample type to \"unfilterable-float\"\r\n if (textureInfo.autoBindSampler) {\r\n samplerType = WebGPUConstants.SamplerBindingType.NonFiltering;\r\n }\r\n sampleType = WebGPUConstants.TextureSampleType.UnfilterableFloat;\r\n }\r\n\r\n entry.texture!.sampleType = sampleType;\r\n\r\n if (samplerInfo) {\r\n const binding = shaderProcessingContext.bindGroupLayoutEntryInfo[samplerInfo.binding.groupIndex][samplerInfo.binding.bindingIndex].index;\r\n bindGroupLayoutEntries[samplerInfo.binding.groupIndex][binding].sampler!.type = samplerType;\r\n }\r\n\r\n bitVal = bitVal << 1;\r\n }\r\n }\r\n }\r\n\r\n const bindGroupLayouts: GPUBindGroupLayout[] = [];\r\n\r\n for (let i = 0; i < bindGroupLayoutEntries.length; ++i) {\r\n bindGroupLayouts[i] = this._device.createBindGroupLayout({\r\n entries: bindGroupLayoutEntries[i],\r\n });\r\n }\r\n\r\n webgpuPipelineContext.bindGroupLayouts = bindGroupLayouts;\r\n\r\n return this._device.createPipelineLayout({ bindGroupLayouts });\r\n }\r\n\r\n private _getVertexInputDescriptor(effect: Effect): GPUVertexBufferLayout[] {\r\n const descriptors: GPUVertexBufferLayout[] = [];\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const attributes = webgpuPipelineContext.shaderProcessingContext.attributeNamesFromEffect;\r\n const locations = webgpuPipelineContext.shaderProcessingContext.attributeLocationsFromEffect;\r\n\r\n let currentGPUBuffer;\r\n let currentGPUAttributes: GPUVertexAttribute[] | undefined;\r\n for (let index = 0; index < attributes.length; index++) {\r\n const location = locations[index];\r\n let vertexBuffer = (this._overrideVertexBuffers && this._overrideVertexBuffers[attributes[index]]) ?? this._vertexBuffers![attributes[index]];\r\n if (!vertexBuffer) {\r\n // In WebGL it's valid to not bind a vertex buffer to an attribute, but it's not valid in WebGPU\r\n // So we must bind a dummy buffer when we are not given one for a specific attribute\r\n vertexBuffer = this._emptyVertexBuffer;\r\n }\r\n\r\n let buffer = vertexBuffer.getBuffer()?.underlyingResource;\r\n\r\n // We reuse the same GPUVertexBufferLayout for all attributes that use the same underlying GPU buffer (and for attributes that follow each other in the attributes array)\r\n let offset = vertexBuffer.byteOffset;\r\n const invalidOffsetRange = !vertexBuffer._validOffsetRange;\r\n if (!(currentGPUBuffer && currentGPUAttributes && currentGPUBuffer === buffer) || invalidOffsetRange) {\r\n const vertexBufferDescriptor: GPUVertexBufferLayout = {\r\n arrayStride: vertexBuffer.byteStride,\r\n stepMode: vertexBuffer.getIsInstanced() ? WebGPUConstants.InputStepMode.Instance : WebGPUConstants.InputStepMode.Vertex,\r\n attributes: [],\r\n };\r\n\r\n descriptors.push(vertexBufferDescriptor);\r\n currentGPUAttributes = vertexBufferDescriptor.attributes;\r\n if (invalidOffsetRange) {\r\n offset = 0; // the offset will be set directly in the setVertexBuffer call\r\n buffer = null; // buffer can't be reused\r\n }\r\n }\r\n\r\n currentGPUAttributes.push({\r\n shaderLocation: location,\r\n offset,\r\n format: WebGPUCacheRenderPipeline._GetVertexInputDescriptorFormat(vertexBuffer),\r\n });\r\n\r\n currentGPUBuffer = buffer;\r\n }\r\n\r\n return descriptors;\r\n }\r\n\r\n private _createRenderPipeline(effect: Effect, topology: GPUPrimitiveTopology, sampleCount: number): GPURenderPipeline {\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const inputStateDescriptor = this._getVertexInputDescriptor(effect);\r\n const pipelineLayout = this._createPipelineLayout(webgpuPipelineContext);\r\n\r\n const colorStates: Array<GPUColorTargetState | null> = [];\r\n const alphaBlend = this._getAphaBlendState();\r\n const colorBlend = this._getColorBlendState();\r\n\r\n if (this._mrtAttachments1 > 0) {\r\n for (let i = 0; i < this._mrtFormats.length; ++i) {\r\n const format = this._mrtFormats[i];\r\n if (format) {\r\n const descr: GPUColorTargetState = {\r\n format,\r\n writeMask: (this._mrtEnabledMask & (1 << i)) !== 0 ? this._writeMask : 0,\r\n };\r\n if (alphaBlend && colorBlend) {\r\n descr.blend = {\r\n alpha: alphaBlend,\r\n color: colorBlend,\r\n };\r\n }\r\n colorStates.push(descr);\r\n } else {\r\n colorStates.push(null);\r\n }\r\n }\r\n } else {\r\n if (this._webgpuColorFormat[0]) {\r\n const descr: GPUColorTargetState = {\r\n format: this._webgpuColorFormat[0],\r\n writeMask: this._writeMask,\r\n };\r\n if (alphaBlend && colorBlend) {\r\n descr.blend = {\r\n alpha: alphaBlend,\r\n color: colorBlend,\r\n };\r\n }\r\n colorStates.push(descr);\r\n } else {\r\n colorStates.push(null);\r\n }\r\n }\r\n\r\n const stencilFrontBack: GPUStencilStateFace = {\r\n compare: WebGPUCacheRenderPipeline._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7 /* ALWAYS */),\r\n depthFailOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1 /* KEEP */),\r\n failOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1 /* KEEP */),\r\n passOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1 /* KEEP */),\r\n };\r\n\r\n let stripIndexFormat: GPUIndexFormat | undefined = undefined;\r\n if (topology === WebGPUConstants.PrimitiveTopology.LineStrip || topology === WebGPUConstants.PrimitiveTopology.TriangleStrip) {\r\n stripIndexFormat = !this._indexBuffer || this._indexBuffer.is32Bits ? WebGPUConstants.IndexFormat.Uint32 : WebGPUConstants.IndexFormat.Uint16;\r\n }\r\n\r\n const depthStencilFormatHasStencil = this._webgpuDepthStencilFormat ? WebGPUTextureHelper.HasStencilAspect(this._webgpuDepthStencilFormat) : false;\r\n\r\n return this._device.createRenderPipeline({\r\n label: `RenderPipeline_${colorStates[0]?.format ?? \"nooutput\"}_${this._webgpuDepthStencilFormat ?? \"nodepth\"}_samples${sampleCount}`,\r\n layout: pipelineLayout,\r\n vertex: {\r\n module: webgpuPipelineContext.stages!.vertexStage.module,\r\n entryPoint: webgpuPipelineContext.stages!.vertexStage.entryPoint,\r\n buffers: inputStateDescriptor,\r\n },\r\n primitive: {\r\n topology,\r\n stripIndexFormat,\r\n frontFace: this._frontFace === 1 ? WebGPUConstants.FrontFace.CCW : WebGPUConstants.FrontFace.CW,\r\n cullMode: !this._cullEnabled ? WebGPUConstants.CullMode.None : this._cullFace === 2 ? WebGPUConstants.CullMode.Front : WebGPUConstants.CullMode.Back,\r\n },\r\n fragment: !webgpuPipelineContext.stages!.fragmentStage\r\n ? undefined\r\n : {\r\n module: webgpuPipelineContext.stages!.fragmentStage.module,\r\n entryPoint: webgpuPipelineContext.stages!.fragmentStage.entryPoint,\r\n targets: colorStates,\r\n },\r\n\r\n multisample: {\r\n count: sampleCount,\r\n /*mask,\r\n alphaToCoverageEnabled,*/\r\n },\r\n depthStencil:\r\n this._webgpuDepthStencilFormat === undefined\r\n ? undefined\r\n : {\r\n depthWriteEnabled: this._depthWriteEnabled,\r\n depthCompare: this._depthTestEnabled ? WebGPUCacheRenderPipeline._GetCompareFunction(this._depthCompare) : WebGPUConstants.CompareFunction.Always,\r\n format: this._webgpuDepthStencilFormat,\r\n stencilFront: this._stencilEnabled && depthStencilFormatHasStencil ? stencilFrontBack : undefined,\r\n stencilBack: this._stencilEnabled && depthStencilFormatHasStencil ? stencilFrontBack : undefined,\r\n stencilReadMask: this._stencilEnabled && depthStencilFormatHasStencil ? this._stencilReadMask : undefined,\r\n stencilWriteMask: this._stencilEnabled && depthStencilFormatHasStencil ? this._stencilWriteMask : undefined,\r\n depthBias: this._depthBias,\r\n depthBiasClamp: this._depthBiasClamp,\r\n depthBiasSlopeScale: this._depthBiasSlopeScale,\r\n },\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webgpuCacheRenderPipeline.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuCacheRenderPipeline.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,IAAK,aAgBJ;AAhBD,WAAK,aAAa;IACd,uEAAmB,CAAA;IACnB,yEAAoB,CAAA;IACpB,+DAA+D;IAC/D,2DAAa,CAAA;IACb,+EAAuB,CAAA;IACvB,2EAAqB,CAAA;IACrB,uEAAmB,CAAA;IACnB,uEAAmB,CAAA;IACnB,6EAAsB,CAAA;IACtB,+DAAe,CAAA;IACf,+DAAe,CAAA;IACf,kEAAiB,CAAA;IACjB,gEAAgB,CAAA;IAEhB,4DAAc,CAAA;AAClB,CAAC,EAhBI,aAAa,KAAb,aAAa,QAgBjB;AAED,MAAM,uBAAuB,GAA+B;IACxD,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE,EAAE,6BAA6B;CAC5C,CAAC;AAEF,MAAM,gBAAgB,GAA+B;IACjD,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM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int/naming-convention */\r\nimport { Constants } from \"../constants\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebGPUHardwareTexture } from \"./webgpuHardwareTexture\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessor } from \"./webgpuShaderProcessor\";\r\nimport { renderableTextureFormatToIndex, WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\n\r\nenum StatePosition {\r\n StencilReadMask = 0,\r\n StencilWriteMask = 1,\r\n //DepthBiasClamp = 1, // not used, so remove it to improve perf\r\n DepthBias = 2,\r\n DepthBiasSlopeScale = 3,\r\n DepthStencilState = 4,\r\n MRTAttachments1 = 5,\r\n MRTAttachments2 = 6,\r\n RasterizationState = 7,\r\n ColorStates = 8,\r\n ShaderStage = 9,\r\n TextureStage = 10,\r\n VertexState = 11, // vertex state will consume positions 11, 12, ... depending on the number of vertex inputs\r\n\r\n NumStates = 12,\r\n}\r\n\r\nconst alphaBlendFactorToIndex: { [name: number]: number } = {\r\n 0: 1, // Zero\r\n 1: 2, // One\r\n 0x0300: 3, // SrcColor\r\n 0x0301: 4, // OneMinusSrcColor\r\n 0x0302: 5, // SrcAlpha\r\n 0x0303: 6, // OneMinusSrcAlpha\r\n 0x0304: 7, // DstAlpha\r\n 0x0305: 8, // OneMinusDstAlpha\r\n 0x0306: 9, // DstColor\r\n 0x0307: 10, // OneMinusDstColor\r\n 0x0308: 11, // SrcAlphaSaturated\r\n 0x8001: 12, // BlendColor\r\n 0x8002: 13, // OneMinusBlendColor\r\n 0x8003: 12, // BlendColor (alpha)\r\n 0x8004: 13, // OneMinusBlendColor (alpha)\r\n};\r\n\r\nconst stencilOpToIndex: { [name: number]: number } = {\r\n 0x0000: 0, // ZERO\r\n 0x1e00: 1, // KEEP\r\n 0x1e01: 2, // REPLACE\r\n 0x1e02: 3, // INCR\r\n 0x1e03: 4, // DECR\r\n 0x150a: 5, // INVERT\r\n 0x8507: 6, // INCR_WRAP\r\n 0x8508: 7, // DECR_WRAP\r\n};\r\n\r\n/** @internal */\r\nexport abstract class WebGPUCacheRenderPipeline {\r\n public static NumCacheHitWithoutHash = 0;\r\n public static NumCacheHitWithHash = 0;\r\n public static NumCacheMiss = 0;\r\n public static NumPipelineCreationLastFrame = 0;\r\n\r\n public disabled: boolean;\r\n\r\n private static _NumPipelineCreationCurrentFrame = 0;\r\n\r\n protected _states: number[];\r\n protected _statesLength: number;\r\n protected _stateDirtyLowestIndex: number;\r\n public lastStateDirtyLowestIndex: number; // for stats only\r\n\r\n private _device: GPUDevice;\r\n private _isDirty: boolean;\r\n private _emptyVertexBuffer: VertexBuffer;\r\n private _parameter: { token: any; pipeline: Nullable<GPURenderPipeline> };\r\n private _kMaxVertexBufferStride;\r\n\r\n private _shaderId: number;\r\n private _alphaToCoverageEnabled: boolean;\r\n private _frontFace: number;\r\n private _cullEnabled: boolean;\r\n private _cullFace: number;\r\n private _clampDepth: boolean;\r\n private _rasterizationState: number;\r\n private _depthBias: number;\r\n private _depthBiasClamp: number;\r\n private _depthBiasSlopeScale: number;\r\n private _colorFormat: number;\r\n private _webgpuColorFormat: (GPUTextureFormat | null)[];\r\n private _mrtAttachments1: number;\r\n private _mrtAttachments2: number;\r\n private _mrtFormats: (GPUTextureFormat | null)[];\r\n private _mrtEnabledMask: number;\r\n private _alphaBlendEnabled: boolean;\r\n private _alphaBlendFuncParams: Array<Nullable<number>>;\r\n private _alphaBlendEqParams: Array<Nullable<number>>;\r\n private _writeMask: number;\r\n private _colorStates: number;\r\n private _depthStencilFormat: number;\r\n private _webgpuDepthStencilFormat: GPUTextureFormat | undefined;\r\n private _depthTestEnabled: boolean;\r\n private _depthWriteEnabled: boolean;\r\n private _depthCompare: number;\r\n private _stencilEnabled: boolean;\r\n private _stencilFrontCompare: number;\r\n private _stencilFrontDepthFailOp: number;\r\n private _stencilFrontPassOp: number;\r\n private _stencilFrontFailOp: number;\r\n private _stencilReadMask: number;\r\n private _stencilWriteMask: number;\r\n private _depthStencilState: number;\r\n private _vertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>;\r\n private _overrideVertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>;\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _textureState: number;\r\n private _useTextureStage: boolean;\r\n\r\n constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer, useTextureStage: boolean) {\r\n this._device = device;\r\n this._useTextureStage = useTextureStage;\r\n this._states = new Array(30); // pre-allocate enough room so that no new allocation will take place afterwards\r\n this._statesLength = 0;\r\n this._stateDirtyLowestIndex = 0;\r\n this._emptyVertexBuffer = emptyVertexBuffer;\r\n this._mrtFormats = [];\r\n this._parameter = { token: undefined, pipeline: null };\r\n this.disabled = false;\r\n this.vertexBuffers = [];\r\n this._kMaxVertexBufferStride = device.limits.maxVertexBufferArrayStride || 2048;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this._isDirty = true;\r\n this.vertexBuffers.length = 0;\r\n this.setAlphaToCoverage(false);\r\n this.resetDepthCullingState();\r\n this.setClampDepth(false);\r\n this.setDepthBias(0);\r\n //this.setDepthBiasClamp(0);\r\n this._webgpuColorFormat = [WebGPUConstants.TextureFormat.BGRA8Unorm];\r\n this.setColorFormat(WebGPUConstants.TextureFormat.BGRA8Unorm);\r\n this.setMRT([]);\r\n this.setAlphaBlendEnabled(false);\r\n this.setAlphaBlendFactors([null, null, null, null], [null, null]);\r\n this.setWriteMask(0xf);\r\n this.setDepthStencilFormat(WebGPUConstants.TextureFormat.Depth24PlusStencil8);\r\n this.setStencilEnabled(false);\r\n this.resetStencilState();\r\n this.setBuffers(null, null, null);\r\n this._setTextureState(0);\r\n }\r\n\r\n protected abstract _getRenderPipeline(param: { token: any; pipeline: Nullable<GPURenderPipeline> }): void;\r\n protected abstract _setRenderPipeline(param: { token: any; pipeline: Nullable<GPURenderPipeline> }): void;\r\n\r\n public readonly vertexBuffers: VertexBuffer[];\r\n\r\n public get colorFormats(): (GPUTextureFormat | null)[] {\r\n return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat;\r\n }\r\n\r\n public readonly mrtAttachments: number[];\r\n public readonly mrtTextureArray: InternalTexture[];\r\n public readonly mrtTextureCount: number = 0;\r\n\r\n public getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number, textureState = 0): GPURenderPipeline {\r\n if (sampleCount > 1) {\r\n // WebGPU only supports 1 or 4\r\n sampleCount = 4;\r\n }\r\n if (this.disabled) {\r\n const topology = WebGPUCacheRenderPipeline._GetTopology(fillMode);\r\n\r\n this._setVertexState(effect); // to fill this.vertexBuffers with correct data\r\n this._setTextureState(textureState);\r\n\r\n this._parameter.pipeline = this._createRenderPipeline(effect, topology, sampleCount);\r\n\r\n WebGPUCacheRenderPipeline.NumCacheMiss++;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame++;\r\n\r\n return this._parameter.pipeline;\r\n }\r\n\r\n this._setShaderStage(effect.uniqueId);\r\n this._setRasterizationState(fillMode, sampleCount);\r\n this._setColorStates();\r\n this._setDepthStencilState();\r\n this._setVertexState(effect);\r\n this._setTextureState(textureState);\r\n\r\n this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex;\r\n\r\n if (!this._isDirty && this._parameter.pipeline) {\r\n this._stateDirtyLowestIndex = this._statesLength;\r\n WebGPUCacheRenderPipeline.NumCacheHitWithoutHash++;\r\n return this._parameter.pipeline;\r\n }\r\n\r\n this._getRenderPipeline(this._parameter);\r\n\r\n this._isDirty = false;\r\n this._stateDirtyLowestIndex = this._statesLength;\r\n\r\n if (this._parameter.pipeline) {\r\n WebGPUCacheRenderPipeline.NumCacheHitWithHash++;\r\n return this._parameter.pipeline;\r\n }\r\n\r\n const topology = WebGPUCacheRenderPipeline._GetTopology(fillMode);\r\n\r\n this._parameter.pipeline = this._createRenderPipeline(effect, topology, sampleCount);\r\n this._setRenderPipeline(this._parameter);\r\n\r\n WebGPUCacheRenderPipeline.NumCacheMiss++;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame++;\r\n\r\n return this._parameter.pipeline;\r\n }\r\n\r\n public endFrame(): void {\r\n WebGPUCacheRenderPipeline.NumPipelineCreationLastFrame = WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame;\r\n WebGPUCacheRenderPipeline._NumPipelineCreationCurrentFrame = 0;\r\n }\r\n\r\n public setAlphaToCoverage(enabled: boolean): void {\r\n this._alphaToCoverageEnabled = enabled;\r\n }\r\n\r\n public setFrontFace(frontFace: number): void {\r\n this._frontFace = frontFace;\r\n }\r\n\r\n public setCullEnabled(enabled: boolean): void {\r\n this._cullEnabled = enabled;\r\n }\r\n\r\n public setCullFace(cullFace: number): void {\r\n this._cullFace = cullFace;\r\n }\r\n\r\n public setClampDepth(clampDepth: boolean): void {\r\n this._clampDepth = clampDepth;\r\n }\r\n\r\n public resetDepthCullingState(): void {\r\n this.setDepthCullingState(false, 2, 1, 0, 0, true, true, Constants.ALWAYS);\r\n }\r\n\r\n public setDepthCullingState(\r\n cullEnabled: boolean,\r\n frontFace: number,\r\n cullFace: number,\r\n zOffset: number,\r\n zOffsetUnits: number,\r\n depthTestEnabled: boolean,\r\n depthWriteEnabled: boolean,\r\n depthCompare: Nullable<number>\r\n ): void {\r\n this._depthWriteEnabled = depthWriteEnabled;\r\n this._depthTestEnabled = depthTestEnabled;\r\n this._depthCompare = (depthCompare ?? Constants.ALWAYS) - 0x0200;\r\n this._cullFace = cullFace;\r\n this._cullEnabled = cullEnabled;\r\n this._frontFace = frontFace;\r\n this.setDepthBiasSlopeScale(zOffset);\r\n this.setDepthBias(zOffsetUnits);\r\n }\r\n\r\n public setDepthBias(depthBias: number): void {\r\n if (this._depthBias !== depthBias) {\r\n this._depthBias = depthBias;\r\n this._states[StatePosition.DepthBias] = depthBias;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBias);\r\n }\r\n }\r\n\r\n /*public setDepthBiasClamp(depthBiasClamp: number): void {\r\n if (this._depthBiasClamp !== depthBiasClamp) {\r\n this._depthBiasClamp = depthBiasClamp;\r\n this._states[StatePosition.DepthBiasClamp] = depthBiasClamp.toString();\r\n this._isDirty = true;\r\n }\r\n }*/\r\n\r\n public setDepthBiasSlopeScale(depthBiasSlopeScale: number): void {\r\n if (this._depthBiasSlopeScale !== depthBiasSlopeScale) {\r\n this._depthBiasSlopeScale = depthBiasSlopeScale;\r\n this._states[StatePosition.DepthBiasSlopeScale] = depthBiasSlopeScale;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBiasSlopeScale);\r\n }\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._webgpuColorFormat[0] = format;\r\n this._colorFormat = renderableTextureFormatToIndex[format ?? \"\"];\r\n }\r\n\r\n public setMRTAttachments(attachments: number[]): void {\r\n (this.mrtAttachments as any) = attachments;\r\n let mask = 0;\r\n for (let i = 0; i < attachments.length; ++i) {\r\n if (attachments[i] !== 0) {\r\n mask += 1 << i;\r\n }\r\n }\r\n if (this._mrtEnabledMask !== mask) {\r\n this._mrtEnabledMask = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1);\r\n }\r\n }\r\n\r\n public setMRT(textureArray: InternalTexture[], textureCount?: number): void {\r\n textureCount = textureCount ?? textureArray.length;\r\n if (textureCount > 10) {\r\n // If we want more than 10 attachments we need to change this method (and the StatePosition enum) but 10 seems plenty: note that WebGPU only supports 8 at the time (2021/12/13)!\r\n // As we need 39 different values we are using 6 bits to encode a texture format, meaning we can encode 5 texture formats in 32 bits\r\n // We are using 2x32 bit values to handle 10 textures\r\n throw \"Can't handle more than 10 attachments for a MRT in cache render pipeline!\";\r\n }\r\n (this.mrtTextureArray as any) = textureArray;\r\n (this.mrtTextureCount as any) = textureCount;\r\n\r\n this._mrtEnabledMask = 0xffff; // all textures are enabled at start (meaning we can write to them). Calls to setMRTAttachments may disable some\r\n\r\n const bits: number[] = [0, 0];\r\n let indexBits = 0,\r\n mask = 0,\r\n numRT = 0;\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n const gpuWrapper = texture?._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n this._mrtFormats[numRT] = gpuWrapper?.format ?? this._webgpuColorFormat[0];\r\n\r\n bits[indexBits] += renderableTextureFormatToIndex[this._mrtFormats[numRT] ?? \"\"] << mask;\r\n mask += 6;\r\n numRT++;\r\n\r\n if (mask >= 32) {\r\n mask = 0;\r\n indexBits++;\r\n }\r\n }\r\n this._mrtFormats.length = numRT;\r\n if (this._mrtAttachments1 !== bits[0] || this._mrtAttachments2 !== bits[1]) {\r\n this._mrtAttachments1 = bits[0];\r\n this._mrtAttachments2 = bits[1];\r\n this._states[StatePosition.MRTAttachments1] = bits[0];\r\n this._states[StatePosition.MRTAttachments2] = bits[1];\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1);\r\n }\r\n }\r\n\r\n public setAlphaBlendEnabled(enabled: boolean): void {\r\n this._alphaBlendEnabled = enabled;\r\n }\r\n\r\n public setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void {\r\n this._alphaBlendFuncParams = factors;\r\n this._alphaBlendEqParams = operations;\r\n }\r\n\r\n public setWriteMask(mask: number): void {\r\n this._writeMask = mask;\r\n }\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._webgpuDepthStencilFormat = format;\r\n this._depthStencilFormat = format === undefined ? 0 : renderableTextureFormatToIndex[format];\r\n }\r\n\r\n public setDepthTestEnabled(enabled: boolean): void {\r\n this._depthTestEnabled = enabled;\r\n }\r\n\r\n public setDepthWriteEnabled(enabled: boolean): void {\r\n this._depthWriteEnabled = enabled;\r\n }\r\n\r\n public setDepthCompare(func: Nullable<number>): void {\r\n this._depthCompare = (func ?? Constants.ALWAYS) - 0x0200;\r\n }\r\n\r\n public setStencilEnabled(enabled: boolean): void {\r\n this._stencilEnabled = enabled;\r\n }\r\n\r\n public setStencilCompare(func: Nullable<number>): void {\r\n this._stencilFrontCompare = (func ?? Constants.ALWAYS) - 0x0200;\r\n }\r\n\r\n public setStencilDepthFailOp(op: Nullable<number>): void {\r\n this._stencilFrontDepthFailOp = op === null ? 1 /* KEEP */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilPassOp(op: Nullable<number>): void {\r\n this._stencilFrontPassOp = op === null ? 2 /* REPLACE */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilFailOp(op: Nullable<number>): void {\r\n this._stencilFrontFailOp = op === null ? 1 /* KEEP */ : stencilOpToIndex[op];\r\n }\r\n\r\n public setStencilReadMask(mask: number): void {\r\n if (this._stencilReadMask !== mask) {\r\n this._stencilReadMask = mask;\r\n this._states[StatePosition.StencilReadMask] = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilReadMask);\r\n }\r\n }\r\n\r\n public setStencilWriteMask(mask: number): void {\r\n if (this._stencilWriteMask !== mask) {\r\n this._stencilWriteMask = mask;\r\n this._states[StatePosition.StencilWriteMask] = mask;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilWriteMask);\r\n }\r\n }\r\n\r\n public resetStencilState(): void {\r\n this.setStencilState(false, Constants.ALWAYS, Constants.KEEP, Constants.REPLACE, Constants.KEEP, 0xff, 0xff);\r\n }\r\n\r\n public setStencilState(\r\n stencilEnabled: boolean,\r\n compare: Nullable<number>,\r\n depthFailOp: Nullable<number>,\r\n passOp: Nullable<number>,\r\n failOp: Nullable<number>,\r\n readMask: number,\r\n writeMask: number\r\n ): void {\r\n this._stencilEnabled = stencilEnabled;\r\n this._stencilFrontCompare = (compare ?? Constants.ALWAYS) - 0x0200;\r\n this._stencilFrontDepthFailOp = depthFailOp === null ? 1 /* KEEP */ : stencilOpToIndex[depthFailOp];\r\n this._stencilFrontPassOp = passOp === null ? 2 /* REPLACE */ : stencilOpToIndex[passOp];\r\n this._stencilFrontFailOp = failOp === null ? 1 /* KEEP */ : stencilOpToIndex[failOp];\r\n this.setStencilReadMask(readMask);\r\n this.setStencilWriteMask(writeMask);\r\n }\r\n\r\n public setBuffers(\r\n vertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>,\r\n indexBuffer: Nullable<DataBuffer>,\r\n overrideVertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }>\r\n ): void {\r\n this._vertexBuffers = vertexBuffers;\r\n this._overrideVertexBuffers = overrideVertexBuffers;\r\n this._indexBuffer = indexBuffer;\r\n }\r\n\r\n private static _GetTopology(fillMode: number): GPUPrimitiveTopology {\r\n switch (fillMode) {\r\n // Triangle views\r\n case Constants.MATERIAL_TriangleFillMode:\r\n return WebGPUConstants.PrimitiveTopology.TriangleList;\r\n case Constants.MATERIAL_PointFillMode:\r\n return WebGPUConstants.PrimitiveTopology.PointList;\r\n case Constants.MATERIAL_WireFrameFillMode:\r\n return WebGPUConstants.PrimitiveTopology.LineList;\r\n // Draw modes\r\n case Constants.MATERIAL_PointListDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.PointList;\r\n case Constants.MATERIAL_LineListDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.LineList;\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n // return this._gl.LINE_LOOP;\r\n // TODO WEBGPU. Line Loop Mode Fallback at buffer load time.\r\n throw \"LineLoop is an unsupported fillmode in WebGPU\";\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.LineStrip;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n return WebGPUConstants.PrimitiveTopology.TriangleStrip;\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n // return this._gl.TRIANGLE_FAN;\r\n // TODO WEBGPU. Triangle Fan Mode Fallback at buffer load time.\r\n throw \"TriangleFan is an unsupported fillmode in WebGPU\";\r\n default:\r\n return WebGPUConstants.PrimitiveTopology.TriangleList;\r\n }\r\n }\r\n\r\n private static _GetAphaBlendOperation(operation: Nullable<number>): GPUBlendOperation {\r\n switch (operation) {\r\n case Constants.GL_ALPHA_EQUATION_ADD:\r\n return WebGPUConstants.BlendOperation.Add;\r\n case Constants.GL_ALPHA_EQUATION_SUBTRACT:\r\n return WebGPUConstants.BlendOperation.Subtract;\r\n case Constants.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:\r\n return WebGPUConstants.BlendOperation.ReverseSubtract;\r\n case Constants.GL_ALPHA_EQUATION_MIN:\r\n return WebGPUConstants.BlendOperation.Min;\r\n case Constants.GL_ALPHA_EQUATION_MAX:\r\n return WebGPUConstants.BlendOperation.Max;\r\n default:\r\n return WebGPUConstants.BlendOperation.Add;\r\n }\r\n }\r\n\r\n private static _GetAphaBlendFactor(factor: Nullable<number>): GPUBlendFactor {\r\n switch (factor) {\r\n case 0:\r\n return WebGPUConstants.BlendFactor.Zero;\r\n case 1:\r\n return WebGPUConstants.BlendFactor.One;\r\n case Constants.GL_ALPHA_FUNCTION_SRC:\r\n return WebGPUConstants.BlendFactor.Src;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusSrc;\r\n case Constants.GL_ALPHA_FUNCTION_SRC_ALPHA:\r\n return WebGPUConstants.BlendFactor.SrcAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusSrcAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_DST_ALPHA:\r\n return WebGPUConstants.BlendFactor.DstAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusDstAlpha;\r\n case Constants.GL_ALPHA_FUNCTION_DST_COLOR:\r\n return WebGPUConstants.BlendFactor.Dst;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusDst;\r\n case Constants.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:\r\n return WebGPUConstants.BlendFactor.SrcAlphaSaturated;\r\n case Constants.GL_ALPHA_FUNCTION_CONSTANT_COLOR:\r\n return WebGPUConstants.BlendFactor.Constant;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:\r\n return WebGPUConstants.BlendFactor.OneMinusConstant;\r\n case Constants.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:\r\n return WebGPUConstants.BlendFactor.Constant;\r\n case Constants.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:\r\n return WebGPUConstants.BlendFactor.OneMinusConstant;\r\n default:\r\n return WebGPUConstants.BlendFactor.One;\r\n }\r\n }\r\n\r\n private static _GetCompareFunction(compareFunction: number): GPUCompareFunction {\r\n switch (compareFunction) {\r\n case 0: // NEVER\r\n return WebGPUConstants.CompareFunction.Never;\r\n case 1: // LESS\r\n return WebGPUConstants.CompareFunction.Less;\r\n case 2: // EQUAL\r\n return WebGPUConstants.CompareFunction.Equal;\r\n case 3: // LEQUAL\r\n return WebGPUConstants.CompareFunction.LessEqual;\r\n case 4: // GREATER\r\n return WebGPUConstants.CompareFunction.Greater;\r\n case 5: // NOTEQUAL\r\n return WebGPUConstants.CompareFunction.NotEqual;\r\n case 6: // GEQUAL\r\n return WebGPUConstants.CompareFunction.GreaterEqual;\r\n case 7: // ALWAYS\r\n return WebGPUConstants.CompareFunction.Always;\r\n }\r\n return WebGPUConstants.CompareFunction.Never;\r\n }\r\n\r\n private static _GetStencilOpFunction(operation: number): GPUStencilOperation {\r\n switch (operation) {\r\n case 0:\r\n return WebGPUConstants.StencilOperation.Zero;\r\n case 1:\r\n return WebGPUConstants.StencilOperation.Keep;\r\n case 2:\r\n return WebGPUConstants.StencilOperation.Replace;\r\n case 3:\r\n return WebGPUConstants.StencilOperation.IncrementClamp;\r\n case 4:\r\n return WebGPUConstants.StencilOperation.DecrementClamp;\r\n case 5:\r\n return WebGPUConstants.StencilOperation.Invert;\r\n case 6:\r\n return WebGPUConstants.StencilOperation.IncrementWrap;\r\n case 7:\r\n return WebGPUConstants.StencilOperation.DecrementWrap;\r\n }\r\n return WebGPUConstants.StencilOperation.Keep;\r\n }\r\n\r\n private static _GetVertexInputDescriptorFormat(vertexBuffer: VertexBuffer): GPUVertexFormat {\r\n const type = vertexBuffer.type;\r\n const normalized = vertexBuffer.normalized;\r\n const size = vertexBuffer.getSize();\r\n\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm8x2 : WebGPUConstants.VertexFormat.Sint8x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm8x4 : WebGPUConstants.VertexFormat.Sint8x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm8x2 : WebGPUConstants.VertexFormat.Uint8x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm8x4 : WebGPUConstants.VertexFormat.Uint8x4;\r\n }\r\n break;\r\n case VertexBuffer.SHORT:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm16x2 : WebGPUConstants.VertexFormat.Sint16x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Snorm16x4 : WebGPUConstants.VertexFormat.Sint16x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n switch (size) {\r\n case 1:\r\n case 2:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm16x2 : WebGPUConstants.VertexFormat.Uint16x2;\r\n case 3:\r\n case 4:\r\n return normalized ? WebGPUConstants.VertexFormat.Unorm16x4 : WebGPUConstants.VertexFormat.Uint16x4;\r\n }\r\n break;\r\n case VertexBuffer.INT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Sint32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Sint32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Sint32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Sint32x4;\r\n }\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Uint32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Uint32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Uint32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Uint32x4;\r\n }\r\n break;\r\n case VertexBuffer.FLOAT:\r\n switch (size) {\r\n case 1:\r\n return WebGPUConstants.VertexFormat.Float32;\r\n case 2:\r\n return WebGPUConstants.VertexFormat.Float32x2;\r\n case 3:\r\n return WebGPUConstants.VertexFormat.Float32x3;\r\n case 4:\r\n return WebGPUConstants.VertexFormat.Float32x4;\r\n }\r\n break;\r\n }\r\n\r\n throw new Error(`Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size}`);\r\n }\r\n\r\n private _getAphaBlendState(): Nullable<GPUBlendComponent> {\r\n if (!this._alphaBlendEnabled) {\r\n return null;\r\n }\r\n\r\n return {\r\n srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),\r\n dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),\r\n operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[1]),\r\n };\r\n }\r\n\r\n private _getColorBlendState(): Nullable<GPUBlendComponent> {\r\n if (!this._alphaBlendEnabled) {\r\n return null;\r\n }\r\n\r\n return {\r\n srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),\r\n dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),\r\n operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[0]),\r\n };\r\n }\r\n\r\n private _setShaderStage(id: number): void {\r\n if (this._shaderId !== id) {\r\n this._shaderId = id;\r\n this._states[StatePosition.ShaderStage] = id;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ShaderStage);\r\n }\r\n }\r\n\r\n private _setRasterizationState(topology: number, sampleCount: number): void {\r\n const frontFace = this._frontFace;\r\n const cullMode = this._cullEnabled ? this._cullFace : 0;\r\n const clampDepth = this._clampDepth ? 1 : 0;\r\n const alphaToCoverage = this._alphaToCoverageEnabled ? 1 : 0;\r\n const rasterizationState = frontFace - 1 + (cullMode << 1) + (clampDepth << 3) + (alphaToCoverage << 4) + (topology << 5) + (sampleCount << 8);\r\n\r\n if (this._rasterizationState !== rasterizationState) {\r\n this._rasterizationState = rasterizationState;\r\n this._states[StatePosition.RasterizationState] = this._rasterizationState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.RasterizationState);\r\n }\r\n }\r\n\r\n private _setColorStates(): void {\r\n let colorStates = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29); // this state has been moved from depthStencilState here because alpha and depth are related (generally when alpha is on, depth write is off and the other way around)\r\n\r\n if (this._alphaBlendEnabled) {\r\n colorStates +=\r\n ((this._alphaBlendFuncParams[0] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[0]]) << 0) +\r\n ((this._alphaBlendFuncParams[1] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[1]]) << 4) +\r\n ((this._alphaBlendFuncParams[2] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[2]]) << 8) +\r\n ((this._alphaBlendFuncParams[3] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[3]]) << 12) +\r\n ((this._alphaBlendEqParams[0] === null ? 1 : this._alphaBlendEqParams[0] - 0x8005) << 16) +\r\n ((this._alphaBlendEqParams[1] === null ? 1 : this._alphaBlendEqParams[1] - 0x8005) << 19);\r\n }\r\n\r\n if (colorStates !== this._colorStates) {\r\n this._colorStates = colorStates;\r\n this._states[StatePosition.ColorStates] = this._colorStates;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ColorStates);\r\n }\r\n }\r\n\r\n private _setDepthStencilState(): void {\r\n const stencilState = !this._stencilEnabled\r\n ? 7 /* ALWAYS */ + (1 /* KEEP */ << 3) + (1 /* KEEP */ << 6) + (1 /* KEEP */ << 9)\r\n : this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9);\r\n\r\n const depthStencilState = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) /* ALWAYS */ << 6) + (stencilState << 10); // stencil front - stencil back is the same\r\n\r\n if (this._depthStencilState !== depthStencilState) {\r\n this._depthStencilState = depthStencilState;\r\n this._states[StatePosition.DepthStencilState] = this._depthStencilState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthStencilState);\r\n }\r\n }\r\n\r\n private _setVertexState(effect: Effect): void {\r\n const currStateLen = this._statesLength;\r\n let newNumStates = StatePosition.VertexState;\r\n\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const attributes = webgpuPipelineContext.shaderProcessingContext.attributeNamesFromEffect;\r\n const locations = webgpuPipelineContext.shaderProcessingContext.attributeLocationsFromEffect;\r\n\r\n let currentGPUBuffer;\r\n let numVertexBuffers = 0;\r\n for (let index = 0; index < attributes.length; index++) {\r\n const location = locations[index];\r\n let vertexBuffer = (this._overrideVertexBuffers && this._overrideVertexBuffers[attributes[index]]) ?? this._vertexBuffers![attributes[index]];\r\n if (!vertexBuffer) {\r\n // In WebGL it's valid to not bind a vertex buffer to an attribute, but it's not valid in WebGPU\r\n // So we must bind a dummy buffer when we are not given one for a specific attribute\r\n vertexBuffer = this._emptyVertexBuffer;\r\n }\r\n\r\n const buffer = vertexBuffer.getBuffer()?.underlyingResource;\r\n\r\n // We optimize usage of GPUVertexBufferLayout: we will create a single GPUVertexBufferLayout for all the attributes which follow each other and which use the same GPU buffer\r\n // However, there are some constraints in the attribute.offset value range, so we must check for them before being able to reuse the same GPUVertexBufferLayout\r\n // See _getVertexInputDescriptor() below\r\n if (vertexBuffer._validOffsetRange === undefined) {\r\n const offset = vertexBuffer.byteOffset;\r\n const formatSize = vertexBuffer.getSize(true);\r\n const byteStride = vertexBuffer.byteStride;\r\n vertexBuffer._validOffsetRange = offset <= this._kMaxVertexBufferStride - formatSize && (byteStride === 0 || offset + formatSize <= byteStride);\r\n }\r\n\r\n if (!(currentGPUBuffer && currentGPUBuffer === buffer && vertexBuffer._validOffsetRange)) {\r\n // we can't combine the previous vertexBuffer with the current one\r\n this.vertexBuffers[numVertexBuffers++] = vertexBuffer;\r\n currentGPUBuffer = vertexBuffer._validOffsetRange ? buffer : null;\r\n }\r\n\r\n const vid = vertexBuffer.hashCode + (location << 7);\r\n\r\n this._isDirty = this._isDirty || this._states[newNumStates] !== vid;\r\n this._states[newNumStates++] = vid;\r\n }\r\n\r\n this.vertexBuffers.length = numVertexBuffers;\r\n\r\n this._statesLength = newNumStates;\r\n this._isDirty = this._isDirty || newNumStates !== currStateLen;\r\n if (this._isDirty) {\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.VertexState);\r\n }\r\n }\r\n\r\n private _setTextureState(textureState: number): void {\r\n if (this._textureState !== textureState) {\r\n this._textureState = textureState;\r\n this._states[StatePosition.TextureStage] = this._textureState;\r\n this._isDirty = true;\r\n this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.TextureStage);\r\n }\r\n }\r\n\r\n private _createPipelineLayout(webgpuPipelineContext: WebGPUPipelineContext): GPUPipelineLayout {\r\n if (this._useTextureStage) {\r\n return this._createPipelineLayoutWithTextureStage(webgpuPipelineContext);\r\n }\r\n\r\n const bindGroupLayouts: GPUBindGroupLayout[] = [];\r\n const bindGroupLayoutEntries = webgpuPipelineContext.shaderProcessingContext.bindGroupLayoutEntries;\r\n\r\n for (let i = 0; i < bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = bindGroupLayoutEntries[i];\r\n\r\n bindGroupLayouts[i] = this._device.createBindGroupLayout({\r\n entries: setDefinition,\r\n });\r\n }\r\n\r\n webgpuPipelineContext.bindGroupLayouts = bindGroupLayouts;\r\n\r\n return this._device.createPipelineLayout({ bindGroupLayouts });\r\n }\r\n\r\n private _createPipelineLayoutWithTextureStage(webgpuPipelineContext: WebGPUPipelineContext): GPUPipelineLayout {\r\n const shaderProcessingContext = webgpuPipelineContext.shaderProcessingContext;\r\n const bindGroupLayoutEntries = shaderProcessingContext.bindGroupLayoutEntries;\r\n\r\n let bitVal = 1;\r\n for (let i = 0; i < bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = bindGroupLayoutEntries[i];\r\n\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = bindGroupLayoutEntries[i][j];\r\n\r\n if (entry.texture) {\r\n const name = shaderProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].name;\r\n const textureInfo = shaderProcessingContext.availableTextures[name];\r\n const samplerInfo = textureInfo.autoBindSampler ? shaderProcessingContext.availableSamplers[name + WebGPUShaderProcessor.AutoSamplerSuffix] : null;\r\n\r\n let sampleType = textureInfo.sampleType;\r\n let samplerType = samplerInfo?.type ?? WebGPUConstants.SamplerBindingType.Filtering;\r\n\r\n if (this._textureState & bitVal && sampleType !== WebGPUConstants.TextureSampleType.Depth) {\r\n // The texture is a 32 bits float texture but the system does not support linear filtering for them:\r\n // we set the sampler to \"non-filtering\" and the texture sample type to \"unfilterable-float\"\r\n if (textureInfo.autoBindSampler) {\r\n samplerType = WebGPUConstants.SamplerBindingType.NonFiltering;\r\n }\r\n sampleType = WebGPUConstants.TextureSampleType.UnfilterableFloat;\r\n }\r\n\r\n entry.texture!.sampleType = sampleType;\r\n\r\n if (samplerInfo) {\r\n const binding = shaderProcessingContext.bindGroupLayoutEntryInfo[samplerInfo.binding.groupIndex][samplerInfo.binding.bindingIndex].index;\r\n bindGroupLayoutEntries[samplerInfo.binding.groupIndex][binding].sampler!.type = samplerType;\r\n }\r\n\r\n bitVal = bitVal << 1;\r\n }\r\n }\r\n }\r\n\r\n const bindGroupLayouts: GPUBindGroupLayout[] = [];\r\n\r\n for (let i = 0; i < bindGroupLayoutEntries.length; ++i) {\r\n bindGroupLayouts[i] = this._device.createBindGroupLayout({\r\n entries: bindGroupLayoutEntries[i],\r\n });\r\n }\r\n\r\n webgpuPipelineContext.bindGroupLayouts = bindGroupLayouts;\r\n\r\n return this._device.createPipelineLayout({ bindGroupLayouts });\r\n }\r\n\r\n private _getVertexInputDescriptor(effect: Effect): GPUVertexBufferLayout[] {\r\n const descriptors: GPUVertexBufferLayout[] = [];\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const attributes = webgpuPipelineContext.shaderProcessingContext.attributeNamesFromEffect;\r\n const locations = webgpuPipelineContext.shaderProcessingContext.attributeLocationsFromEffect;\r\n\r\n let currentGPUBuffer;\r\n let currentGPUAttributes: GPUVertexAttribute[] | undefined;\r\n for (let index = 0; index < attributes.length; index++) {\r\n const location = locations[index];\r\n let vertexBuffer = (this._overrideVertexBuffers && this._overrideVertexBuffers[attributes[index]]) ?? this._vertexBuffers![attributes[index]];\r\n if (!vertexBuffer) {\r\n // In WebGL it's valid to not bind a vertex buffer to an attribute, but it's not valid in WebGPU\r\n // So we must bind a dummy buffer when we are not given one for a specific attribute\r\n vertexBuffer = this._emptyVertexBuffer;\r\n }\r\n\r\n let buffer = vertexBuffer.getBuffer()?.underlyingResource;\r\n\r\n // We reuse the same GPUVertexBufferLayout for all attributes that use the same underlying GPU buffer (and for attributes that follow each other in the attributes array)\r\n let offset = vertexBuffer.byteOffset;\r\n const invalidOffsetRange = !vertexBuffer._validOffsetRange;\r\n if (!(currentGPUBuffer && currentGPUAttributes && currentGPUBuffer === buffer) || invalidOffsetRange) {\r\n const vertexBufferDescriptor: GPUVertexBufferLayout = {\r\n arrayStride: vertexBuffer.byteStride,\r\n stepMode: vertexBuffer.getIsInstanced() ? WebGPUConstants.InputStepMode.Instance : WebGPUConstants.InputStepMode.Vertex,\r\n attributes: [],\r\n };\r\n\r\n descriptors.push(vertexBufferDescriptor);\r\n currentGPUAttributes = vertexBufferDescriptor.attributes;\r\n if (invalidOffsetRange) {\r\n offset = 0; // the offset will be set directly in the setVertexBuffer call\r\n buffer = null; // buffer can't be reused\r\n }\r\n }\r\n\r\n currentGPUAttributes.push({\r\n shaderLocation: location,\r\n offset,\r\n format: WebGPUCacheRenderPipeline._GetVertexInputDescriptorFormat(vertexBuffer),\r\n });\r\n\r\n currentGPUBuffer = buffer;\r\n }\r\n\r\n return descriptors;\r\n }\r\n\r\n private _createRenderPipeline(effect: Effect, topology: GPUPrimitiveTopology, sampleCount: number): GPURenderPipeline {\r\n const webgpuPipelineContext = effect._pipelineContext as WebGPUPipelineContext;\r\n const inputStateDescriptor = this._getVertexInputDescriptor(effect);\r\n const pipelineLayout = this._createPipelineLayout(webgpuPipelineContext);\r\n\r\n const colorStates: Array<GPUColorTargetState | null> = [];\r\n const alphaBlend = this._getAphaBlendState();\r\n const colorBlend = this._getColorBlendState();\r\n\r\n if (this._mrtAttachments1 > 0) {\r\n for (let i = 0; i < this._mrtFormats.length; ++i) {\r\n const format = this._mrtFormats[i];\r\n if (format) {\r\n const descr: GPUColorTargetState = {\r\n format,\r\n writeMask: (this._mrtEnabledMask & (1 << i)) !== 0 ? this._writeMask : 0,\r\n };\r\n if (alphaBlend && colorBlend) {\r\n descr.blend = {\r\n alpha: alphaBlend,\r\n color: colorBlend,\r\n };\r\n }\r\n colorStates.push(descr);\r\n } else {\r\n colorStates.push(null);\r\n }\r\n }\r\n } else {\r\n if (this._webgpuColorFormat[0]) {\r\n const descr: GPUColorTargetState = {\r\n format: this._webgpuColorFormat[0],\r\n writeMask: this._writeMask,\r\n };\r\n if (alphaBlend && colorBlend) {\r\n descr.blend = {\r\n alpha: alphaBlend,\r\n color: colorBlend,\r\n };\r\n }\r\n colorStates.push(descr);\r\n } else {\r\n colorStates.push(null);\r\n }\r\n }\r\n\r\n const stencilFrontBack: GPUStencilStateFace = {\r\n compare: WebGPUCacheRenderPipeline._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7 /* ALWAYS */),\r\n depthFailOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1 /* KEEP */),\r\n failOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1 /* KEEP */),\r\n passOp: WebGPUCacheRenderPipeline._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1 /* KEEP */),\r\n };\r\n\r\n let stripIndexFormat: GPUIndexFormat | undefined = undefined;\r\n if (topology === WebGPUConstants.PrimitiveTopology.LineStrip || topology === WebGPUConstants.PrimitiveTopology.TriangleStrip) {\r\n stripIndexFormat = !this._indexBuffer || this._indexBuffer.is32Bits ? WebGPUConstants.IndexFormat.Uint32 : WebGPUConstants.IndexFormat.Uint16;\r\n }\r\n\r\n const depthStencilFormatHasStencil = this._webgpuDepthStencilFormat ? WebGPUTextureHelper.HasStencilAspect(this._webgpuDepthStencilFormat) : false;\r\n\r\n return this._device.createRenderPipeline({\r\n label: `RenderPipeline_${colorStates[0]?.format ?? \"nooutput\"}_${this._webgpuDepthStencilFormat ?? \"nodepth\"}_samples${sampleCount}_textureState${this._textureState}`,\r\n layout: pipelineLayout,\r\n vertex: {\r\n module: webgpuPipelineContext.stages!.vertexStage.module,\r\n entryPoint: webgpuPipelineContext.stages!.vertexStage.entryPoint,\r\n buffers: inputStateDescriptor,\r\n },\r\n primitive: {\r\n topology,\r\n stripIndexFormat,\r\n frontFace: this._frontFace === 1 ? WebGPUConstants.FrontFace.CCW : WebGPUConstants.FrontFace.CW,\r\n cullMode: !this._cullEnabled ? WebGPUConstants.CullMode.None : this._cullFace === 2 ? WebGPUConstants.CullMode.Front : WebGPUConstants.CullMode.Back,\r\n },\r\n fragment: !webgpuPipelineContext.stages!.fragmentStage\r\n ? undefined\r\n : {\r\n module: webgpuPipelineContext.stages!.fragmentStage.module,\r\n entryPoint: webgpuPipelineContext.stages!.fragmentStage.entryPoint,\r\n targets: colorStates,\r\n },\r\n\r\n multisample: {\r\n count: sampleCount,\r\n /*mask,\r\n alphaToCoverageEnabled,*/\r\n },\r\n depthStencil:\r\n this._webgpuDepthStencilFormat === undefined\r\n ? undefined\r\n : {\r\n depthWriteEnabled: this._depthWriteEnabled,\r\n depthCompare: this._depthTestEnabled ? WebGPUCacheRenderPipeline._GetCompareFunction(this._depthCompare) : WebGPUConstants.CompareFunction.Always,\r\n format: this._webgpuDepthStencilFormat,\r\n stencilFront: this._stencilEnabled && depthStencilFormatHasStencil ? stencilFrontBack : undefined,\r\n stencilBack: this._stencilEnabled && depthStencilFormatHasStencil ? stencilFrontBack : undefined,\r\n stencilReadMask: this._stencilEnabled && depthStencilFormatHasStencil ? this._stencilReadMask : undefined,\r\n stencilWriteMask: this._stencilEnabled && depthStencilFormatHasStencil ? this._stencilWriteMask : undefined,\r\n depthBias: this._depthBias,\r\n depthBiasClamp: this._depthBiasClamp,\r\n depthBiasSlopeScale: this._depthBiasSlopeScale,\r\n },\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -26,7 +26,7 @@ export declare class WebGPUTextureHelper {
|
|
|
26
26
|
private _deferredReleaseTextures;
|
|
27
27
|
private _commandEncoderForCreation;
|
|
28
28
|
static ComputeNumMipmapLevels(width: number, height: number): number;
|
|
29
|
-
constructor(device: GPUDevice, glslang: any, tintWASM: Nullable<WebGPUTintWASM>, bufferManager: WebGPUBufferManager);
|
|
29
|
+
constructor(device: GPUDevice, glslang: any, tintWASM: Nullable<WebGPUTintWASM>, bufferManager: WebGPUBufferManager, enabledExtensions: GPUFeatureName[]);
|
|
30
30
|
private _getPipeline;
|
|
31
31
|
private _getVideoPipeline;
|
|
32
32
|
private static _GetTextureTypeFromFormat;
|
|
@@ -253,8 +253,7 @@ export const renderableTextureFormatToIndex = {
|
|
|
253
253
|
depth24plus: 34,
|
|
254
254
|
"depth24plus-stencil8": 35,
|
|
255
255
|
depth32float: 36,
|
|
256
|
-
"
|
|
257
|
-
"depth32float-stencil8": 38,
|
|
256
|
+
"depth32float-stencil8": 37,
|
|
258
257
|
};
|
|
259
258
|
/** @internal */
|
|
260
259
|
export class WebGPUTextureHelper {
|
|
@@ -264,7 +263,7 @@ export class WebGPUTextureHelper {
|
|
|
264
263
|
//------------------------------------------------------------------------------
|
|
265
264
|
// Initialization / Helpers
|
|
266
265
|
//------------------------------------------------------------------------------
|
|
267
|
-
constructor(device, glslang, tintWASM, bufferManager) {
|
|
266
|
+
constructor(device, glslang, tintWASM, bufferManager, enabledExtensions) {
|
|
268
267
|
this._pipelines = {};
|
|
269
268
|
this._compiledShaders = [];
|
|
270
269
|
this._videoPipelines = {};
|
|
@@ -274,6 +273,10 @@ export class WebGPUTextureHelper {
|
|
|
274
273
|
this._glslang = glslang;
|
|
275
274
|
this._tintWASM = tintWASM;
|
|
276
275
|
this._bufferManager = bufferManager;
|
|
276
|
+
if (enabledExtensions.indexOf(WebGPUConstants.FeatureName.RG11B10UFloatRenderable) !== -1) {
|
|
277
|
+
const keys = Object.keys(renderableTextureFormatToIndex);
|
|
278
|
+
renderableTextureFormatToIndex[WebGPUConstants.TextureFormat.RG11B10UFloat] = renderableTextureFormatToIndex[keys[keys.length - 1]] + 1;
|
|
279
|
+
}
|
|
277
280
|
this._mipmapSampler = device.createSampler({ minFilter: WebGPUConstants.FilterMode.Linear });
|
|
278
281
|
this._videoSampler = device.createSampler({ minFilter: WebGPUConstants.FilterMode.Linear });
|
|
279
282
|
this._ubCopyWithOfst = this._bufferManager.createBuffer(4 * 4, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst).underlyingResource;
|
|
@@ -879,9 +882,23 @@ export class WebGPUTextureHelper {
|
|
|
879
882
|
case 10:
|
|
880
883
|
throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
|
|
881
884
|
case 13:
|
|
882
|
-
|
|
885
|
+
switch (format) {
|
|
886
|
+
case 5:
|
|
887
|
+
return WebGPUConstants.TextureFormat.RG11B10UFloat;
|
|
888
|
+
case 11:
|
|
889
|
+
throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV";
|
|
890
|
+
default:
|
|
891
|
+
return WebGPUConstants.TextureFormat.RG11B10UFloat;
|
|
892
|
+
}
|
|
883
893
|
case 14:
|
|
884
|
-
|
|
894
|
+
switch (format) {
|
|
895
|
+
case 5:
|
|
896
|
+
return WebGPUConstants.TextureFormat.RGB9E5UFloat;
|
|
897
|
+
case 11:
|
|
898
|
+
throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV";
|
|
899
|
+
default:
|
|
900
|
+
return WebGPUConstants.TextureFormat.RGB9E5UFloat;
|
|
901
|
+
}
|
|
885
902
|
case 8:
|
|
886
903
|
throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
|
|
887
904
|
case 9:
|
|
@@ -1251,13 +1268,14 @@ export class WebGPUTextureHelper {
|
|
|
1251
1268
|
height: imageBitmap.height,
|
|
1252
1269
|
depthOrArrayLayers: layerCount,
|
|
1253
1270
|
};
|
|
1271
|
+
const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? WebGPUConstants.TextureUsage.RenderAttachment : 0;
|
|
1254
1272
|
const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);
|
|
1255
1273
|
const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(imageBitmap.width, imageBitmap.height) : 1;
|
|
1256
1274
|
const usages = usage >= 0 ? usage : WebGPUConstants.TextureUsage.CopySrc | WebGPUConstants.TextureUsage.CopyDst | WebGPUConstants.TextureUsage.TextureBinding;
|
|
1257
|
-
additionalUsages |= hasMipmaps && !isCompressedFormat ? WebGPUConstants.TextureUsage.CopySrc |
|
|
1275
|
+
additionalUsages |= hasMipmaps && !isCompressedFormat ? WebGPUConstants.TextureUsage.CopySrc | renderAttachmentFlag : 0;
|
|
1258
1276
|
if (!isCompressedFormat && !is3D) {
|
|
1259
1277
|
// we don't know in advance if the texture will be updated with copyExternalImageToTexture (which requires to have those flags), so we need to force the flags all the times
|
|
1260
|
-
additionalUsages |=
|
|
1278
|
+
additionalUsages |= renderAttachmentFlag | WebGPUConstants.TextureUsage.CopyDst;
|
|
1261
1279
|
}
|
|
1262
1280
|
const gpuTexture = this._device.createTexture({
|
|
1263
1281
|
label: `Texture${is3D ? "3D" : "2D"}_${label ? label + "_" : ""}${textureSize.width}x${textureSize.height}x${textureSize.depthOrArrayLayers}_${hasMipmaps ? "wmips" : "womips"}_${format}_samples${sampleCount}`,
|
|
@@ -1283,13 +1301,14 @@ export class WebGPUTextureHelper {
|
|
|
1283
1301
|
}
|
|
1284
1302
|
const width = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].width : imageBitmaps.width;
|
|
1285
1303
|
const height = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].height : imageBitmaps.height;
|
|
1304
|
+
const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? WebGPUConstants.TextureUsage.RenderAttachment : 0;
|
|
1286
1305
|
const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);
|
|
1287
1306
|
const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;
|
|
1288
1307
|
const usages = usage >= 0 ? usage : WebGPUConstants.TextureUsage.CopySrc | WebGPUConstants.TextureUsage.CopyDst | WebGPUConstants.TextureUsage.TextureBinding;
|
|
1289
|
-
additionalUsages |= hasMipmaps && !isCompressedFormat ? WebGPUConstants.TextureUsage.CopySrc |
|
|
1308
|
+
additionalUsages |= hasMipmaps && !isCompressedFormat ? WebGPUConstants.TextureUsage.CopySrc | renderAttachmentFlag : 0;
|
|
1290
1309
|
if (!isCompressedFormat) {
|
|
1291
1310
|
// we don't know in advance if the texture will be updated with copyExternalImageToTexture (which requires to have those flags), so we need to force the flags all the times
|
|
1292
|
-
additionalUsages |=
|
|
1311
|
+
additionalUsages |= renderAttachmentFlag | WebGPUConstants.TextureUsage.CopyDst;
|
|
1293
1312
|
}
|
|
1294
1313
|
const gpuTexture = this._device.createTexture({
|
|
1295
1314
|
label: `TextureCube_${label ? label + "_" : ""}${width}x${height}x6_${hasMipmaps ? "wmips" : "womips"}_${format}_samples${sampleCount}`,
|