Nvidia OpenGL compiler bug (-k * log2(r)); bugged

If on Windows - run webbrowser in OpenGL mode:

chrome.exe --use-angle=gl

in Nvidia-OpenGL this will be red - and different numbers

EXPECTED - both sides same and -511

Minimal shader code in shadertoy format:

#define BUG
float smoothMinEx(float a, float b, float k){
    k *= 1.0;
    float r = exp2(-a / k) + exp2(-b / k);
#ifdef BUG
    return (-k * log2(r));
#else
    return -1.*(k * log2(r));
#endif
}

void mainImage(out vec4 O,  vec2 U){
    U /= iResolution.xy;
    O = 100.*vec4( smoothMinEx(0.1,smoothMinEx( U.x, U.y, .1),0.4*0.25) );
}

Confirmed by many ppl with different drivers (Linux drivers version 560-580 range)

I tested in Linux on Nvidia drivers 575 - bug present.

even simpler code:

void mainImage(out vec4 O,  vec2 U )
{
    float k = .1, v,
          r = U.x / iResolution.x; // range [0..1] horizontally
    
#if 0
    v = (-k) * r ;   // bug
#else
    v = -(k*r);
#endif    

    O = vec4(-v/k); 
 // O = -O;
}

This shader compiles to the right result just fine on Pascal, try using the -highp specifier to circumvent compiler optimizations

you on Windows or Linux

if on Windows - which browser? you used OpenGL mode?

shader bug confirmed by many ppl with RTX gpus 20XX-40XX

I also tested on RTX

it would seem OpenGL is only supplied via Direct3D11 vs_5_0 ps_5_0 on Windows builds of Chrome and Edge for the past 12 months due to unfixed issues.

click Win+R

paste

chrome.exe --use-angle=gl

it should use OpenGL in Chrome