noggit3 icon indicating copy to clipboard operation
noggit3 copied to clipboard

swapping textures crashes if replaced texture was last reference

Open bloerwald opened this issue 5 years ago • 2 comments

If the replaced texture is the last instance of that texture, it will be erased within the slot, leading to a glDeleteTextures() without active context.

VCRUNTIME140                                  CxxThrowException
opengl\context.cpp (57)                       opengl::`anonymous namespace'::verify_context_and_check_for_gl_errors::verify_context_and_check_for_gl_errors
opengl\context.cpp (285)                      opengl::context::deleteTextures
opengl\texture.cpp (20)                       opengl::texture::~texture
                                              std::map<std::string,blp_texture>::_Erase_unchecked
noggit\multimap_with_normalized_key.hpp (89)  noggit::async_object_multimap_with_normalized_key<blp_texture>::erase
Qt5Core                                       QtPrivate::QFunctorSlotObject<<lambda_1f883b93a2eca3bd8ea76fc535a6773d>,0,QtPrivate::List<>,void>::impl
Qt5Core                                       QMetaObject::activate
Qt5Widgets                                    QAbstractButton::clicked

bloerwald avatar Nov 17 '20 11:11 bloerwald

Also when clicking Select. tldr: check all buttons for context. tlldr: we should lazily delete textures in the next render loop instead of directly.

bloerwald avatar Nov 21 '20 15:11 bloerwald

#58 and #12 are similar. in recent years a pattern in (multithreaded) engines has emerged where gpu commands are collected in different threads (command buffers) and are then submitted to the gpu as batches in one or multiple render threads. something along those lines would avoid all situations where currently makeCurrent() is called. big change tho.

bkleiner avatar Mar 08 '21 10:03 bkleiner