Unable to release textures created by the general context

I came across a problem using common contexts:

I have two threads, each of which has one context, say Thr1 (thread1) with Ctx1 (Context1) and Thr2 and Ctx2. Ctx2 was created in conjunction with Ctx1.

Then, in Thr2, I create some textures with Ctx2 as the current context and do some rendering. After that, I destroy Ctx2 and end Thr2.

Now the problem has arisen: after I destroy Ctx2, the textures created under Ctx2 are not released (some of them, but not all). I use gDebugger to profile my program and see that these textures are not released and are listed in Ctx1.

As I repeat, create Thr2 / Ctx2 and create textures and destroy Thr2 / Ctx2, the textures are getting bigger and bigger, as well as memory.

What I tried:

Remove textures in Thr2 before destroying Ctx2;

In Thr2, make Ctx1 as current and try to remove the textures before Ctx2 is destroyed;

+4
source share
1 answer

This sounds like the expected behavior.

To explain the lifetime of objects with multiple contexts, I'm going to use the word pool to describe a set of textures. I do not think that there is a universal terminology for the concept, therefore it is as good as everything.

, , . , . , , . , , .

, , . , . , . , . ( ) , .

2 . , 1 2. 2. . , 1 ( ) . , . , 2 , , 2.

, , glDeleteTexture(). , 1 2.

, , , , , FBO, , , . , , (., , D.1.2 . 337 OpenGL 3.3).

+5

Source: https://habr.com/ru/post/1584151/


All Articles