From 81ae88d2d50d9b655f617e61fbd003167e624fa8 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 26 Jan 2018 18:32:33 +1000 Subject: [PATCH] AbstractTexture: Fix crash in Vulkan backend when freeing texture --- Source/Core/VideoBackends/D3D/DXTexture.cpp | 1 + Source/Core/VideoBackends/OGL/OGLTexture.cpp | 1 + Source/Core/VideoBackends/Vulkan/VKTexture.cpp | 2 +- Source/Core/VideoCommon/AbstractTexture.cpp | 5 ----- Source/Core/VideoCommon/AbstractTexture.h | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/DXTexture.cpp b/Source/Core/VideoBackends/D3D/DXTexture.cpp index d5c1d85476..7be3264a74 100644 --- a/Source/Core/VideoBackends/D3D/DXTexture.cpp +++ b/Source/Core/VideoBackends/D3D/DXTexture.cpp @@ -83,6 +83,7 @@ DXTexture::DXTexture(const TextureConfig& tex_config) : AbstractTexture(tex_conf DXTexture::~DXTexture() { + g_renderer->UnbindTexture(this); m_texture->Release(); } diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp index 55b50927d3..89b6436f2b 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp +++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp @@ -121,6 +121,7 @@ OGLTexture::OGLTexture(const TextureConfig& tex_config) : AbstractTexture(tex_co OGLTexture::~OGLTexture() { + g_renderer->UnbindTexture(this); if (m_texId) glDeleteTextures(1, &m_texId); diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index dd341d5001..0edaec8a63 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -93,7 +93,7 @@ std::unique_ptr VKTexture::Create(const TextureConfig& tex_config) VKTexture::~VKTexture() { // Texture is automatically cleaned up, however, we don't want to leave it bound. - StateTracker::GetInstance()->UnbindTexture(m_texture->GetView()); + g_renderer->UnbindTexture(this); if (m_framebuffer != VK_NULL_HANDLE) g_command_buffer_mgr->DeferFramebufferDestruction(m_framebuffer); } diff --git a/Source/Core/VideoCommon/AbstractTexture.cpp b/Source/Core/VideoCommon/AbstractTexture.cpp index c3df347e48..e4a42ad62b 100644 --- a/Source/Core/VideoCommon/AbstractTexture.cpp +++ b/Source/Core/VideoCommon/AbstractTexture.cpp @@ -15,11 +15,6 @@ AbstractTexture::AbstractTexture(const TextureConfig& c) : m_config(c) { } -AbstractTexture::~AbstractTexture() -{ - g_renderer->UnbindTexture(this); -} - bool AbstractTexture::Save(const std::string& filename, unsigned int level) { // We can't dump compressed textures currently (it would mean drawing them to a RGBA8 diff --git a/Source/Core/VideoCommon/AbstractTexture.h b/Source/Core/VideoCommon/AbstractTexture.h index 1ba316aaa8..faf6076156 100644 --- a/Source/Core/VideoCommon/AbstractTexture.h +++ b/Source/Core/VideoCommon/AbstractTexture.h @@ -15,7 +15,7 @@ class AbstractTexture { public: explicit AbstractTexture(const TextureConfig& c); - virtual ~AbstractTexture(); + virtual ~AbstractTexture() = default; virtual void CopyRectangleFromTexture(const AbstractTexture* src, const MathUtil::Rectangle& src_rect, u32 src_layer,