Sign in to follow this  
ShmeeBegek

Texture access in Fragment Programs

Recommended Posts

I've been architecting the GFX Engine for my game, and I am wondering about the use of more texture accesses vs. more calculations in Fragment Programs. Many sources (including "The Cg Tutorial") seem to encourage the use of tables stored in textures over doing calculations in a fragment program. But in my experience Texture Access is very slow, and I'm not sure that using a texture is actually more efficient than just, say, converting from spherical to Cartesian coordinates using the standard trig. functions. I have an FX 5900 with 128MB Video RAM, so I don't think that my card is simply mis-leading me. Thanks for all comments and suggestions, ~SPH Edit: I would also think that textures accessed by coordinates defined by input texture coords. could have more optimized access, is this true / how does it factor in? [Edited by - ShmeeBegek on August 5, 2004 1:07:15 PM]

Share this post


Link to post
Share on other sites
From what I know, the fragment program has to be looked at as a whole. For example, some documentation from Nvidia encourages sort of an interleaved use of texture and arithmatic instructions. They say that if such instructions are independant, they run in parallel.

As for operations such as conversion from spherical to cartesian
coordinates, it is my humble opinion that a texture access will most likely be faster than all the instructions required to do
this (it requires two SCS instructions or atleast some
multiplications and additions to approximate).



SporadicFire.

Share this post


Link to post
Share on other sites
Actually, nVidia's programming guide suggests that sin/cos (and log) are micro-operations in FX and later nV chips, and therefore using them is at least as fast or faster than equivalent texture lookup.
However, especially for small-sized textures, the lookup should be very fast also. Larger textures might not work well with texel cache, and that potentially slows down their access.
That, and if you need to achieve more than one trigonometric operation (for example 4) at the same time, texture lookup is probably more efficient in any case.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this