PDA

View Full Version : More than 3 texture3D lookups hangs application



marfa713
04-20-2004, 11:08 PM
I've got a small problem. I use a 3D noise texture now, but for some reason the application hangs when I do more than 3 lookups in the texture. I'm trying to do a cloudy sky and would like to use 4-5 octaves of this pregenerated noise. At first I thought that maybe there's a limitation on number of lookups per texture unit, so I bound the texture object to texture units 0-3, but with the same result.

Has anyone encountered any such limitation?

Markus
---
Radeon 9800 Pro, Catalyst 4.4

Corrail
04-21-2004, 02:24 AM
What do you get when you call glGetInfoLog?

pantxua
04-21-2004, 05:32 AM
I have the same problem with doing a convolution (with a ATI 9800 pro):
when i try to lookup more than three times in my texture, my program crashs. I have the same problem with using a for loop.

uniform sampler2D BaseImage;

void main (void)
vec4 sum = texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, 1));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(-1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, -1));

gl_FragColor = sum * vec4(0.25);
}

But I have no solution

Corrail
04-21-2004, 05:41 AM
I got a similar problem. When sampeling more than 3 textures glGetInfoLog returns me a warning, that the shader will run in software because of exceeding texture indirections...

pantxua
04-21-2004, 05:47 AM
I have no warning, my infolog is : "Link successful. The GLSL vertex shader will run in hardware. the GLSL fragment Shader will run in hardware.", but i still have the problem :)

marfa713
04-21-2004, 05:51 AM
I get the same message as you Corrail.

pantxua
04-21-2004, 05:57 AM
where do you you put your infolog in your code ?

pantxua
04-21-2004, 07:15 AM
ok, i have the same message in the infolog which is "number of texture indirections exceeded"

PanzerSchreck
04-21-2004, 07:49 AM
That's a known flaw in ATI's current glsl-implementation. I've noticed that (with 2D-texture lookups) some months ago, but ATI still haven't fixed this.

This was btw. also the case with ARB_FP, where a similiar problem existed and took ATI some time to
fix.

It seems that ATI's glsl-implementation takes normal lookups for dependant lookups, which isn't correct. Hopefully they'll fix that within one of their next drivers (instead of including such useless crap as those "smartshaders").

pantxua
04-21-2004, 08:55 AM
ok, i will wait for next ATI driver but is there another way to make a convolution without using more than 3 textures lookups ?

Pierre B.
04-21-2004, 02:26 PM
Originally posted by pantxua:
I have the same problem with doing a convolution (with a ATI 9800 pro):
when i try to lookup more than three times in my texture, my program crashs. I have the same problem with using a for loop.

uniform sampler2D BaseImage;

void main (void)
vec4 sum = texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, 1));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(-1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(1, 0));
sum += texture2D(BaseImage, gl_TexCoord[0].st + vec2(0, -1));

gl_FragColor = sum * vec4(0.25);
}

But I have no solution
since you are storing the result of all texture lookups in the same temporary variable, it is technically a texture indirection.

one way to workaround would be to store the four lookups in four variables, and to add them to get your final sum.

A better compiler could do this for you.

Pierre B.

pantxua
04-21-2004, 10:25 PM
thx but storing the four lookups in four variables has the same result than storing the result of four lookups in the same temporary variable. The hote that the next ATI driver will have a better compiler which will work with more than 3 texture lookups.

marfa713
04-22-2004, 12:44 AM
I tested my shader with an FX5900 card and Forceware 60.72. Works like a charm!!

al_bob
04-22-2004, 05:37 AM
AFAIK there is a limit of 4 dependent texture reads on the Radeon cards. When you compute gl_TexCoord[0].st + vec2(0, 1), you're computing a texture coordinate in the shader, thus it counts as a dependent read.

However, it looks like you're using exactly 4 reads, so it should just work.

Alternatively, you can try computing the texture coordinates in a vertex shader and using them directly in the fragment shader. This will avoid the extra computations in the fragment program and turn dependent texture reads into independent ones.

pantxua
04-22-2004, 11:47 PM
ok, i've done it with 5 texture lookups :

uniform sampler2D BaseImage;
varying vec2 TexCoord;
void main (void)
{
vec2 textcoord = TexCoord;
float tmp = 1.0/512.0;
float div = 1.0/5.0;
vec2 coord1 = textcoord + vec2(0, 0);
vec2 coord2 = textcoord + vec2(0, tmp);
vec2 coord3 = textcoord + vec2(-tmp, 0);
vec2 coord4 = textcoord + vec2(0, -tmp);
vec2 coord5 = textcoord + vec2(0, 0);
vec4 sum = texture2D(BaseImage, coord1);
sum+= texture2D(BaseImage, coord2);
sum+= texture2D(BaseImage, coord3);
sum+= texture2D(BaseImage, coord4);
sum+= texture2D(BaseImage, coord5);
gl_FragColor = (sum)* vec4(div);
}

with one lookup more my application crash. So I will try to do my convolution with cg while waiting for ati's driver :)
thx a lot