title: Format conversions in OpenGL images
body: <p>It seems like I am completely confused by OpenGL format conversions related to image load/store.
  I came from DX world, where things are relatively clear. For example: </p>
  
  <ol>
  <li>You create a texture with some specific format (say <code>RGBA32_FLOAT</code>)</li>
  <li>You declare an RW texture in your shader <code>RWTexture2D&lt;float4&gt;</code> that matches the format</li>
  <li>You read/write to/from texture</li>
  </ol>
  
  <p>You can also bind say <code>RGBA8_UNORM</code>texture to <code>RWTexture2D&lt;float4&gt;</code> and DirectX will perform format conversion in an obvious and clear way.</p>
  
  <p>Now say I want to do the same thing in OpenGL. So I</p>
  
  <ol>
  <li>Create GL texture with GL_RGBA32F internal format </li>
  <li>In my shader, I declare <code>layout(rgba32f) uniform image2D myImg;</code></li>
  <li>I bind my texture to image in shader with <code>glBindImageTexture( ..., GL_RGBA32F);</code></li>
  </ol>
  
  <p>So I counted four places where I specify the format: </p>
  
  <ol>
  <li>When I create the texture</li>
  <li><p>Two times when I declare image unit:</p>
  
  <ul>
  <li><code>layout(rgba32f)</code></li>
  <li><code>image2D</code> itself tells me that all load/store operations will take <code>vec4</code> (not <code>ivec4</code> or <code>uvec4</code>)</li>
  </ul></li>
  <li><p>When I bind image with <code>glBindImageTexture</code></p></li>
  </ol>
  
  <p>I cannot understand what is the purpose of <code>layout(rgba32f)</code>, which seems totally redundant. It seems that knowing internal texture format is enough to perform all format conversions. What layout do I need to specify if my internal texture format is normalized <code>RGBA8</code> and image is defined as <code>uniform image2D myImg;</code>? And why do I need to specify the layout at all, isn't it clear what kind of format conversions should be performed? 
  The only idea I have that justifies these layouts is to perform data reinterpretation like writing raw <code>RGBA32F</code> data to <code>RGBA32U</code> texture, which does not seem to be very useful for me. Besides, you have functions like <code>floatBitsToInt()</code> that do that work. </p>
  
  <p>What is the purpose of passing the format to <code>glBindImageTexture</code> is a complete mystery for me.</p>
  
  <p>So all these layouts is a huge source of confusion for me. Could you please help me better understand the reasoning behind them?</p>