Occlusion query and instance buffers

So the underutilized boolean and counting occlusion queries look ideal for predicated rendering given no API support. This should work for 5s and above.
  1. generate a set of indexes in an instance buffer

  2. have occlusion query write an 8-byte value to that indexed buffer location

  3. read the buffer location from each instance.

  4. in vertex shader, lookup buffer value at index, and vertkill all instance vertices if 8-byte value is 0

Seems like this should work. This means the instance buffer is dynamically changed on the gpu after it is submitted. The buffer would need to be "private" space for gpu writes, but could be "shared" on iOS. Does this seem viable?

One thing that would be useful as an extension to occlusion
  1. only write 0, and not any positive values to knock out instance counts.

  2. be able to write to 4 bytes instead of 8 to knock out ICB values

  3. being able to submit instanced boxes with queries on each one. The current queries require a scoped draw per box which is a lot of commands submitted


Occlusion query and instance buffers
 
 
Q