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 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: Gemotry Pass to cullin & Transform Feeedback Buffers

  1. #21
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,598
    Quote Originally Posted by martel View Post
    IT WORKS!!! IT WORKS!!!
    Sweet!

    But doing tests only works for the stream 0, would you tell me what would be the logic for N streams? (now I was trying to capture 2 streams in to 2 querys objects)
    It's just a small variation on the same theme.

    If you're writing to multiple streams with TF, you can query the GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN counts separately for each stream by having an active query object per stream. Start/stop the queries with glBeginQueryIndexed and glEndQueryIndexed. Then query the result as usual:

    Code cpp:
      // Generate queries to determine how many entries written
      GLuint outquery[ TF_NUM_OUT ];
      glGenQueries( TF_NUM_OUT, outquery );
      for ( int i = 0; i < TF_NUM_OUT; i++ )
        glBeginQueryIndexed( GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, i, outquery[i] );
     
      // --- EXECUTE TRANSFORM FEEDBACK RUN WRITING TO MULTIPLE STREAMS HERE ---
     
      // Query/print how many entries written
      GLint counts[ TF_NUM_OUT ];
      for ( int i = 0; i < TF_NUM_OUT; i++ )
      {
        glEndQueryIndexed ( GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, i );
        glGetQueryObjectiv( outquery[i], GL_QUERY_RESULT, &counts[i] );
        printf( "Num primitives written for output %d = %d\n", i, counts[i] );
      }
      glDeleteQueries( TF_NUM_OUT, outquery );

    This is copy/paste from some old standalone example code I whipped up years ago which reads back the primitives written to the CPU in a counts[] array.

    To change this to use ARB_query_buffer_object, just make the trivial change to bind the drawIndirectBuffer to GL_QUERY_BUFFER before calling glGetQueryObjectuiv to fetch the result into the specified offset of the bound buffer, rather than calling glGetQueryObjectiv as I do here to query the result into a CPU-side counts[] array.

    This same code was in the example source:


    I pointed you to above by the way.
    Last edited by Dark Photon; 09-30-2018 at 03:18 PM.

  2. #22
    Junior Member Newbie
    Join Date
    Dec 2017
    Posts
    21
    Excellent! next step : build INDIRECT_BUFFER to do all in one single draw call : glMultiDrawElementsIndirect()

Posting Permissions

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