Closed MoeMod closed 5 years ago
While it will not give potential overhead, may I ask, how it's happened if A releases texture while B still using it? I mean, typically resource releasing should happen on map reloading, engine shutdown and such. In that case B should re-load texture again.
If you need to update content of GL texture, it's better to use GL functions for that, omitting Xash's texture management.
Maybe it's an architectural problem and isn't an engine bug.
OK, maybe something was wrong in my client code...
Problem
When both A and B get an texture id from engine by GL_LoadTexture, it's possible to reuse the id by hash table. However, if A frees it by GL_FreeTexture but B doesn't, the texture will be invalid for B... It means that B may try to draw / free an invalid texture that was already freed.
Possible solution
Add a reference count for r_textures, and only really free it if (count==0).
Associated source file
engine/client/gl_image.c