From 98aeee5b5b120afba850607e497c55f3cc93a51c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 7 Aug 2019 10:12:59 +0200 Subject: rhi: Avoid generating gl errors in ES 2.0 contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...due to setting the unsupported texture compare mode. This keeps wasm happy (gl errors show up in the console there). Change-Id: I5de8bce8e793c709272f3df499d2320c7b07ff71 Reviewed-by: Christian Strømme --- src/gui/rhi/qrhigles2.cpp | 17 ++++++++++++----- src/gui/rhi/qrhigles2_p_p.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 379801efbd..92aaf9d4b0 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -472,6 +472,11 @@ bool QRhiGles2::create(QRhi::Flags flags) else caps.compute = caps.ctxMajor > 4 || (caps.ctxMajor == 4 && caps.ctxMinor >= 3); // 4.3 + if (caps.gles) + caps.textureCompareMode = caps.ctxMajor >= 3; // ES 3.0 + else + caps.textureCompareMode = true; + if (!caps.gles) f->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); // else (with gles) this is always on @@ -2376,11 +2381,13 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_T, samplerD->d.glwrapt); // 3D textures not supported by GLES 2.0 or by us atm... //f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_R, samplerD->d.glwrapr); - if (samplerD->d.gltexcomparefunc != GL_NEVER) { - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_FUNC, samplerD->d.gltexcomparefunc); - } else { - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_NONE); + if (caps.textureCompareMode) { + if (samplerD->d.gltexcomparefunc != GL_NEVER) { + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_FUNC, samplerD->d.gltexcomparefunc); + } else { + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_NONE); + } } texD->samplerState = samplerD->d; } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 88a6144b42..259d16ca5e 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -768,6 +768,7 @@ public: uint instancing : 1; uint baseVertex : 1; uint compute : 1; + uint textureCompareMode : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QVector supportedCompressedFormats; -- cgit v1.2.3