0

Are there critical performance differences between

GLuint vao[2];
glGenVertexArrays(2, &vao);

// and

GLuint vao1[1], vao2[1];
glGenVertexArrays(1, &vao1);
glGenVertexArrays(1, &vao2);

I think of course latter one would have bad performance but due to my shallow understanding, I don't know how much would it be and why it's bad.

Not knowing how much vao the program will hold and be generating, is the latter one proper way to generate new VAO, keep generating size-one buffer? (ex: in the constructer of class)

5
  • 1
    Why not GLuint vao1, vao2; glGenVertexArrays(1, &vao1); glGenVertexArrays(1, &vao2);? Commented Jun 7, 2021 at 12:59
  • It's up to the implementation how this is implemented. You might be able to answer this for a specific driver version on a specific GPU, but there will not be any general answer. Commented Jun 7, 2021 at 13:08
  • @Rabbid76 Ah, my mistake sorry, I'll fix it Commented Jun 7, 2021 at 13:09
  • @BDL I just got curious that is it okay to generate and keep my vao indices in non-linear memory space. I was not aware of it that even this would be affected my GPU driver. Commented Jun 7, 2021 at 13:10
  • @MyBug18: OpenGL is just a specification. You driver implements this specification. Unless the specification explicitly states how a method has to operate, it's up to the implementation (the driver) what it does. Commented Jun 7, 2021 at 13:31

1 Answer 1

1

You shound't imply those GLuint handles are stored in linear memory, and even if they are it doesn't mean the memory for objects those represent is continuous. It can be, or can be not during runtime, and it also depends on the access patterns you hint OpenGL when creating buffers. Graphic drivers do all that book keeping for you, including memory layout optimization. If you want to get an idea how drivers could potentially manage OpenGL objects and video memory, take a look at Vulkan API and best practices related to memory management. But again, in OpenGL you don't have that level of control.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.