public sealed class PickingBufferThe ring of readback buffers a picking stage copies into.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Read back asynchronously, several frames later. Mapping a buffer the GPU may still be writing means waiting for the GPU, and doing that in the frame the click happened turns a click into a stall of however long the frame had left to run. The ring is Latency deep and a pick is resolved when its slot comes round again, by which time the copy has certainly landed.
⚠ One pixel is copied, not the target. A full-resolution R32 readback is sixteen megabytes a frame for a 4K viewport and answers a question about one pixel. The rectangle copied is the one the pointer is in — which is also why the picking pass can be skipped entirely on every frame nobody clicked.
The buffers are made once and kept. They are four bytes each; allocating one per click would put a device allocation on the click path, which is the one path where a hitch is felt as the tool being unresponsive.
Fields and properties (3)
public int LatencyHow many frames a pick takes to come back.
public PickRequest? RequestedThe pick waiting to be drawn this frame, if any.
public static Int3 CopySizeThe size of the region copied out of the id target.
Methods (6)
public PickingBuffer(IGraphicsDevice device, int latency = 3)Makes a ring of readback buffers.
public long Request(int x, int y, bool additive = false)Asks what is under a point.
public bool TryTakeRequest(out BufferHandle destination, out PickRequest request)The buffer this frame's copy should go into, if there is a copy to make.
public bool Advance(out PickResult result)Moves to the next slot and answers whatever the one it lands on was asked.
public void Abandon()Forgets every outstanding pick.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (3)
- PickingRendererVixen.Editor.SceneView
- ScenePresenterVixen.Editor.App
- SceneViewportVixen.Editor.SceneView