Nvidia 169.21 driver bug in GLSL

· by Steve · Read in about 2 min · (303 Words)

I recently discovered that the Nvidia 169.x driver stream has a new bug with GLSL, which manifested itself as this error message from the linker:

fatal error C9999: Bad scope in ConvertLocalReferences()

This is with GLSL that worked perfectly fine in the previous major driver version, and it cropped up in our HDR compositor. Upon checking, this was a known bug in the driver since it was in beta, but unfortunately it appears the driver was let out with it still there. The bug manifests itself when you use multiple GLSL file attachments to declare common functions - unless you attach the files which define those functions before the files which use them, you will get this error. This is wrong, the attachment ordering shouldn’t matter, and it actually worked fine that way before.

For the moment, since this driver is now ‘in the wild’, I’ve put a workaround into Ogre to cope with it. Our GLSL handler now always attaches child programs first (those that you declare with the ‘attach’ directive in the material script), before the main program source - this makes sense since functions will always be in these child attachments. We also attach in the order that you declare them, so you should be able to work around this bug even if you have more complex shader set ups. Our HDR demo works again on Nvidia with this change.

Nvidia are normally pretty good with their GL drivers (and indeed, I’m regularly pointing at them as a good example of how not to screw them up), so it’s a shame this one wasn’t fixed before the driver was finalised. I’ll see if I can find out why it’s still there and what the ETA on it is, although I doubt I’ll get much info until after the festive season.