Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Works on nVidia, but not ATI

  1. #1
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    6

    Works on nVidia, but not ATI

    Hi! I am makin an OpenGL game framework in C#, and I just switched to clean OpenGL 3.2 and removed all fixed functionality. This works just fine on my GeForce 9800, but not at all on ATI Radeon 5770.

    The issue seems to be shader related, but compilation and linking is successfull, and glValidate returns all okay. GetLocation functions returns expected values, but nothing appears when rendering.

    Has anyone encountered a similar issue? I think it must be some issue with glUniform or glAttribPointer, but I have no idea what.

    Familiar to anyone?

  2. #2
    Member Regular Contributor DmitryM's Avatar
    Join Date
    Mar 2009
    Location
    Toronto
    Posts
    435

    Re: Works on nVidia, but not ATI

    Nop, many of us have GL 3.2 working (almost) fine on ATI, including me.
    You are probably doing something wrong.

  3. #3
    Junior Member Newbie OpenGLPrgrmr's Avatar
    Join Date
    Feb 2005
    Location
    America
    Posts
    3

    Re: Works on nVidia, but not ATI

    If you're using a Core/Forward-Compatible context, it's likely you're using something that was removed. Nvidia isn't as strict in catching these as ATI is.

    Try the AMD_debug_output extension, it should return anything it's having a problem with.

  4. #4
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    6

    Re: Works on nVidia, but not ATI

    Yeah, I guess I am doing something wrong, but there is so little code that can actually go wrong... I could try to disable the core profile and see if that is the issue.

    Also I'll look into the AMD_debug_output extension, thanks

  5. #5
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    934

    Re: Works on nVidia, but not ATI

    Be worry, nVidia has a "it always works" policy in their drivers which is fine while working only on nVidia but you may have written OpenGL code which is not conform which won't work on AMD. It doesn't mean that AMD drivers doesn't have bugs!
    Good luck!

  6. #6
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    6

    Re: Works on nVidia, but not ATI

    GL_AMD_debug_output didn't tell me anything, but glGetError() after glDrawElements returned GL_INVALID_OPERATION, which seems to point to that there is an issue with the buffers, and vertex attribute binding, not with the shaders.

    I'm still stumped on this though.

    What I basicly do, is create the buffers, fill them with data using BufferData, and then for every object this happens (i.e. SetVertexBuffer is called, and then SetIndexBuffer):

    Code :
    public void SetVertexBuffer(OpenGL.IVertexBuffer vert)
    {
    	if (vertex_buffer != null)
    		vertex_buffer.MakeNonCurrent();
    	if (vert != null)
    	{
    		// Apply shader attributes for this vertex buffer
    		if(active_shader != null && active_shader is StdMaterial)
    			vert.ApplyStdMaterial(active_shader as StdMaterial);
    		// Bind vertex buffer
    		vert.MakeCurrent();
    	}
    	vertex_buffer = vert;
    }
     
    public void SetIndexBuffer(OpenGL.IIndexBuffer indices)
    {
    	if (index_buffer != null)
    		index_buffer.MakeNonCurrent();
    	if (indices != null)
    		indices.MakeCurrent();
    	index_buffer = indices;
    }

    {VertexBuffer<T>}.MakeCurrent() does this:
    Code :
    public override void MakeCurrent()
    {
    	base.MakeCurrent();
     
    	for (int i = 0; i < elements.Count; i++)
    	{
    		if (elements[i].attribute != 0xffffffff)
    		{
    			OpenGL.glEnableVertexAttribArray(elements[i].attribute);
    			if(elements[i].gl_type == OpenGL.Const.GL_INT)
    				OpenGL.glVertexAttribIPointer(elements[i].attribute, elements[i].dimensions, elements[i].gl_type, size_of_t, elements[i].offset_value);
    			else 
    				OpenGL.glVertexAttribPointer(elements[i].attribute, elements[i].dimensions, elements[i].gl_type, OpenGL.boolean.FALSE, size_of_t, elements[i].offset_value);
    		}
    	}
    }
    where base.MakeCurrent() basicly calls glBindBuffer(). Where target for vertex buffers is GL_ARRAY_BUFFER, and GL_ELEMENT_ARRAY_BUFFER for index buffers.

    elements[i].attribute is retrieved from the shader earlier in the Draw() function.

    Can anyone point out something obvious here? I'm pulling my hair over this.

  7. #7
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    934

    Re: Works on nVidia, but not ATI

    You must use a Vertex Array Object.

    The default VAO has been deprecated...

  8. #8
    Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    293

    Re: Works on nVidia, but not ATI

    i was just about to write the same under the assumption you are on a GL 3.2 core profile (forward compatible flag?) context. i tried to quickly look up the deprecation of the default VAO in the spec but did not find it... Groovounet do you have the reference in the spec?

    Edit, found it:

    OpenGL 3.2 spec, chapter E.2.2 Removed Features
    Client vertex and index arrays - all vertex array attribute and element array index pointers must refer to buffer objects. The default vertex array object (the name zero) is also deprecated. Calling VertexAttribPointer when no buffer object or no vertex array object is bound will generate an INVALID_OPERATION error, as will calling any array drawing command when no vertex array object is bound.

  9. #9
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    6

    Re: Works on nVidia, but not ATI

    I should probably have mentioned that base.MakeCurrent() calls glBindBuffer(target, handle); where target is GL_ARRAY_BUFFER for VB and GL_ELEMENT_ARRAY_BUFFER for IB.
    Vertex buffer and IndexBuffer inherits from BufferObject<T> which contains this behavior.

    ApplyStdMaterial assigns element[i].attribute.

    The offset value is a pointer to the first element in the structure, and not a real pointer. Maybe this is the wrong way to do it?

    Here is a OpenGL Call only list of what happens in a normal draw operation:
    Code :
    glUseProgram(4);
    glBindFragDataLocation(4, 1, "out_frag");
    glBindBuffer(GL_ARRAY_BUFFER, 2);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, OpenGL.boolean.FALSE, 32, 0);
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, 3, GL_FLOAT, OpenGL.boolean.FALSE, 32, 12);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 3);
    glDrawElements(GL_TRIANGLES, 384, GL_UNSIGNED_INT, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glUseProgram(0);

    Here is the structure in use:
    Code :
    public struct VertexPositionTexCoordNormal
    {
    	public Vector3 Position;
    	public Vector3 Normal;
    	public Vector2 TexCoord;
     
    	public static readonly VertexBufferDescriptor Descriptor = new VertexBufferDescriptor(
    		new ElementType[] 
    		{
    			ElementType.Position3Float,
    			ElementType.Normal3Float,
    			ElementType.TexCoord2Float
    		}, typeof(VertexPositionTexCoordNormal));
     
    }

    This would be so much easier if I had an ATI card.

    Thanks for all suggestions so far

  10. #10
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    450

    Re: Works on nVidia, but not ATI

    does putting
    Code :
    glGenVertexArrays(1, &amp;vaoID);
    glBindVertexArray(vaoID);
    before your code solve the problem? If so it's because the default VAO (the VAO named 0) has been deprecated as Groovounet mentioned. NVidia still allows it to be used without throwing the required errors, but ATI doesn't allow it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •