e2cf4f3126547e6be955a8c4146e64dbf77c6c9a542c9fe1676883da0530937d.json 32 KB

1
  1. {"ast":null,"code":"const filterToBits = [0 | 0 << 1 | 0 << 2,\n// not used\n0 | 0 << 1 | 0 << 2,\n// TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\n1 | 1 << 1 | 0 << 2,\n// TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\n1 | 1 << 1 | 1 << 2,\n// TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\n0 | 0 << 1 | 0 << 2,\n// TEXTURE_NEAREST_NEAREST_MIPNEAREST\n0 | 1 << 1 | 0 << 2,\n// TEXTURE_NEAREST_LINEAR_MIPNEAREST\n0 | 1 << 1 | 1 << 2,\n// TEXTURE_NEAREST_LINEAR_MIPLINEAR\n0 | 1 << 1 | 0 << 2,\n// TEXTURE_NEAREST_LINEAR\n0 | 0 << 1 | 1 << 2,\n// TEXTURE_NEAREST_NEAREST_MIPLINEAR\n1 | 0 << 1 | 0 << 2,\n// TEXTURE_LINEAR_NEAREST_MIPNEAREST\n1 | 0 << 1 | 1 << 2,\n// TEXTURE_LINEAR_NEAREST_MIPLINEAR\n1 | 1 << 1 | 0 << 2,\n// TEXTURE_LINEAR_LINEAR_MIPNEAREST\n1 | 0 << 1 | 0 << 2 // TEXTURE_LINEAR_NEAREST\n];\n// subtract 0x01FF from the comparison function value before indexing this array!\nconst comparisonFunctionToBits = [0 << 3 | 0 << 4 | 0 << 5 | 0 << 6,\n// undefined\n0 << 3 | 0 << 4 | 0 << 5 | 1 << 6,\n// NEVER\n0 << 3 | 0 << 4 | 1 << 5 | 0 << 6,\n// LESS\n0 << 3 | 0 << 4 | 1 << 5 | 1 << 6,\n// EQUAL\n0 << 3 | 1 << 4 | 0 << 5 | 0 << 6,\n// LEQUAL\n0 << 3 | 1 << 4 | 0 << 5 | 1 << 6,\n// GREATER\n0 << 3 | 1 << 4 | 1 << 5 | 0 << 6,\n// NOTEQUAL\n0 << 3 | 1 << 4 | 1 << 5 | 1 << 6,\n// GEQUAL\n1 << 3 | 0 << 4 | 0 << 5 | 0 << 6 // ALWAYS\n];\nconst filterNoMipToBits = [0 << 7,\n// not used\n1 << 7,\n// TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\n1 << 7,\n// TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\n0 << 7,\n// TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\n0 << 7,\n// TEXTURE_NEAREST_NEAREST_MIPNEAREST\n0 << 7,\n// TEXTURE_NEAREST_LINEAR_MIPNEAREST\n0 << 7,\n// TEXTURE_NEAREST_LINEAR_MIPLINEAR\n1 << 7,\n// TEXTURE_NEAREST_LINEAR\n0 << 7,\n// TEXTURE_NEAREST_NEAREST_MIPLINEAR\n0 << 7,\n// TEXTURE_LINEAR_NEAREST_MIPNEAREST\n0 << 7,\n// TEXTURE_LINEAR_NEAREST_MIPLINEAR\n0 << 7,\n// TEXTURE_LINEAR_LINEAR_MIPNEAREST\n1 << 7 // TEXTURE_LINEAR_NEAREST\n];\n/** @internal */\nexport class WebGPUCacheSampler {\n constructor(device) {\n this._samplers = {};\n this._device = device;\n this.disabled = false;\n }\n static GetSamplerHashCode(sampler) {\n var _sampler$_cachedWrapU, _sampler$_cachedWrapV, _sampler$_cachedWrapR;\n // The WebGPU spec currently only allows values 1 and 4 for anisotropy\n const anisotropy = sampler._cachedAnisotropicFilteringLevel ? sampler._cachedAnisotropicFilteringLevel : 1;\n const code = filterToBits[sampler.samplingMode] + comparisonFunctionToBits[(sampler._comparisonFunction || 0x0202) - 0x0200 + 1] + filterNoMipToBits[sampler.samplingMode] + (\n // handle the lodMinClamp = lodMaxClamp = 0 case when no filter used for mip mapping\n ((_sampler$_cachedWrapU = sampler._cachedWrapU) !== null && _sampler$_cachedWrapU !== void 0 ? _sampler$_cachedWrapU : 1) << 8) + (((_sampler$_cachedWrapV = sampler._cachedWrapV) !== null && _sampler$_cachedWrapV !== void 0 ? _sampler$_cachedWrapV : 1) << 10) + (((_sampler$_cachedWrapR = sampler._cachedWrapR) !== null && _sampler$_cachedWrapR !== void 0 ? _sampler$_cachedWrapR : 1) << 12) + ((sampler.useMipMaps ? 1 : 0) << 14) + (\n // need to factor this in because _getSamplerFilterDescriptor depends on samplingMode AND useMipMaps!\n anisotropy << 15);\n return code;\n }\n static _GetSamplerFilterDescriptor(sampler, anisotropy) {\n let magFilter, minFilter, mipmapFilter, lodMinClamp, lodMaxClamp;\n const useMipMaps = sampler.useMipMaps;\n switch (sampler.samplingMode) {\n case 11:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 3:\n case 3:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n } else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 8:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n } else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 4:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 5:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 6:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n } else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 7:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 1:\n case 1:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 9:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 10:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n } else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 2:\n case 2:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 12:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n default:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n }\n if (anisotropy > 1 && (lodMinClamp !== 0 || lodMaxClamp !== 0) && mipmapFilter !== \"nearest\" /* WebGPUConstants.FilterMode.Nearest */) {\n return {\n magFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n mipmapFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n anisotropyEnabled: true\n };\n }\n return {\n magFilter,\n minFilter,\n mipmapFilter,\n lodMinClamp,\n lodMaxClamp\n };\n }\n static _GetWrappingMode(mode) {\n switch (mode) {\n case 1:\n return \"repeat\" /* WebGPUConstants.AddressMode.Repeat */;\n case 0:\n return \"clamp-to-edge\" /* WebGPUConstants.AddressMode.ClampToEdge */;\n case 2:\n return \"mirror-repeat\" /* WebGPUConstants.AddressMode.MirrorRepeat */;\n }\n return \"repeat\" /* WebGPUConstants.AddressMode.Repeat */;\n }\n static _GetSamplerWrappingDescriptor(sampler) {\n return {\n addressModeU: this._GetWrappingMode(sampler._cachedWrapU),\n addressModeV: this._GetWrappingMode(sampler._cachedWrapV),\n addressModeW: this._GetWrappingMode(sampler._cachedWrapR)\n };\n }\n static _GetSamplerDescriptor(sampler, label) {\n const anisotropy = sampler.useMipMaps && sampler._cachedAnisotropicFilteringLevel ? sampler._cachedAnisotropicFilteringLevel : 1;\n const filterDescriptor = this._GetSamplerFilterDescriptor(sampler, anisotropy);\n return {\n label,\n ...filterDescriptor,\n ...this._GetSamplerWrappingDescriptor(sampler),\n compare: sampler._comparisonFunction ? WebGPUCacheSampler.GetCompareFunction(sampler._comparisonFunction) : undefined,\n maxAnisotropy: filterDescriptor.anisotropyEnabled ? anisotropy : 1\n };\n }\n static GetCompareFunction(compareFunction) {\n switch (compareFunction) {\n case 519:\n return \"always\" /* WebGPUConstants.CompareFunction.Always */;\n case 514:\n return \"equal\" /* WebGPUConstants.CompareFunction.Equal */;\n case 516:\n return \"greater\" /* WebGPUConstants.CompareFunction.Greater */;\n case 518:\n return \"greater-equal\" /* WebGPUConstants.CompareFunction.GreaterEqual */;\n case 513:\n return \"less\" /* WebGPUConstants.CompareFunction.Less */;\n case 515:\n return \"less-equal\" /* WebGPUConstants.CompareFunction.LessEqual */;\n case 512:\n return \"never\" /* WebGPUConstants.CompareFunction.Never */;\n case 517:\n return \"not-equal\" /* WebGPUConstants.CompareFunction.NotEqual */;\n default:\n return \"less\" /* WebGPUConstants.CompareFunction.Less */;\n }\n }\n getSampler(sampler, bypassCache = false, hash = 0, label) {\n if (this.disabled) {\n return this._device.createSampler(WebGPUCacheSampler._GetSamplerDescriptor(sampler, label));\n }\n if (bypassCache) {\n hash = 0;\n } else if (hash === 0) {\n hash = WebGPUCacheSampler.GetSamplerHashCode(sampler);\n }\n let gpuSampler = bypassCache ? undefined : this._samplers[hash];\n if (!gpuSampler) {\n gpuSampler = this._device.createSampler(WebGPUCacheSampler._GetSamplerDescriptor(sampler, label));\n if (!bypassCache) {\n this._samplers[hash] = gpuSampler;\n }\n }\n return gpuSampler;\n }\n}","map":{"version":3,"names":["filterToBits","comparisonFunctionToBits","filterNoMipToBits","WebGPUCacheSampler","constructor","device","_samplers","_device","disabled","GetSamplerHashCode","sampler","_sampler$_cachedWrapU","_sampler$_cachedWrapV","_sampler$_cachedWrapR","anisotropy","_cachedAnisotropicFilteringLevel","code","samplingMode","_comparisonFunction","_cachedWrapU","_cachedWrapV","_cachedWrapR","useMipMaps","_GetSamplerFilterDescriptor","magFilter","minFilter","mipmapFilter","lodMinClamp","lodMaxClamp","anisotropyEnabled","_GetWrappingMode","mode","_GetSamplerWrappingDescriptor","addressModeU","addressModeV","addressModeW","_GetSamplerDescriptor","label","filterDescriptor","compare","GetCompareFunction","undefined","maxAnisotropy","compareFunction","getSampler","bypassCache","hash","createSampler","gpuSampler"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/webgpuCacheSampler.js"],"sourcesContent":["\nconst filterToBits = [\n 0 | (0 << 1) | (0 << 2), // not used\n 0 | (0 << 1) | (0 << 2), // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\n 1 | (1 << 1) | (0 << 2), // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\n 1 | (1 << 1) | (1 << 2), // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\n 0 | (0 << 1) | (0 << 2), // TEXTURE_NEAREST_NEAREST_MIPNEAREST\n 0 | (1 << 1) | (0 << 2), // TEXTURE_NEAREST_LINEAR_MIPNEAREST\n 0 | (1 << 1) | (1 << 2), // TEXTURE_NEAREST_LINEAR_MIPLINEAR\n 0 | (1 << 1) | (0 << 2), // TEXTURE_NEAREST_LINEAR\n 0 | (0 << 1) | (1 << 2), // TEXTURE_NEAREST_NEAREST_MIPLINEAR\n 1 | (0 << 1) | (0 << 2), // TEXTURE_LINEAR_NEAREST_MIPNEAREST\n 1 | (0 << 1) | (1 << 2), // TEXTURE_LINEAR_NEAREST_MIPLINEAR\n 1 | (1 << 1) | (0 << 2), // TEXTURE_LINEAR_LINEAR_MIPNEAREST\n 1 | (0 << 1) | (0 << 2), // TEXTURE_LINEAR_NEAREST\n];\n// subtract 0x01FF from the comparison function value before indexing this array!\nconst comparisonFunctionToBits = [\n (0 << 3) | (0 << 4) | (0 << 5) | (0 << 6), // undefined\n (0 << 3) | (0 << 4) | (0 << 5) | (1 << 6), // NEVER\n (0 << 3) | (0 << 4) | (1 << 5) | (0 << 6), // LESS\n (0 << 3) | (0 << 4) | (1 << 5) | (1 << 6), // EQUAL\n (0 << 3) | (1 << 4) | (0 << 5) | (0 << 6), // LEQUAL\n (0 << 3) | (1 << 4) | (0 << 5) | (1 << 6), // GREATER\n (0 << 3) | (1 << 4) | (1 << 5) | (0 << 6), // NOTEQUAL\n (0 << 3) | (1 << 4) | (1 << 5) | (1 << 6), // GEQUAL\n (1 << 3) | (0 << 4) | (0 << 5) | (0 << 6), // ALWAYS\n];\nconst filterNoMipToBits = [\n 0 << 7, // not used\n 1 << 7, // TEXTURE_NEAREST_SAMPLINGMODE / TEXTURE_NEAREST_NEAREST\n 1 << 7, // TEXTURE_BILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR\n 0 << 7, // TEXTURE_TRILINEAR_SAMPLINGMODE / TEXTURE_LINEAR_LINEAR_MIPLINEAR\n 0 << 7, // TEXTURE_NEAREST_NEAREST_MIPNEAREST\n 0 << 7, // TEXTURE_NEAREST_LINEAR_MIPNEAREST\n 0 << 7, // TEXTURE_NEAREST_LINEAR_MIPLINEAR\n 1 << 7, // TEXTURE_NEAREST_LINEAR\n 0 << 7, // TEXTURE_NEAREST_NEAREST_MIPLINEAR\n 0 << 7, // TEXTURE_LINEAR_NEAREST_MIPNEAREST\n 0 << 7, // TEXTURE_LINEAR_NEAREST_MIPLINEAR\n 0 << 7, // TEXTURE_LINEAR_LINEAR_MIPNEAREST\n 1 << 7, // TEXTURE_LINEAR_NEAREST\n];\n/** @internal */\nexport class WebGPUCacheSampler {\n constructor(device) {\n this._samplers = {};\n this._device = device;\n this.disabled = false;\n }\n static GetSamplerHashCode(sampler) {\n // The WebGPU spec currently only allows values 1 and 4 for anisotropy\n const anisotropy = sampler._cachedAnisotropicFilteringLevel ? sampler._cachedAnisotropicFilteringLevel : 1;\n const code = filterToBits[sampler.samplingMode] +\n comparisonFunctionToBits[(sampler._comparisonFunction || 0x0202) - 0x0200 + 1] +\n filterNoMipToBits[sampler.samplingMode] + // handle the lodMinClamp = lodMaxClamp = 0 case when no filter used for mip mapping\n ((sampler._cachedWrapU ?? 1) << 8) +\n ((sampler._cachedWrapV ?? 1) << 10) +\n ((sampler._cachedWrapR ?? 1) << 12) +\n ((sampler.useMipMaps ? 1 : 0) << 14) + // need to factor this in because _getSamplerFilterDescriptor depends on samplingMode AND useMipMaps!\n (anisotropy << 15);\n return code;\n }\n static _GetSamplerFilterDescriptor(sampler, anisotropy) {\n let magFilter, minFilter, mipmapFilter, lodMinClamp, lodMaxClamp;\n const useMipMaps = sampler.useMipMaps;\n switch (sampler.samplingMode) {\n case 11:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 3:\n case 3:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n }\n else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 8:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n }\n else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 4:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 5:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 6:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n }\n else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 7:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 1:\n case 1:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 9:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n lodMinClamp = lodMaxClamp = 0;\n }\n break;\n case 10:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n if (!useMipMaps) {\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n }\n else {\n mipmapFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n }\n break;\n case 2:\n case 2:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n case 12:\n magFilter = \"linear\" /* WebGPUConstants.FilterMode.Linear */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n default:\n magFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n minFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n mipmapFilter = \"nearest\" /* WebGPUConstants.FilterMode.Nearest */;\n lodMinClamp = lodMaxClamp = 0;\n break;\n }\n if (anisotropy > 1 && (lodMinClamp !== 0 || lodMaxClamp !== 0) && mipmapFilter !== \"nearest\" /* WebGPUConstants.FilterMode.Nearest */) {\n return {\n magFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n minFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n mipmapFilter: \"linear\" /* WebGPUConstants.FilterMode.Linear */,\n anisotropyEnabled: true,\n };\n }\n return {\n magFilter,\n minFilter,\n mipmapFilter,\n lodMinClamp,\n lodMaxClamp,\n };\n }\n static _GetWrappingMode(mode) {\n switch (mode) {\n case 1:\n return \"repeat\" /* WebGPUConstants.AddressMode.Repeat */;\n case 0:\n return \"clamp-to-edge\" /* WebGPUConstants.AddressMode.ClampToEdge */;\n case 2:\n return \"mirror-repeat\" /* WebGPUConstants.AddressMode.MirrorRepeat */;\n }\n return \"repeat\" /* WebGPUConstants.AddressMode.Repeat */;\n }\n static _GetSamplerWrappingDescriptor(sampler) {\n return {\n addressModeU: this._GetWrappingMode(sampler._cachedWrapU),\n addressModeV: this._GetWrappingMode(sampler._cachedWrapV),\n addressModeW: this._GetWrappingMode(sampler._cachedWrapR),\n };\n }\n static _GetSamplerDescriptor(sampler, label) {\n const anisotropy = sampler.useMipMaps && sampler._cachedAnisotropicFilteringLevel ? sampler._cachedAnisotropicFilteringLevel : 1;\n const filterDescriptor = this._GetSamplerFilterDescriptor(sampler, anisotropy);\n return {\n label,\n ...filterDescriptor,\n ...this._GetSamplerWrappingDescriptor(sampler),\n compare: sampler._comparisonFunction ? WebGPUCacheSampler.GetCompareFunction(sampler._comparisonFunction) : undefined,\n maxAnisotropy: filterDescriptor.anisotropyEnabled ? anisotropy : 1,\n };\n }\n static GetCompareFunction(compareFunction) {\n switch (compareFunction) {\n case 519:\n return \"always\" /* WebGPUConstants.CompareFunction.Always */;\n case 514:\n return \"equal\" /* WebGPUConstants.CompareFunction.Equal */;\n case 516:\n return \"greater\" /* WebGPUConstants.CompareFunction.Greater */;\n case 518:\n return \"greater-equal\" /* WebGPUConstants.CompareFunction.GreaterEqual */;\n case 513:\n return \"less\" /* WebGPUConstants.CompareFunction.Less */;\n case 515:\n return \"less-equal\" /* WebGPUConstants.CompareFunction.LessEqual */;\n case 512:\n return \"never\" /* WebGPUConstants.CompareFunction.Never */;\n case 517:\n return \"not-equal\" /* WebGPUConstants.CompareFunction.NotEqual */;\n default:\n return \"less\" /* WebGPUConstants.CompareFunction.Less */;\n }\n }\n getSampler(sampler, bypassCache = false, hash = 0, label) {\n if (this.disabled) {\n return this._device.createSampler(WebGPUCacheSampler._GetSamplerDescriptor(sampler, label));\n }\n if (bypassCache) {\n hash = 0;\n }\n else if (hash === 0) {\n hash = WebGPUCacheSampler.GetSamplerHashCode(sampler);\n }\n let gpuSampler = bypassCache ? undefined : this._samplers[hash];\n if (!gpuSampler) {\n gpuSampler = this._device.createSampler(WebGPUCacheSampler._GetSamplerDescriptor(sampler, label));\n if (!bypassCache) {\n this._samplers[hash] = gpuSampler;\n }\n }\n return gpuSampler;\n }\n}\n"],"mappings":"AACA,MAAMA,YAAY,GAAG,CACjB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE;AAAE;AACzB,CAAC,GAAI,CAAC,IAAI,CAAE,GAAI,CAAC,IAAI,CAAE,CAAE;AAAA,CAC5B;AACD;AACA,MAAMC,wBAAwB,GAAG,CAC5B,CAAC,IAAI,C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