aconstlink / motor

Software Framework for Audio/Visual/Interactive Real-Time Applications
MIT License
1 stars 0 forks source link

gl4 binding attributes error with msl #53

Closed aconstlink closed 4 months ago

aconstlink commented 4 months ago

When using streamout/transform feedback, the order of the vertex buffer attributes seem to violate the order of bound location.

For example,

in vec4_t pos ;
in vec4_t color ;

at program linkage those variables are coming in the opposite order but the locations are correct. glGetActiveAttrib gives the order color then pos like so

for( active attributs )
glGetActiveAttrib

0 -> color with location 1 1 -> pos with location 0

The violation is that somehow now the color in the vertex buffer is getting bound to pos in the shader.

In the test scenario, there is only one shader used which is the transform feedback test shader.

aconstlink commented 4 months ago

Here it comes.

The problem is when a geometry object is used with multiple shaders, even is only one shader is uesed, where the vertex array object stores the bindings and in the second shader compiled, does not use an attribute, so the binding is invalidated and removed from the vertex array object.

There is only one solution to this. vertex array objects need to be stored per render object. A render object requires a shader and a geometry to work. So the binding of the vertex buffer attribute to the shader location should be stored there.