Provide following Information:
The GLSL shader that we are working on (Anime4K) works on mpv v0.30 and v0.31, but it does not work anymore on v0.32.
Running the shader with older versions of mpv yields the correct result, while on the newest version (0.32) it results in a black/blue screen.
The shader in question is: https://github.com/bloc97/Anime4K/blob/master/glsl/Anime4K_Hybrid_v2.0RC2.glsl
And I was notified of this bug thanks to this issue:
https://github.com/bloc97/Anime4K/issues/66
I have narrowed it down to three if() functions that are causing the black screen. Coincidentally all three if functions are there to accelerate the shader (return the original/empty texture if there is no processing to be done).
Removing these three if functions solves the problem, but the algorithm becomes much slower. Since it worked for older versions of mpv, I think there might be a bug in the newest version's GLSL compiler.
This problem is also confirmed on AMD Vega Series (mine) and Nvidia RTX 2070 (see issue above).
Line 247:
if (c < 0.1) {
return vec4(0);
}
Line 304:
if (LUMAD_tex(HOOKED_pos).x < 0.1) {
return vec4(0);
}
Line 413:
if (abs(dc.x + dc.y) <= 0.0001) {
return SCALED_tex(HOOKED_pos);
}
Shaders that work on older versions of MPV should work on the latest version.
Shaders that worked before do not work anymore.
See links above.
[ 0.123][v][vo/gpu/d3d11] Initializing SPIR-V compiler 'shaderc'
Probably an upstream shaderc issue then. Might be worth it to find out what version of shaderc this is built with.
I can confirm at least that the latest windows build on sourceforge (mpv-x86_64-20200301-git-e7bab00) still has this behaviour.
https://sourceforge.net/projects/mpv-player-windows/files/64bit/
I don't even see any compile errors in your log, which I'd expect if you get the mpv blue screen?..
There's no compile time error, there's some kind of runtime error where the texture becomes invalid for some reason, and accessing it causes a lighter 'blue screen' on my GPU (AMD Vega) and a black screen on Nvidia RTX 2070 gpu.
To be clear mpv has not crashed and you can still see the osd, profiler and subtitles.
The shader seems to work perfectly well with the _vulkan_ backend. Doesn't that also use shaderc?
@dixie-flatliner See e.g., #6814. It is possible that different backends behave differently, though they all use shaderc. (And in the issue mentioned, it was indeed a shaderc bug.)
Seems to be caused by: https://github.com/KhronosGroup/SPIRV-Tools/pull/3151
https://github.com/KhronosGroup/SPIRV-Tools/issues/3244 includes a fix.
I believe it's a problem with d3d11 API. On windows, d3d11 is used by default.
If I use gpu-api=opengl or gpu-api=vulkan, it works fine.
Seems to be caused by: KhronosGroup/SPIRV-Tools#3151
KhronosGroup/SPIRV-Tools#3244 includes a fix.
Does that mean this issue can be closed?
Most helpful comment
Seems to be caused by: https://github.com/KhronosGroup/SPIRV-Tools/pull/3151
https://github.com/KhronosGroup/SPIRV-Tools/issues/3244 includes a fix.