Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Almost all Vulkan shaders are broken on NVIDIA graphics cards (except Turing GPUs) #40133

Closed
danilw opened this issue Jul 5, 2020 · 3 comments

Comments

@danilw
Copy link

danilw commented Jul 5, 2020

I make this bugreport just to make you know, about status of Vulkan drivers in Nvidia
this original bugreport to Khronos forum link
Bug confirmed on Nvidia 7XX, 9XX, 1XXX cards

Godot version:
Godot 4.0

OS/device including version:
Linux and Windows, Nvidia Only

Issue description:
the bug works on Linux and Windows, all drivers start from 2019(I did not test older)
imgur video link, how bug look like in Godot 4.0
Correct shader result this shader shadertoy link (fixed, link work now)

Bug is - just launch this shader, or any shader that uses fract(or mod) and floor
Godot 4.0 result:
1

Steps to reproduce:
shader code:

shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,unshaded;


void vertex() {
    
}

vec4 mainImage( in vec2 fragCoord , vec2 iResolution)
{
    vec2 st = fragCoord.xy/iResolution.xy;
    float ratio = iResolution.x/iResolution.y;
    st.x *= ratio;
    float time = 1.+max(0.,min(0.,st.x));
    vec3 color = vec3(0.0);
    float rows = 30.0;
    vec2 ipos = floor(st*rows);
    vec2 fpos = fract(st*rows);

    float pct = 1.0;
    vec2 v=mod(fpos,vec2(9.));
    pct *=v.x*v.y;

    //BUG

    if ((ipos.y > 0.0)||(ipos.x < fract(time))) {
        color = vec3(pct);
    }


    //FIX
/*
    if (ipos.y > 0.0) {
        color = vec3(pct);
    }
    if (ipos.x < fract(time)) {
        color = vec3(pct);
    }
*/
    return vec4(1.-color , 1.0);
}

void fragment() {
    
    vec4 c=vec4(0.);
    c=mainImage(UV*512., vec2(512.));
    ALBEDO = c.rgb;
}


This shader works fine in OpenGL on the same hardware. (in Godot3 or webbrowser)

Minimal reproduction project:
Godot 4.0 project with this shader
shader_test.zip

@danilw danilw changed the title almost all Vulkan shaders currently broken on all Nvidia cards except 2XXX series almost all Vulkan shaders currently are broken on all Nvidia cards except 2XXX series Jul 5, 2020
@Calinou Calinou changed the title almost all Vulkan shaders currently are broken on all Nvidia cards except 2XXX series Almost all Vulkan shaders are broken on NVIDIA graphics cards (except Turing GPUs) Jul 5, 2020
@Chaosus Chaosus added this to the 4.0 milestone Jul 5, 2020
@Anutrix
Copy link
Contributor

Anutrix commented Jul 8, 2020

Does the fix solve the issue?
If yes, then the issue is with logical operator ||?

@danilw
Copy link
Author

danilw commented Jul 8, 2020

Does the fix solve the issue?

fix solve only this shader

If yes, then the issue is with logical operator ||?

I have found this bug when sorting lots(hundreds) my shaders, and like "lots" of them got noise or other similar sort of bugs
all "snow-like shaders" that generate noise layers(from texture or shader random) broken, and lots of other shaders broken
I can list(show source) some of the bugged shaders, that have a real use, if you want

I did not dig too much to see "source of bug"(I do not want to spend weeks on that doing free job(I have enough of debugging, it cost way too much time for me, im not a free beta tester for corporations))
even if its only "or" operator bug... this is just impossible rewrite all shaders removing all or operator when even simple shaders use 10-20 if operators with or

also, this bug triggered only when all variables "local", if you make any variable as varying(even final color), original time is push-const and push-const is count as local, but if send this time as varying or uniform bug gone

change fract to vec2(ivec2(<VAL>*1000.)%1000)/1000.; also fix bug
change float time to:

varying float timex;
void vertex() {
    timex=1.+max(0.,min(0.,UV.x));
}

and time=timex; in mainImage also fix bug

or change structure of this logic(with the same result) - bug gone... so it can be variables or floor/mod/fract operator bug(removing those operators or rewriting them also fix bug)

so for me this bug is global and ruin lots of my own shaders, randomly, fixing this bug "by hands" I do not see realistic

I have post bugreport to Nvidia forum and Khronos forum, I do not know if they gonna fix it

@danilw
Copy link
Author

danilw commented Oct 20, 2020

fixed in 456.71 Windows driver version

@danilw danilw closed this as completed Oct 20, 2020
@clayjohn clayjohn added archived and removed bug labels Oct 20, 2020
@clayjohn clayjohn removed this from the 4.0 milestone Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants