View Full Version : Questions about mapping huge array to GPU
I am trying to write a GPU based fluid solver for physically fluid simulation. I want to passing a HUGE array with size greater than
float[8,000,000]. Obviously it's unwise to directly declare a uniform semantic array with that size in either vertex program or fragment program. So how can I passing such huge array to fragment program in Cg? To packing these data in a texture?
09-07-2005, 10:25 PM
I don't know whether this array indicates values that are assigned per-vertex or per-fragment. But yes, in case the values are out of the [0, 1] range then you can pass them to a fragment shader through a floating point texture and since you won't be needing floating point blending and/or mipmapping therefore even NV3x or R3xx grade hardware would do. In case these values can fit the [0, 255] range then you can pass them as a regular texture. As for per-vertex values, you can use vertex (or some other like normal, texcoord etc.) arrays to pass these values to the vertex shader.
Thanks for your reply. I am using a NV4* seris GPU, so it's not diffcult to do what you say. I want to pass such array to a pixel program cause I want to lookup a crucial data in such array to decide this fragment's color. You know, physical based simulation usually identifies different physical parameter with different color. The array data is not restricted within 0-256, I don't know how to pack such array data into a texture in case the data exceeds 2^8.
09-08-2005, 01:26 AM
You can do that as well but you will get precision problems. The idea is to basically scale every value by the highest value that can exist e.g. if 5000 is the highest value then you divide every index in the array by 5000 to get them into 0 - 1 range. You can later scale these values back to the 0 - 5000 range in the fragment shader. But you will get precision problems in this case if the scaling value is too high and i believe precision is critical in fluid simulation (i hope i am not wrong :) ).
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.