Question

I'm working in HLSL, and I'm getting this error from one of my shaders:

error X4505: maximum temp register index exceeded

The line that's causing this is:

int count = Passes[input.Tex.y].y;

Passes is defined as:

cbuffer Style  
{  
     float3 Passes[256];  
     ...  
}

and input.Tex is a float2 declared as a TEXCOORD.

Can anybody explain this error to me please? It isn't documented on MSDN (or anywhere else as far as I can tell) and it isn't clear to me what is wrong here.

I'm using shader model 4.0 level 9_3.

Was it helpful?

Solution

Right now it reads the float as an integer index into the array. Say your float is 1.0f, this means 3F80 0000 in hex or 1,065,353,216 in decimal. It now tries to read the adress Passes + 1065353216 * sizeof(float3) This quite obviously registry index exceeded considering a single constant holds 4096 max constant.

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476898(v=vs.85).aspx#Shader_Constant_Buffer

OTHER TIPS

If this is in a pixel shader, array indexing might not be supported and your compiler might generate code like this:

if (input.Tex.y == 0)
  count = Passes[0];
else if (input.Tex.y == 1)
  count = Passes[1];
...
else if (input.Tex.y == 255)
  count = Passes[255];

I believe level 9_3 code doesn't support array indexing in a pixel shader. You should check the disassembly for very lengthy code. You might have to decrease 256 to 128 or 64 to make it compile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top