@luma.gl/shadertools
Version:
Shader module system for luma.gl
59 lines (52 loc) • 2.02 kB
text/typescript
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import {PlatformInfo} from './platform-info';
/** Adds defines to help identify GPU architecture / platform */
export function getPlatformShaderDefines(platformInfo: PlatformInfo): string {
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
`;
}
}