UNPKG

2.2 kBSource Map (JSON)View Raw
1{"version":3,"file":"setPrecision.js","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":["PRECISION"],"mappings":";;;;;;AAW6B,SAAA,YAAA,CAAA,GAAA,EAAa,oBAA+B,qBACzE,EAAA;AACI,EAAA,IAAI,GAAI,CAAA,SAAA,CAAU,CAAG,EAAA,CAAC,MAAM,WAC5B,EAAA;AAEI,IAAA,IAAI,SAAY,GAAA,kBAAA,CAAA;AAGhB,IAAA,IAAI,kBAAuB,KAAAA,mBAAA,CAAU,IAAQ,IAAA,qBAAA,KAA0BA,oBAAU,IACjF,EAAA;AACI,MAAA,SAAA,GAAYA,mBAAU,CAAA,MAAA,CAAA;AAAA,KAC1B;AAEA,IAAA,OAAO,CAAa,UAAA,EAAA,SAAA,CAAA;AAAA,EAAqB,GAAA,CAAA,CAAA,CAAA;AAAA,GAC7C,MAAA,IACS,0BAA0BA,mBAAU,CAAA,IAAA,IAAQ,IAAI,SAAU,CAAA,CAAA,EAAG,EAAE,CAAA,KAAM,iBAC9E,EAAA;AAEI,IAAO,OAAA,GAAA,CAAI,OAAQ,CAAA,iBAAA,EAAmB,mBAAmB,CAAA,CAAA;AAAA,GAC7D;AAEA,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}
\No newline at end of file