9dfe2ae1b20e7cd348d49443da76fb8ccd703cf584bc5fe02d24f187b68fd81a.json 144 KB

1
  1. {"ast":null,"code":"/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable babylonjs/available */\n/* eslint-disable jsdoc/require-jsdoc */\n// License for the mipmap generation code:\n//\n// Copyright 2020 Brandon Jones\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nimport * as WebGPUConstants from \"./webgpuConstants.js\";\nimport { WebGPUHardwareTexture } from \"./webgpuHardwareTexture.js\";\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper.js\";\nimport { Finalize, Initialize, Process } from \"../Processors/shaderProcessor.js\";\n// TODO WEBGPU improve mipmap generation by using compute shaders\nconst mipmapVertexSource = `\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\n\n varying vTex: vec2f;\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.vTex = tex[input.vertexIndex];\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n `;\nconst mipmapFragmentSource = `\n var imgSampler: sampler;\n var img: texture_2d<f32>;\n\n varying vTex: vec2f;\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n fragmentOutputs.color = textureSample(img, imgSampler, input.vTex);\n }\n `;\nconst invertYPreMultiplyAlphaVertexSource = `\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\n\n var img: texture_2d<f32>;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n #ifdef INVERTY\n vertexOutputs.vTextureSize = vec2f(textureDimensions(img, 0));\n #endif\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n `;\nconst invertYPreMultiplyAlphaFragmentSource = `\n var img: texture_2d<f32>;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n #ifdef INVERTY\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(input.vTextureSize.y - input.position.y)), 0);\n #else\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n fragmentOutputs.color = vec4f(color.rgb * color.a, color.a);\n #endif\n fragmentOutputs.color = color;\n }\n `;\nconst invertYPreMultiplyAlphaWithOfstVertexSource = invertYPreMultiplyAlphaVertexSource;\nconst invertYPreMultiplyAlphaWithOfstFragmentSource = `\n var img: texture_2d<f32>;\n uniform ofstX: f32;\n uniform ofstY: f32;\n uniform width: f32;\n uniform height: f32;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n if (input.position.x < uniforms.ofstX || input.position.x >= uniforms.ofstX + uniforms.width) {\n discard;\n }\n if (input.position.y < uniforms.ofstY || input.position.y >= uniforms.ofstY + uniforms.height) {\n discard;\n }\n #ifdef INVERTY\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(uniforms.ofstY + uniforms.height - (input.position.y - uniforms.ofstY))), 0);\n #else\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color = vec4f(color.rgb * color.a, color.a);\n #endif\n fragmentOutputs.color = color;\n }\n `;\nconst clearVertexSource = `\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n `;\nconst clearFragmentSource = `\n uniform color: vec4f;\n\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n fragmentOutputs.color = uniforms.color;\n }\n `;\nconst copyVideoToTextureVertexSource = `\n struct VertexOutput {\n @builtin(position) Position : vec4<f32>,\n @location(0) fragUV : vec2<f32>\n }\n\n @vertex\n fn main(\n @builtin(vertex_index) VertexIndex : u32\n ) -> VertexOutput {\n var pos = array<vec2<f32>, 4>(\n vec2(-1.0, 1.0),\n vec2( 1.0, 1.0),\n vec2(-1.0, -1.0),\n vec2( 1.0, -1.0)\n );\n var tex = array<vec2<f32>, 4>(\n vec2(0.0, 0.0),\n vec2(1.0, 0.0),\n vec2(0.0, 1.0),\n vec2(1.0, 1.0)\n );\n\n var output: VertexOutput;\n\n output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n output.fragUV = tex[VertexIndex];\n\n return output;\n }\n `;\nconst copyVideoToTextureFragmentSource = `\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2<f32>\n ) -> @location(0) vec4<f32> {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);\n }\n `;\nconst copyVideoToTextureInvertYFragmentSource = `\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2<f32>\n ) -> @location(0) vec4<f32> {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));\n }\n `;\nvar PipelineType;\n(function (PipelineType) {\n PipelineType[PipelineType[\"MipMap\"] = 0] = \"MipMap\";\n PipelineType[PipelineType[\"InvertYPremultiplyAlpha\"] = 1] = \"InvertYPremultiplyAlpha\";\n PipelineType[PipelineType[\"Clear\"] = 2] = \"Clear\";\n PipelineType[PipelineType[\"InvertYPremultiplyAlphaWithOfst\"] = 3] = \"InvertYPremultiplyAlphaWithOfst\";\n})(PipelineType || (PipelineType = {}));\nvar VideoPipelineType;\n(function (VideoPipelineType) {\n VideoPipelineType[VideoPipelineType[\"DontInvertY\"] = 0] = \"DontInvertY\";\n VideoPipelineType[VideoPipelineType[\"InvertY\"] = 1] = \"InvertY\";\n})(VideoPipelineType || (VideoPipelineType = {}));\nconst shadersForPipelineType = [{\n vertex: mipmapVertexSource,\n fragment: mipmapFragmentSource\n}, {\n vertex: invertYPreMultiplyAlphaVertexSource,\n fragment: invertYPreMultiplyAlphaFragmentSource\n}, {\n vertex: clearVertexSource,\n fragment: clearFragmentSource\n}, {\n vertex: invertYPreMultiplyAlphaWithOfstVertexSource,\n fragment: invertYPreMultiplyAlphaWithOfstFragmentSource\n}];\n/**\n * Map a (renderable) texture format (GPUTextureFormat) to an index for fast lookup (in caches for eg)\n * The number of entries should not go over 64! Else, the code in WebGPUCacheRenderPipeline.setMRT should be updated\n */\nexport const renderableTextureFormatToIndex = {\n \"\": 0,\n r8unorm: 1,\n r8uint: 2,\n r8sint: 3,\n r16uint: 4,\n r16sint: 5,\n r16float: 6,\n rg8unorm: 7,\n rg8uint: 8,\n rg8sint: 9,\n r32uint: 10,\n r32sint: 11,\n r32float: 12,\n rg16uint: 13,\n rg16sint: 14,\n rg16float: 15,\n rgba8unorm: 16,\n \"rgba8unorm-srgb\": 17,\n rgba8uint: 18,\n rgba8sint: 19,\n bgra8unorm: 20,\n \"bgra8unorm-srgb\": 21,\n rgb10a2uint: 22,\n rgb10a2unorm: 23,\n /* rg11b10ufloat: this entry is dynamically added if the \"RG11B10UFloatRenderable\" extension is supported */\n rg32uint: 24,\n rg32sint: 25,\n rg32float: 26,\n rgba16uint: 27,\n rgba16sint: 28,\n rgba16float: 29,\n rgba32uint: 30,\n rgba32sint: 31,\n rgba32float: 32,\n stencil8: 33,\n depth16unorm: 34,\n depth24plus: 35,\n \"depth24plus-stencil8\": 36,\n depth32float: 37,\n \"depth32float-stencil8\": 38,\n r16unorm: 39,\n rg16unorm: 40,\n rgba16unorm: 41,\n r16snorm: 42,\n rg16snorm: 43,\n rgba16snorm: 44\n};\n/** @internal */\nexport class WebGPUTextureManager {\n //------------------------------------------------------------------------------\n // Initialization / Helpers\n //------------------------------------------------------------------------------\n constructor(engine, device, bufferManager, enabledExtensions) {\n this._pipelines = {};\n this._compiledShaders = [];\n this._videoPipelines = {};\n this._videoCompiledShaders = [];\n this._deferredReleaseTextures = [];\n this._engine = engine;\n this._device = device;\n this._bufferManager = bufferManager;\n if (enabledExtensions.indexOf(\"rg11b10ufloat-renderable\" /* WebGPUConstants.FeatureName.RG11B10UFloatRenderable */) !== -1) {\n const keys = Object.keys(renderableTextureFormatToIndex);\n renderableTextureFormatToIndex[\"rg11b10ufloat\" /* WebGPUConstants.TextureFormat.RG11B10UFloat */] = renderableTextureFormatToIndex[keys[keys.length - 1]] + 1;\n }\n this._mipmapSampler = device.createSampler({\n minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */\n });\n this._videoSampler = device.createSampler({\n minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */\n });\n this._ubCopyWithOfst = this._bufferManager.createBuffer(4 * 4, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBCopyWithOffset\").underlyingResource;\n this._getPipeline(\"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */);\n this._getVideoPipeline(\"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */);\n }\n _getPipeline(format, type = PipelineType.MipMap, params) {\n const index = type === PipelineType.MipMap ? 1 << 0 : type === PipelineType.InvertYPremultiplyAlpha ? ((params.invertY ? 1 : 0) << 1) + ((params.premultiplyAlpha ? 1 : 0) << 2) : type === PipelineType.Clear ? 1 << 3 : type === PipelineType.InvertYPremultiplyAlphaWithOfst ? ((params.invertY ? 1 : 0) << 4) + ((params.premultiplyAlpha ? 1 : 0) << 5) : 0;\n if (!this._pipelines[format]) {\n this._pipelines[format] = [];\n }\n let pipelineAndBGL = this._pipelines[format][index];\n if (!pipelineAndBGL) {\n let defines = \"\";\n if (type === PipelineType.InvertYPremultiplyAlpha || type === PipelineType.InvertYPremultiplyAlphaWithOfst) {\n if (params.invertY) {\n defines += \"#define INVERTY\\n\";\n }\n if (params.premultiplyAlpha) {\n defines += \"#define PREMULTIPLYALPHA\\n\";\n }\n }\n let modules = this._compiledShaders[index];\n if (!modules) {\n let vertexCode = shadersForPipelineType[type].vertex;\n let fragmentCode = shadersForPipelineType[type].fragment;\n const processorOptions = {\n defines: defines.split(\"\\n\"),\n indexParameters: null,\n isFragment: false,\n shouldUseHighPrecisionShader: true,\n processor: this._engine._getShaderProcessor(1 /* ShaderLanguage.WGSL */),\n supportsUniformBuffers: true,\n shadersRepository: \"\",\n includesShadersStore: {},\n version: (this._engine.version * 100).toString(),\n platformName: this._engine.shaderPlatformName,\n processingContext: this._engine._getShaderProcessingContext(1 /* ShaderLanguage.WGSL */, true),\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer\n };\n Initialize(processorOptions);\n // Disable special additions not needed here\n processorOptions.processor.pureMode = true;\n Process(vertexCode, processorOptions, migratedVertexCode => {\n vertexCode = migratedVertexCode;\n }, this._engine);\n processorOptions.isFragment = true;\n Process(fragmentCode, processorOptions, migratedFragmentCode => {\n fragmentCode = migratedFragmentCode;\n }, this._engine);\n const final = Finalize(vertexCode, fragmentCode, processorOptions);\n // Restore\n processorOptions.processor.pureMode = false;\n const vertexModule = this._device.createShaderModule({\n code: final.vertexCode\n });\n const fragmentModule = this._device.createShaderModule({\n code: final.fragmentCode\n });\n modules = this._compiledShaders[index] = [vertexModule, fragmentModule];\n }\n const pipeline = this._device.createRenderPipeline({\n layout: \"auto\" /* WebGPUConstants.AutoLayoutMode.Auto */,\n vertex: {\n module: modules[0],\n entryPoint: \"main\"\n },\n fragment: {\n module: modules[1],\n entryPoint: \"main\",\n targets: [{\n format\n }]\n },\n primitive: {\n topology: \"triangle-strip\" /* WebGPUConstants.PrimitiveTopology.TriangleStrip */,\n stripIndexFormat: \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */\n }\n });\n pipelineAndBGL = this._pipelines[format][index] = [pipeline, pipeline.getBindGroupLayout(0)];\n }\n return pipelineAndBGL;\n }\n _getVideoPipeline(format, type = VideoPipelineType.DontInvertY) {\n const index = type === VideoPipelineType.InvertY ? 1 << 0 : 0;\n if (!this._videoPipelines[format]) {\n this._videoPipelines[format] = [];\n }\n let pipelineAndBGL = this._videoPipelines[format][index];\n if (!pipelineAndBGL) {\n let modules = this._videoCompiledShaders[index];\n if (!modules) {\n const vertexModule = this._device.createShaderModule({\n code: copyVideoToTextureVertexSource\n });\n const fragmentModule = this._device.createShaderModule({\n code: index === 0 ? copyVideoToTextureFragmentSource : copyVideoToTextureInvertYFragmentSource\n });\n modules = this._videoCompiledShaders[index] = [vertexModule, fragmentModule];\n }\n const pipeline = this._device.createRenderPipeline({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_CopyVideoToTexture_${format}_${index === 0 ? \"DontInvertY\" : \"InvertY\"}`,\n layout: \"auto\" /* WebGPUConstants.AutoLayoutMode.Auto */,\n vertex: {\n module: modules[0],\n entryPoint: \"main\"\n },\n fragment: {\n module: modules[1],\n entryPoint: \"main\",\n targets: [{\n format\n }]\n },\n primitive: {\n topology: \"triangle-strip\" /* WebGPUConstants.PrimitiveTopology.TriangleStrip */,\n stripIndexFormat: \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */\n }\n });\n pipelineAndBGL = this._videoPipelines[format][index] = [pipeline, pipeline.getBindGroupLayout(0)];\n }\n return pipelineAndBGL;\n }\n setCommandEncoder(encoder) {\n this._commandEncoderForCreation = encoder;\n }\n copyVideoToTexture(video, texture, format, invertY = false, commandEncoder) {\n var _commandEncoder$pushD, _commandEncoder, _commandEncoder$popDe, _commandEncoder2;\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getVideoPipeline(format, invertY ? VideoPipelineType.InvertY : VideoPipelineType.DontInvertY);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n (_commandEncoder$pushD = (_commandEncoder = commandEncoder).pushDebugGroup) === null || _commandEncoder$pushD === void 0 || _commandEncoder$pushD.call(_commandEncoder, `copy video to texture - invertY=${invertY}`);\n const webgpuHardwareTexture = texture._hardwareTexture;\n const renderPassDescriptor = {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_copyVideoToTexture_${format}_${invertY ? \"InvertY\" : \"DontInvertY\"}${texture.label ? \"_\" + texture.label : \"\"}`,\n colorAttachments: [{\n view: webgpuHardwareTexture.underlyingResource.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n }]\n };\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const descriptor = {\n layout: bindGroupLayout,\n entries: [{\n binding: 0,\n resource: this._videoSampler\n }, {\n binding: 1,\n resource: this._device.importExternalTexture({\n source: video.underlyingResource\n })\n }]\n };\n const bindGroup = this._device.createBindGroup(descriptor);\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n (_commandEncoder$popDe = (_commandEncoder2 = commandEncoder).popDebugGroup) === null || _commandEncoder$popDe === void 0 || _commandEncoder$popDe.call(_commandEncoder2);\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n invertYPreMultiplyAlpha(gpuOrHdwTexture, width, height, format, invertY = false, premultiplyAlpha = false, faceIndex = 0, mipLevel = 0, layers = 1, ofstX = 0, ofstY = 0, rectWidth = 0, rectHeight = 0, commandEncoder,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n allowGPUOptimization) {\n var _commandEncoder$pushD2, _commandEncoder3, _webgpuHardwareTextur, _webgpuHardwareTextur2, _commandEncoder$popDe2, _commandEncoder4;\n const useRect = rectWidth !== 0;\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format, useRect ? PipelineType.InvertYPremultiplyAlphaWithOfst : PipelineType.InvertYPremultiplyAlpha, {\n invertY,\n premultiplyAlpha\n });\n faceIndex = Math.max(faceIndex, 0);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n (_commandEncoder$pushD2 = (_commandEncoder3 = commandEncoder).pushDebugGroup) === null || _commandEncoder$pushD2 === void 0 || _commandEncoder$pushD2.call(_commandEncoder3, `internal process texture - invertY=${invertY} premultiplyAlpha=${premultiplyAlpha}`);\n let gpuTexture;\n if (WebGPUTextureHelper.IsHardwareTexture(gpuOrHdwTexture)) {\n gpuTexture = gpuOrHdwTexture.underlyingResource;\n if (!(invertY && !premultiplyAlpha && layers === 1 && faceIndex === 0)) {\n // we optimize only for the most likely case (invertY=true, premultiplyAlpha=false, layers=1, faceIndex=0) to avoid dealing with big caches\n gpuOrHdwTexture = undefined;\n }\n } else {\n gpuTexture = gpuOrHdwTexture;\n gpuOrHdwTexture = undefined;\n }\n if (!gpuTexture) {\n return;\n }\n if (useRect) {\n this._bufferManager.setRawData(this._ubCopyWithOfst, 0, new Float32Array([ofstX, ofstY, rectWidth, rectHeight]), 0, 4 * 4);\n }\n const webgpuHardwareTexture = gpuOrHdwTexture;\n const outputTexture = (_webgpuHardwareTextur = webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 ? void 0 : webgpuHardwareTexture._copyInvertYTempTexture) !== null && _webgpuHardwareTextur !== void 0 ? _webgpuHardwareTextur : this.createTexture({\n width,\n height,\n layers: 1\n }, false, false, false, false, false, format, 1, commandEncoder, 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */, undefined, \"TempTextureForCopyWithInvertY\");\n const renderPassDescriptor = (_webgpuHardwareTextur2 = webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 ? void 0 : webgpuHardwareTexture._copyInvertYRenderPassDescr) !== null && _webgpuHardwareTextur2 !== void 0 ? _webgpuHardwareTextur2 : {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_invertYPreMultiplyAlpha_${format}_${invertY ? \"InvertY\" : \"DontInvertY\"}_${premultiplyAlpha ? \"PremultiplyAlpha\" : \"DontPremultiplyAlpha\"}`,\n colorAttachments: [{\n view: outputTexture.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: 0,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: 0\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n }]\n };\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n let bindGroup = useRect ? webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 ? void 0 : webgpuHardwareTexture._copyInvertYBindGroupWithOfst : webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 ? void 0 : webgpuHardwareTexture._copyInvertYBindGroup;\n if (!bindGroup) {\n const descriptor = {\n layout: bindGroupLayout,\n entries: [{\n binding: 0,\n resource: gpuTexture.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: mipLevel,\n mipLevelCount: 1,\n arrayLayerCount: layers,\n baseArrayLayer: faceIndex\n })\n }]\n };\n if (useRect) {\n descriptor.entries.push({\n binding: 1,\n resource: {\n buffer: this._ubCopyWithOfst\n }\n });\n }\n bindGroup = this._device.createBindGroup(descriptor);\n }\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n commandEncoder.copyTextureToTexture({\n texture: outputTexture\n }, {\n texture: gpuTexture,\n mipLevel,\n origin: {\n x: 0,\n y: 0,\n z: faceIndex\n }\n }, {\n width,\n height,\n depthOrArrayLayers: 1\n });\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._copyInvertYTempTexture = outputTexture;\n webgpuHardwareTexture._copyInvertYRenderPassDescr = renderPassDescriptor;\n if (useRect) {\n webgpuHardwareTexture._copyInvertYBindGroupWithOfst = bindGroup;\n } else {\n webgpuHardwareTexture._copyInvertYBindGroup = bindGroup;\n }\n } else {\n this._deferredReleaseTextures.push([outputTexture, null]);\n }\n (_commandEncoder$popDe2 = (_commandEncoder4 = commandEncoder).popDebugGroup) === null || _commandEncoder$popDe2 === void 0 || _commandEncoder$popDe2.call(_commandEncoder4);\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n copyWithInvertY(srcTextureView, format, renderPassDescriptor, commandEncoder) {\n var _commandEncoder$pushD3, _commandEncoder5, _commandEncoder$popDe3, _commandEncoder6;\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format, PipelineType.InvertYPremultiplyAlpha, {\n invertY: true,\n premultiplyAlpha: false\n });\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n (_commandEncoder$pushD3 = (_commandEncoder5 = commandEncoder).pushDebugGroup) === null || _commandEncoder$pushD3 === void 0 || _commandEncoder$pushD3.call(_commandEncoder5, `internal copy texture with invertY`);\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const bindGroup = this._device.createBindGroup({\n layout: bindGroupLayout,\n entries: [{\n binding: 0,\n resource: srcTextureView\n }]\n });\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n (_commandEncoder$popDe3 = (_commandEncoder6 = commandEncoder).popDebugGroup) === null || _commandEncoder$popDe3 === void 0 || _commandEncoder$popDe3.call(_commandEncoder6);\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n //------------------------------------------------------------------------------\n // Creation\n //------------------------------------------------------------------------------\n createTexture(imageBitmap, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, is3D = false, format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label) {\n sampleCount = WebGPUTextureHelper.GetSample(sampleCount);\n const layerCount = imageBitmap.layers || 1;\n const textureSize = {\n width: imageBitmap.width,\n height: imageBitmap.height,\n depthOrArrayLayers: layerCount\n };\n const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : 0;\n const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);\n const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(imageBitmap.width, imageBitmap.height) : 1;\n const usages = usage >= 0 ? usage : 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 2 /* WebGPUConstants.TextureUsage.CopyDst */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */;\n additionalUsages |= hasMipmaps && !isCompressedFormat ? 1 /* WebGPUConstants.TextureUsage.CopySrc */ | renderAttachmentFlag : 0;\n if (!isCompressedFormat && !is3D) {\n // 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\n additionalUsages |= renderAttachmentFlag | 2 /* WebGPUConstants.TextureUsage.CopyDst */;\n }\n const gpuTexture = this._device.createTexture({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_Texture${is3D ? \"3D\" : \"2D\"}_${label ? label + \"_\" : \"\"}${textureSize.width}x${textureSize.height}x${textureSize.depthOrArrayLayers}_${hasMipmaps ? \"wmips\" : \"womips\"}_${format}_samples${sampleCount}`,\n size: textureSize,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format,\n usage: usages | additionalUsages,\n sampleCount,\n mipLevelCount\n });\n if (WebGPUTextureHelper.IsImageBitmap(imageBitmap)) {\n this.updateTexture(imageBitmap, gpuTexture, imageBitmap.width, imageBitmap.height, layerCount, format, 0, 0, invertY, premultiplyAlpha, 0, 0);\n if (hasMipmaps && generateMipmaps) {\n this.generateMipmaps(gpuTexture, format, mipLevelCount, 0, is3D, commandEncoder);\n }\n }\n return gpuTexture;\n }\n createCubeTexture(imageBitmaps, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label) {\n sampleCount = WebGPUTextureHelper.GetSample(sampleCount);\n const width = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].width : imageBitmaps.width;\n const height = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].height : imageBitmaps.height;\n const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : 0;\n const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);\n const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;\n const usages = usage >= 0 ? usage : 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 2 /* WebGPUConstants.TextureUsage.CopyDst */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */;\n additionalUsages |= hasMipmaps && !isCompressedFormat ? 1 /* WebGPUConstants.TextureUsage.CopySrc */ | renderAttachmentFlag : 0;\n if (!isCompressedFormat) {\n // 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\n additionalUsages |= renderAttachmentFlag | 2 /* WebGPUConstants.TextureUsage.CopyDst */;\n }\n const gpuTexture = this._device.createTexture({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureCube_${label ? label + \"_\" : \"\"}${width}x${height}x6_${hasMipmaps ? \"wmips\" : \"womips\"}_${format}_samples${sampleCount}`,\n size: {\n width,\n height,\n depthOrArrayLayers: 6\n },\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format,\n usage: usages | additionalUsages,\n sampleCount,\n mipLevelCount\n });\n if (WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps)) {\n this.updateCubeTextures(imageBitmaps, gpuTexture, width, height, format, invertY, premultiplyAlpha, 0, 0);\n if (hasMipmaps && generateMipmaps) {\n this.generateCubeMipmaps(gpuTexture, format, mipLevelCount, commandEncoder);\n }\n }\n return gpuTexture;\n }\n generateCubeMipmaps(gpuTexture, format, mipLevelCount, commandEncoder) {\n var _commandEncoder$pushD4, _commandEncoder7, _commandEncoder$popDe4, _commandEncoder8;\n const useOwnCommandEncoder = commandEncoder === undefined;\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n (_commandEncoder$pushD4 = (_commandEncoder7 = commandEncoder).pushDebugGroup) === null || _commandEncoder$pushD4 === void 0 || _commandEncoder$pushD4.call(_commandEncoder7, `create cube mipmaps - ${mipLevelCount} levels`);\n for (let f = 0; f < 6; ++f) {\n this.generateMipmaps(gpuTexture, format, mipLevelCount, f, false, commandEncoder);\n }\n (_commandEncoder$popDe4 = (_commandEncoder8 = commandEncoder).popDebugGroup) === null || _commandEncoder$popDe4 === void 0 || _commandEncoder$popDe4.call(_commandEncoder8);\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n generateMipmaps(gpuOrHdwTexture, format, mipLevelCount, faceIndex = 0, is3D = false, commandEncoder) {\n var _commandEncoder$pushD5, _commandEncoder9, _commandEncoder$popDe5, _commandEncoder10;\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format);\n faceIndex = Math.max(faceIndex, 0);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n (_commandEncoder$pushD5 = (_commandEncoder9 = commandEncoder).pushDebugGroup) === null || _commandEncoder$pushD5 === void 0 || _commandEncoder$pushD5.call(_commandEncoder9, `create mipmaps for face #${faceIndex} - ${mipLevelCount} levels`);\n let gpuTexture;\n if (WebGPUTextureHelper.IsHardwareTexture(gpuOrHdwTexture)) {\n gpuTexture = gpuOrHdwTexture.underlyingResource;\n gpuOrHdwTexture._mipmapGenRenderPassDescr = gpuOrHdwTexture._mipmapGenRenderPassDescr || [];\n gpuOrHdwTexture._mipmapGenBindGroup = gpuOrHdwTexture._mipmapGenBindGroup || [];\n } else {\n gpuTexture = gpuOrHdwTexture;\n gpuOrHdwTexture = undefined;\n }\n if (!gpuTexture) {\n return;\n }\n const webgpuHardwareTexture = gpuOrHdwTexture;\n for (let i = 1; i < mipLevelCount; ++i) {\n var _webgpuHardwareTextur3, _webgpuHardwareTextur4, _webgpuHardwareTextur5, _webgpuHardwareTextur6;\n const renderPassDescriptor = (_webgpuHardwareTextur3 = webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 || (_webgpuHardwareTextur4 = webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex]) === null || _webgpuHardwareTextur4 === void 0 ? void 0 : _webgpuHardwareTextur4[i - 1]) !== null && _webgpuHardwareTextur3 !== void 0 ? _webgpuHardwareTextur3 : {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_generateMipmaps_${format}_faceIndex${faceIndex}_level${i}`,\n colorAttachments: [{\n view: gpuTexture.createView({\n format,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: i,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: faceIndex\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n }]\n };\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex] = webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex] || [];\n webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex][i - 1] = renderPassDescriptor;\n }\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const bindGroup = (_webgpuHardwareTextur5 = webgpuHardwareTexture === null || webgpuHardwareTexture === void 0 || (_webgpuHardwareTextur6 = webgpuHardwareTexture._mipmapGenBindGroup[faceIndex]) === null || _webgpuHardwareTextur6 === void 0 ? void 0 : _webgpuHardwareTextur6[i - 1]) !== null && _webgpuHardwareTextur5 !== void 0 ? _webgpuHardwareTextur5 : this._device.createBindGroup({\n layout: bindGroupLayout,\n entries: [{\n binding: 0,\n resource: gpuTexture.createView({\n format,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: i - 1,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: faceIndex\n })\n }, {\n binding: 1,\n resource: this._mipmapSampler\n }]\n });\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._mipmapGenBindGroup[faceIndex] = webgpuHardwareTexture._mipmapGenBindGroup[faceIndex] || [];\n webgpuHardwareTexture._mipmapGenBindGroup[faceIndex][i - 1] = bindGroup;\n }\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n }\n (_commandEncoder$popDe5 = (_commandEncoder10 = commandEncoder).popDebugGroup) === null || _commandEncoder$popDe5 === void 0 || _commandEncoder$popDe5.call(_commandEncoder10);\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n createGPUTextureForInternalTexture(texture, width, height, depth, creationFlags, dontCreateMSAATexture) {\n if (!texture._hardwareTexture) {\n texture._hardwareTexture = new WebGPUHardwareTexture(this._engine);\n }\n if (width === undefined) {\n width = texture.width;\n }\n if (height === undefined) {\n height = texture.height;\n }\n if (depth === undefined) {\n depth = texture.depth;\n }\n const gpuTextureWrapper = texture._hardwareTexture;\n const isStorageTexture = ((creationFlags !== null && creationFlags !== void 0 ? creationFlags : 0) & 1) !== 0;\n gpuTextureWrapper.format = WebGPUTextureHelper.GetWebGPUTextureFormat(texture.type, texture.format, texture._useSRGBBuffer);\n gpuTextureWrapper.textureUsages = texture._source === 5 /* InternalTextureSource.RenderTarget */ || texture.source === 6 /* InternalTextureSource.MultiRenderTarget */ ? 4 /* WebGPUConstants.TextureUsage.TextureBinding */ | 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : texture._source === 12 /* InternalTextureSource.DepthStencil */ ? 4 /* WebGPUConstants.TextureUsage.TextureBinding */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : -1;\n gpuTextureWrapper.textureAdditionalUsages = isStorageTexture ? 8 /* WebGPUConstants.TextureUsage.StorageBinding */ : 0;\n const hasMipMaps = texture.generateMipMaps;\n const layerCount = depth || 1;\n let mipmapCount;\n if (texture._maxLodLevel !== null) {\n mipmapCount = texture._maxLodLevel;\n } else {\n mipmapCount = hasMipMaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;\n }\n if (texture.isCube) {\n var _texture$label;\n const gpuTexture = this.createCubeTexture({\n width,\n height\n }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);\n gpuTextureWrapper.set(gpuTexture);\n const arrayLayerCount = texture.is3D ? 1 : layerCount;\n const format = WebGPUTextureHelper.GetDepthFormatOnly(gpuTextureWrapper.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(gpuTextureWrapper.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n const dimension = texture.is2DArray ? \"cube-array\" /* WebGPUConstants.TextureViewDimension.CubeArray */ : \"cube\" /* WebGPUConstants.TextureViewDimension.Cube */;\n gpuTextureWrapper.createView({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureViewCube${texture.is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${hasMipMaps ? \"wmips\" : \"womips\"}_${format}_${dimension}_${aspect}_${(_texture$label = texture.label) !== null && _texture$label !== void 0 ? _texture$label : \"noname\"}`,\n format,\n dimension,\n mipLevelCount: mipmapCount,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount: 6,\n aspect\n }, isStorageTexture);\n } else {\n var _texture$label2;\n const gpuTexture = this.createTexture({\n width,\n height,\n layers: layerCount\n }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, texture.is3D, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);\n gpuTextureWrapper.set(gpuTexture);\n const arrayLayerCount = texture.is3D ? 1 : layerCount;\n const format = WebGPUTextureHelper.GetDepthFormatOnly(gpuTextureWrapper.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(gpuTextureWrapper.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n const dimension = texture.is2DArray ? \"2d-array\" /* WebGPUConstants.TextureViewDimension.E2dArray */ : texture.is3D ? \"3d\" /* WebGPUConstants.TextureDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */;\n gpuTextureWrapper.createView({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureView${texture.is3D ? \"3D\" : \"2D\"}${texture.is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}${texture.is3D ? \"x\" + layerCount : \"\"}_${hasMipMaps ? \"wmips\" : \"womips\"}_${format}_${dimension}_${aspect}_${(_texture$label2 = texture.label) !== null && _texture$label2 !== void 0 ? _texture$label2 : \"noname\"}`,\n format,\n dimension,\n mipLevelCount: mipmapCount,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount,\n aspect\n }, isStorageTexture);\n }\n texture.width = texture.baseWidth = width;\n texture.height = texture.baseHeight = height;\n texture.depth = texture.baseDepth = depth;\n if (!dontCreateMSAATexture) {\n this.createMSAATexture(texture, texture.samples);\n }\n return gpuTextureWrapper;\n }\n createMSAATexture(texture, samples, releaseExisting = true, index = 0) {\n const gpuTextureWrapper = texture._hardwareTexture;\n if (releaseExisting) {\n gpuTextureWrapper === null || gpuTextureWrapper === void 0 || gpuTextureWrapper.releaseMSAATexture();\n }\n if (!gpuTextureWrapper || (samples !== null && samples !== void 0 ? samples : 1) <= 1) {\n return;\n }\n const width = texture.width;\n const height = texture.height;\n const gpuMSAATexture = this.createTexture({\n width,\n height,\n layers: 1\n }, false, false, false, false, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, 16 /* WebGPUConstants.TextureUsage.RenderAttachment */, 0, texture.label ? \"MSAA_\" + texture.label : \"MSAA\");\n gpuTextureWrapper.setMSAATexture(gpuMSAATexture, index);\n }\n //------------------------------------------------------------------------------\n // Update\n //------------------------------------------------------------------------------\n updateCubeTextures(imageBitmaps, gpuTexture, width, height, format, invertY = false, premultiplyAlpha = false, offsetX = 0, offsetY = 0) {\n const faces = [0, 3, 1, 4, 2, 5];\n for (let f = 0; f < faces.length; ++f) {\n const imageBitmap = imageBitmaps[faces[f]];\n this.updateTexture(imageBitmap, gpuTexture, width, height, 1, format, f, 0, invertY, premultiplyAlpha, offsetX, offsetY);\n }\n }\n // TODO WEBGPU handle data source not being in the same format than the destination texture?\n updateTexture(imageBitmap, texture, width, height, layers, format, faceIndex = 0, mipLevel = 0, invertY = false, premultiplyAlpha = false, offsetX = 0, offsetY = 0, allowGPUOptimization) {\n const gpuTexture = WebGPUTextureHelper.IsInternalTexture(texture) ? texture._hardwareTexture.underlyingResource : texture;\n const blockInformation = WebGPUTextureHelper.GetBlockInformationFromFormat(format);\n const gpuOrHdwTexture = WebGPUTextureHelper.IsInternalTexture(texture) ? texture._hardwareTexture : texture;\n const textureCopyView = {\n texture: gpuTexture,\n origin: {\n x: offsetX,\n y: offsetY,\n z: Math.max(faceIndex, 0)\n },\n mipLevel: mipLevel,\n premultipliedAlpha: premultiplyAlpha\n };\n const textureExtent = {\n width: Math.ceil(width / blockInformation.width) * blockInformation.width,\n height: Math.ceil(height / blockInformation.height) * blockInformation.height,\n depthOrArrayLayers: layers || 1\n };\n if (imageBitmap.byteLength !== undefined) {\n imageBitmap = imageBitmap;\n const bytesPerRow = Math.ceil(width / blockInformation.width) * blockInformation.length;\n const aligned = Math.ceil(bytesPerRow / 256) * 256 === bytesPerRow;\n if (aligned) {\n const commandEncoder = this._device.createCommandEncoder({});\n const buffer = this._bufferManager.createRawBuffer(imageBitmap.byteLength, WebGPUConstants.BufferUsage.MapWrite | WebGPUConstants.BufferUsage.CopySrc, true, \"TempBufferForUpdateTexture\" + (gpuTexture ? \"_\" + gpuTexture.label : \"\"));\n const arrayBuffer = buffer.getMappedRange();\n new Uint8Array(arrayBuffer).set(imageBitmap);\n buffer.unmap();\n commandEncoder.copyBufferToTexture({\n buffer: buffer,\n offset: 0,\n bytesPerRow,\n rowsPerImage: height\n }, textureCopyView, textureExtent);\n this._device.queue.submit([commandEncoder.finish()]);\n this._bufferManager.releaseBuffer(buffer);\n } else {\n this._device.queue.writeTexture(textureCopyView, imageBitmap, {\n offset: 0,\n bytesPerRow,\n rowsPerImage: height\n }, textureExtent);\n }\n if (invertY || premultiplyAlpha) {\n if (WebGPUTextureHelper.IsInternalTexture(texture)) {\n const dontUseRect = offsetX === 0 && offsetY === 0 && width === texture.width && height === texture.height;\n this.invertYPreMultiplyAlpha(gpuOrHdwTexture, texture.width, texture.height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, offsetX, offsetY, dontUseRect ? 0 : width, dontUseRect ? 0 : height, undefined, allowGPUOptimization);\n } else {\n // we should never take this code path\n // eslint-disable-next-line no-throw-literal\n throw \"updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!\";\n }\n }\n } else {\n imageBitmap = imageBitmap;\n if (invertY) {\n textureCopyView.premultipliedAlpha = false; // we are going to handle premultiplyAlpha ourselves\n // we must preprocess the image\n if (WebGPUTextureHelper.IsInternalTexture(texture) && offsetX === 0 && offsetY === 0 && width === texture.width && height === texture.height) {\n // optimization when the source image is the same size than the destination texture and offsets X/Y == 0:\n // we simply copy the source to the destination and we apply the preprocessing on the destination\n this._device.queue.copyExternalImageToTexture({\n source: imageBitmap\n }, textureCopyView, textureExtent);\n this.invertYPreMultiplyAlpha(gpuOrHdwTexture, width, height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, 0, 0, 0, 0, undefined, allowGPUOptimization);\n } else {\n // we must apply the preprocessing on the source image before copying it into the destination texture\n const commandEncoder = this._device.createCommandEncoder({});\n // create a temp texture and copy the image to it\n const srcTexture = this.createTexture({\n width,\n height,\n layers: 1\n }, false, false, false, false, false, format, 1, commandEncoder, 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */, undefined, \"TempTextureForUpdateTexture\");\n this._deferredReleaseTextures.push([srcTexture, null]);\n textureExtent.depthOrArrayLayers = 1;\n this._device.queue.copyExternalImageToTexture({\n source: imageBitmap\n }, {\n texture: srcTexture\n }, textureExtent);\n textureExtent.depthOrArrayLayers = layers || 1;\n // apply the preprocessing to this temp texture\n this.invertYPreMultiplyAlpha(srcTexture, width, height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, 0, 0, 0, 0, commandEncoder, allowGPUOptimization);\n // copy the temp texture to the destination texture\n commandEncoder.copyTextureToTexture({\n texture: srcTexture\n }, textureCopyView, textureExtent);\n this._device.queue.submit([commandEncoder.finish()]);\n }\n } else {\n // no preprocessing: direct copy to destination texture\n this._device.queue.copyExternalImageToTexture({\n source: imageBitmap\n }, textureCopyView, textureExtent);\n }\n }\n }\n readPixels(texture, x, y, width, height, format, faceIndex = 0, mipLevel = 0, buffer = null, noDataConversion = false) {\n const blockInformation = WebGPUTextureHelper.GetBlockInformationFromFormat(format);\n const bytesPerRow = Math.ceil(width / blockInformation.width) * blockInformation.length;\n const bytesPerRowAligned = Math.ceil(bytesPerRow / 256) * 256;\n const size = bytesPerRowAligned * height;\n const gpuBuffer = this._bufferManager.createRawBuffer(size, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempBufferForReadPixels\" + (texture.label ? \"_\" + texture.label : \"\"));\n const commandEncoder = this._device.createCommandEncoder({});\n commandEncoder.copyTextureToBuffer({\n texture,\n mipLevel,\n origin: {\n x,\n y,\n z: Math.max(faceIndex, 0)\n }\n }, {\n buffer: gpuBuffer,\n offset: 0,\n bytesPerRow: bytesPerRowAligned\n }, {\n width,\n height,\n depthOrArrayLayers: 1\n });\n this._device.queue.submit([commandEncoder.finish()]);\n return this._bufferManager.readDataFromBuffer(gpuBuffer, size, width, height, bytesPerRow, bytesPerRowAligned, WebGPUTextureHelper.GetTextureTypeFromFormat(format), 0, buffer, true, noDataConversion);\n }\n //------------------------------------------------------------------------------\n // Dispose\n //------------------------------------------------------------------------------\n releaseTexture(texture) {\n if (WebGPUTextureHelper.IsInternalTexture(texture)) {\n const hardwareTexture = texture._hardwareTexture;\n const irradianceTexture = texture._irradianceTexture;\n // We can't destroy the objects just now because they could be used in the current frame - we delay the destroying after the end of the frame\n this._deferredReleaseTextures.push([hardwareTexture, irradianceTexture]);\n } else {\n this._deferredReleaseTextures.push([texture, null]);\n }\n }\n destroyDeferredTextures() {\n for (let i = 0; i < this._deferredReleaseTextures.length; ++i) {\n const [hardwareTexture, irradianceTexture] = this._deferredReleaseTextures[i];\n if (hardwareTexture) {\n if (WebGPUTextureHelper.IsHardwareTexture(hardwareTexture)) {\n hardwareTexture.release();\n } else {\n hardwareTexture.destroy();\n }\n }\n irradianceTexture === null || irradianceTexture === void 0 || irradianceTexture.dispose();\n }\n this._deferredReleaseTextures.length = 0;\n }\n}","map":{"version":3,"names":["WebGPUConstants","WebGPUHardwareTexture","WebGPUTextureHelper","Finalize","Initialize","Process","mipmapVertexSource","mipmapFragmentSource","invertYPreMultiplyAlphaVertexSource","invertYPreMultiplyAlphaFragmentSource","invertYPreMultiplyAlphaWithOfstVertexSource","invertYPreMultiplyAlphaWithOfstFragmentSource","clearVertexSource","clearFragmentSource","copyVideoToTextureVertexSource","copyVideoToTextureFragmentSource","copyVideoToTextureInvertYFragmentSource","PipelineType","VideoPipelineType","shadersForPipelineType","vertex","fragment","renderableTextureFormatToIndex","r8unorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8uint","rgba8sint","bgra8unorm","rgb10a2uint","rgb10a2unorm","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth32float","r16unorm","rg16unorm","rgba16unorm","r16snorm","rg16snorm","rgba16snorm","WebGPUTextureManager","constructor","engine","device","bufferManager","enabledExtensions","_pipelines","_compiledShaders","_videoPipelines","_videoCompiledShaders","_deferredReleaseTextures","_engine","_device","_bufferManager","indexOf","keys","Object","length","_mipmapSampler","createSampler","minFilter","_videoSampler","_ubCopyWithOfst","createBuffer","BufferUsage","Uniform","CopyDst","underlyingResource","_getPipeline","_getVideoPipeline","format","type","MipMap","params","index","InvertYPremultiplyAlpha","invertY","premultiplyAlpha","Clear","InvertYPremultiplyAlphaWithOfst","pipelineAndBGL","defines","modules","vertexCode","fragmentCode","processorOptions","split","indexParameters","isFragment","shouldUseHighPrecisionShader","processor","_getShaderProcessor","supportsUniformBuffers","shadersRepository","includesShadersStore","version","toString","platformName","shaderPlatformName","processingContext","_getShaderProcessingContext","isNDCHalfZRange","useReverseDepthBuffer","pureMode","migratedVertexCode","migratedFragmentCode","final","vertexModule","createShaderModule","code","fragmentModule","pipeline","createRenderPipeline","layout","module","entryPoint","targets","primitive","topology","stripIndexFormat","getBindGroupLayout","DontInvertY","InvertY","label","uniqueId","setCommandEncoder","encoder","_commandEncoderForCreation","copyVideoToTexture","video","texture","commandEncoder","_commandEncoder$pushD","_commandEncoder","_commandEncoder$popDe","_commandEncoder2","useOwnCommandEncoder","undefined","bindGroupLayout","createCommandEncoder","pushDebugGroup","call","webgpuHardwareTexture","_hardwareTexture","renderPassDescriptor","colorAttachments","view","createView","dimension","mipLevelCount","baseArrayLayer","baseMipLevel","arrayLayerCount","aspect","loadOp","storeOp","passEncoder","beginRenderPass","descriptor","entries","binding","resource","importExternalTexture","source","bindGroup","createBindGroup","setPipeline","setBindGroup","draw","end","popDebugGroup","queue","submit","finish","invertYPreMultiplyAlpha","gpuOrHdwTexture","width","height","faceIndex","mipLevel","layers","ofstX","ofstY","rectWidth","rectHeight","allowGPUOptimization","_commandEncoder$pushD2","_commandEncoder3","_webgpuHardwareTextur","_webgpuHardwareTextur2","_commandEncoder$popDe2","_commandEncoder4","useRect","Math","max","gpuTexture","IsHardwareTexture","setRawData","Float32Array","outputTexture","_copyInvertYTempTexture","createTexture","_copyInvertYRenderPassDescr","_copyInvertYBindGroupWithOfst","_copyInvertYBindGroup","push","buffer","copyTextureToTexture","origin","x","y","z","depthOrArrayLayers","copyWithInvertY","srcTextureView","_commandEncoder$pushD3","_commandEncoder5","_commandEncoder$popDe3","_commandEncoder6","imageBitmap","hasMipmaps","generateMipmaps","is3D","sampleCount","usage","additionalUsages","GetSample","layerCount","textureSize","renderAttachmentFlag","isCompressedFormat","IsCompressedFormat","ComputeNumMipmapLevels","usages","size","IsImageBitmap","updateTexture","createCubeTexture","imageBitmaps","IsImageBitmapArray","updateCubeTextures","generateCubeMipmaps","_commandEncoder$pushD4","_commandEncoder7","_commandEncoder$popDe4","_commandEncoder8","f","_commandEncoder$pushD5","_commandEncoder9","_commandEncoder$popDe5","_commandEncoder10","_mipmapGenRenderPassDescr","_mipmapGenBindGroup","i","_webgpuHardwareTextur3","_webgpuHardwareTextur4","_webgpuHardwareTextur5","_webgpuHardwareTextur6","createGPUTextureForInternalTexture","depth","creationFlags","dontCreateMSAATexture","gpuTextureWrapper","isStorageTexture","GetWebGPUTextureFormat","_useSRGBBuffer","textureUsages","_source","textureAdditionalUsages","hasMipMaps","generateMipMaps","mipmapCount","_maxLodLevel","isCube","_texture$label","set","GetDepthFormatOnly","HasDepthAndStencilAspects","is2DArray","_texture$label2","baseWidth","baseHeight","baseDepth","createMSAATexture","samples","releaseExisting","releaseMSAATexture","gpuMSAATexture","setMSAATexture","offsetX","offsetY","faces","IsInternalTexture","blockInformation","GetBlockInformationFromFormat","textureCopyView","premultipliedAlpha","textureExtent","ceil","byteLength","bytesPerRow","aligned","createRawBuffer","MapWrite","CopySrc","arrayBuffer","getMappedRange","Uint8Array","unmap","copyBufferToTexture","offset","rowsPerImage","releaseBuffer","writeTexture","dontUseRect","copyExternalImageToTexture","srcTexture","readPixels","noDataConversion","bytesPerRowAligned","gpuBuffer","MapRead","copyTextureToBuffer","readDataFromBuffer","GetTextureTypeFromFormat","releaseTexture","hardwareTexture","irradianceTexture","_irradianceTexture","destroyDeferredTextures","release","destroy","dispose"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuTextureManager.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable babylonjs/available */\n/* eslint-disable jsdoc/require-jsdoc */\n// License for the mipmap generation code:\n//\n// Copyright 2020 Brandon Jones\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nimport * as WebGPUConstants from \"./webgpuConstants.js\";\n\nimport { WebGPUHardwareTexture } from \"./webgpuHardwareTexture.js\";\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper.js\";\nimport { Finalize, Initialize, Process } from \"../Processors/shaderProcessor.js\";\n// TODO WEBGPU improve mipmap generation by using compute shaders\nconst mipmapVertexSource = `\r\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\r\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\r\n\r\n varying vTex: vec2f;\r\n\r\n @vertex\r\n fn main(input : VertexInputs) -> FragmentInputs {\r\n vertexOutputs.vTex = tex[input.vertexIndex];\r\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\r\n }\r\n `;\nconst mipmapFragmentSource = `\r\n var imgSampler: sampler;\r\n var img: texture_2d<f32>;\r\n\r\n varying vTex: vec2f;\r\n\r\n @fragment\r\n fn main(input: FragmentInputs) -> FragmentOutputs {\r\n fragmentOutputs.color = textureSample(img, imgSampler, input.vTex);\r\n }\r\n `;\nconst invertYPreMultiplyAlphaVertexSource = `\r\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\r\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\r\n\r\n var img: texture_2d<f32>;\r\n\r\n #ifdef INVERTY\r\n varying vTextureSize: vec2f;\r\n #endif\r\n\r\n @vertex\r\n fn main(input : VertexInputs) -> FragmentInputs {\r\n #ifdef INVERTY\r\n vertexOutputs.vTextureSize = vec2f(textureDimensions(img, 0));\r\n #endif\r\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\r\n }\r\n `;\nconst invertYPreMultiplyAlphaFragmentSource = `\r\n var img: texture_2d<f32>;\r\n\r\n #ifdef INVERTY\r\n varying vTextureSize: vec2f;\r\n #endif\r\n\r\n @fragment\r\n fn main(input: FragmentInputs) -> FragmentOutputs {\r\n #ifdef INVERTY\r\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(input.vTextureSize.y - input.position.y)), 0);\r\n #else\r\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\r\n #endif\r\n #ifdef PREMULTIPLYALPHA\r\n fragmentOutputs.color = vec4f(color.rgb * color.a, color.a);\r\n #endif\r\n fragmentOutputs.color = color;\r\n }\r\n `;\nconst invertYPreMultiplyAlphaWithOfstVertexSource = invertYPreMultiplyAlphaVertexSource;\nconst invertYPreMultiplyAlphaWithOfstFragmentSource = `\r\n var img: texture_2d<f32>;\r\n uniform ofstX: f32;\r\n uniform ofstY: f32;\r\n uniform width: f32;\r\n uniform height: f32;\r\n\r\n #ifdef INVERTY\r\n varying vTextureSize: vec2f;\r\n #endif\r\n\r\n @fragment\r\n fn main(input: FragmentInputs) -> FragmentOutputs {\r\n if (input.position.x < uniforms.ofstX || input.position.x >= uniforms.ofstX + uniforms.width) {\r\n discard;\r\n }\r\n if (input.position.y < uniforms.ofstY || input.position.y >= uniforms.ofstY + uniforms.height) {\r\n discard;\r\n }\r\n #ifdef INVERTY\r\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(uniforms.ofstY + uniforms.height - (input.position.y - uniforms.ofstY))), 0);\r\n #else\r\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\r\n #endif\r\n #ifdef PREMULTIPLYALPHA\r\n color = vec4f(color.rgb * color.a, color.a);\r\n #endif\r\n fragmentOutputs.color = color;\r\n }\r\n `;\nconst clearVertexSource = `\r\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\r\n\r\n @vertex\r\n fn main(input : VertexInputs) -> FragmentInputs {\r\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\r\n }\r\n `;\nconst clearFragmentSource = `\r\n uniform color: vec4f;\r\n\r\n\r\n @fragment\r\n fn main(input: FragmentInputs) -> FragmentOutputs {\r\n fragmentOutputs.color = uniforms.color;\r\n }\r\n `;\nconst copyVideoToTextureVertexSource = `\r\n struct VertexOutput {\r\n @builtin(position) Position : vec4<f32>,\r\n @location(0) fragUV : vec2<f32>\r\n }\r\n\r\n @vertex\r\n fn main(\r\n @builtin(vertex_index) VertexIndex : u32\r\n ) -> VertexOutput {\r\n var pos = array<vec2<f32>, 4>(\r\n vec2(-1.0, 1.0),\r\n vec2( 1.0, 1.0),\r\n vec2(-1.0, -1.0),\r\n vec2( 1.0, -1.0)\r\n );\r\n var tex = array<vec2<f32>, 4>(\r\n vec2(0.0, 0.0),\r\n vec2(1.0, 0.0),\r\n vec2(0.0, 1.0),\r\n vec2(1.0, 1.0)\r\n );\r\n\r\n var output: VertexOutput;\r\n\r\n output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);\r\n output.fragUV = tex[VertexIndex];\r\n\r\n return output;\r\n }\r\n `;\nconst copyVideoToTextureFragmentSource = `\r\n @group(0) @binding(0) var videoSampler: sampler;\r\n @group(0) @binding(1) var videoTexture: texture_external;\r\n\r\n @fragment\r\n fn main(\r\n @location(0) fragUV: vec2<f32>\r\n ) -> @location(0) vec4<f32> {\r\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);\r\n }\r\n `;\nconst copyVideoToTextureInvertYFragmentSource = `\r\n @group(0) @binding(0) var videoSampler: sampler;\r\n @group(0) @binding(1) var videoTexture: texture_external;\r\n\r\n @fragment\r\n fn main(\r\n @location(0) fragUV: vec2<f32>\r\n ) -> @location(0) vec4<f32> {\r\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));\r\n }\r\n `;\nvar PipelineType;\n(function (PipelineType) {\n PipelineType[PipelineType[\"MipMap\"] = 0] = \"MipMap\";\n PipelineType[PipelineType[\"InvertYPremultiplyAlpha\"] = 1] = \"InvertYPremultiplyAlpha\";\n PipelineType[PipelineType[\"Clear\"] = 2] = \"Clear\";\n PipelineType[PipelineType[\"InvertYPremultiplyAlphaWithOfst\"] = 3] = \"InvertYPremultiplyAlphaWithOfst\";\n})(PipelineType || (PipelineType = {}));\nvar VideoPipelineType;\n(function (VideoPipelineType) {\n VideoPipelineType[VideoPipelineType[\"DontInvertY\"] = 0] = \"DontInvertY\";\n VideoPipelineType[VideoPipelineType[\"InvertY\"] = 1] = \"InvertY\";\n})(VideoPipelineType || (VideoPipelineType = {}));\nconst shadersForPipelineType = [\n { vertex: mipmapVertexSource, fragment: mipmapFragmentSource },\n { vertex: invertYPreMultiplyAlphaVertexSource, fragment: invertYPreMultiplyAlphaFragmentSource },\n { vertex: clearVertexSource, fragment: clearFragmentSource },\n { vertex: invertYPreMultiplyAlphaWithOfstVertexSource, fragment: invertYPreMultiplyAlphaWithOfstFragmentSource },\n];\n/**\n * Map a (renderable) texture format (GPUTextureFormat) to an index for fast lookup (in caches for eg)\n * The number of entries should not go over 64! Else, the code in WebGPUCacheRenderPipeline.setMRT should be updated\n */\nexport const renderableTextureFormatToIndex = {\n \"\": 0,\n r8unorm: 1,\n r8uint: 2,\n r8sint: 3,\n r16uint: 4,\n r16sint: 5,\n r16float: 6,\n rg8unorm: 7,\n rg8uint: 8,\n rg8sint: 9,\n r32uint: 10,\n r32sint: 11,\n r32float: 12,\n rg16uint: 13,\n rg16sint: 14,\n rg16float: 15,\n rgba8unorm: 16,\n \"rgba8unorm-srgb\": 17,\n rgba8uint: 18,\n rgba8sint: 19,\n bgra8unorm: 20,\n \"bgra8unorm-srgb\": 21,\n rgb10a2uint: 22,\n rgb10a2unorm: 23,\n /* rg11b10ufloat: this entry is dynamically added if the \"RG11B10UFloatRenderable\" extension is supported */\n rg32uint: 24,\n rg32sint: 25,\n rg32float: 26,\n rgba16uint: 27,\n rgba16sint: 28,\n rgba16float: 29,\n rgba32uint: 30,\n rgba32sint: 31,\n rgba32float: 32,\n stencil8: 33,\n depth16unorm: 34,\n depth24plus: 35,\n \"depth24plus-stencil8\": 36,\n depth32float: 37,\n \"depth32float-stencil8\": 38,\n r16unorm: 39,\n rg16unorm: 40,\n rgba16unorm: 41,\n r16snorm: 42,\n rg16snorm: 43,\n rgba16snorm: 44,\n};\n/** @internal */\nexport class WebGPUTextureManager {\n //------------------------------------------------------------------------------\n // Initialization / Helpers\n //------------------------------------------------------------------------------\n constructor(engine, device, bufferManager, enabledExtensions) {\n this._pipelines = {};\n this._compiledShaders = [];\n this._videoPipelines = {};\n this._videoCompiledShaders = [];\n this._deferredReleaseTextures = [];\n this._engine = engine;\n this._device = device;\n this._bufferManager = bufferManager;\n if (enabledExtensions.indexOf(\"rg11b10ufloat-renderable\" /* WebGPUConstants.FeatureName.RG11B10UFloatRenderable */) !== -1) {\n const keys = Object.keys(renderableTextureFormatToIndex);\n renderableTextureFormatToIndex[\"rg11b10ufloat\" /* WebGPUConstants.TextureFormat.RG11B10UFloat */] = renderableTextureFormatToIndex[keys[keys.length - 1]] + 1;\n }\n this._mipmapSampler = device.createSampler({ minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */ });\n this._videoSampler = device.createSampler({ minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */ });\n this._ubCopyWithOfst = this._bufferManager.createBuffer(4 * 4, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBCopyWithOffset\").underlyingResource;\n this._getPipeline(\"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */);\n this._getVideoPipeline(\"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */);\n }\n _getPipeline(format, type = PipelineType.MipMap, params) {\n const index = type === PipelineType.MipMap\n ? 1 << 0\n : type === PipelineType.InvertYPremultiplyAlpha\n ? ((params.invertY ? 1 : 0) << 1) + ((params.premultiplyAlpha ? 1 : 0) << 2)\n : type === PipelineType.Clear\n ? 1 << 3\n : type === PipelineType.InvertYPremultiplyAlphaWithOfst\n ? ((params.invertY ? 1 : 0) << 4) + ((params.premultiplyAlpha ? 1 : 0) << 5)\n : 0;\n if (!this._pipelines[format]) {\n this._pipelines[format] = [];\n }\n let pipelineAndBGL = this._pipelines[format][index];\n if (!pipelineAndBGL) {\n let defines = \"\";\n if (type === PipelineType.InvertYPremultiplyAlpha || type === PipelineType.InvertYPremultiplyAlphaWithOfst) {\n if (params.invertY) {\n defines += \"#define INVERTY\\n\";\n }\n if (params.premultiplyAlpha) {\n defines += \"#define PREMULTIPLYALPHA\\n\";\n }\n }\n let modules = this._compiledShaders[index];\n if (!modules) {\n let vertexCode = shadersForPipelineType[type].vertex;\n let fragmentCode = shadersForPipelineType[type].fragment;\n const processorOptions = {\n defines: defines.split(\"\\n\"),\n indexParameters: null,\n isFragment: false,\n shouldUseHighPrecisionShader: true,\n processor: this._engine._getShaderProcessor(1 /* ShaderLanguage.WGSL */),\n supportsUniformBuffers: true,\n shadersRepository: \"\",\n includesShadersStore: {},\n version: (this._engine.version * 100).toString(),\n platformName: this._engine.shaderPlatformName,\n processingContext: this._engine._getShaderProcessingContext(1 /* ShaderLanguage.WGSL */, true),\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer,\n };\n Initialize(processorOptions);\n // Disable special additions not needed here\n processorOptions.processor.pureMode = true;\n Process(vertexCode, processorOptions, (migratedVertexCode) => {\n vertexCode = migratedVertexCode;\n }, this._engine);\n processorOptions.isFragment = true;\n Process(fragmentCode, processorOptions, (migratedFragmentCode) => {\n fragmentCode = migratedFragmentCode;\n }, this._engine);\n const final = Finalize(vertexCode, fragmentCode, processorOptions);\n // Restore\n processorOptions.processor.pureMode = false;\n const vertexModule = this._device.createShaderModule({\n code: final.vertexCode,\n });\n const fragmentModule = this._device.createShaderModule({\n code: final.fragmentCode,\n });\n modules = this._compiledShaders[index] = [vertexModule, fragmentModule];\n }\n const pipeline = this._device.createRenderPipeline({\n layout: \"auto\" /* WebGPUConstants.AutoLayoutMode.Auto */,\n vertex: {\n module: modules[0],\n entryPoint: \"main\",\n },\n fragment: {\n module: modules[1],\n entryPoint: \"main\",\n targets: [\n {\n format,\n },\n ],\n },\n primitive: {\n topology: \"triangle-strip\" /* WebGPUConstants.PrimitiveTopology.TriangleStrip */,\n stripIndexFormat: \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */,\n },\n });\n pipelineAndBGL = this._pipelines[format][index] = [pipeline, pipeline.getBindGroupLayout(0)];\n }\n return pipelineAndBGL;\n }\n _getVideoPipeline(format, type = VideoPipelineType.DontInvertY) {\n const index = type === VideoPipelineType.InvertY ? 1 << 0 : 0;\n if (!this._videoPipelines[format]) {\n this._videoPipelines[format] = [];\n }\n let pipelineAndBGL = this._videoPipelines[format][index];\n if (!pipelineAndBGL) {\n let modules = this._videoCompiledShaders[index];\n if (!modules) {\n const vertexModule = this._device.createShaderModule({\n code: copyVideoToTextureVertexSource,\n });\n const fragmentModule = this._device.createShaderModule({\n code: index === 0 ? copyVideoToTextureFragmentSource : copyVideoToTextureInvertYFragmentSource,\n });\n modules = this._videoCompiledShaders[index] = [vertexModule, fragmentModule];\n }\n const pipeline = this._device.createRenderPipeline({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_CopyVideoToTexture_${format}_${index === 0 ? \"DontInvertY\" : \"InvertY\"}`,\n layout: \"auto\" /* WebGPUConstants.AutoLayoutMode.Auto */,\n vertex: {\n module: modules[0],\n entryPoint: \"main\",\n },\n fragment: {\n module: modules[1],\n entryPoint: \"main\",\n targets: [\n {\n format,\n },\n ],\n },\n primitive: {\n topology: \"triangle-strip\" /* WebGPUConstants.PrimitiveTopology.TriangleStrip */,\n stripIndexFormat: \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */,\n },\n });\n pipelineAndBGL = this._videoPipelines[format][index] = [pipeline, pipeline.getBindGroupLayout(0)];\n }\n return pipelineAndBGL;\n }\n setCommandEncoder(encoder) {\n this._commandEncoderForCreation = encoder;\n }\n copyVideoToTexture(video, texture, format, invertY = false, commandEncoder) {\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getVideoPipeline(format, invertY ? VideoPipelineType.InvertY : VideoPipelineType.DontInvertY);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n commandEncoder.pushDebugGroup?.(`copy video to texture - invertY=${invertY}`);\n const webgpuHardwareTexture = texture._hardwareTexture;\n const renderPassDescriptor = {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_copyVideoToTexture_${format}_${invertY ? \"InvertY\" : \"DontInvertY\"}${texture.label ? \"_\" + texture.label : \"\"}`,\n colorAttachments: [\n {\n view: webgpuHardwareTexture.underlyingResource.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */,\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n },\n ],\n };\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const descriptor = {\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: this._videoSampler,\n },\n {\n binding: 1,\n resource: this._device.importExternalTexture({\n source: video.underlyingResource,\n }),\n },\n ],\n };\n const bindGroup = this._device.createBindGroup(descriptor);\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n commandEncoder.popDebugGroup?.();\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n invertYPreMultiplyAlpha(gpuOrHdwTexture, width, height, format, invertY = false, premultiplyAlpha = false, faceIndex = 0, mipLevel = 0, layers = 1, ofstX = 0, ofstY = 0, rectWidth = 0, rectHeight = 0, commandEncoder, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n allowGPUOptimization) {\n const useRect = rectWidth !== 0;\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format, useRect ? PipelineType.InvertYPremultiplyAlphaWithOfst : PipelineType.InvertYPremultiplyAlpha, {\n invertY,\n premultiplyAlpha,\n });\n faceIndex = Math.max(faceIndex, 0);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n commandEncoder.pushDebugGroup?.(`internal process texture - invertY=${invertY} premultiplyAlpha=${premultiplyAlpha}`);\n let gpuTexture;\n if (WebGPUTextureHelper.IsHardwareTexture(gpuOrHdwTexture)) {\n gpuTexture = gpuOrHdwTexture.underlyingResource;\n if (!(invertY && !premultiplyAlpha && layers === 1 && faceIndex === 0)) {\n // we optimize only for the most likely case (invertY=true, premultiplyAlpha=false, layers=1, faceIndex=0) to avoid dealing with big caches\n gpuOrHdwTexture = undefined;\n }\n }\n else {\n gpuTexture = gpuOrHdwTexture;\n gpuOrHdwTexture = undefined;\n }\n if (!gpuTexture) {\n return;\n }\n if (useRect) {\n this._bufferManager.setRawData(this._ubCopyWithOfst, 0, new Float32Array([ofstX, ofstY, rectWidth, rectHeight]), 0, 4 * 4);\n }\n const webgpuHardwareTexture = gpuOrHdwTexture;\n const outputTexture = webgpuHardwareTexture?._copyInvertYTempTexture ??\n this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, format, 1, commandEncoder, 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */, undefined, \"TempTextureForCopyWithInvertY\");\n const renderPassDescriptor = webgpuHardwareTexture?._copyInvertYRenderPassDescr ?? {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_invertYPreMultiplyAlpha_${format}_${invertY ? \"InvertY\" : \"DontInvertY\"}_${premultiplyAlpha ? \"PremultiplyAlpha\" : \"DontPremultiplyAlpha\"}`,\n colorAttachments: [\n {\n view: outputTexture.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: 0,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: 0,\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n },\n ],\n };\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n let bindGroup = useRect ? webgpuHardwareTexture?._copyInvertYBindGroupWithOfst : webgpuHardwareTexture?._copyInvertYBindGroup;\n if (!bindGroup) {\n const descriptor = {\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: gpuTexture.createView({\n format,\n dimension: \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: mipLevel,\n mipLevelCount: 1,\n arrayLayerCount: layers,\n baseArrayLayer: faceIndex,\n }),\n },\n ],\n };\n if (useRect) {\n descriptor.entries.push({\n binding: 1,\n resource: {\n buffer: this._ubCopyWithOfst,\n },\n });\n }\n bindGroup = this._device.createBindGroup(descriptor);\n }\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n commandEncoder.copyTextureToTexture({\n texture: outputTexture,\n }, {\n texture: gpuTexture,\n mipLevel,\n origin: {\n x: 0,\n y: 0,\n z: faceIndex,\n },\n }, {\n width,\n height,\n depthOrArrayLayers: 1,\n });\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._copyInvertYTempTexture = outputTexture;\n webgpuHardwareTexture._copyInvertYRenderPassDescr = renderPassDescriptor;\n if (useRect) {\n webgpuHardwareTexture._copyInvertYBindGroupWithOfst = bindGroup;\n }\n else {\n webgpuHardwareTexture._copyInvertYBindGroup = bindGroup;\n }\n }\n else {\n this._deferredReleaseTextures.push([outputTexture, null]);\n }\n commandEncoder.popDebugGroup?.();\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n copyWithInvertY(srcTextureView, format, renderPassDescriptor, commandEncoder) {\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format, PipelineType.InvertYPremultiplyAlpha, { invertY: true, premultiplyAlpha: false });\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n commandEncoder.pushDebugGroup?.(`internal copy texture with invertY`);\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const bindGroup = this._device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: srcTextureView,\n },\n ],\n });\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n commandEncoder.popDebugGroup?.();\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n //------------------------------------------------------------------------------\n // Creation\n //------------------------------------------------------------------------------\n createTexture(imageBitmap, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, is3D = false, format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label) {\n sampleCount = WebGPUTextureHelper.GetSample(sampleCount);\n const layerCount = imageBitmap.layers || 1;\n const textureSize = {\n width: imageBitmap.width,\n height: imageBitmap.height,\n depthOrArrayLayers: layerCount,\n };\n const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : 0;\n const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);\n const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(imageBitmap.width, imageBitmap.height) : 1;\n const usages = usage >= 0 ? usage : 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 2 /* WebGPUConstants.TextureUsage.CopyDst */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */;\n additionalUsages |= hasMipmaps && !isCompressedFormat ? 1 /* WebGPUConstants.TextureUsage.CopySrc */ | renderAttachmentFlag : 0;\n if (!isCompressedFormat && !is3D) {\n // 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\n additionalUsages |= renderAttachmentFlag | 2 /* WebGPUConstants.TextureUsage.CopyDst */;\n }\n const gpuTexture = this._device.createTexture({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_Texture${is3D ? \"3D\" : \"2D\"}_${label ? label + \"_\" : \"\"}${textureSize.width}x${textureSize.height}x${textureSize.depthOrArrayLayers}_${hasMipmaps ? \"wmips\" : \"womips\"}_${format}_samples${sampleCount}`,\n size: textureSize,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format,\n usage: usages | additionalUsages,\n sampleCount,\n mipLevelCount,\n });\n if (WebGPUTextureHelper.IsImageBitmap(imageBitmap)) {\n this.updateTexture(imageBitmap, gpuTexture, imageBitmap.width, imageBitmap.height, layerCount, format, 0, 0, invertY, premultiplyAlpha, 0, 0);\n if (hasMipmaps && generateMipmaps) {\n this.generateMipmaps(gpuTexture, format, mipLevelCount, 0, is3D, commandEncoder);\n }\n }\n return gpuTexture;\n }\n createCubeTexture(imageBitmaps, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label) {\n sampleCount = WebGPUTextureHelper.GetSample(sampleCount);\n const width = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].width : imageBitmaps.width;\n const height = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].height : imageBitmaps.height;\n const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : 0;\n const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);\n const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;\n const usages = usage >= 0 ? usage : 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 2 /* WebGPUConstants.TextureUsage.CopyDst */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */;\n additionalUsages |= hasMipmaps && !isCompressedFormat ? 1 /* WebGPUConstants.TextureUsage.CopySrc */ | renderAttachmentFlag : 0;\n if (!isCompressedFormat) {\n // 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\n additionalUsages |= renderAttachmentFlag | 2 /* WebGPUConstants.TextureUsage.CopyDst */;\n }\n const gpuTexture = this._device.createTexture({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureCube_${label ? label + \"_\" : \"\"}${width}x${height}x6_${hasMipmaps ? \"wmips\" : \"womips\"}_${format}_samples${sampleCount}`,\n size: {\n width,\n height,\n depthOrArrayLayers: 6,\n },\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format,\n usage: usages | additionalUsages,\n sampleCount,\n mipLevelCount,\n });\n if (WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps)) {\n this.updateCubeTextures(imageBitmaps, gpuTexture, width, height, format, invertY, premultiplyAlpha, 0, 0);\n if (hasMipmaps && generateMipmaps) {\n this.generateCubeMipmaps(gpuTexture, format, mipLevelCount, commandEncoder);\n }\n }\n return gpuTexture;\n }\n generateCubeMipmaps(gpuTexture, format, mipLevelCount, commandEncoder) {\n const useOwnCommandEncoder = commandEncoder === undefined;\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n commandEncoder.pushDebugGroup?.(`create cube mipmaps - ${mipLevelCount} levels`);\n for (let f = 0; f < 6; ++f) {\n this.generateMipmaps(gpuTexture, format, mipLevelCount, f, false, commandEncoder);\n }\n commandEncoder.popDebugGroup?.();\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n generateMipmaps(gpuOrHdwTexture, format, mipLevelCount, faceIndex = 0, is3D = false, commandEncoder) {\n const useOwnCommandEncoder = commandEncoder === undefined;\n const [pipeline, bindGroupLayout] = this._getPipeline(format);\n faceIndex = Math.max(faceIndex, 0);\n if (useOwnCommandEncoder) {\n commandEncoder = this._device.createCommandEncoder({});\n }\n commandEncoder.pushDebugGroup?.(`create mipmaps for face #${faceIndex} - ${mipLevelCount} levels`);\n let gpuTexture;\n if (WebGPUTextureHelper.IsHardwareTexture(gpuOrHdwTexture)) {\n gpuTexture = gpuOrHdwTexture.underlyingResource;\n gpuOrHdwTexture._mipmapGenRenderPassDescr = gpuOrHdwTexture._mipmapGenRenderPassDescr || [];\n gpuOrHdwTexture._mipmapGenBindGroup = gpuOrHdwTexture._mipmapGenBindGroup || [];\n }\n else {\n gpuTexture = gpuOrHdwTexture;\n gpuOrHdwTexture = undefined;\n }\n if (!gpuTexture) {\n return;\n }\n const webgpuHardwareTexture = gpuOrHdwTexture;\n for (let i = 1; i < mipLevelCount; ++i) {\n const renderPassDescriptor = webgpuHardwareTexture?._mipmapGenRenderPassDescr[faceIndex]?.[i - 1] ?? {\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_generateMipmaps_${format}_faceIndex${faceIndex}_level${i}`,\n colorAttachments: [\n {\n view: gpuTexture.createView({\n format,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: i,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: faceIndex,\n }),\n loadOp: \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n },\n ],\n };\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex] = webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex] || [];\n webgpuHardwareTexture._mipmapGenRenderPassDescr[faceIndex][i - 1] = renderPassDescriptor;\n }\n const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);\n const bindGroup = webgpuHardwareTexture?._mipmapGenBindGroup[faceIndex]?.[i - 1] ??\n this._device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: gpuTexture.createView({\n format,\n dimension: is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n baseMipLevel: i - 1,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n baseArrayLayer: faceIndex,\n }),\n },\n {\n binding: 1,\n resource: this._mipmapSampler,\n },\n ],\n });\n if (webgpuHardwareTexture) {\n webgpuHardwareTexture._mipmapGenBindGroup[faceIndex] = webgpuHardwareTexture._mipmapGenBindGroup[faceIndex] || [];\n webgpuHardwareTexture._mipmapGenBindGroup[faceIndex][i - 1] = bindGroup;\n }\n passEncoder.setPipeline(pipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4, 1, 0, 0);\n passEncoder.end();\n }\n commandEncoder.popDebugGroup?.();\n if (useOwnCommandEncoder) {\n this._device.queue.submit([commandEncoder.finish()]);\n commandEncoder = null;\n }\n }\n createGPUTextureForInternalTexture(texture, width, height, depth, creationFlags, dontCreateMSAATexture) {\n if (!texture._hardwareTexture) {\n texture._hardwareTexture = new WebGPUHardwareTexture(this._engine);\n }\n if (width === undefined) {\n width = texture.width;\n }\n if (height === undefined) {\n height = texture.height;\n }\n if (depth === undefined) {\n depth = texture.depth;\n }\n const gpuTextureWrapper = texture._hardwareTexture;\n const isStorageTexture = ((creationFlags ?? 0) & 1) !== 0;\n gpuTextureWrapper.format = WebGPUTextureHelper.GetWebGPUTextureFormat(texture.type, texture.format, texture._useSRGBBuffer);\n gpuTextureWrapper.textureUsages =\n texture._source === 5 /* InternalTextureSource.RenderTarget */ || texture.source === 6 /* InternalTextureSource.MultiRenderTarget */\n ? 4 /* WebGPUConstants.TextureUsage.TextureBinding */ | 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */\n : texture._source === 12 /* InternalTextureSource.DepthStencil */\n ? 4 /* WebGPUConstants.TextureUsage.TextureBinding */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */\n : -1;\n gpuTextureWrapper.textureAdditionalUsages = isStorageTexture ? 8 /* WebGPUConstants.TextureUsage.StorageBinding */ : 0;\n const hasMipMaps = texture.generateMipMaps;\n const layerCount = depth || 1;\n let mipmapCount;\n if (texture._maxLodLevel !== null) {\n mipmapCount = texture._maxLodLevel;\n }\n else {\n mipmapCount = hasMipMaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;\n }\n if (texture.isCube) {\n const gpuTexture = this.createCubeTexture({ width, height }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);\n gpuTextureWrapper.set(gpuTexture);\n const arrayLayerCount = texture.is3D ? 1 : layerCount;\n const format = WebGPUTextureHelper.GetDepthFormatOnly(gpuTextureWrapper.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(gpuTextureWrapper.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n const dimension = texture.is2DArray ? \"cube-array\" /* WebGPUConstants.TextureViewDimension.CubeArray */ : \"cube\" /* WebGPUConstants.TextureViewDimension.Cube */;\n gpuTextureWrapper.createView({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureViewCube${texture.is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${hasMipMaps ? \"wmips\" : \"womips\"}_${format}_${dimension}_${aspect}_${texture.label ?? \"noname\"}`,\n format,\n dimension,\n mipLevelCount: mipmapCount,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount: 6,\n aspect,\n }, isStorageTexture);\n }\n else {\n const gpuTexture = this.createTexture({ width, height, layers: layerCount }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, texture.is3D, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);\n gpuTextureWrapper.set(gpuTexture);\n const arrayLayerCount = texture.is3D ? 1 : layerCount;\n const format = WebGPUTextureHelper.GetDepthFormatOnly(gpuTextureWrapper.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(gpuTextureWrapper.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n const dimension = texture.is2DArray\n ? \"2d-array\" /* WebGPUConstants.TextureViewDimension.E2dArray */\n : texture.is3D\n ? \"3d\" /* WebGPUConstants.TextureDimension.E3d */\n : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */;\n gpuTextureWrapper.createView({\n label: `BabylonWebGPUDevice${this._engine.uniqueId}_TextureView${texture.is3D ? \"3D\" : \"2D\"}${texture.is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}${texture.is3D ? \"x\" + layerCount : \"\"}_${hasMipMaps ? \"wmips\" : \"womips\"}_${format}_${dimension}_${aspect}_${texture.label ?? \"noname\"}`,\n format,\n dimension,\n mipLevelCount: mipmapCount,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount,\n aspect,\n }, isStorageTexture);\n }\n texture.width = texture.baseWidth = width;\n texture.height = texture.baseHeight = height;\n texture.depth = texture.baseDepth = depth;\n if (!dontCreateMSAATexture) {\n this.createMSAATexture(texture, texture.samples);\n }\n return gpuTextureWrapper;\n }\n createMSAATexture(texture, samples, releaseExisting = true, index = 0) {\n const gpuTextureWrapper = texture._hardwareTexture;\n if (releaseExisting) {\n gpuTextureWrapper?.releaseMSAATexture();\n }\n if (!gpuTextureWrapper || (samples ?? 1) <= 1) {\n return;\n }\n const width = texture.width;\n const height = texture.height;\n const gpuMSAATexture = this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, 16 /* WebGPUConstants.TextureUsage.RenderAttachment */, 0, texture.label ? \"MSAA_\" + texture.label : \"MSAA\");\n gpuTextureWrapper.setMSAATexture(gpuMSAATexture, index);\n }\n //------------------------------------------------------------------------------\n // Update\n //------------------------------------------------------------------------------\n updateCubeTextures(imageBitmaps, gpuTexture, width, height, format, invertY = false, premultiplyAlpha = false, offsetX = 0, offsetY = 0) {\n const faces = [0, 3, 1, 4, 2, 5];\n for (let f = 0; f < faces.length; ++f) {\n const imageBitmap = imageBitmaps[faces[f]];\n this.updateTexture(imageBitmap, gpuTexture, width, height, 1, format, f, 0, invertY, premultiplyAlpha, offsetX, offsetY);\n }\n }\n // TODO WEBGPU handle data source not being in the same format than the destination texture?\n updateTexture(imageBitmap, texture, width, height, layers, format, faceIndex = 0, mipLevel = 0, invertY = false, premultiplyAlpha = false, offsetX = 0, offsetY = 0, allowGPUOptimization) {\n const gpuTexture = WebGPUTextureHelper.IsInternalTexture(texture) ? texture._hardwareTexture.underlyingResource : texture;\n const blockInformation = WebGPUTextureHelper.GetBlockInformationFromFormat(format);\n const gpuOrHdwTexture = WebGPUTextureHelper.IsInternalTexture(texture) ? texture._hardwareTexture : texture;\n const textureCopyView = {\n texture: gpuTexture,\n origin: {\n x: offsetX,\n y: offsetY,\n z: Math.max(faceIndex, 0),\n },\n mipLevel: mipLevel,\n premultipliedAlpha: premultiplyAlpha,\n };\n const textureExtent = {\n width: Math.ceil(width / blockInformation.width) * blockInformation.width,\n height: Math.ceil(height / blockInformation.height) * blockInformation.height,\n depthOrArrayLayers: layers || 1,\n };\n if (imageBitmap.byteLength !== undefined) {\n imageBitmap = imageBitmap;\n const bytesPerRow = Math.ceil(width / blockInformation.width) * blockInformation.length;\n const aligned = Math.ceil(bytesPerRow / 256) * 256 === bytesPerRow;\n if (aligned) {\n const commandEncoder = this._device.createCommandEncoder({});\n const buffer = this._bufferManager.createRawBuffer(imageBitmap.byteLength, WebGPUConstants.BufferUsage.MapWrite | WebGPUConstants.BufferUsage.CopySrc, true, \"TempBufferForUpdateTexture\" + (gpuTexture ? \"_\" + gpuTexture.label : \"\"));\n const arrayBuffer = buffer.getMappedRange();\n new Uint8Array(arrayBuffer).set(imageBitmap);\n buffer.unmap();\n commandEncoder.copyBufferToTexture({\n buffer: buffer,\n offset: 0,\n bytesPerRow,\n rowsPerImage: height,\n }, textureCopyView, textureExtent);\n this._device.queue.submit([commandEncoder.finish()]);\n this._bufferManager.releaseBuffer(buffer);\n }\n else {\n this._device.queue.writeTexture(textureCopyView, imageBitmap, {\n offset: 0,\n bytesPerRow,\n rowsPerImage: height,\n }, textureExtent);\n }\n if (invertY || premultiplyAlpha) {\n if (WebGPUTextureHelper.IsInternalTexture(texture)) {\n const dontUseRect = offsetX === 0 && offsetY === 0 && width === texture.width && height === texture.height;\n this.invertYPreMultiplyAlpha(gpuOrHdwTexture, texture.width, texture.height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, offsetX, offsetY, dontUseRect ? 0 : width, dontUseRect ? 0 : height, undefined, allowGPUOptimization);\n }\n else {\n // we should never take this code path\n // eslint-disable-next-line no-throw-literal\n throw \"updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!\";\n }\n }\n }\n else {\n imageBitmap = imageBitmap;\n if (invertY) {\n textureCopyView.premultipliedAlpha = false; // we are going to handle premultiplyAlpha ourselves\n // we must preprocess the image\n if (WebGPUTextureHelper.IsInternalTexture(texture) && offsetX === 0 && offsetY === 0 && width === texture.width && height === texture.height) {\n // optimization when the source image is the same size than the destination texture and offsets X/Y == 0:\n // we simply copy the source to the destination and we apply the preprocessing on the destination\n this._device.queue.copyExternalImageToTexture({ source: imageBitmap }, textureCopyView, textureExtent);\n this.invertYPreMultiplyAlpha(gpuOrHdwTexture, width, height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, 0, 0, 0, 0, undefined, allowGPUOptimization);\n }\n else {\n // we must apply the preprocessing on the source image before copying it into the destination texture\n const commandEncoder = this._device.createCommandEncoder({});\n // create a temp texture and copy the image to it\n const srcTexture = this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, format, 1, commandEncoder, 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */, undefined, \"TempTextureForUpdateTexture\");\n this._deferredReleaseTextures.push([srcTexture, null]);\n textureExtent.depthOrArrayLayers = 1;\n this._device.queue.copyExternalImageToTexture({ source: imageBitmap }, { texture: srcTexture }, textureExtent);\n textureExtent.depthOrArrayLayers = layers || 1;\n // apply the preprocessing to this temp texture\n this.invertYPreMultiplyAlpha(srcTexture, width, height, format, invertY, premultiplyAlpha, faceIndex, mipLevel, layers || 1, 0, 0, 0, 0, commandEncoder, allowGPUOptimization);\n // copy the temp texture to the destination texture\n commandEncoder.copyTextureToTexture({ texture: srcTexture }, textureCopyView, textureExtent);\n this._device.queue.submit([commandEncoder.finish()]);\n }\n }\n else {\n // no preprocessing: direct copy to destination texture\n this._device.queue.copyExternalImageToTexture({ source: imageBitmap }, textureCopyView, textureExtent);\n }\n }\n }\n readPixels(texture, x, y, width, height, format, faceIndex = 0, mipLevel = 0, buffer = null, noDataConversion = false) {\n const blockInformation = WebGPUTextureHelper.GetBlockInformationFromFormat(format);\n const bytesPerRow = Math.ceil(width / blockInformation.width) * blockInformation.length;\n const bytesPerRowAligned = Math.ceil(bytesPerRow / 256) * 256;\n const size = bytesPerRowAligned * height;\n const gpuBuffer = this._bufferManager.createRawBuffer(size, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempBufferForReadPixels\" + (texture.label ? \"_\" + texture.label : \"\"));\n const commandEncoder = this._device.createCommandEncoder({});\n commandEncoder.copyTextureToBuffer({\n texture,\n mipLevel,\n origin: {\n x,\n y,\n z: Math.max(faceIndex, 0),\n },\n }, {\n buffer: gpuBuffer,\n offset: 0,\n bytesPerRow: bytesPerRowAligned,\n }, {\n width,\n height,\n depthOrArrayLayers: 1,\n });\n this._device.queue.submit([commandEncoder.finish()]);\n return this._bufferManager.readDataFromBuffer(gpuBuffer, size, width, height, bytesPerRow, bytesPerRowAligned, WebGPUTextureHelper.GetTextureTypeFromFormat(format), 0, buffer, true, noDataConversion);\n }\n //------------------------------------------------------------------------------\n // Dispose\n //------------------------------------------------------------------------------\n releaseTexture(texture) {\n if (WebGPUTextureHelper.IsInternalTexture(texture)) {\n const hardwareTexture = texture._hardwareTexture;\n const irradianceTexture = texture._irradianceTexture;\n // We can't destroy the objects just now because they could be used in the current frame - we delay the destroying after the end of the frame\n this._deferredReleaseTextures.push([hardwareTexture, irradianceTexture]);\n }\n else {\n this._deferredReleaseTextures.push([texture, null]);\n }\n }\n destroyDeferredTextures() {\n for (let i = 0; i < this._deferredReleaseTextures.length; ++i) {\n const [hardwareTexture, irradianceTexture] = this._deferredReleaseTextures[i];\n if (hardwareTexture) {\n if (WebGPUTextureHelper.IsHardwareTexture(hardwareTexture)) {\n hardwareTexture.release();\n }\n else {\n hardwareTexture.destroy();\n }\n }\n irradianceTexture?.dispose();\n }\n this._deferredReleaseTextures.length = 0;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,eAAe,MAAM,sBAAsB;AAEvD,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,QAAQ,kCAAkC;AAChF;AACA,MAAMC,kBAAkB,GAAG;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,oBAAoB,GAAG;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,mCAAmC,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,qCAAqC,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,2CAA2C,GAAGF,mCAAmC;AACvF,MAAMG,6CAA6C,GAAG;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,iBAAiB,GAAG;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,mBAAmB,GAAG;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,8BAA8B,GAAG;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,MAAMC,gCAAgC,GA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