Skip to content

Commit 45f1d13

Browse files
committed
fixup-smoothstep
1 parent 9e8b7ad commit 45f1d13

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/engine/renderer/GLUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ struct GLConfig
130130
bool textureGatherAvailable;
131131
bool texture3DAvailable;
132132
bool mat3x2Available;
133-
bool assumeSmoothstep;
134133
bool incrementalShaderCompilation;
135134
int maxDrawBuffers;
136135

src/engine/renderer/gl_shader.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,16 @@ R"(#if !defined(GENERATED_COMPAT_HEADER)
544544
)";
545545

546546
// definition of functions missing in early GLSL
547-
if( glConfig.shadingLanguageVersion <= 120 && !glConfig.assumeSmoothstep ) {
548-
str += "float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); }\n";
549-
}
547+
str +=
548+
R"(#if __VERSION__ <= 120
549+
float mySmoothstep(float edge0, float edge1, float x)
550+
{
551+
float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
552+
return t * t * (3.0 - 2.0 * t);
553+
}
554+
#define smoothstep mySmoothstep
555+
#endif
556+
)";
550557

551558
if ( !glConfig.gpuShader5Available && glConfig.gpuShader4Available )
552559
{

src/engine/sys/sdl_glimp.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ static Cvar::Cvar<bool> workaround_glDriver_amd_oglp_disableBindlessTexture(
151151
"workaround.glDriver.amd.oglp.disableBindlessTexture",
152152
"Disable ARB_bindless_texture on AMD OGLP driver",
153153
Cvar::NONE, true );
154-
static Cvar::Cvar<bool> workaround_glDriver_gl4es_assumeSmoothstep(
155-
"workaround.glDriver.gl4es.assumeSmoothstep",
156-
"Assume smoothstep is always declared on GL4ES",
157-
Cvar::NONE, true );
158154
static Cvar::Cvar<bool> workaround_glDriver_gl4es_disableIncrementalShaderCompilation(
159155
"workaround.glDriver.gl4es.disableIncrementalShaderCompilation",
160156
"Disable incremental shader compilation on GL4ES",
@@ -2117,13 +2113,6 @@ static void GLimp_InitExtensions()
21172113

21182114
if ( glConfig.driverVendor == glDriverVendor_t::GL4ES )
21192115
{
2120-
if ( glConfig.shadingLanguageVersion <= 120
2121-
&& workaround_glDriver_gl4es_assumeSmoothstep.Get() )
2122-
{
2123-
logger.Notice( "Found GLSL 1.20 on GL4ES translation layer, assuming smoothstep() is always declared." );
2124-
glConfig.assumeSmoothstep = true;
2125-
}
2126-
21272116
if ( glConfig.incrementalShaderCompilation
21282117
&& workaround_glDriver_gl4es_disableIncrementalShaderCompilation.Get() )
21292118
{
@@ -2985,7 +2974,6 @@ bool GLimp_Init()
29852974

29862975
Cvar::Latch( workaround_glDriver_amd_adrenalin_disableBindlessTexture );
29872976
Cvar::Latch( workaround_glDriver_amd_oglp_disableBindlessTexture );
2988-
Cvar::Latch( workaround_glDriver_gl4es_assumeSmoothstep );
29892977
Cvar::Latch( workaround_glDriver_gl4es_disableIncrementalShaderCompilation );
29902978
Cvar::Latch( workaround_glDriver_gl4es_disableMat3x2 );
29912979
Cvar::Latch( workaround_glDriver_gl4es_disableTexture3D );

0 commit comments

Comments
 (0)