Hello,
I have been working on getting occlusion testing working on iOS Metal. My question is how I can reliably access the result buffer when the GPU has
finished writing the contents of the visibility test.
For Example:
I create the buffer where contents will be written to.
m_pBuffer = cMetalRenderer->m_pcDevice.newBufferWithLength (1 * 8, 0);
I set the visibility mode in the render command encoder.
uint32 iOffset = 0;
sRenderCommandEncoder.setVisibilityResultMode (MTLVisibilityResultModeBoolean, iOffset);
Now to access the contents I do something like this:
uint64 result = (uint64 *) m_pBuffer.contents ();
My question is how do I set this up so that I can reliably access the contents of the buffer when the GPU has written the results to the buffer. I want
to avoid causing a stall if I just read the buffer while the GPU is updating it.
Perhaps someone can point me to some code examples or some resources that would allow me to do this. Or is it "guaranteed" that I can read the contents
next frame?
Thanks in advance for anyones help....