HLSL: cast bracket dereference index to int type if not.
HLSL can index arrays using operator[] with non-integer types, and inserts a conversion to a uint if needed.
This commit is contained in:
parent
38a425355b
commit
2efd6c6d0c
5 changed files with 175 additions and 0 deletions
9
Test/hlsl.nonint-index.frag
Normal file
9
Test/hlsl.nonint-index.frag
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
static const float array[3] = { 1, 2, 3 };
|
||||
|
||||
float main(float input : IN) : SV_Target0
|
||||
{
|
||||
// non-integer indexes get converted to uints:
|
||||
// uint(input) 3.0 2.0 1.0
|
||||
return array[input] + array[2.0] + array[true] + array[false];
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue