UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

1 lines 2.64 kB
{"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":";AAsBO,SAAS,eAAA,CACZ,GAAA,EACA,OAAA,EACA,UAAA,EAEJ;AACI,EAAA,MAAM,qBAAA,GAAwB,UAAA,GAAa,OAAA,CAAQ,6BAAA,GAAgC,OAAA,CAAQ,2BAAA;AAE3F,EAAA,IAAI,GAAA,CAAI,SAAA,CAAU,CAAA,EAAG,CAAC,MAAM,WAAA,EAC5B;AAEI,IAAA,IAAI,SAAA,GAAY,UAAA,GAAa,OAAA,CAAQ,0BAAA,GAA6B,OAAA,CAAQ,wBAAA;AAG1E,IAAA,IAAI,SAAA,KAAc,OAAA,IAAW,qBAAA,KAA0B,OAAA,EACvD;AACI,MAAA,SAAA,GAAY,SAAA;AAAA,IAChB;AAEA,IAAA,OAAO,aAAa,SAAS,CAAA;AAAA,EAAY,GAAG,CAAA,CAAA;AAAA,EAChD,CAAA,MAAA,IACS,0BAA0B,OAAA,IAAW,GAAA,CAAI,UAAU,CAAA,EAAG,EAAE,MAAM,iBAAA,EACvE;AAEI,IAAA,OAAO,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,mBAAmB,CAAA;AAAA,EAC7D;AAEA,EAAA,OAAO,GAAA;AACX;;;;"}