{"version":3,"file":"maxRecommendedTextures.mjs","sources":["../../../../../src/rendering/batcher/gl/utils/maxRecommendedTextures.ts"],"sourcesContent":["import { getTestContext } from '../../../renderers/gl/shader/program/getTestContext';\nimport { checkMaxIfStatementsInShader } from './checkMaxIfStatementsInShader';\n\nlet maxTexturesPerBatchCache: number | null = null;\n\n/**\n * Returns the maximum number of textures that can be batched. This uses WebGL1's `MAX_TEXTURE_IMAGE_UNITS`.\n * The response for this is that to get this info via WebGPU, we would need to make a context, which\n * would make this function async, and we want to avoid that.\n * @private\n * @returns {number} The maximum number of textures that can be batched\n */\nexport function getMaxTexturesPerBatch(): number\n{\n if (maxTexturesPerBatchCache) return maxTexturesPerBatchCache;\n\n const gl = getTestContext();\n\n // step 1: first check max textures the GPU can handle.\n maxTexturesPerBatchCache = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);\n\n // step 2: check the maximum number of if statements the shader can have too..\n maxTexturesPerBatchCache = checkMaxIfStatementsInShader(\n maxTexturesPerBatchCache, gl);\n\n gl.getExtension('WEBGL_lose_context')?.loseContext();\n\n return maxTexturesPerBatchCache;\n}\n"],"names":[],"mappings":";;;;AAGA,IAAI,wBAA0C,GAAA,IAAA,CAAA;AASvC,SAAS,sBAChB,GAAA;AACI,EAAI,IAAA,wBAAA;AAA0B,IAAO,OAAA,wBAAA,CAAA;AAErC,EAAA,MAAM,KAAK,cAAe,EAAA,CAAA;AAG1B,EAA2B,wBAAA,GAAA,EAAA,CAAG,YAAa,CAAA,EAAA,CAAG,uBAAuB,CAAA,CAAA;AAGrE,EAA2B,wBAAA,GAAA,4BAAA;AAAA,IACvB,wBAAA;AAAA,IAA0B,EAAA;AAAA,GAAE,CAAA;AAEhC,EAAG,EAAA,CAAA,YAAA,CAAa,oBAAoB,CAAA,EAAG,WAAY,EAAA,CAAA;AAEnD,EAAO,OAAA,wBAAA,CAAA;AACX;;;;"}