PDA

View Full Version : Certain ATI chips and GLSL



grxmx
07-31-2006, 10:56 PM
Ok, I've been having a recurrent problem with the X800 chip and running extremely simple GLSL vertex/shader program pairs.

Essentially what Ive got is a very simple multitexure blend demo which just passes through the position and a pair of tex coords. Sample both textures and mul the color...simple right?

Well apparently on the X800 the jist im getting is that some render state is defaulting the device back to software, so we're getting about 2FPS on the X800, and all nVidia cards are running 95FPS+ Problem is right now what Im doing is so minimalistic that I cant really pin down whats causing it to do this. We've forced off any hw FSAA and Aniso.

This is with the current released catalyst drivers. So is there something really simple that Im just not getting about ATI/GLSL or, might it be a driver bug??

Thanx for any help.

Korval
07-31-2006, 11:18 PM
Yeah, this is hardly enough information to be able to actually be of any help.

We would need to see your code and your shader, preferably some kind of minimal test case that exhibits the problem.

grxmx
07-31-2006, 11:48 PM
Well, the code that manages the GL state is pretty deeply embedded in the render mgmt code. The setup code is all very simple, there is one vertex buffer, and one index buffer allocated w/ STATIC_DRAW. Add the shader program object at init time as well.

I'll conjur up approximately whats going on here:
http://3xile.pastebin.ca/109591

I apologize if the code is very generic, but thats about whats going on there. Assured the code works for nVidia cards wonderfully. If there's anything more specific needed I'd certainly be glad to post that.

I appreciate :)

sqrt[-1]
08-01-2006, 12:05 AM
I seem to recall ATI having some problems with POINT_SMOOTH/LINE_SMOOTH/POLYGON_SMOOTH and GLSL.

Try searching in your code for any glHint or SMOOTH type paramaters.

grxmx
08-01-2006, 12:11 AM
I just checked the status of all, and they all come back false.

Sunray
08-01-2006, 12:53 AM
Have you read the compile and link info logs?

grxmx
08-01-2006, 01:00 AM
The info log returns no log. There were no link errors.

k_szczech
08-01-2006, 01:16 AM
What's your texture internal format, size and filtering? Have you tried to run this program without shader?

grxmx
08-01-2006, 01:30 AM
Yea, the internal format is RGB8, linear filtering on a 512x512 base texture and a 128x128 lightmap. The program runs fine with no shaders bound.

mjkrol
08-01-2006, 04:33 AM
Try this code:


///////////////////////////////////////////////////////////////////////////////////
vertex program
///////////////////////////////////////////////////////////////////////////////////

void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
}


//////////////////////////////////////////////////////////////////////////////
fragment program
////////////////////////////////////////////////////////////////////////////

uniform sampler2D baseTex;
uniform sampler2D lmTex;

void main(void)
{
vec4 baseCol = texture2DProj(baseTex, gl_TexCoord[0]);
vec4 lmCol = texture2DProj(lmTex, gl_TexCoord[1]);

gl_FragColor = baseCol * lmCol;
}This can produce slightly different results, but for your simple case this is a good point to start with.

grxmx
08-01-2006, 11:34 PM
The above code yields the same result.

mjkrol
08-02-2006, 01:13 AM
Then try the following formula in your vertex shader:

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;Instead of:

gl_Position = ftransform();

grxmx
08-02-2006, 01:14 AM
Actually, when retrieving the link info log on the program object, the ATI card does return that the VP and FP would run on hardware. The nVidia card doesnt return a link log at all.

execom_rt
08-07-2006, 06:30 AM
The slow down you've noticed is that the ATI renderer is reverting to a software rendering method that strictly follows the OpenGL specification instead of rendering incorrect results.

The Win32 OpenGL implementation doesn't have a 'pure' mode (in DirectX language), or ' AGL_NO_RECOVERY' on MacOSX, that forbid software fallback.

Having the the software fallback happens for various reasons which are not (well) documented : it could be some various render states enabled even after the shader has been linked succesfully in hardware.

Such render states (i've noticed) that produces software fallback: line or point smoothing, enabling fog - under some specific circumstances -, rendering into a texture using an unsupported texture adress mode, or enabling transparency when rendering into a floating point texture, using the polygon offset (when access gl_FragCoord).

In your code, try to using the gl_TexCoord instead of using varying vec2, or using varying vec4 and pack your two varying vec2 into 1 vec4.

Call glUseProgramObjectARB(currentProgramObject); just before the glDrawElements, not before setting your vertex data.

Finally, try a simpler shader (gl_Position = ftransform(); / gl_FragColor = vec4(1.0,1.0,1.0,1.0)), and check if the software fallback is seen or not.

If all is not working, using ARB_vertex_program and ARB_fragment_program extensions, which are less prone to software rendering fallback on ATI (and generally better performer when correctly written).

Humus
08-09-2006, 12:29 PM
grxmx, could you send me the app with source to epersson 'at' ati.com so I can take a look at it?