@luma.gl/shadertools
Version:
Shader module system for luma.gl
52 lines • 2.07 kB
JavaScript
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
/** Adds defines to help identify GPU architecture / platform */
export function getPlatformShaderDefines(platformInfo) {
switch (platformInfo?.gpu.toLowerCase()) {
case 'apple':
return /* glsl */ `\
// Apple optimizes away the calculation necessary for emulated fp64
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
`;
case 'nvidia':
return /* glsl */ `\
// Nvidia optimizes away the calculation necessary for emulated fp64
`;
case 'intel':
return /* glsl */ `\
// Intel optimizes away the calculation necessary for emulated fp64
// Intel's built-in 'tan' function doesn't have acceptable precision
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
`;
case 'amd':
// AMD Does not eliminate fp64 code
return /* glsl */ `\
`;
default:
// We don't know what GPU it is, could be that the GPU driver or
// browser is not implementing UNMASKED_RENDERER constant and not
// reporting a correct name
return /* glsl */ `\
// Prevent driver from optimizing away the calculation necessary for emulated fp64
// Headless Chrome's software shader 'tan' function doesn't have acceptable precision
// If the GPU doesn't have full 32 bits precision, will causes overflow
`;
}
}
//# sourceMappingURL=platform-defines.js.map