From f8690867d346b9b3363b314c770b856bd6a8c1f8 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 5 Aug 2016 17:14:57 -0700 Subject: [PATCH] Allow plugins to query if a texture is ready to render --- libraries/gpu-gl/src/gpu/gl/GLBackend.h | 1 + libraries/gpu-gl/src/gpu/gl/GLBackendTexture.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.h b/libraries/gpu-gl/src/gpu/gl/GLBackend.h index f130db0ade..eaa87f2498 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.h @@ -163,6 +163,7 @@ public: virtual GLuint getFramebufferID(const FramebufferPointer& framebuffer) const = 0; virtual GLuint getTextureID(const TexturePointer& texture, bool needTransfer = true) const = 0; + virtual bool isTextureReady(const TexturePointer& texture) const; virtual void releaseBuffer(GLuint id, Size size) const; virtual void releaseTexture(GLuint id, Size size) const; diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendTexture.cpp index 6d9b5fd2c7..1ccaabf381 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendTexture.cpp @@ -14,6 +14,13 @@ using namespace gpu; using namespace gpu::gl; +bool GLBackend::isTextureReady(const TexturePointer& texture) const { + // DO not transfer the texture, this call is expected for rendering texture + GLTexture* object = syncGPUObject(texture, true); + return object && object->isReady(); +} + + void GLBackend::do_generateTextureMips(Batch& batch, size_t paramOffset) { TexturePointer resourceTexture = batch._textures.get(batch._params[paramOffset + 0]._uint); if (!resourceTexture) {