0
\$\begingroup\$

I am now doing some optimization for rendering process. I notice that in my game some objects is totally static and never changed.

In my old way, I will create a uniform buffer every frame, and put variables in it, such as objectToWorldMatrix, LightData etc. Then use glBindBufferBase to bind buffer to right slot. The glBindBufferBase cost 0.03ms ~ 0.05ms for 376 objects.

In my new way, I will cache the uniform buffer and just use glBindBufferBase to bind my cached buffer every frame. The glBindBufferBase will cost 0.13ms ~ 0.21ms for 376 objects.

The results is so weird. Why are costs of glBindBufferBase different? Did I miss some special optimization for new created buffer?

Furthermore, Do I need to call glBindBufferBase in every frame if the buffer is constant? Some people say OpenGL is a state machine and setting will not be changed unless you change it. However, I found if I just set it once, my objects would not be rendered.

The results is so weird. Why are costs of glBindBufferBase different? Did I miss some special optimization for new created buffer?

Furthermore, Do I need to call glBindBufferBase in every frame if the buffer is constant? Some people say OpenGL is a state machine and setting will not be changed unless you change it. However, I found if I just set it once, my objects would not be rendered.

\$\endgroup\$
1
  • \$\begingroup\$ I found that if I do Map/Unmap before glBindBufferBase, I can get some perfomance boost? But why? \$\endgroup\$ Oct 8 '21 at 2:21

You must log in to answer this question.

Browse other questions tagged .