PDA

View Full Version : ABRfp 1.0 texture lookups



flamz
09-03-2004, 09:46 AM
Anyone know how many texture lookups I can do in a fragment probram profile ARBfp 1.0?

it chokes after six on my ATI FireGL X2 for some reason... normal?

jra101
09-03-2004, 10:14 AM
Call glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, &numTexInstructions) to query the number of texture instructions allowed by your GPU.

flamz
09-03-2004, 11:16 AM
= 32
not sure why it fails.......

jra101
09-03-2004, 11:39 AM
Most likely texture indirections, try calling glGetString(GL_PROGRAM_ERROR_STRING_ARB) to get a more detailed error message from your GL implementation.

flamz
09-03-2004, 01:55 PM
thanks for your help. I managed to figure out that it was indeed texture indirections.

I'm doing a sort of blur and need to mess around with the texture coordinates before every fetch. I'm am right when I say that the minute you screw around with texture coordinates inside a fp, you get an indirection when you fetch?

zeckensack
09-03-2004, 02:35 PM
Originally posted by flamz:
thanks for your help. I managed to figure out that it was indeed texture indirections.

I'm doing a sort of blur and need to mess around with the texture coordinates before every fetch. I'm am right when I say that the minute you screw around with texture coordinates inside a fp, you get an indirection when you fetch?Not quite. You can use fragment.texcoord[n] as an input to calculations without creating an extra level of dependency. Eg you can "safely" do this:
!!ARBfp1.0
MUL result.color,fragment.texcoord[0],fragment.color;
ENDAn indirection refers to using a computed result as a texture coordinate (ie as an input) for a texture lookup instruction (TEX or TXP) ... as opposed to a straight interpolated fragment.texcoord[n], which does not constitute an extra indirection.

I hope this made sense :)

sqrt[-1]
09-03-2004, 03:56 PM
Perhaps also do a get for GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB
to see what your card supports.

Then do a get of
GL_PROGRAM_TEX_INDIRECTIONS_ARB
after you load the program to see how many indirections you make in the program.

jwatte
09-03-2004, 08:12 PM
It also helps to group as many tex load instructions together as you can. For ATI hardware, even using some temporaries can help (although NVIDIA hates temporaries).

Assuming you have a bunch of deltas off a center point, with attached weights, to implement a blur filter, you might do something like this (I forget the exact syntax -- been in HLSL land for too long):

ADD temp1.xy, texcoord[0], deltas[0];
ADD temp2.xy, texcoord[0], deltas[1];
ADD temp3.xy, texcoord[0], deltas[2];
ADD temp4.xy, texcoord[0], deltas[3];
TEX temp1, sampler1, temp1;
TEX temp2, sampler1, temp2;
TEX temp3, sampler1, temp3;
TEX temp4, sampler1, temp4;
MUL temp1, temp1, deltas[0].w;
MAD temp1, temp1, temp2, deltas[1].w;
MAD temp1, temp1, temp3, deltas[1].w;
MAD temp1, temp1, temp4, deltas[1].w;

This will make it very clear that you're using one indirection before the tex instructions, and there's no dependency between tex instructions. Otherwise, the driver may believe there are dependencies even when there aren't. For example, if you texture into a temporary, and then re-use that temporary for some other value, and then use that other value for the next texturing, the drivers may believe it's an indirection. Use separately named temporaries instead (the drivers can often do coloring/merging to optimize these out).

harsman
09-04-2004, 04:30 AM
Also make sure you have the latest ATI drivers. The drivers ability to recognise what actually is an indirection and what can be optimised away varies pretty wildly between versions.