{"version":3,"file":"setPrecision.mjs","sources":["../../../src/shader/utils/setPrecision.ts"],"sourcesContent":["import { PRECISION } from '@pixi/constants';\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 * @private\n * @param {string} src - The shader source\n * @param {PIXI.PRECISION} requestedPrecision - The request float precision of the shader.\n * @param {PIXI.PRECISION} maxSupportedPrecision - The maximum precision the shader supports.\n * @returns {string} modified shader source\n */\nexport function setPrecision(src: string, requestedPrecision: PRECISION, maxSupportedPrecision: PRECISION): string\n{\n    if (src.substring(0, 9) !== 'precision')\n    {\n        // no precision supplied, so PixiJS will add the requested level.\n        let precision = requestedPrecision;\n\n        // If highp is requested but not supported, downgrade precision to a level all devices support.\n        if (requestedPrecision === PRECISION.HIGH && maxSupportedPrecision !== PRECISION.HIGH)\n        {\n            precision = PRECISION.MEDIUM;\n        }\n\n        return `precision ${precision} float;\\n${src}`;\n    }\n    else if (maxSupportedPrecision !== PRECISION.HIGH && 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":";AAWgB,SAAA,aAAa,KAAa,oBAA+B,uBACzE;AACI,MAAI,IAAI,UAAU,GAAG,CAAC,MAAM,aAC5B;AAEI,QAAI,YAAY;AAGZ,WAAA,uBAAuB,UAAU,QAAQ,0BAA0B,UAAU,SAE7E,YAAY,UAAU,SAGnB,aAAa,SAAS;AAAA,EAAY,GAAG;AAAA,EAAA,WAEvC,0BAA0B,UAAU,QAAQ,IAAI,UAAU,GAAG,EAAE,MAAM;AAGnE,WAAA,IAAI,QAAQ,mBAAmB,mBAAmB;AAGtD,SAAA;AACX;"}