   [HLSL] Why isn't the index correct when using large arrays?
  I have an HLSL effect that makes use of storing world transforms in an array:float4x4 WorldTransforms[20];I read the correct world transform by passing in an index using the PSIZE semantic:struct VertexShaderInput{    float4 Position: POSITION0;    float3 Normal: NORMAL0;    float2 TextureCoordinates : TEXCOORD0;    float Index: PSIZE0;  };and then using that as follows:float4x4 worldTransform = WorldTransforms[round(input.Index)];The problem is that the above method doesn't work if I change the WorldTransforms array size to 200:float4x4 WorldTransforms[200];Why is this happening?   
  vs_2_0 and vs_3_0 shaders are going to max out at 256 constant registers. That means a max of 64 float4x4's if you have no other constants. Your shader will still compile since technically a GPU/driver can support more than 256, but in reality they all cap out at 256.   ;  So what are my alternatives?  Multiple passes?   ;  Yeah you'll either need to use more draw calls, or use hardware instancing. You can use a texture too, but that's only supported by SM3.0 hardware (in which case you support instancing anyway) and only has good performance on DX10-capable hardware.Also keep in mind that if you're setting your matrices into shader constants in column-major format (which is the default), then you don't need the last row since it will always be (0, 0, 0, 1). So you can pack your matrices as float3x4's, and then each world matrix will only use 3 registers instead of 4.   ;Quote:Also keep in mind that if you're setting your matrices into shader constants in column-major format (which is the default), then you don't need the last row since it will always be (0, 0, 0, 1). So you can pack your matrices as float3x4's, and then each world matrix will only use 3 registers instead of 4.Good thinking.  Thank you.   ;  And if you really want it you can get float2x4 by using translation (x,y,z) uniform scale (w) and quaternion (x,y,z,w) instead of a 4x4 matrix ... have to expand back on GPU though   ;And if you really want it you can get float2x4 by using translation (x,y,z) uniform scale (w) and quaternion (x,y,z,w) instead of a 4x4 matrix ... have to expand back on GPU thoughWhen you are exceeding the constant limits the only other real option is to move the data into a texture.   Depending how bad you are hammering the hardware (google for shader constant waterfalling) it might even be substantially faster to switch to a set of texture lookups.   