title: opengl 4.3 compute shader not writing value to buffer
body: <p>I am having a weird problem with compute shaders since I changed the structure size of a buffer I was passing in to the shader. </p>
  
  <pre><code>struct Particle
  {
      vec3 position;
      vec2 uv;
      vec3 accumulated_normal;
      int id;
      int flattened_id;
      int movable;
      // can the particle move or not ? used to pin parts of the cloth
      float mass;
      // the mass of the particle (is always 1 in this example)
      vec3 old_pos;
      // the position of the particle in the previous time step, used as part of the verlet numerical integration scheme
      vec3 acceleration;
      // a vector representing the current acceleration of the particle
  };
  </code></pre>
  
  <p>Defined like this. I was having problems trying to use the flattened id so I wanted to write the id's back to the buffer I was passing in. The shader looks something like this.</p>
  
  <pre><code>layout (local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
  
  void main()
  {
      unsigned int flattened_id = gl_LocalInvocationIndex;
  
      particleBuffer.particles[0].id = 16;
      particleBuffer.particles[1].id = 17;
      particleBuffer.particles[2].id = 18;
      particleBuffer.particles[3].id = 19;
      //particleBuffer.particles[4].id = 20;
  }
  </code></pre>
  
  <p>So till this point it is fine but the moment I uncomment the last line which is the particleBuffer.particles[4], the mesh vanishes from the screen. I have managed to change the position data from this mesh before but this seems strange. I verified that I have indeed 16 elements of the buffer which I am passing in so it should not go out of bounds either (i.e. cloth1.particles.size() = 16). Any ideas ?? 
  The entire code is here..
  <a href="https://github.com/ssarangi/OpenGL_Cloth/tree/master/cloth_4_3_compute" rel="nofollow">https://github.com/ssarangi/OpenGL_Cloth/tree/master/cloth_4_3_compute</a></p>
  
  <pre><code>glUseProgram(computeShader);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, cloth1.vertex_vbo_storage);
  glBufferData(GL_SHADER_STORAGE_BUFFER, cloth1.particles.size() * sizeof(Particle), &amp;(cloth1.particles[0]), GL_DYNAMIC_COPY);
  
  glDispatchCompute(1, 1, 1);
  
  {
      GLenum err = gl3wGetError();
  }
  
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
  
  glBindBuffer(GL_ARRAY_BUFFER, cloth1.vertex_vbo_storage);
  Particle * ptr = reinterpret_cast&lt;Particle *&gt;(glMapBufferRange(GL_ARRAY_BUFFER, 0, cloth1.particles.size() * sizeof(Particle), GL_MAP_READ_BIT));
  
  memcpy(&amp;cloth1.particles[0], ptr, cloth1.particles.size()*sizeof(Particle));
  glUnmapBuffer(GL_ARRAY_BUFFER);
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  </code></pre>
  
  <p><strong>***********************</strong> EDITED with Andon's comments <strong>******************************</strong>
  This is the new layout from the C++ side.</p>
  
  <pre><code>struct Particle
  {
      vec4 position;
      vec2 uv;
      vec4 accumulated_normal;
      vec4 old_pos; // the position of the particle in the previous time step, used as part of the verlet numerical integration scheme
      vec4 acceleration; // a vector representing the current acceleration of the particle
      int id;
      int flattened_id;
      int movable; // can the particle move or not ? used to pin parts of the cloth
      float mass; // the mass of the particle (is always 1 in this example)
  </code></pre>
  
  <p>The GLSL side definition. What I am unsure about is if the padding elements need to be included in the glsl structure or not. It still doesn't update the ID's.</p>
  
  <pre><code>struct Particle
  {
      vec4 position;
      vec2 uv;
      vec4 accumulated_normal;
      vec4 old_pos; // the position of the particle in the previous time step, used as part of the verlet numerical integration scheme
      vec4 acceleration; // a vector representing the current acceleration of the particle
      int id;
      int flattened_id;
      int movable; // can the particle move or not ? used to pin parts of the cloth
      float mass; // the mass of the particle (is always 1 in this example)
  };
  </code></pre>