Don't sync textures with unsupported formats to the GPU

This commit is contained in:
Brad Davis 2018-01-15 13:43:49 -08:00
parent 17e9c3d00c
commit aeb7ca17a5
2 changed files with 13 additions and 1 deletions

View file

@ -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() {

View file

@ -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<GLESTexture>(texture);
if (!object) {
switch (texture.getUsageType()) {