Created
September 22, 2020 06:26
-
-
Save shrinktofit/d49a258e1ae4c76be9d45255ea111d30 to your computer and use it in GitHub Desktop.
[WebGL] Print shader numeric type precisions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shaderTypes: [number, string][] = [ | |
[gl.VERTEX_SHADER, 'Vertex shader'], | |
[gl.FRAGMENT_SHADER, 'Fragment shader'], | |
]; | |
const precisionTypes: [number, string][] = [ | |
[gl.HIGH_FLOAT, 'High float'], | |
[gl.MEDIUM_FLOAT, 'Medium float'], | |
[gl.LOW_FLOAT, 'Low float'], | |
[gl.HIGH_INT, 'High int'], | |
[gl.MEDIUM_INT, 'Medium int'], | |
[gl.LOW_INT, 'Low int'], | |
]; | |
for (const [shaderType, shaderTypeName] of shaderTypes) { | |
console.info(`${shaderTypeName} precisions:`); | |
for (const [precisionType, precisionTypeName] of precisionTypes) { | |
const precisionFormat = gl.getShaderPrecisionFormat(shaderType, precisionType); | |
if (precisionFormat) { | |
const { rangeMin, rangeMax, precision } = precisionFormat; | |
console.info( | |
`${precisionTypeName}: [-2^${rangeMin}, 2^${rangeMax}]` + | |
(precision ? `, 2^${-precision}` : '') | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment