View Full Version : ATI - indirect index sampler limitation

01-20-2012, 08:53 AM
For reference to anyone else with the same problem:

The following works on NVIDIA but not on "ATI Radeon HD 4800 Series"

uniform sampler2D ShadowTexture[2];
void main()
int splitPlane = 0;
float value = texture2D(ShadowTexture[splitPlane], vec2(0.0, 0.0)).x;

With amd_catalyst_12.1a_preview_win7_32-64 ,you get the following error

ERROR: error(#15) Extension: 'sm5' isn't supported=> sampler array isn't support indirect index Sampler array indexes must be integral constant expressions

With earlier drivers, the fragment is discarded without any error.

01-20-2012, 09:46 AM
The Radeon HD 4800 series does not support shader model 5. Therefore non-constant indices aren't allowed for array lookups. If you change the following line

const int splitPlane = 0;

it should work. I bet you're testing on a GeForce 4xx+ model, right? These support SM5 so your comparison is a bit lacking. If your testing with a GF 2xx- generation card then the CG compiler doesn't obey the limitations of SM4 correctly.

If you want shader model 5 you need to upgrade to a HD 5000+ card.

Edit: BTW, are you implementing cascaded shadow maps?

01-21-2012, 01:37 AM
Many thanks. That makes sense.

Yes, we have implemented cascaded shadow maps - good guess!

It now works fine by avoiding using the non-const array lookups.

(by expanding the loop "for (int splitPlane=0; splitPlane<3; splitPlane++)")

01-21-2012, 02:31 AM
In that case you can also pack 1-4 views into a single texture if that fits your render path more naturally (as it does in my case).