Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Problems with glVertexPointer

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Problems with glVertexPointer

    Hi

    Because of performance reasons i wanted to align my vertices to 32 bit. Therefore i did this:

    glVertexPointer (4, GL_FLOAT, 0, (GLvoid*) (pointer));

    But i only get a black screen. So i tried this:

    glVertexPointer (3, GL_FLOAT, sizeof (GL_FLOAT), (GLvoid*) (pointer));

    However now i get very interessting objects, but not those i intended to get. I even tried this:

    glVertexPointer (3, GL_FLOAT, 1, (GLvoid*) (pointer));

    Because i thought the stride might be in units of "type" (GL_FLOAT), instead of bytes, but the results are equally confusing.

    Has anyone ever had the same problems? Does glVertexPointer not support the stride parameter, or do i have to do something different?

    I know i loaded my data correctly into the memory. If i donīt align my data to 32 bit but only use 3 elements, the results are correct.
    I have a Geforce 2 with the latest drivers.

    And another interessting thing: If i use system-memory i get around 300 FPS (of course with not-aligned vertices). If i use VRAM without VAR, i get 100 FPS, if i use VRAM with VAR, i get 300 FPS. So using VRAM is terribly slow without VAR, but with VAR, it is only equally fast?? (I draw around 1000 triangles, at the moment, so will there be a difference, if i draw more?).

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  2. #2
    Intern Contributor
    Join Date
    Jan 2002
    Location
    Stockholm, Sweden
    Posts
    75

    Re: Problems with glVertexPointer

    VRAM without VAR. What is that? Do you mean you dont call glVertexArrayRangeNV on the pointer? VRAM == VAR.

    And why do you cast the pointer to (void*).
    float* pVRAM = (float*)wglAllocateMemoryNV(numfloats * sizeof(float), 0.0f, 0.0f, 1.0f);
    glVertexPointer(4, GL_FLOAT, 0, pVRAM);

    The reason you get same performance with and w/o VAR is probably beacuse you are not vertex limited == ýou have overperformance with too little work to do. In this case you might even get the same fps using glVertex();

    fritzlang

    [This message has been edited by fritzlang (edited 12-12-2002).]

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: Problems with glVertexPointer

    Originally posted by fritzlang:
    VRAM without VAR. What is that? Do you mean you dont call glVertexArrayRangeNV on the pointer? VRAM == VAR.

    And why do you cast the pointer to (void*).
    float* pVRAM = wglAllocateVRAM..bla..bla
    glVertexPointer(4, GL_FLOAT, 0, pVRAM);

    The reason you get same performance with and w/o VAR is probably beacuse you are not vertex limited == ýou have overperformance with too little work to do. In this case you might even get the same fps using glVertex();

    fritzlang

    Yes, i was not so sure, if VRAM and VAR HAVE to be use together, therefore i asked about it.

    The casting of the pointer doesnīt matter. I only casted it to (GLvoid*) because the function itself uses this type.

    I think you are right, 1000 triangles is not much work, good to see that my pc is so fast, that there is no difference at all.

    However i still donīt know how to use vertices that are aligned to 32 bit.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  4. #4
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Los Angeles, CA
    Posts
    208

    Re: Problems with glVertexPointer

    glVertexPointer(3, GL_FLOAT, 4 * sizeof(GLfloat), (GLvoid*)pointer);

  5. #5
    Intern Contributor
    Join Date
    Jan 2002
    Location
    Stockholm, Sweden
    Posts
    75

    Re: Problems with glVertexPointer

    Is there any point in aligning to 32bit?

    This is from the Nvidia Geforce3 faq:
    [quote]
    >In general, the smallest vertex size >possible should be used, as this helps AGP
    >bandwidth and your memory footprint. >Padding vertices to the next multiple of
    >32-bytes (so, a 40 byte vertex gets padded >to 64 bytes) can slightly improve
    >performance in the case of scattered memory >accesses, but roughly sequential
    <access will provide better performance and >eliminate the need to pad. In general,
    >padding is not recommended.

    Any experience on this? What's the most common case among you guys here?

    fritzlang

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Problems with glVertexPointer

    Both 3 floats, and 4 floats, are equally aligned on 32 bits.

    VAR has alignment restrictions that are, at a minimum, 32 bit aligned.

    If you're doing software processing, aligning so you can fit an even number of vertices in a cache line is beneficial.

    The argument for "stride" to glVertexPointer is the number of BYTES between each first element.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: Problems with glVertexPointer

    Originally posted by Coriolis:
    glVertexPointer(3, GL_FLOAT, 4 * sizeof(GLfloat), (GLvoid*)pointer);
    This works, at last. I always interpreted the stride value to be the number of bytes between the end of one vertex and the beginning of the next, not as the complete size of one vertex (does anyone understand this sentence?).

    I tested it and there was no difference in speed, although my 1000 triangle app is no good benchmark, of course ;-)

    Thanks, to all of you.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  8. #8
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Los Angeles, CA
    Posts
    208

    Re: Problems with glVertexPointer

    The documentation is a bit misleading when it says that "0 means tightly packed".

    When it says that vertex data should be aligned on a 32-bit boundary, that means the first vertex of the array, not every vertex in the array.

Posting Permissions

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