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

@ -87,6 +87,7 @@ namespace skyline::gpu {
// Create a texture as we cannot find one that matches
auto texture{std::make_shared<Texture>(gpu, guestTexture)};
texture->SetupGuestMappings();
texture->TransitionLayout(vk::ImageLayout::eGeneral);
auto it{texture->guest->mappings.begin()};
textures.emplace(mappingEnd, TextureMapping{texture, it, guestMapping});