Skip to content

Commit fb0271f

Browse files
austinEngDawn LUCI CQ
authored andcommitted
Track whether TextureGL owns the handle and should delete it
Change-Id: I2cf21fb0924c47aeb1aeae298661dc4a128a0c6c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/147100 Reviewed-by: Loko Kung <[email protected]> Reviewed-by: Stephen White <[email protected]> Commit-Queue: Austin Eng <[email protected]> Kokoro: Kokoro <[email protected]>
1 parent 83ef71e commit fb0271f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/dawn/native/opengl/TextureGL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Texture::Texture(Device* device, const TextureDescriptor* descriptor)
186186
const OpenGLFunctions& gl = device->GetGL();
187187

188188
gl.GenTextures(1, &mHandle);
189+
mOwnsHandle = true;
189190
uint32_t levels = GetNumMipLevels();
190191

191192
const GLFormat& glFormat = GetGLFormat();
@@ -216,7 +217,7 @@ Texture::~Texture() {}
216217

217218
void Texture::DestroyImpl() {
218219
TextureBase::DestroyImpl();
219-
if (mHandle != 0) {
220+
if (mOwnsHandle) {
220221
const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
221222
gl.DeleteTextures(1, &mHandle);
222223
mHandle = 0;

src/dawn/native/opengl/TextureGL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Texture final : public TextureBase {
4545
MaybeError ClearTexture(const SubresourceRange& range, TextureBase::ClearValue clearValue);
4646

4747
GLuint mHandle;
48+
bool mOwnsHandle = false;
4849
GLenum mTarget;
4950
uint32_t mGenID = 0;
5051
};

0 commit comments

Comments
 (0)