48c69ddb416a07449665baaf0ca4b2689d003ebe2a2eadc29d18372cc870a774.json 12 KB

1
  1. {"ast":null,"code":"import { ILog2 } from \"../../Maths/math.scalar.functions.js\";\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper.js\";\n/** @internal */\nexport class WebGPUHardwareTexture {\n get underlyingResource() {\n return this._webgpuTexture;\n }\n getMSAATexture(index) {\n var _this$_webgpuMSAAText, _this$_webgpuMSAAText2;\n return (_this$_webgpuMSAAText = (_this$_webgpuMSAAText2 = this._webgpuMSAATexture) === null || _this$_webgpuMSAAText2 === void 0 ? void 0 : _this$_webgpuMSAAText2[index]) !== null && _this$_webgpuMSAAText !== void 0 ? _this$_webgpuMSAAText : null;\n }\n setMSAATexture(texture, index) {\n if (!this._webgpuMSAATexture) {\n this._webgpuMSAATexture = [];\n }\n this._webgpuMSAATexture[index] = texture;\n }\n releaseMSAATexture(index) {\n if (this._webgpuMSAATexture) {\n if (index !== undefined) {\n this._engine._textureHelper.releaseTexture(this._webgpuMSAATexture[index]);\n delete this._webgpuMSAATexture[index];\n } else {\n for (const texture of this._webgpuMSAATexture) {\n this._engine._textureHelper.releaseTexture(texture);\n }\n this._webgpuMSAATexture = null;\n }\n }\n }\n constructor(_engine, existingTexture = null) {\n this._engine = _engine;\n /** @internal */\n this._originalFormatIsRGB = false;\n this.format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */;\n this.textureUsages = 0;\n this.textureAdditionalUsages = 0;\n this._webgpuTexture = existingTexture;\n this._webgpuMSAATexture = null;\n this.view = null;\n this.viewForWriting = null;\n }\n set(hardwareTexture) {\n this._webgpuTexture = hardwareTexture;\n }\n setUsage(_textureSource, generateMipMaps, is2DArray, isCube, is3D, width, height, depth) {\n let viewDimension = \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */;\n let arrayLayerCount = 1;\n if (isCube) {\n viewDimension = is2DArray ? \"cube-array\" /* WebGPUConstants.TextureViewDimension.CubeArray */ : \"cube\" /* WebGPUConstants.TextureViewDimension.Cube */;\n arrayLayerCount = 6 * (depth || 1);\n } else if (is3D) {\n viewDimension = \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */;\n arrayLayerCount = 1;\n } else if (is2DArray) {\n viewDimension = \"2d-array\" /* WebGPUConstants.TextureViewDimension.E2dArray */;\n arrayLayerCount = depth;\n }\n const format = WebGPUTextureHelper.GetDepthFormatOnly(this.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(this.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n this.createView({\n label: `TextureView${is3D ? \"3D\" : isCube ? \"Cube\" : \"2D\"}${is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${generateMipMaps ? \"wmips\" : \"womips\"}_${this.format}_${viewDimension}`,\n format,\n dimension: viewDimension,\n mipLevelCount: generateMipMaps ? ILog2(Math.max(width, height)) + 1 : 1,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount,\n aspect\n });\n }\n createView(descriptor, createViewForWriting = false) {\n this.view = this._webgpuTexture.createView(descriptor);\n if (createViewForWriting && descriptor) {\n const saveNumMipMaps = descriptor.mipLevelCount;\n descriptor.mipLevelCount = 1;\n this.viewForWriting = this._webgpuTexture.createView(descriptor);\n descriptor.mipLevelCount = saveNumMipMaps;\n }\n }\n reset() {\n this._webgpuTexture = null;\n this._webgpuMSAATexture = null;\n this.view = null;\n this.viewForWriting = null;\n }\n release() {\n var _this$_webgpuTexture, _this$_copyInvertYTem;\n (_this$_webgpuTexture = this._webgpuTexture) === null || _this$_webgpuTexture === void 0 || _this$_webgpuTexture.destroy();\n this.releaseMSAATexture();\n (_this$_copyInvertYTem = this._copyInvertYTempTexture) === null || _this$_copyInvertYTem === void 0 || _this$_copyInvertYTem.destroy();\n this.reset();\n }\n}","map":{"version":3,"names":["ILog2","WebGPUTextureHelper","WebGPUHardwareTexture","underlyingResource","_webgpuTexture","getMSAATexture","index","_this$_webgpuMSAAText","_this$_webgpuMSAAText2","_webgpuMSAATexture","setMSAATexture","texture","releaseMSAATexture","undefined","_engine","_textureHelper","releaseTexture","constructor","existingTexture","_originalFormatIsRGB","format","textureUsages","textureAdditionalUsages","view","viewForWriting","set","hardwareTexture","setUsage","_textureSource","generateMipMaps","is2DArray","isCube","is3D","width","height","depth","viewDimension","arrayLayerCount","GetDepthFormatOnly","aspect","HasDepthAndStencilAspects","createView","label","dimension","mipLevelCount","Math","max","baseArrayLayer","baseMipLevel","descriptor","createViewForWriting","saveNumMipMaps","reset","release","_this$_webgpuTexture","_this$_copyInvertYTem","destroy","_copyInvertYTempTexture"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuHardwareTexture.js"],"sourcesContent":["import { ILog2 } from \"../../Maths/math.scalar.functions.js\";\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper.js\";\n/** @internal */\nexport class WebGPUHardwareTexture {\n get underlyingResource() {\n return this._webgpuTexture;\n }\n getMSAATexture(index) {\n return this._webgpuMSAATexture?.[index] ?? null;\n }\n setMSAATexture(texture, index) {\n if (!this._webgpuMSAATexture) {\n this._webgpuMSAATexture = [];\n }\n this._webgpuMSAATexture[index] = texture;\n }\n releaseMSAATexture(index) {\n if (this._webgpuMSAATexture) {\n if (index !== undefined) {\n this._engine._textureHelper.releaseTexture(this._webgpuMSAATexture[index]);\n delete this._webgpuMSAATexture[index];\n }\n else {\n for (const texture of this._webgpuMSAATexture) {\n this._engine._textureHelper.releaseTexture(texture);\n }\n this._webgpuMSAATexture = null;\n }\n }\n }\n constructor(_engine, existingTexture = null) {\n this._engine = _engine;\n /** @internal */\n this._originalFormatIsRGB = false;\n this.format = \"rgba8unorm\" /* WebGPUConstants.TextureFormat.RGBA8Unorm */;\n this.textureUsages = 0;\n this.textureAdditionalUsages = 0;\n this._webgpuTexture = existingTexture;\n this._webgpuMSAATexture = null;\n this.view = null;\n this.viewForWriting = null;\n }\n set(hardwareTexture) {\n this._webgpuTexture = hardwareTexture;\n }\n setUsage(_textureSource, generateMipMaps, is2DArray, isCube, is3D, width, height, depth) {\n let viewDimension = \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */;\n let arrayLayerCount = 1;\n if (isCube) {\n viewDimension = is2DArray ? \"cube-array\" /* WebGPUConstants.TextureViewDimension.CubeArray */ : \"cube\" /* WebGPUConstants.TextureViewDimension.Cube */;\n arrayLayerCount = 6 * (depth || 1);\n }\n else if (is3D) {\n viewDimension = \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */;\n arrayLayerCount = 1;\n }\n else if (is2DArray) {\n viewDimension = \"2d-array\" /* WebGPUConstants.TextureViewDimension.E2dArray */;\n arrayLayerCount = depth;\n }\n const format = WebGPUTextureHelper.GetDepthFormatOnly(this.format);\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(this.format) ? \"depth-only\" /* WebGPUConstants.TextureAspect.DepthOnly */ : \"all\" /* WebGPUConstants.TextureAspect.All */;\n this.createView({\n label: `TextureView${is3D ? \"3D\" : isCube ? \"Cube\" : \"2D\"}${is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${generateMipMaps ? \"wmips\" : \"womips\"}_${this.format}_${viewDimension}`,\n format,\n dimension: viewDimension,\n mipLevelCount: generateMipMaps ? ILog2(Math.max(width, height)) + 1 : 1,\n baseArrayLayer: 0,\n baseMipLevel: 0,\n arrayLayerCount,\n aspect,\n });\n }\n createView(descriptor, createViewForWriting = false) {\n this.view = this._webgpuTexture.createView(descriptor);\n if (createViewForWriting && descriptor) {\n const saveNumMipMaps = descriptor.mipLevelCount;\n descriptor.mipLevelCount = 1;\n this.viewForWriting = this._webgpuTexture.createView(descriptor);\n descriptor.mipLevelCount = saveNumMipMaps;\n }\n }\n reset() {\n this._webgpuTexture = null;\n this._webgpuMSAATexture = null;\n this.view = null;\n this.viewForWriting = null;\n }\n release() {\n this._webgpuTexture?.destroy();\n this.releaseMSAATex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