Jump to content
  • Advertisement
Sign in to follow this  
hotpixel

[HLSL] Invalid const register num

This topic is 3690 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm trying to play with arrays for dynamic lights in HLSL but am coming across this problem in my HLSL:
Quote:
Error (209): error X5589: Invalid const register num: 32. Max allowed is 31.
this is my HLSL
Quote:
PixelToFrame MeshPixelShader(VS_OUTPUT PSIn) { PixelToFrame Output = (PixelToFrame)0; float DiffuseLightingFactor = 0; for (int i=0; i<xNumLights; i++) { DiffuseLightingFactor += DotProduct(xLightPos, PSIn.Pos3D, PSIn.Normal); } float4 OutColor; OutColor = tex2D(ColoredTextureSampler, PSIn.Tex0) * DiffuseLightingFactor; Output.Color = OutColor; return Output; }
the strange thing is that the error is coming up for line:
Quote:
OutColor = tex2D(ColoredTextureSampler, PSIn.Tex0) * DiffuseLightingFactor;
this is how I am registering my light variables at the top of my HLSL
Quote:
static const int MAX_LIGHTS = 26; float4 xLightPos[MAX_LIGHTS]; int xNumLights = 0;
I don't understand where it's getting 32 from and why that line instead of my for loop which is obviously where it's falling down because that's where the array is, it's quite obviously something stupid that I'm doing through my lack of understanding of HLSL. Thanks guys, Andy

Share this post


Link to post
Share on other sites
Advertisement
Wow same thing just happened to me but the error i get is

error X5589: Invalid const register num: 34. Max allowed is 31.

Does it have something to do with the number of instructions you can have?

I'm trying to run different lights at the same time through my fx file.

Share this post


Link to post
Share on other sites
Yeah i think it is something to do with the number of commands you run in HLSL. I changed from version 2 to version 3 and now the error doesn't appear.

if you look on wiki it says that in shader version 2 max number of constant registers is 32 while in shader version 3 it is 224.

What the constant registers is something i'm not so clear on.

Share this post


Link to post
Share on other sites
Sounds like you are compiling your shader to too low of a version. Pixel and Vertex shader model 3 support 256 constant registers I believe. Pixel shader model 2 only has 32 constant registers I believe.

Share this post


Link to post
Share on other sites
Quote:
Original post by hotpixel
Quote:

static const int MAX_LIGHTS = 26;
float4 xLightPos[MAX_LIGHTS];
int xNumLights = 0;


This array is taking up 26 of the constants. Temp variables used in the shader code also take up your constant registers too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!