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 3 of 3

Thread: Shaders and Texture func call overhead?

  1. #1
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    51

    Shaders and Texture func call overhead?

    I'm trying to well merge all separated parts I've developed and tested one by one separately.
    I'm in trouble during Rendering() pass. Deeply I need to "re-order" some functions call to avoid overhead of useless functions.

    My rendering function calls are:

    1. [shader] glLinkProgram(...);
    2. [shader] glUseProgram(...);
    3. [shader] set Uniform Buffer Object with some data
    4. for each Mesh do...
      1. [texture] glActiveTexture(...);
      2. [texture] glBindTexture(...);
      3. [texture] glUniform1i(...);
      4. [texture] glBindSampler(...);
      5. [vbo] glBindBuffer(GL_ARRAY_BUFFER...);
      6. [vbo] glEnableVertexAttribArray(...);
      7. [vbo] glVertexAttribPointer(...);
      8. [vbo] glDrawInstanced(...);

    5. end_for;


    I was wondering if I could remove latest 2 [texture] calls.
    I think it's useless to bind together Samplers and Textures each loop cycle.
    This binding is static and it doesn't change.

    Is it possibile to do something to avoid few function calls?
    Thanks for your help!

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    This binding is static and it doesn't change.
    If it doesn't change, why do you call the functions?

    Is it possibile to do something to avoid few function calls?
    The simple rule is: if you don't need to modify GL state, just don't.

  3. #3
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    51
    The binding is static/fixed but I need to call it at least one time to create their "relationship"....but when I should call it?
    Online I've found I need to bind Samples-to-Textures when I change ShaderProgram....in another website I've found the opposite...so I'm a bit confused.

    Logically it became useless to bind same things at every frame/loop. VBOs needs to be binded at every frame because I need to "select" what "model" to render, but this special Sampler-Texture binding is something like to a Parameter: fixed until I want to change it.

    So, where I should need to call this fixed binding?

Posting Permissions

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