/GPU-my-list-of-bugs

Vulkan and other GPU API bugs I found.

MIT LicenseMIT

GPU-my-list-of-bugs

what is it - list of bugs I found writing shaders, mostly shader bugs.


Some information related to GPU-stuff can be found it my blog:


Debug:

To test this bugs in Vulkan:

Just launch webbrowser in Vulkan mode:

chrome.exe --use-angle=vulkan --enable-features=Vulkan,DefaultANGLEVulkan,VulkanFromANGLE --incognito

To test in OpenGL:

On Windows Linux - just launch Webbroser in OpenGL mode chrome.exe --use-angle=gl --incognito

For linux /usr/bin/google-chrome-stable with same parameters.

To test shaders result in CPU-shader emulation:

Use swiftshader (works on every platform but this is not best option)

chrome.exe --use-gl=swiftshader-webgl --incognito

Many of listed shaders will crash swiftshader or have completely wrong result because bugs in swiftshader.

Use OpenGL Mesa LLVM (llvmpipe) OpenGL emulation (best option)

Xephyr -br -ac -noreset -screen 1280x720 :10&

And launch firefox there DISPLAY=:10 XDG_SESSION_TYPE=x11 firefox

It will render WebGL on CPU llvmpipe driver. (do not launch chrome this way, chrome will use swiftshader instead of llvmpipe). To see that llvmpipe used - DISPLAY=:10 glxinfo | grep OpenGL | grep string

Other way is try to use - LIBGL_ALWAYS_SOFTWARE=1 __GLX_VENDOR_LIBRARY_NAME=mesa VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.i686.json:/usr/share/vulkan/icd.d/lvp_icd.x86_64.json <command>

Use Vulkan Mesa LLVM lavapipe (llvmpipe) Vulkan emulation (can be unstable)

In Linux install package something like libvulkan_lvp - Mesa vulkan driver for LVP (use package search in your Linux).

And select --gpu=0 in my vulkan-shadertoy-launcher launch line option. GPU should be detected as:

Vulkan GPU - CPU: llvmpipe (LLVM 13.0.0, 256 bits) (id: 0x0000) from vendor 0x10005 [driver version: 0x0001, API version: 0x4020C3]


List of shader bugs:

Shadertoy links, click on Screenshot previews to see full image.

Screenshot, click to open Bug link
BUG ANGLE dFd broken on break - Angle bug
BUG Nvidia const to array (array index bug) - Nvidia OpenGL and Vulkan driver shader compiler bug, Other Nvidia OpenGL bugs in array
BUG Vulkan AMD array indexing (array index bug) - AMD Vulkan driver bug, bugreport. And if you combine this code with Nvidia Vulkan array indexing bug - you can have shader that bugged on both Nvidia and AMD at same time (yeee super cool).
BUG Rand/Hash pre-calculated - I think this is not expected, related to blog post Float precision on GPU, bugs/features
BUG floatBitsToUint comp vs real - related to blog post Float precision on GPU, bugs/features
BUG floatBits uintBits - different version of same bug above - shader pre-compiler change behavior of pre-compiled values when used uintBitsToFloat.
BUG Vulkan Nvidia sin hash - sin hash broken in Vulkan on Nvidia, when in OpenGL everything fine.
BUG sin not same on AMD/Nvidia - similar as "sin hash broken" above, but in not-noise shader, in fractal shader sin making different visual image.
BUG mod2pi does not fix sin/cos AMD/Nvidia - same shader as above, uncomment first two lines with define, obvious idea to fix sin inconsistensy just mod(x,2*PI) but it not just "not fix" it change pattern on Nvidia where it was working, on Nvidia pattern on left side with define will be different compare to no define.
BUG Nvidia OpenGL ruins float - Nvidia OpenGL GLSL compiler somehow ruins float, look code.
Test shader - OS detector - Nvidia 4060 - framebuffers and youtube-panorama videos are broken in Chrome-Vulkan. Video, Chrome.
BUG Float loop iterations - Never use float as loop-iterator, this can be considered as "not a bug" and expected, but Nvidia have some special float-behavior in OpenGL, I think this is reason for this.
BUG AMD textureGrad vs discard - Bug - it look like conflict of discard and textureGrad, bug works only in Linux on new mesa in AMD in OpenGL, found it in this shader.
BUG AMD performance dFd if ruin - When this specific shader run in 32-bit buffer - it get 1000x slowdown because use of fwidth/dFd and if condition after - idk it so weird, when it run in 8-bit buffer - its fine no slowdown, related to shader compiler I think. AMD

BUG Nvidia Vulkan driver no comp - Nvidia Vulkan driver compiler bug, happening in Chrome

BUG Angle 20x slowdown - DX11 FXC bug

BUG AMD branching optimization - I do not know is it AMD or ANGLE bug - bug works only in ANGLE, and I tested it only in AMD.

BUG Chrome or Nvidia compiling - Nvidia OpenGL compiler bug

BUG Vulkan AMD crash - old bug, fixed already

BUG Vulkan AMD loop bug - old bug, fixed already

BUG Vulkan Nvidia noise bug - fixed already, but very weird - basically all shaders that use fract and mod was bugged in Nvidia Vulkan for 5 years and no one noticed... Videos of this bug 1 2

BUG OpenGL Nvidia high GPU usage - Nvidia OpenGL compiler bug

BUG smoothstep( 1, 0 ,0) specs - smoothsep on GPU does not follow specs, when on CPU it does.

BUG Nvidia OpenGL compiler bug - Nvidia OpenGL compiler bug, fixed in 510+ driver.

Old GLES2 depth write bug on AMD - still broken, I think it another wontfix because no one care about OpenGL. (Note - by clicking this link you may trigger interesting web-bug, look below "Interesting amd forums bug" - just press enter in address text in webbrowser if you get 403)


Not a Bug, its expected behavior but it still weird

Screenshot, click to open Bug link
one of my shaders on iPhone - video webm link This my shader TV Scene, wall of TV run on iPhone - fad from Shadertoy discord shared this video.
BUG Nvidia OpenGL arrays wrong (array and matX indexing) - only Nvidia OpenGL. Can be considered as "not a bug" because UB line 29 ext_3[return_zero()] += -2147483648 as function argument, so in unknown what will be first += or passing as parameter.
BUG 32-bit float precision - related to blog post Float precision on GPU, bugs/features
BUG 32-bit float precision test - Look function colorAniso() in shader, for some reason this noise happens when camera look on plane(explained there). Also I use this shader to compare 32bit floats vs 64 bit floats. (more shaders to compare float vs double Shadertoy shader, list in comments )
BUG GPU driver unroll prediction - using break in loop adds precision to operation, expected because shader compiler compile shader diferently for each case.
BUG GPU precision never 0 - related to blog post Float precision on GPU, bugs/features
BUG Nvidia Vulkan UB behavior - weird UB behavior that result not same image depends on GPU, Vulkan only
Using double in functions that does not support double may result crash after launching shader, on screenshot application crashed after rendering first frame in shader code exp(dvec2(sqrt(exp can only precess 16 and 32 bit floats by specs). Link to zip with exe to test bug_nv_double_specs_crash.zip
BUG normalize bugs - related to Cubemap GLSL shader debug functions - normalize does not return vector with length 1.0
BUG float precision patterns - patterns of sin, sqrt diferent between GPUs (look screenshot), related to Float precision on GPU, bugs/features
BUG linear interpolation test - float linear interpolation test on diferent GPU diferent result (look comments in code)
BUG 32-bit float pattern 2 - behavior related to losing float precision on small and large numbers, read comment and look two screenshots on shadertoy page. When screen has square size then determinant and inverse return some small and large numbers that leads to precision loss and this pattern on screenshot.
TEST noise repetition - patters of fract and sin hash and noise, by searching same values on image. histogram of noise
BUG STL slowdown - Only Nvidia OpenGL slowdown, OpenGL Nvidia shader compiler for some reason dont like when arrray is argument. Related to Decompiling Nvidia shaders, and optimizing blog.
Optimized ML/Neural shader - Nvidia case when CONST buffer become too large and it destroy performance. Related to Decompiling Nvidia shaders, and optimizing blog.
BUG Nvidia float as argument bug - (OpenGL and Vulkan) Nvidia OpenGL GLSL compiler somehow generates wrong floats when const floats used as argument of function, look code. (look like this is not bug, its compiler inconsistency, read shader code comments) (the "bug" is - floor((900./37.)*1000.)/1000. is 24.323999 on CPU and 24.324001 on GPU)
TEST - About fract-hash consistensy. Comparison for Rough Seas shader, discussion Hash without Sine. Look this two gif - OpenGL AMD (red) and Nvidia (green) and Vulklan AMD when iTime calculated on GPU as non-const and when it is const. On screenshot left - Vulkan Nvidia there appears lines I think because of sincos implementation on Nvidia. To test - #define iTime (8998.3+floor((900./37.)*1000.+float(min(iFrame,0)))/1000.) to Rough Seas shader code, to test iTime as const - remove +float(min(iFrame,0)).
BUG Cubemap rendering order on load - WebGL behavior depends on GPU and rendering API. Watch this youtube video.
BUG float calc inconsistency - Bug is - I was debugging/making TAA and was comparing result of "my controlable camera" to "static camera" - and result were not equal when camera matrix and everything was equal, I tested every single value line by line, and in TAA I was worrying that I miss "pixel jittering" somewhere and result was pointing on it... to not spread confusstion - this is "not bug" I just forgot that GPU are inconsistant in float computations, and when two equal values come from different sources result of operations on them will be not equal to same float value that come from single source.
BUG float calc inconsistency - Bug is - result of ro1 + rd - ro2 where ro1 and ro2 is equal - will not be equal to rd. Same as BUG GPU precision never 0.
Bug with Undefined Behavior in Nvidia GPUs, and since this is UB it can be considered as expected behavior. This is third version of similar UB behaviour bug I reported before(to Nvidia and Chrome in bugreports). Most strange for me(and why I think this is bug) - visual result generated by shader changed/reacting to outside activity (other apps that use GPU). Watch this video(Youtube) to see this bug behavior. Download exe/linux version bug_nv_ub_leaks_v3_1.zip with shader source.
4-th edition of bug above with uninitialized variables, but now it work on AMD GPU(only OpenGL only Linux), when before it was not. This youtube video show it working. Mentioned in this changelog (search s48).
BUG Mip inconsistent Vulkan/Ogl - When sampler2D have no mipmaps but has linear filter and shader has push_const - functions texture has some unpredictable result. (woks only in this specific shader(shader made from other large shader where I found this bug)). Bug does not work when shader does not have push_constants. Bug work on Shadertoy only in OpenGL mode chrome.exe --use-angle=gl and only when FBO has mipmaps. But in OpenGL this is "not a bug" or atleast it can be explained. Update 2023 - now this bug works in Webbgowser but mipmaps required Chrome. Youtube video of this bug. This shader also include second bug/behavior - on video 00:31 - but I think this is Shadertoy website behavior - alpha-value of mipmap change not same as rgb value when it supposed to be same.
BUG TEST Rough Seas fract hash - Just test shader for this blog post Hash Noise stability in GPU Shaders, blog mirror.
Related-example of fract-hash instability described in blog post Hash Noise stability in GPU Shaders, blog mirror. Shader link.
BUG WebGL wrong compile error - 1./0. generate uintBitsToFloat error in Firefox - for some reason.
Firefox bugreport with details and code - float [1024] arr; - Firefox 130 does not allow const data >=1024 - incorrectly ignoring MAX_FRAGMENT_UNIFORM_COMPONENTS
TEST bits 32 r/w block[8x2] and TEST bits r/w block[8x8x8] - Again about STL in Nvidia shader, read blog Decompiling Nvidia shaders or blog-mirror. Result OpenGL Nvidia 4060 block[8x8x8] - 20FPS on 1080p, block[8x2] - 60fps on 1080p. Vulkan - I get 60fps on both but with block[8x8x8] is 100% GPU usage when block[8x2] is 30% GPU usage.

Nvidia OpenGL can not compile this shader - arrays - for some reason Nvidia driver(555) compiler crash because of mi_o_y function - I fixed it by clamp array range, if remove clamp in arrays in mi_o_y function - bug will work.

BUG Vulkan uint32 128 bytes push constant (does not work from WebGL, need modification read Shadertoy comment) - (not a bug) - just reminder for myself: in Vulkan - Any member of a push constant block that is declared as an array must only be accessed with dynamically uniform indices. If you use array as push const then result will be this - screenshot 1, screenshot 2. Do not use array as push-constant in Vulkan. khronos.org/registry/vulkan/specs

BUG Vulkan not equal to OpenGL - UB behavior in OpenGL and Vulkan. I think it because CPU-side precompilation result UB diferently.

BUG cubemap rayDir to fragCoord - related to Cubemap GLSL shader debug functions

BUG tile rendering dFd test - not a bug, its expected behavior - dFd and texture functions return wrong result on edges when tile size not even. Related to tile rendering example and advanced tile render (look line 4 in Common)

AMD bindless seems bugged - links to bugreports 1 2 3. I was debugging/looking GL_ARB_bindless_texture in app Nu.Gaia originally and coult not see obvious reasons why it not work on AMD only. Khronos Bindless_Texture say - "Bindless textures are not safe. The API is given fewer opportunities to ensure sane behavior; it is up to the programmer to maintain integrity." - and there no tools to debug, renderdoc does not support bindless, only what working I found is apitrace and glintercept - but they also show everything same on amd/nvidia, so I have no idea why this is not working on amd. As you see on video - other apps that use bindless also bugged on amd, so I assumed, may be wrong - that "it is amd driver bug/behavior with bindless".

Chrome Vulkan: Fix line-loop draw arrays after elements - Google confirmed and fixed one Vulkan related bug in their browser.

Interesting amd forums bug, not related to graphics, just funny.


Angle experience - some of bug-related experience (unexpected behavior when your code is fine) - launching my GLSL card game in ANGLE fist time (video), Godot in ANGLE FBO size jump (video), till 2019 (pre 76 version) Chrome had broken instanced particles support.


Driver updates:

Summer 2021 AMD update their driver (Linux and Windows, close and opensource) with fixing all my bugs that I reported during 2020-2021. Vulkan only fixes, OpenGL still very broken there. (that makes my GLSL Auto Tetris and other my demos work in Vulkan on AMD GPUs)