180 808-00504-0000-003
NVIDIA
Cg Language Toolkit
The declaration and use of arrays of arrays is in the same style as in C. That is, if
the 2D array A is declared as
then, the following statements are true:
! The array is indexed as A[row][column].
! The array can be built with a constructor using
! A[0] is equivalent to {A[0][0], A[0][1], A[0][2], A[0][3]}.
Support must be provided for any
struct containing arrays.
Minimum Array Requirements
Profiles are required to provide partial support for certain kinds of arrays. This
partial support is designed to support vectors and matrices in all profiles. For
vertex profiles, it is additionally designed to support arrays of light state
(indexed by light number) passed as uniform parameters, and arrays of skinning
matrices passed as uniform parameters.
Profiles must support subscripting, copying, and swizzling of vectors and
matrices. However, subscripting with run-time computed indices is not required
to be supported.
Vertex profiles must support the following operations for any non-packed array
that is a uniform parameter to the program, or is an element of a structure that
is a uniform parameter to the program. This requirement also applies when the
array is indirectly a uniform program parameter (that is, it and or the structure
containing it has been passed via a chain of
in function parameters). The two
operations that must be supported are
! Rvalue subscripting by a run-time computed value or a compile-time value
! Passing the entire array as a parameter to a function, where the
corresponding formal function parameter is declared as
in
The following operations are explicitly not required to be supported:
! Lvalue subscripting
! Copying
! Other operators, including multiply, add, compare, and so on
float A[4][4];
A = { {A[0][0], A[0][1], A[0][2], A[0][3]},
{A[1][0], A[1][1], A[1][2], A[1][3]},
{A[2][0], A[2][1], A[2][2], A[2][3]},
{A[3][0], A[3][1], A[3][2], A[3][3]} };