Perform OpenGL texture cleanup only on main thread.

This commit is contained in:
Bartosz Taudul 2020-08-15 15:02:36 +02:00
parent a3d8b5d225
commit 28af5230d3
3 changed files with 7 additions and 5 deletions

View File

@ -21,10 +21,10 @@ void* MakeTexture()
return (void*)(intptr_t)tex;
}
void FreeTexture( void* _tex )
void FreeTexture( void* _tex, void(*runOnMainThread)(std::function<void()>) )
{
auto tex = (GLuint)(intptr_t)_tex;
glDeleteTextures( 1, &tex );
runOnMainThread( [tex] { glDeleteTextures( 1, &tex ); } );
}
void UpdateTexture( void* _tex, const char* data, int w, int h )

View File

@ -1,11 +1,13 @@
#ifndef __TRACYTEXTURE_HPP__
#define __TRACYTEXTURE_HPP__
#include <functional>
namespace tracy
{
void* MakeTexture();
void FreeTexture( void* tex );
void FreeTexture( void* tex, void(*runOnMainThread)(std::function<void()>) );
void UpdateTexture( void* tex, const char* data, int w, int h );
}

View File

@ -192,8 +192,8 @@ View::~View()
if( m_compare.loadThread.joinable() ) m_compare.loadThread.join();
if( m_saveThread.joinable() ) m_saveThread.join();
if( m_frameTexture ) FreeTexture( m_frameTexture );
if( m_playback.texture ) FreeTexture( m_playback.texture );
if( m_frameTexture ) FreeTexture( m_frameTexture, m_cbMainThread );
if( m_playback.texture ) FreeTexture( m_playback.texture, m_cbMainThread );
assert( s_instance != nullptr );
s_instance = nullptr;