title: imageStore() doesn't work with integer types
body: <p>I bind a texture to both a texture unit and a image unit, write to it via <code>imageStore()</code> in the compute shader, and sample it with a <code>sampler2D</code> in the fragment shader.</p>
  
  <p>This works when the pixel format is floating point, but stops working with integers. <code>glGetError()</code> yields nothing.</p>
  
  <p><code>glew</code> and <code>glm</code> are used; should be irrelevant to the problem though.</p>
  
  <p>main.cpp:</p>
  
  <pre><code>constexpr glm::vec2 TEX_DIM = { 2048.0f, 2048.0f / ASPECT_RATIO };
  constexpr int LOCAL_WORKGROUP_SIZE = 32;
  
  // After setting up vbo, etc //////////
  
  // Texture
  
  const unsigned int texSlot = 0;
  unsigned int texId;
  
  glGenTextures(1, &amp;texId);
  glBindTexture(GL_TEXTURE_2D, texId);
  
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  
  glBindTexture(GL_TEXTURE_2D, 0);
  
  glActiveTexture(GL_TEXTURE0 + texSlot);
  glBindTexture(GL_TEXTURE_2D, texId);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, int(TEX_DIM.x), int(TEX_DIM.y), 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
  
  // Binding to image unit
  
  const unsigned int imageSlot = 0;
  glBindImageTexture(imageSlot, texId, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R8);
  
  // Shaders
  
  unsigned int computeShader;
  unsigned int graphicsShader;
  
  // After creating shaders //////////
  
  // Graphics shader
  
  glUseProgram(graphicsShader);
  glUniform1i(glGetUniformLocation(graphicsShader, "uTexture"), texSlot);
  glUniformMatrix4fv(glGetUniformLocation(graphicsShader, "uMVP"), 1, GL_FALSE, &amp;mvp);
  
  auto mvp = glm::ortho(0.0f, (float)WINDOW_WIDTH, 0.0f, (float)WINDOW_HEIGHT, -1.0f, 1.0f);
  
  // Compute shader
  
  glUseProgram(computeShader);
  glUniform1i(glGetUniformLocation(computeShader, "uImage"), imageSlot);
  
  // After validating shaders //////////
  
  while (true)
  {
      // Compute
  
      glUseProgram(computeShader);
      glDispatchCompute(TEX_DIM.x / LOCAL_WORKGROUP_SIZE, TEX_DIM.y / LOCAL_WORKGROUP_SIZE, 1);
      glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
  
      // Draw
  
      glClear(GL_COLOR_BUFFER_BIT);
  
      glUseProgram(graphicsShader);
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
  
      glfwSwapBuffers(window);
  }
  </code></pre>
  
  <p>Compute Shader:</p>
  
  <pre class="lang-c prettyprint-override"><code># version 430 core
  
  layout(local_size_x = 32, local_size_y = 32) in;
  
  layout(r8) uniform image2D uImage;
  
  void main()
  {
      // Writing all to red, for testing purpose
      imageStore(uImage, ivec2(gl_GlobalInvocationID.xy), vec4(1.0, 0.0, 0.0, 0.0));
  }
  </code></pre>
  
  <p>Vertex Shader:</p>
  
  <pre class="lang-c prettyprint-override"><code># version 430 core
  
  layout(location = 0) in vec2 position;
  layout(location = 1) in vec2 texCoord;
  out vec2 vTexCoord;
  
  uniform mat4 uMVP;
  
  void main()
  {
      gl_Position = uMVP * vec4(position, 0.0, 1.0);
      vTexCoord = texCoord;
  }
  </code></pre>
  
  <p>Fragment Shader:</p>
  
  <pre class="lang-c prettyprint-override"><code># version 430 core
  
  in vec2 vTexCoord;
  out vec4 color;
  
  uniform sampler2D uTexture;
  
  void main()
  {
      color = vec4(
          texture(uTexture, vTexCoord).x,
          0.0, 0.0, 1.0
      );
  }
  </code></pre>
  
  <p>Below is my attempt to convert the minimal program to be using integers instead; gives me a black screen but no errors otherwize.</p>
  
  <p>main.cpp:</p>
  
  <pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, int(TEX_DIM.x), int(TEX_DIM.y), 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, nullptr);
  glBindImageTexture(imageSlot, texId, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R8UI);
  </code></pre>
  
  <p>Compute Shader:</p>
  
  <pre class="lang-c prettyprint-override"><code>layout(r8ui) uniform uimage2D uImage;
  
  void main()
  {
      // Writing all to red, for testing purpose
      imageStore(uImage, ivec2(gl_GlobalInvocationID.xy), uvec4(255, 0, 0, 0));
  }
  </code></pre>
  
  <p>Fragment Shader:</p>
  
  <pre class="lang-c prettyprint-override"><code>uniform usampler2D uTexture;
  
  void main()
  {
      color = vec4(
          float(texture(uTexture, vTexCoord).x) / 256.0,
          0.0, 0.0, 1.0
      );
  }
  </code></pre>
  
  <p>I've thought about <code>GL_R8UI</code> being incompatable but the <a href="https://www.khronos.org/opengl/wiki/Image_Load_Store" rel="nofollow noreferrer">wiki</a> says both <code>GL_R8</code> and <code>GL_R8UI</code> are fine to use.</p>