Centralize shader dumping

Also, use 'debug' instead of 'bad' in filenames when dumping shaders with the debug
flag enabled.