From aeb7ca17a5986c38c3924507436b003ee9361aa8 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 15 Jan 2018 13:43:49 -0800 Subject: [PATCH] Don't sync textures with unsupported formats to the GPU --- libraries/gpu-gles/src/gpu/gles/GLESBackend.h | 2 +- .../gpu-gles/src/gpu/gles/GLESBackendTexture.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackend.h b/libraries/gpu-gles/src/gpu/gles/GLESBackend.h index 19f8575802..aeda054e72 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackend.h +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackend.h @@ -32,7 +32,7 @@ public: static const GLint RESOURCE_TRANSFER_EXTRA_TEX_UNIT { 33 }; static const GLint RESOURCE_BUFFER_TEXBUF_TEX_UNIT { 34 }; static const GLint RESOURCE_BUFFER_SLOT0_TEX_UNIT { 35 }; - + static bool supportedTextureFormat(const gpu::Element& format); explicit GLESBackend(bool syncCache) : Parent(syncCache) {} GLESBackend() : Parent() {} virtual ~GLESBackend() { diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp index 2c029ad2f3..d2fa2aabab 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp @@ -19,6 +19,12 @@ using namespace gpu; using namespace gpu::gl; using namespace gpu::gles; +bool GLESBackend::supportedTextureFormat(const gpu::Element& format) { + // FIXME distinguish between GLES and GL compressed formats after support + // for the former is added to gpu::Element + return !format.isCompressed(); +} + GLTexture* GLESBackend::syncGPUObject(const TexturePointer& texturePointer) { if (!texturePointer) { return nullptr; @@ -34,6 +40,12 @@ GLTexture* GLESBackend::syncGPUObject(const TexturePointer& texturePointer) { return nullptr; } + // Check whether the texture is in a format we can deal with + auto format = texture.getTexelFormat(); + if (!supportedTextureFormat(format)) { + return nullptr; + } + GLESTexture* object = Backend::getGPUObject(texture); if (!object) { switch (texture.getUsageType()) {