{"version":3,"file":"ensurePrecision.mjs","sources":["../../../../../../../src/rendering/renderers/gl/shader/program/preprocessors/ensurePrecision.ts"],"sourcesContent":["import type { PRECISION } from '../../const';\n\ninterface EnsurePrecisionOptions\n{\n    requestedVertexPrecision: PRECISION;\n    requestedFragmentPrecision: PRECISION;\n    maxSupportedVertexPrecision: PRECISION;\n    maxSupportedFragmentPrecision: PRECISION;\n}\n\n/**\n * Sets the float precision on the shader, ensuring the device supports the request precision.\n * If the precision is already present, it just ensures that the device is able to handle it.\n * @param src\n * @param options\n * @param options.requestedVertexPrecision\n * @param options.requestedFragmentPrecision\n * @param options.maxSupportedVertexPrecision\n * @param options.maxSupportedFragmentPrecision\n * @param isFragment\n * @private\n */\nexport function ensurePrecision(\n    src: string,\n    options: EnsurePrecisionOptions,\n    isFragment: boolean,\n): string\n{\n    const maxSupportedPrecision = isFragment ? options.maxSupportedFragmentPrecision : options.maxSupportedVertexPrecision;\n\n    if (src.substring(0, 9) !== 'precision')\n    {\n        // no precision supplied, so PixiJS will add the requested level.\n        let precision = isFragment ? options.requestedFragmentPrecision : options.requestedVertexPrecision;\n\n        // If highp is requested but not supported, downgrade precision to a level all devices support.\n        if (precision === 'highp' && maxSupportedPrecision !== 'highp')\n        {\n            precision = 'mediump';\n        }\n\n        return `precision ${precision} float;\\n${src}`;\n    }\n    else if (maxSupportedPrecision !== 'highp' && src.substring(0, 15) === 'precision highp')\n    {\n        // precision was supplied, but at a level this device does not support, so downgrading to mediump.\n        return src.replace('precision highp', 'precision mediump');\n    }\n\n    return src;\n}\n"],"names":[],"mappings":";AAsBgB,SAAA,eAAA,CACZ,GACA,EAAA,OAAA,EACA,UAEJ,EAAA;AACI,EAAA,MAAM,qBAAwB,GAAA,UAAA,GAAa,OAAQ,CAAA,6BAAA,GAAgC,OAAQ,CAAA,2BAAA,CAAA;AAE3F,EAAA,IAAI,GAAI,CAAA,SAAA,CAAU,CAAG,EAAA,CAAC,MAAM,WAC5B,EAAA;AAEI,IAAA,IAAI,SAAY,GAAA,UAAA,GAAa,OAAQ,CAAA,0BAAA,GAA6B,OAAQ,CAAA,wBAAA,CAAA;AAG1E,IAAI,IAAA,SAAA,KAAc,OAAW,IAAA,qBAAA,KAA0B,OACvD,EAAA;AACI,MAAY,SAAA,GAAA,SAAA,CAAA;AAAA,KAChB;AAEA,IAAA,OAAO,aAAa,SAAS,CAAA;AAAA,EAAY,GAAG,CAAA,CAAA,CAAA;AAAA,GAChD,MAAA,IACS,0BAA0B,OAAW,IAAA,GAAA,CAAI,UAAU,CAAG,EAAA,EAAE,MAAM,iBACvE,EAAA;AAEI,IAAO,OAAA,GAAA,CAAI,OAAQ,CAAA,iBAAA,EAAmB,mBAAmB,CAAA,CAAA;AAAA,GAC7D;AAEA,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}