title: Metal/Metal2 + Swift: How to pass complex Swift structure as shader argument?
body: <p>I have a struct in Metal:</p>
  
  <pre><code>struct BlurDesc {
      short fenceRows;
      short offs;
      short sampleCnt;
      float muls[64];
  };
  </code></pre>
  
  <p>It is used as a shader argument:</p>
  
  <pre><code>kernel void hBlurCompute(
      constant BlurDesc &amp; blurDesc [[ buffer(0) ]],
      texture2d&lt;half, access::read&gt; srcTexture [[ texture(0) ]],
      texture2d&lt;half, access::write&gt; hBlurTexture [[ texture(1) ]],
      ushort gid [[ thread_position_in_grid ]]
  ) {
  </code></pre>
  
  <p>Here is the corresponding Swift struct:</p>
  
  <pre><code>struct BlurDesc {
      var fenceRows : Int16 = 0
      var offs : Int16 = -32
      var sampleCnt : Int16 = 64
      let muls = Array&lt;Float&gt;(repeating: (1.0/64), count: 64)
  }
  
  var blurDesc = BlurDesc()
  </code></pre>
  
  <p>How can I pass the Swift struct to the shader as argument?</p>
  
  <p>Is it possible to create a byte buffer from it with the right byte order and pass it to: <em>MTLDevice.makeBuffer(bytes pointer: UnsafeRawPointer, length: Int, options: MTLResourceOptions = [])</em> somehow?</p>