Compute shader layout buffer always return 0


#1

Hi, i’m trying to modify computerShaderParticlesExample from 9.8 version to add new layout buffer.
I’m trying to do it using the same approach like in first buffer “particles”.
I’ve added structure to shader and App.h

struct Particle2 {
			float px;
			float py;
};

Also modfied shader

layout(std140, binding=2) buffer dataTex{
	Particle2 ptest[];
};

And change binding of indices from 2 to 3

layout(std140, binding=3) buffer indices{
	uint idx[];
};

The main fuction. i want to get value of this data and to use it. in current case alwaws first value for simplicity.

 void main(){    
        float d = ptest[0].px;
	float dy = ptest[0].py;
	vec3 poss = vec3(d, dy, 88.0);
        p[gl_GlobalInvocationID.x].pos.xyz = poss;
	p[gl_GlobalInvocationID.x].vel.xyz = poss;
	p[gl_GlobalInvocationID.x].color.rgb = poss;
	p[gl_GlobalInvocationID.x].color.a = 0.4;
}

The App.c had modfied by adding in setup:

        particles2.resize(1024 * 8);
	particles2[0].px = 200;
	particles2[0].py = 400;
        tttDataBuffer.allocate(particles2, GL_DYNAMIC_DRAW);
	vbo.setVertexBuffer(tttDataBuffer, 4, sizeof(Particle2));
        ..... (code from example)
        tttDataBuffer.bindBase(GL_SHADER_STORAGE_BUFFER, 2);

I’m expecting that all points will be located at (200, 400) but in reality all of them in (0,0).
It’s the simplest modification that not work.(i’ve laso tried to to it using only vector without structure directly and using uniform sampler2DRect backbuffer, but in this cases i can get only first float value, second and another values always the same as first in shader.
So what i do wrong in this simliest modification?

Thank you for this great framework.


#2

I’ve commented “vbo.setVertexBuffer(tttDataBuffer, 4, sizeof(Particle2));”
And everything works