Citing section 33.8 "Display Timing Queries", the description of
VK_GOOGLE_display_timing's vkGetPastPresentationTimingGOOGLE()
the spec states that "The results for a given swapchain and presentID are
only returned once from vkGetPastPresentationTimingGOOGLE."
In other words, every VkPastPresentationTimingGOOGLE timing record
stored in the internal queue must get removed from the internal queue,
once it was returned to the calling client application via a successfull
call to vkGetPastPresentationTimingGOOGLE().
The current implementation does not remove delivered entries from the
queue. Instead it keeps the last kMaxPresentationHistory (== 60) records,
so the internal queue grows to its maximum fill level and never empties.
Successive calls to vkGetPastPresentationTimingGOOGLE() deliver the same
records repeatedly, confusing applications which are written according to
spec.
This commit changes the queueing behavior to properly remove items from
the queue, so that it operates in a FIFO fashion and only retains items which
have not been fetched yet, up to kMaxPresentationHistory, after which the
oldest items get discarded.
Tested on macOS 10.15.7 with AMD for different intervals between calling
vkGetPastPresentationTimingGOOGLE() and different input values for
pPresentationTimingCount, to make sure it behaves properly for cases like
1 item in queue at query time, queue half full at query time, queue completely
full, queue "overflowing" - ie. items are properly discarded in FIFO order, and
for fetching 1 item at a time, multiple items (partially emptying the queue in
each iteration) or all items (emptying the queue in one go).