title: C++ type on GPU(Metal), how to save the type of another variable into a class, and make sure all the class instance have the same size?
body: <p>Pseudocode on CPU side:</p>
  <pre><code>class Sphere {
  //some property 
  }
  
  class Square {
  //some property
  }
  
  class BVH {
      Type type; // save the type of Sphere or Square, or other types.
      // But the instance of this class should maintain the same size.
  }
  </code></pre>
  <p>It's possible using <code>enum</code> as type, then checking type and branching on GPU. I already got it working on GPU. But if I can save the <code>type</code> directly into this class, maybe I can do type cast and use template on GPU. In my understanding, it will reduce all the ugly branching.</p>
  <p>All the logic happens on GPU side, CPU side is only preparing data. GPU(Metal) doesn't super class and virtual function, but template is supported. It's better to avoid any std stuff unless I can get the same type on GPU.</p>