Radeon vs nVidia rendering - game issue

Started by
6 comments, last by furrymaster 12 years ago
Hi,
some time ago I wrote simple game which looks like arkanoid. And everything would be fine if not one BIG problem: on nVidia graphic cards my game is rendering everything what i want, but on Radeon you can't see anything else than black background. I dont use any special instructions for shaders or opengl. I use simple VBO + VAO + shader GLSL(#verison 120).

Game:
http://www.wupload.com/file/2676932477/antyNoid.zip

Sample shader:

#version 120
uniform mat4 modelViewProjectionMatrix;
in vec3 in_Position;
void main(void)
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position=vec4(in_Position.xy*2,0,1);
}


Do you have any idea what I am doing wrong? What should I check to know where is difference between using opengl+shader in nVidia and in Radeon? Can it be the problem of shaders? (all are in defaultData of game, some can look stragne because of shader-merging system, but it works fine).

Oh and: I dont get any Opengl/Shader compile errors what is so strange too.
If I helped you rate me
Advertisement
As a guess it's because you're mixing old-style vertex shader inputs (gl_MultiTexCoord0) with new-style user-defined inputs (in_Position). You should be using one or the other, not both, and NVIDIA is known to be permissive about this kind of thing (even when it violates the spec).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Hi!

I've seen issues with attribute locations on ATI cards, while it just worked fine on Nvidia. If you've done something wrong here, ATI drivers will be silent, while Nvidia drivers will figure out something approriate.
Attribute locations connect the vertex attributes passed in to the variable names in your shader code. Before linking it goes like this:
glBindAttribLocation(myProgram, 0, "in_Position");
This connects the first vertex attribute (0) to the shader variable "in_Position".

(If you use GLSL > #330 you can specify them explicitly in the shader code. That's what I always do.)
layout(location = 0) in vec3 in_Position;
EDIT: The "in" belongs behind the layout. (Nvidia doesn't seem to care, but Radeon does. :))

There is a third way to get the binding location after linking but I wouldn't recommend it, since this means you have to tailor your VAO attributes so that they fit the expectations of the shader... which is problematic if you have two different shaders which should render the same geometry. Because it could mean you need a VAO for each shader...

But still, as mhagain said, it could as well be because of mixing fixed function stuff with user-defined inputs. It's not a good idea to mix them. I'd suggest to fix this first and if it still doesn't work check whether you specified the binding locations correctly.

Cheers!

#version 120
...
gl_Position=vec4(in_Position.xy*2,0,1);
...
Oh and: I dont get any Opengl/Shader compile errors what is so strange too.

Odd.

[s]I am not 100% sure (have not used glsl v120 for a very-very long time), but the position line should be invalid (it is not invalid since v300, i think). It should be written as "... .xy*2.0,0.0,1.0);". Common error from old days (NV did base its glsl implementation on its CG work and largely ignores the finer points of the specification). Worth a check me thinks.[/s]

Also, compilation error might have been postponed to linking time (doubtful for this particular error tho) - so, did you check for linker errors?

edit: i was a bit annoyed that i can not remeber when the int/float nonsense got fixed in glsl - and after a bit of digging ... not sure when, but it is OK at least in 120 (http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf section 4.1.10). So, nevermind that.
Tsus u are right. I've checked that if i get attribute exactly before redner and set it into VAO i get good render in radeon. But it's unusefull in real time. I thin I'll use this layout-location code. Than you all so much.
If I helped you rate me
I'm trying to use laoyut + location but radeon gives error:
Shader compilation: Vertex shader failed to compile with the following errors:
ERROR: 0:4: error(#132) Syntax error: 'layout' parse error
ERROR: error(#273) 1 compilation errors. No code generated[/quote]
This error is for example here:

//VERT:
#version 330

in layout(location = 0) vec2 in_Position;
in layout(location = 1) vec2 in_TexCoord;
uniform mat4 modelViewProjectionMatrix;
out vec2 txCoord;
void main()
{

txCoord = in_TexCoord;
gl_Position= modelViewProjectionMatrix*vec4(in_Position,0,1);
}
//FRAG:
#version 330
in vec2 txCoord;
uniform sampler2D tex;
void main()
{
gl_FragColor=texture2D( tex, txCoord );
}

What am I doing wrong? And why NV doesn't get any error?
If I helped you rate me
According to this site it is:
layout(location = 0) in vec3 in_Position;
The "in" belongs behind the layout... sorry for the inconvenience.
I don't have a Radeon at hand to test it on, but I think this is the problem.
yes thats right, I have noticed this after writting last post :) Thank you so much for help. These layout location is so useful thing:)
If I helped you rate me

This topic is closed to new replies.

Advertisement