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:

[li][shader] glLinkProgram(…);[/li][li][shader] glUseProgram(…);[/li][li][shader] set Uniform Buffer Object with some data[/li][li]for each Mesh do…[/li][LIST=1]
[li][texture] glActiveTexture(…);[/li][li][texture] glBindTexture(…);[/li][li][texture] glUniform1i(…);[/li][li][texture] glBindSampler(…);[/li][li][vbo] glBindBuffer(GL_ARRAY_BUFFER…);[/li][li][vbo] glEnableVertexAttribArray(…);[/li][li][vbo] glVertexAttribPointer(…);[/li][li][vbo] glDrawInstanced(…);[/li][/ol]


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!

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.

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?