Native textures don't destroy their handles;

If a Texture is created from a handle, that means someone else created
it, so we expect them to destroy it.  We were always destroying handles,
and I guess this was usually okay because glDeleteTextures is idempotent.

However, we're seeing a crash in the Oculus driver when OVR is torn
down.  Presumably it is trying to access its swapchain textures after we
destroyed them.  Not sure why this wasn't an observable issue before,
maybe it's a new regression.  Still, it makes sense to only delete the
GL texture handle if we were the one that created it.

We don't need to check this for the renderbuffer since we always own those.
This commit is contained in:
bjorn 2021-04-27 22:24:42 -06:00
parent 51f81c9db6
commit 25bb12d07c
1 changed files with 1 additions and 1 deletions

View File

@ -1740,7 +1740,7 @@ Texture* lovrTextureCreateFromHandle(uint32_t handle, TextureType type, uint32_t
void lovrTextureDestroy(void* ref) {
Texture* texture = ref;
glDeleteTextures(1, &texture->id);
if (!texture->native) glDeleteTextures(1, &texture->id);
glDeleteRenderbuffers(1, &texture->msaaId);
lovrGpuDestroySyncResource(texture, texture->incoherent);
state.stats.textureMemory -= getTextureMemorySize(texture);