Fix crashes on new drivers #91
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes two issues surfaced by newer nvidia drivers
It is now common for the driver to return swapchain images out-of-order, which crashes on an assert. Simply removing the assert is incorrect given this behavior and would result in overlapping use of the
rendering_completesemaphores. Instead I moved the acquire semaphore into the frame data, to make sure there are enough if the number of frames is increased in the future (frames in flight is the bound on acquire semaphores). I then renamedrendering_completetoready_for_presentsemaphores in the swapchain, which I think is a bit more descriptive of exactly their purpose, and index them based on the returned presentation index from the driver. In this way we guarantee that theready_for_presentsemaphore is not in use when we wait on it before presentation.The
prefix_scanregime always accesses out toSEGMENT_SIZE * SEGMENT_SIZE(currently 1024 * 1024) element in the input buffer. Previously, we were passing it a buffer withMAX_ENTRIESelements (which is only 1024 * 64). So, we were accessing out of bounds quite dramatically. Probably the better solution here would be to make it adapt to the input buffer size dynamically and/or reduce the static size to matchMAX_ENTRIES, but I haven't gone through the algorithm closely enough to adapt it yet