Skip to content

Commit

Permalink
Merge pull request #16670 from hrydgard/memory-leak-fix
Browse files Browse the repository at this point in the history
DrawContext destructor: Need to call DestroyPresets earlier.
  • Loading branch information
unknownbrackets committed Dec 29, 2022
2 parents bd2a0c9 + d83f84f commit 47e85cd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Common/GPU/D3D11/thin3d_d3d11.cpp
Expand Up @@ -341,6 +341,8 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
}

D3D11DrawContext::~D3D11DrawContext() {
DestroyPresets();

upBuffer_->Release();
packTexture_->Release();

Expand Down
1 change: 1 addition & 0 deletions Common/GPU/D3D9/thin3d_d3d9.cpp
Expand Up @@ -815,6 +815,7 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID
}

D3D9Context::~D3D9Context() {
DestroyPresets();
}

ShaderModule *D3D9Context::CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t size, const char *tag) {
Expand Down
2 changes: 2 additions & 0 deletions Common/GPU/OpenGL/thin3d_gl.cpp
Expand Up @@ -764,6 +764,8 @@ OpenGLContext::OpenGLContext() {
}

OpenGLContext::~OpenGLContext() {
DestroyPresets();

for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
renderManager_.DeletePushBuffer(frameData_[i].push);
}
Expand Down
2 changes: 2 additions & 0 deletions Common/GPU/Vulkan/thin3d_vulkan.cpp
Expand Up @@ -1004,6 +1004,8 @@ VKContext::VKContext(VulkanContext *vulkan)
}

VKContext::~VKContext() {
DestroyPresets();

delete nullTexture_;
// This also destroys all descriptor sets.
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/thin3d.cpp
Expand Up @@ -523,7 +523,7 @@ void DrawContext::DestroyPresets() {
}

DrawContext::~DrawContext() {
DestroyPresets();
// TODO: Can't call DestroyPresets here, too late.
}

void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format) {
Expand Down

0 comments on commit 47e85cd

Please sign in to comment.