Use weak_ptr for TrapHandler Callbacks

The lifetime of the `this` pointer in the trap callbacks could be invalid as the lifetime of the underlying `Buffer`/`Texture` object wasn't guaranteed, this commit fixes that by passing a `weak_ptr` of the objects into the callbacks which is locked during the callbacks and ensures that a destroyed object isn't accessed.

Co-authored-by: Billy Laws <blaws05@gmail.com>
This commit is contained in:
PixelyIon
2022-07-25 22:52:45 +05:30
parent 96d8676d5b
commit 9d294b9ccc
6 changed files with 58 additions and 21 deletions

View File

@ -117,7 +117,7 @@ namespace skyline::gpu {
friend BufferManager;
/**
* @brief Sets up mirror mappings for the guest mappings
* @brief Sets up mirror mappings for the guest mappings, this must be called after construction for the mirror to be valid
*/
void SetupGuestMappings();
@ -138,6 +138,10 @@ namespace skyline::gpu {
return span<u8>(backing);
}
/**
* @brief Creates a buffer object wrapping the guest buffer with a backing that can represent the guest buffer data
* @note The guest mappings will not be setup until SetupGuestMappings() is called
*/
Buffer(GPU &gpu, GuestBuffer guest);
/**