HLSL: Enforce Constant Register Limit at Compile Time
Posted
by Andrew Russell
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Russell
Published on 2010-05-19T07:26:15Z
Indexed on
2010/05/19
7:30 UTC
Read the original article
Hit count: 335
hlsl
In HLSL, is there any way to limit the number of constant registers that the compiler uses?
Specifically, if I have something like:
float4 foobar[300];
In a vs_2_0 vertex shader, the compiler will merrily generate the effect with more than 256 constant registers. But a 2.0 vertex shader is only guaranteed to have access to 256 constant registers, so when I try to use the effect, it fails in an obscure and GPU-dependent way at runtime. I would much rather have it fail at compile time.
This problem is especially annoying as the compiler itself allocates constant registers behind the scenes, on top of the ones I am asking for. I have to check the assembly to see if I'm over the limit.
Ideally I'd like to do this in HLSL (I'm using the XNA content pipeline), but if there's a flag that can be passed to the compiler that would also be interesting.
© Stack Overflow or respective owner