Cost of updating uniforms in rendering ?

This topic contains 3 replies, has 2 voices, and was last updated by  WonwooLee 5 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30944

    WonwooLee
    Member
    Hello. 
    I’m writing a rendering routine, where uniform variables are frequently updated. 
    My code is something like this : 
    glUseProgram(id) ; // start shader 
    for(…) 
    {
       //Update uniforms
       glUniform… 
       glUniform…
       …
       // Render a scene 
       renderScene() ; 
       glUseProgram(0) ; // end shader 
    [/CODE]
    My questions are : 
    – Does this freqnent update of uniforms slow my rendering routine ? 
    – What is the cost of updating a uniform  ?  
    Thanks in advance. 

    [CODE]

    glUseProgram(id) ; // start shader 
    for(…) 
    {
       //Update uniforms
       glUniform… 
       glUniform…
       …
       // Render a scene 
       renderScene() ; 
       glUseProgram(0) ; // end shader 
    [/CODE]
    My questions are : 
    – Does this freqnent update of uniforms slow my rendering routine ? 
    – What is the cost of updating a uniform  ?  
    Thanks in advance. 
    #36064

    WonwooLee
    Member
    I missed a ‘}’ at the end of the code. 
    The code should be like this : 
    glUseProgram(id) ; // start shader 
    for(…) 
    {
       //Update uniforms
       glUniform… 
       glUniform…
       …
       // Render a scene 
       renderScene() ; 
    }
    glUseProgram(0) ; // end shader 
    [/CODE]

    [CODE]

    glUseProgram(id) ; // start shader 
    for(…) 
    {
       //Update uniforms
       glUniform… 
       glUniform…
       …
       // Render a scene 
       renderScene() ; 
    }
    glUseProgram(0) ; // end shader 
    [/CODE]
    #36065

    Arron
    Member

    Hi WonwooLee.

    The cost of updating uniforms is almost certainly minimal in comparison to other operations performed per-frame therefore I wouldn’t recommend spending time trying to ‘optimise’ this aspect unless you’ve profiled your application and determined that it is a bottleneck. However, this is very unlikely.
    #36066

    WonwooLee
    Member

    So, the operation may not bother my application.
    That’s a good news.

    Thanks !

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.