On the newest driver (I don’t know if older drivers also have this), version 531.79, on an RTX 3080 graphics pipeline creation is very slow when using (large) arrays as function arguments (>20 minutes, after which I quit trying to create the pipeline). I have a minimal reproducible solution here:
NvidiaBugs.zip (29.3 KB)
The implementation is in “SlowPipelineCreation.cpp”, and the shaders are in “shaders/slow_pipeline_creation”
You can change the different tests by changing the define: “TRY_TEST” at the top of “shader.frag”, there is also a bit more explanation there.
The amount of SPIRV generated is also not a lot.
As far as I know, using arrays like this as function arguments should not make copies of the whole buffer, but even if it does, then the only slowdown should be during execution, the creation of the pipeline should not hang for more than 20 minutes.
When I used 32 as a base count (here every material is supposed to have 9 textures), it still took really long, but it managed to create in ~5 seconds (which is still incredibly slow). However since I used vk::PipelineCache, every time I tried to create the pipeline again, with the exact same shaders and configuration, it took just a normal amount of time (not exactly timed, but it should be in the millisecond range).
I also tried with a base count of 64 (which, again, means that the total sampler2D count is 64 * 9, and the amount of materials is 64) it took ~35 seconds to create the pipeline.