Jump to content

  • Log In with Google      Sign In   
  • Create Account


Radeon vs nVidia rendering - game issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 March 2012 - 01:38 PM

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

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7654

Like
1Likes
Like

Posted 18 March 2012 - 03:59 PM

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).

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Tsus   Members   -  Reputation: 1011

Like
2Likes
Like

Posted 18 March 2012 - 04:31 PM

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!

Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)


#4 tanzanite7   Members   -  Reputation: 1204

Like
0Likes
Like

Posted 20 March 2012 - 12:42 AM

#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.

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.

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.

#5 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 20 March 2012 - 01:46 PM

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

#6 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 21 March 2012 - 01:15 PM

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

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

#7 Tsus   Members   -  Reputation: 1011

Like
0Likes
Like

Posted 21 March 2012 - 02:34 PM

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.

Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)


#8 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 23 March 2012 - 12:42 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS