Centralize shader dumping

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