I came across strange HLSL behavior. I am trying to use an array that is contained within a structure, for example (pixel shader code):
struct VSOUT {
float4 projected : SV_POSITION;
float3 pos: POSITION;
float3 normal : NORMAL;
};
struct Something {
float a[17];
};
float4 shMain (VSOUT input) : SV_Target {
Something s;
for (int i = 0; i < (int)(input.pos.x * 800); ++i)
s.a[(int)input.pos.x] = input.pos.x;
return col * s.a[(int)input.pos.x];
}
The code doesn't make sense logically, it's just a sample. The problem is that when I try to compile this code, I get the following error (line 25 is the line for the loop):
(25.7): Error X3511: Forcing the loop to deploy, but the deployment failed.
, ( float a[17] shMain), , .
: DirectX (unrollable) for-loop ? ? , ?
4.0, DirectX 10 SDK 2010 .
EDIT:
, Something :
struct VSOUT {
float4 projected : SV_POSITION;
float3 pos: POSITION;
float3 normal : NORMAL;
};
float4 shMain (VSOUT input) : SV_Target {
float a[17];
for (int i = 0; i < (int)(input.pos.x * 800); ++i)
a[(int)input.pos.x] = input.pos.x;
return col * a[(int)input.pos.x];
}
. , [loop] for-loop, , ( ).