Fix some synchronization flaws

- shader: add barrier at the end of each iteration to avoid writing before the reading finished
- cpp: add synchronization between compute and graphics, the image barrier is not enough for the data visibility between different submission

	modified:   data/shaders/computenbody/particle_calculate.comp
	modified:   data/shaders/computenbody/particle_calculate.comp.spv
	modified:   examples/computenbody/computenbody.cpp
This commit is contained in:
JC Liang 2019-06-17 19:31:00 +08:00
parent b2add91d2c
commit b575a1ff1a
3 changed files with 50 additions and 17 deletions

View file

@ -62,6 +62,9 @@ void main()
vec3 len = other.xyz - position.xyz;
acceleration.xyz += GRAVITY * len * other.w / pow(dot(len, len) + SOFTEN, POWER);
}
memoryBarrierShared();
barrier();
}
particles[index].vel.xyz += ubo.deltaT * acceleration.xyz;