Post by Scythenweights[numWeights-1] = 1;
Which results in the error "Array reference can not be used as an l-value"
weights[1] = 1;
Why, and is there a way around this?
HLSL is limited by the limitations of the underlying capabilities provided
by the assembly language that they must compile to. The operation you
specify requires relative addressing of registers, which is very limited:
1. Constant registers can be relatively addressed with the a0 register in
all vertex shader versions.
2. Constant registers can be relatively addressed with either the a0 or aL
loop counter in VS2.x and VS3.0
3. Color input registers can be relatively addressed with the aL loop
counter in PS3.0
Note that all of the above operations apply to read-only registers, none of
which could be l-values.
As for why weights[1] works, since the index is a constant it really
references a specific value, and can be mapped to a specific register at
compile time.
Assuming numWeights is an constant input to the shader, then you might be
able to do this by declaring it as a parameter to the shader function with
the "uniform" usage, and specify the appropriate number of weights when
specifying your shaders in the technique - this would likely require you to
use a separate technique for each possible value of numWeights. This could
allow the compiler to convert the array reference to a static value
reference, creating shader functions for each configuration specified by
your techniques.
--
Robert Dunlop
The X-Zone
http://www.directxzone.org/
Microsoft DirectX MVP
-------------
The opinions expressed in this message are my own personal views and do not
reflect the official views of the Microsoft Corporation.
The MVP program does not constitute employment or contractual obligation
with Microsoft.