Indexed constant memory

Hello,

Is there a way to do indexed constants in CUDA? The index will be a value read from a texture.

I am thinking of code as follows:

char constname[ 50 ];
for ( int i = 0; i < scene.num_materials; ++i )
{
sprintf( constname, “c_constname%d”, i );
cudaMemcpyToSymbol( constname, &consts[ i ], sizeof( uint32 ), 0,
cudaMemcpyHostToDevice );
}

Is this what th pesky 4th argument to cudaMemcpyToSymbol is for? How would it be used?

Thanks