View Full Version : Trouble with arrays
I am trying to implement the convolution examples in chapter 16 of the orange book, but I am having trouble with arrays. I have an nVidia 6800 Ultra.
If I declare the array as shown in the book:
uniform vec2 Offset;
and try to set the uniforms from my app, I get an error saying that the profile must be defined at compile time.
How do I do that? And what if I want to change the data at run-time?
I also tried to hardwire the data within my fragment shader by defining all 25 values, but I don't know the proper syntax for this. How would I declare the array and define the data as constants?
Thanks for any help.
01-26-2005, 08:02 AM
I guess it's not the array which results in the error but the way you access it. There is no programmable array access in fragment programs today. Vertex programs have an address register to do that.
If the 25 elements vec2 array is a filter kernel and the compiler doesn't unroll a 5x5 loop for you, you could try to rearrange the code or unroll by hand (ugh), or try a newer driver.
For fully programmable data access you can always put the data into a texture and access it with texture lookups.
So are you saying that it is the use of a variable index that is getting me? Offset[i]
This is my first time trying to use both arrays and for loops, so I may be doing things wrong.
If I replace the "i" index with hardwired indices, there is no point in having the for loop.
Do other cards support this functionality? Such as the 3Dlabs card. If not, why is this example in the boook.
Regarding drivers - I would love to get a newer driver, but the lastest released and the lastest beta drivers from nVidia don't even work on my computer. I am using 70.41 because it is the only one that works at all. I have a dual Opteron motherboard with the 6800 card. This seems to be an unsupported combination.
By hardwiring my indices I was able to get the array to work.
But I may have uncovered a compiler error.
If I make my array size 25, the data in one of those registers overwrites one of my other uniform variables. Smaller arrays work fine, but large ones step on other values. I think the compiler is not properly allocating the hardware registers.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.