How vertex shader operates on vertices?

Hi,

Does the vertex shader operates on each vertices consequently or operates on every vertices at one time? This question is related with the glVertexAttribPointer().

Let’s say I sent bunch of data into the VBO. I use glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0) to tell the openGL what format is our vertex array data in the buffer object is stored in and how to interpret the array of data stored in the buffer.

Let’s say I have 5 vertices here,

When I input the value to the vertex shader, what will it pass to the vertex shader? In this example, 4 values of each vertices will be passed to the vertex shader?Or every 4 values of every 5 vertices will be passed to vertex shader?

So, vertex shader operates on each vertices accordingly or 5 vertices at one time? Quite confusing here…More explanation required… =.=

Confused about your confusion…
Do this makes any difference for you ?

Because what actually happens is both complex and dependent on the hardware. Typically lots of ’ vertex threads’ will work in parallel using the same vertex shader code, each with all the values needed for one vertex.

Ya.This is what I want. If the vertex shader cannot operates on every vertices in parallel, then I cannot use this method already. Can give some examples of ‘vertex threads’?

I am going to write a vertex shader but I want it to operates on every vertices in parallel using the same code. Means different vertex data will pass to the vertex shader.

So I restate what I meant above :

You have absolutely NO CONTROL on this.
Just do your vertex shader.

It’s confusing what you’re really asking here.

Do you mean can a vertex shader execute in parallel? If so, yes, but each individual instance of the shader can only operate on one vertex.

Do you mean can a single vertex shader operate on more than one vertex? If so, no.

The vertex shader will work in parallel on each vertex that u push into the vertex stream.

So, you means I can create as many vertex shader as I can? And these vertex shader can executes in parallel? But not a vertex shader executes on every vertex in parallel?

Can explain further? I am not sure that u r talking exactly the same with mhagain?

Can explain further? I am not sure that u r talking exactly the same with mhagain?

It’s really very simple. A vertex shader is a relatively short program that is given a series of inputs, called vertex attributes. Each set of attributes represents a single vertex in the mesh. The job of the vertex shader is to output values based on those vertex attributes and parameters (called uniforms) that have been set by the outside world. So one vertex in, one vertex out.

Because the execution of each vertex shader is dependent only on its input parameters (within the scope of a single glDraw* call), the hardware is given the freedom to run multiple instances of a vertex shader simultaneously. This does not mean that any particular number of them will be run simultaneously at any particular time; that depends on how the driver decides to schedule resources. What matters is that this happens “fast”.

Okay…It means that there is a scheduling algorithm inside the GPU to schedule how to execute the vertex shader? By the way, is the maximum number of attributes that each vertex can possess is 4 only?

Okay…It means that there is a scheduling algorithm inside the GPU to schedule how to execute the vertex shader?

Scheduling happens. Whether it’s on the GPU, CPU, or some combination of the two is an implementation detail.

By the way, is the maximum number of attributes that each vertex can possess is 4 only?

I’m fairly sure I answered this already. I have no idea where you got 4 from.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.