Indexing arrays in loops

Win XP/6800/Whatever the latest nVidia drivers are.

Simple vertex program…

uniform some struct foo[ 10 ];

main( )
{
int i;

for ( i = 0; i (less than) 10; i++ ) {

somting that indexes foo[ i ].whatever;

}
}

This works fine. Buut if you have…

uniform int loop_count;

And change the for loop to…

for ( i = 0; i (less than) loop_count; i++ )

The loop will work but indexing ‘foo’ will not work.

Say in ‘main’ I declare “int j;” and then within
the loop do;

j = 0;
somthing = foo[ j ].whatever;

This works.

If I do:

if ( i == 0 )
j = 0;
else
j = 0;

somthing = foo[ j ].whatever;

Doesn’t work.

Indexing based on a uniform in a fragment program simply makes the compiler explode. But I’m not too worried about this yet.

The following vertex program ( which obviously doesn’t actually do anything - just to illustrate the point ):

void main( )
{
int i, j;
float farray[ 10 ];

j = 0;
for ( i = 0; ( i (less than) 10 ) &&  ( j (less than) 10 ); i++ ) {

    farray[ j ] = 1;
    j += 1;

}

gl_Position = ftransform( );

}

Produces the following error:

(18) : fatal error C9999: Invalid lvalue in assignment in CreateDag

I can reproduce this issue and I’ve filed a bug report. This should be fixed in a future release of the driver.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.