The latest catalyst (11.5) appears to have a bug with glBindSampler - it fails with INVALID_VALUE on totally valid arguments.
I traced the assembly code in the driver and found out that it does wrong argument validation - at the place where it checks if the first argument is between 0 and MAX_TEXTURE_IMAGE_UNITS-1 it also checks if the second argument is zero (which it is not) - if either of these two is false it generates INVALID_VALUE. Nonzero second argument is valid when it is taken from glGenSamplers.
When i nop-ed out the second condition in the driver dll, it works perfectly.
I am posting this, in case anyone else has encountered this problem too, to let him know how it can be fixed.
Also if any ATI driver guy is reading this forum, please fix this bug!
This bug is present in the older version 11.2 too.
I did some investigation into this, and it looks like you must call glSamplerParameter() before calling glBindSampler(). I don’t think the ATI driver is creating a sampler object until they get a glSamplerParameter() call.
Yes, it is a driver bug. The sampler object has not been created in the driver when calling glBindSampler. Instead, driver sees no existing sampler object and returns INVALID_VALUE. Similar as texture object, the sampler object is lazy created in the glBindXXXX. However, the current AMD driver fails to do so.
I now apply sampler state before binding sampler to texture unit. This workaround works for most textures. However, this is not quite enough: I still have to setup texture filtering (linear/linear) in the texture object in order to get PCF shadow maps working correctly.