Skip to content

Commit 57453a8

Browse files
committed
wip: rewrite unpackUnorm4x8 with explicit typing
1 parent 13886d8 commit 57453a8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/engine/renderer/gl_shader.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,6 @@ static std::string GenCompatHeader() {
529529
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";
530530
}
531531

532-
if ( !glConfig2.gpuShader5Available ) {
533-
str += "#define unpackUnorm4x8( value ) ( ( vec4( value, value >> 8, value >> 16, value >> 24 ) & 0xFF ) / 255.0f )\n";
534-
}
535-
536532
/* Driver bug: Adrenaline/OGLP drivers fail to recognise the ARB function versions when they return a 4.6 context
537533
and the shaders get #version 460 core, so add #define's for them here */
538534
if ( glConfig2.driverVendor == glDriverVendor_t::ATI && glConfig2.shaderAtomicCounterOpsAvailable ) {

src/engine/renderer/glsl_source/common.glsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ array must be in the form of uvec4 array[] */
4545

4646
// Common functions
4747

48+
#if !defined(HAVE_ARB_gpu_shader5) && defined(HAVE_EXT_gpu_shader4)
49+
vec4 unpackUnorm4x8( uint value )
50+
{
51+
uint x = value & 255u;
52+
uint y = ( value >> 8u ) & 255u;
53+
uint z = ( value >> 16u ) & 255u;
54+
uint w = ( value >> 24u ) & 255u;
55+
56+
return vec4( x, y, z, w ) / 255.0f;
57+
}
58+
#endif
59+
4860
#if defined(HAVE_EXT_gpu_shader4)
4961
#define colorPack uint
5062
#define colorModulatePack uint

0 commit comments

Comments
 (0)