title: DX11 minimum buffer sizes
body: <p>After creating a few constant buffers, some of them started to not initialize correctly.</p>
  
  <p>A constant buffer is created with a struct called MiscStream, which is defined:</p>
  
  <pre><code>struct MiscStream {
      int rw,rh;
      float shine_factor;
      float dist_factor;
      int random_number;
  };
  </code></pre>
  
  <p>And initialized with:</p>
  
  <pre><code>D3D11_BUFFER_DESC dx_misc_buffer_desc;
  ID3D11Buffer* dx_misc_buffer;
  
  ZeroMemory(&amp;dx_misc_buffer_desc,sizeof dx_misc_buffer_desc);
  
      dx_misc_buffer_desc.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
      dx_misc_buffer_desc.Usage=D3D11_USAGE_DYNAMIC;
      dx_misc_buffer_desc.ByteWidth=sizeof(MiscStream);
      dx_misc_buffer_desc.StructureByteStride=0;
      dx_misc_buffer_desc.CPUAccessFlags=D3D11_CPU_ACCESS_WRITE;
      dx_misc_buffer_desc.MiscFlags=0;
  
  hr=dx_device-&gt;CreateBuffer(&amp;dx_misc_buffer_desc,NULL,&amp;dx_misc_buffer);
  </code></pre>
  
  <p>hr would be returned as E_INVALIDARG, and the program would fail.</p>
  
  <p>Many of the other constant buffers are set up this way, but they all had vectors and matrices in their structures.</p>
  
  <p>I changed the MiscStruct to</p>
  
  <pre><code>struct MiscStream {
      D3DXVECTOR3 __r;
      int rw,rh;
      float shine_factor;
      float dist_factor;
      int random_number;
  };
  </code></pre>
  
  <p>And it worked without error.</p>
  
  <p>Is there a minimum structure size?
  What is happening?</p>