{"ast":null,"code":"/* eslint-disable babylonjs/available */\n/* eslint-disable jsdoc/require-jsdoc */\nimport { ExternalTexture } from \"../../Materials/Textures/externalTexture.js\";\nimport { WebGPUCacheSampler } from \"./webgpuCacheSampler.js\";\n/** @internal */\nexport class WebGPUMaterialContext {\n get forceBindGroupCreation() {\n // If there is at least one external texture to bind, we must recreate the bind groups each time\n // because we need to retrieve a new texture each frame (by calling device.importExternalTexture)\n return this._numExternalTextures > 0;\n }\n get hasFloatOrDepthTextures() {\n return this._numFloatOrDepthTextures > 0;\n }\n constructor() {\n this.uniqueId = WebGPUMaterialContext._Counter++;\n this.updateId = 0;\n this.textureState = 0;\n this.reset();\n }\n reset() {\n this.samplers = {};\n this.textures = {};\n this.isDirty = true;\n this._numFloatOrDepthTextures = 0;\n this._numExternalTextures = 0;\n }\n setSampler(name, sampler) {\n let samplerCache = this.samplers[name];\n let currentHashCode = -1;\n if (!samplerCache) {\n this.samplers[name] = samplerCache = {\n sampler,\n hashCode: 0\n };\n } else {\n currentHashCode = samplerCache.hashCode;\n }\n samplerCache.sampler = sampler;\n samplerCache.hashCode = sampler ? WebGPUCacheSampler.GetSamplerHashCode(sampler) : 0;\n const isDirty = currentHashCode !== samplerCache.hashCode;\n if (isDirty) {\n this.updateId++;\n }\n this.isDirty || (this.isDirty = isDirty);\n }\n setTexture(name, texture) {\n var _texture$uniqueId;\n let textureCache = this.textures[name];\n let currentTextureId = -1;\n if (!textureCache) {\n this.textures[name] = textureCache = {\n texture,\n isFloatOrDepthTexture: false,\n isExternalTexture: false\n };\n } else {\n var _textureCache$texture, _textureCache$texture2;\n currentTextureId = (_textureCache$texture = (_textureCache$texture2 = textureCache.texture) === null || _textureCache$texture2 === void 0 ? void 0 : _textureCache$texture2.uniqueId) !== null && _textureCache$texture !== void 0 ? _textureCache$texture : -1;\n }\n if (textureCache.isExternalTexture) {\n this._numExternalTextures--;\n }\n if (textureCache.isFloatOrDepthTexture) {\n this._numFloatOrDepthTextures--;\n }\n if (texture) {\n textureCache.isFloatOrDepthTexture = texture.type === 1 || texture.format >= 13 && texture.format <= 18;\n textureCache.isExternalTexture = ExternalTexture.IsExternalTexture(texture);\n if (textureCache.isFloatOrDepthTexture) {\n this._numFloatOrDepthTextures++;\n }\n if (textureCache.isExternalTexture) {\n this._numExternalTextures++;\n }\n } else {\n textureCache.isFloatOrDepthTexture = false;\n textureCache.isExternalTexture = false;\n }\n textureCache.texture = texture;\n const isDirty = currentTextureId !== ((_texture$uniqueId = texture === null || texture === void 0 ? void 0 : texture.uniqueId) !== null && _texture$uniqueId !== void 0 ? _texture$uniqueId : -1);\n if (isDirty) {\n this.updateId++;\n }\n this.isDirty || (this.isDirty = isDirty);\n }\n}\nWebGPUMaterialContext._Counter = 0;","map":{"version":3,"names":["ExternalTexture","WebGPUCacheSampler","WebGPUMaterialContext","forceBindGroupCreation","_numExternalTextures","hasFloatOrDepthTextures","_numFloatOrDepthTextures","constructor","uniqueId","_Counter","updateId","textureState","reset","samplers","textures","isDirty","setSampler","name","sampler","samplerCache","currentHashCode","hashCode","GetSamplerHashCode","setTexture","texture","_texture$uniqueId","textureCache","currentTextureId","isFloatOrDepthTexture","isExternalTexture","_textureCache$texture","_textureCache$texture2","type","format","IsExternalTexture"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuMaterialContext.js"],"sourcesContent":["/* eslint-disable babylonjs/available */\n/* eslint-disable jsdoc/require-jsdoc */\nimport { ExternalTexture } from \"../../Materials/Textures/externalTexture.js\";\n\nimport { WebGPUCacheSampler } from \"./webgpuCacheSampler.js\";\n/** @internal */\nexport class WebGPUMaterialContext {\n get forceBindGroupCreation() {\n // If there is at least one external texture to bind, we must recreate the bind groups each time\n // because we need to retrieve a new texture each frame (by calling device.importExternalTexture)\n return this._numExternalTextures > 0;\n }\n get hasFloatOrDepthTextures() {\n return this._numFloatOrDepthTextures > 0;\n }\n constructor() {\n this.uniqueId = WebGPUMaterialContext._Counter++;\n this.updateId = 0;\n this.textureState = 0;\n this.reset();\n }\n reset() {\n this.samplers = {};\n this.textures = {};\n this.isDirty = true;\n this._numFloatOrDepthTextures = 0;\n this._numExternalTextures = 0;\n }\n setSampler(name, sampler) {\n let samplerCache = this.samplers[name];\n let currentHashCode = -1;\n if (!samplerCache) {\n this.samplers[name] = samplerCache = { sampler, hashCode: 0 };\n }\n else {\n currentHashCode = samplerCache.hashCode;\n }\n samplerCache.sampler = sampler;\n samplerCache.hashCode = sampler ? WebGPUCacheSampler.GetSamplerHashCode(sampler) : 0;\n const isDirty = currentHashCode !== samplerCache.hashCode;\n if (isDirty) {\n this.updateId++;\n }\n this.isDirty || (this.isDirty = isDirty);\n }\n setTexture(name, texture) {\n let textureCache = this.textures[name];\n let currentTextureId = -1;\n if (!textureCache) {\n this.textures[name] = textureCache = { texture, isFloatOrDepthTexture: false, isExternalTexture: false };\n }\n else {\n currentTextureId = textureCache.texture?.uniqueId ?? -1;\n }\n if (textureCache.isExternalTexture) {\n this._numExternalTextures--;\n }\n if (textureCache.isFloatOrDepthTexture) {\n this._numFloatOrDepthTextures--;\n }\n if (texture) {\n textureCache.isFloatOrDepthTexture =\n texture.type === 1 ||\n (texture.format >= 13 && texture.format <= 18);\n textureCache.isExternalTexture = ExternalTexture.IsExternalTexture(texture);\n if (textureCache.isFloatOrDepthTexture) {\n this._numFloatOrDepthTextures++;\n }\n if (textureCache.isExternalTexture) {\n this._numExternalTextures++;\n }\n }\n else {\n textureCache.isFloatOrDepthTexture = false;\n textureCache.isExternalTexture = false;\n }\n textureCache.texture = texture;\n const isDirty = currentTextureId !== (texture?.uniqueId ?? -1);\n if (isDirty) {\n this.updateId++;\n }\n this.isDirty || (this.isDirty = isDirty);\n }\n}\nWebGPUMaterialContext._Counter = 0;\n"],"mappings":"AAAA;AACA;AACA,SAASA,eAAe,QAAQ,6CAA6C;AAE7E,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D;AACA,OAAO,MAAMC,qBAAqB,CAAC;EAC/B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