Skip to content

Commit

Permalink
Remove getVersionDefines
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer committed Mar 7, 2024
1 parent e68c99c commit 73cba9c
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 79 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {glsl} from '../glsl-utils/highlight';
import {resolveModules} from './resolve-modules';
import {PlatformInfo} from './platform-info';
import {getPlatformShaderDefines, getVersionDefines} from './platform-defines';
import {getPlatformShaderDefines} from './platform-defines';
import {injectShader, DECLARATION_INJECT_MARKER} from './shader-injections';
import {transpileGLSLShader} from '../shader-transpiler/transpile-glsl-shader';
import {ShaderModuleInstance} from '../shader-module/shader-module-instance';
Expand Down Expand Up @@ -196,7 +196,6 @@ export function assembleWGSLShader(platformInfo: PlatformInfo, options: Assemble
// ${getShaderNameDefine({id, source, type})}
// ${getShaderType(type)}
// ${getPlatformShaderDefines(platformInfo)}
// ${getVersionDefines(platformInfo)}
// ${getApplicationDefines(allDefines)}
// ${isVertex ? '' : FRAGMENT_SHADER_PROLOGUE}
// `
Expand Down Expand Up @@ -342,7 +341,6 @@ ${sourceVersionDirective}
${getShaderNameDefine({id, source, stage})}
${`#define SHADER_TYPE_${stage.toUpperCase()}`}
${getPlatformShaderDefines(platformInfo)}
${getVersionDefines(platformInfo)}
${stage === 'fragment' ? FRAGMENT_SHADER_PROLOGUE : ''}
// ----- APPLICATION DEFINES -------------------------
Expand Down
60 changes: 0 additions & 60 deletions modules/shadertools/src/lib/shader-assembly/platform-defines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,63 +57,3 @@ export function getPlatformShaderDefines(platformInfo: PlatformInfo): string {
`;
}
}

/** Adds defines to let shaders portably v1/v3 check for features */
export function getVersionDefines(platformInfo: PlatformInfo): string {
let versionDefines = '';

if (platformInfo.features.has('webgl2')) {
versionDefines += glsl`\
# define FEATURE_GLSL_DERIVATIVES
# define FEATURE_GLSL_DRAW_BUFFERS
# define FEATURE_GLSL_FRAG_DEPTH
# define FEATURE_GLSL_TEXTURE_LOD
`;
}

if (!platformInfo.features.has('webgl2')) {
if (platformInfo.features.has('glsl-frag-depth')) {
versionDefines += glsl`\
// FEATURE_GLSL_FRAG_DEPTH => gl_FragDepth is available
#ifdef GL_EXT_frag_depth
# extension GL_EXT_frag_depth : enable
# define FEATURE_GLSL_FRAG_DEPTH
# define FRAG_DEPTH
# define gl_FragDepth gl_FragDepthEXT
#endif
`;
}
if (platformInfo?.features.has('glsl-derivatives')) {
versionDefines += glsl`\
// FEATURE_GLSL_DERIVATIVES => dxdF, dxdY and fwidth are available
#if defined(GL_OES_standard_derivatives) || defined(FEATURE_GLSL_DERIVATIVES)
# extension GL_OES_standard_derivatives : enable
# define FEATURE_GLSL_DERIVATIVES
#endif
`;
}
if (platformInfo?.features.has('glsl-frag-data')) {
versionDefines += glsl`\
// FEATURE_GLSL_DRAW_BUFFERS => gl_FragData[] is available
#ifdef GL_EXT_draw_buffers
# extension GL_EXT_draw_buffers : require
# define FEATURE_GLSL_DRAW_BUFFERS
#endif
`;
}
if (platformInfo?.features.has('glsl-texture-lod')) {
versionDefines += glsl`\
// TEXTURE_LOD => texture2DLod etc are available
#ifdef GL_EXT_shader_texture_lod
# extension GL_EXT_shader_texture_lod : enable
# define FEATURE_GLSL_TEXTURE_LOD
# define TEXTURE_LOD
#endif
`;
}
}
return versionDefines;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
import {glsl} from '../../../lib/glsl-utils/highlight';

export const fs = glsl`\
#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
# error PBR fragment shader: Texture LOD is not available
#endif
#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)
# error PBR fragment shader: Derivatives are not available
#endif
precision highp float;
uniform bool pbr_uUnlit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
import {glsl} from '../../../lib/glsl-utils/highlight';

export const fs = glsl`\
#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
# error PBR fragment shader: Texture LOD is not available
#endif
#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)
# error PBR fragment shader: Derivatives are not available
#endif
precision highp float;
uniform Projection {
Expand Down

0 comments on commit 73cba9c

Please sign in to comment.