The key to determine the vertices

I am writing an opengl application, and for vertices, normals, and colors, I use separate buffers as follows:

GLuint vertex_buffer, normal_buffer, color_buffer;

My supervisor tells me that if I define a structure like:

struct vertex {
    glm::vec3 pos;
    glm::vec3 normal;
    glm::vec3 color;
};
GLuint vertex_buffer;

and then define a buffer for these vertices, my application will be much faster, because when the position is cached, the normals and colors will be in the cache line.

I believe that defining such a structure does not have such a big impact on performance, since defining a vertex, such as a structure, will reduce the number of vertices in the cache structure when defining them as separate buffers, will result in three different cache lines for positions, normals and flowers in cache. So, nothing has changed. It's true?

+3
3

, .

. ( ) ( , , ), VBOs ( !). :

enter image description here

, ​​.

( , !) - GPU, .

, :

:

  • GPU, . , , , . () - , / , , , . .

  • , , GPU. API .

  • , . / . , .

  • .

:

Vertex

+4

.

( , , )

, , . , , , , .

tl; dr "", .

+3

: " - " - . . " , " ".

?

, . ( 2000), . .

This is due to the way access to modern memory of GPUs, and in fact, modern cache lines of modern GPUs are not indexes at the memory address, but according to the access pattern (that is, the first separate memory access in the shader receives the first cache line, the second is the second line of the cache, etc.).

+2
source

All Articles