Fix BufferManager::FindOrCreate Recreation Bugs

It was determined that `FindOrCreate` has several issues which this commit fixes:
* It wouldn't correctly handle locking of the newly created `Buffer` as the constructor would setup traps prior to being able to lock it which could lead to UB
* It wouldn't propagate the `usedByContext`/`everHadInlineUpdate` flags correctly
* It wouldn't correctly set the `dirtyState` of the buffer according to that of its source buffers
This commit is contained in:
PixelyIon
2022-07-17 18:18:33 +05:30
parent d1a682eace
commit 38d3ff4300
3 changed files with 93 additions and 83 deletions

View File

@ -140,13 +140,6 @@ namespace skyline::gpu {
Buffer(GPU &gpu, GuestBuffer guest);
/**
* @brief Creates a Buffer that is pre-synchronised with the contents of the input buffers
* @param tag The tag to associate locking of srcBuffers with
* @param srcBuffers Span of overlapping source buffers
*/
Buffer(GPU &gpu, GuestBuffer guest, ContextTag tag, span<std::shared_ptr<Buffer>> srcBuffers);
/**
* @brief Creates a host-only Buffer which isn't backed by any guest buffer
* @note The created buffer won't have a mirror so any operations cannot depend on a mirror existing
@ -222,6 +215,13 @@ namespace skyline::gpu {
*/
bool PollFence();
/**
* @brief Invalidates the Buffer on the guest and deletes the trap that backs this buffer as it is no longer necessary
* @note This will not clear any views or delegates on the buffer, it will only remove guest mappings and delete the trap
* @note The buffer **must** be locked prior to calling this
*/
void Invalidate();
/**
* @brief Synchronizes the host buffer with the guest
* @param rwTrap If true, the guest buffer will be read/write trapped rather than only being write trapped which is more efficient than calling MarkGpuDirty directly after