Is there an effect not to use an activated attribute?

Should I disable shader attributes when switching to a shader for a program that uses fewer (or different locations) attributes?

I enable and disable these attributes with glEnableVertexAttribArray () / glDisableVertexAttribArray ().

Is there any performance impact, or some errors may be caused, or will enabling / disabling be slower than activating all attributes and activating them?

+4
source share
1 answer

The OP most likely already understands the first part, but let me just repeat some points of the vertex attributes to establish the basis for the more interesting part. I assume that all vertex data comes from buffers, rather than talking about where type calls are used to call "constant" values ​​for attributes glVertexAttrib3f().

  • The calls glEnableVertexAttribArray()both glVertexAttribPointer()determine which vertex attributes are included, and describe how the GPU should retrieve their values. This includes their location in memory, the number of components, their type, pitch, etc. In the remainder of this answer, I will call the collected state indicated by these calls the "vertex attribute state".
  • . (VAO) . , . VAO , , .
  • attribute/in , in. , in. .

, , in . , . , , , glEnableVertexAttribArray() VAO, .

, , : , ?

, . , , . . , , .

? , . :

  • A , .
  • B , . , .

A, . .

B . , / . , , , . , / , , . .

, , . , . , , , , . , , , , .

, , . , , . . , , . , VAO, glBindVertexArray(), / API.

+5

All Articles