summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-10-07 14:52:58 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-08 11:01:11 +0200
commitea227fb9152759bcb425c44565651a5032aba134 (patch)
tree9d7e6de91082061267e585d80fe072acd445c005 /src/gui
parent96eea43d3be0dac71d2fde6645ddc87143f096cd (diff)
rhi: gl: Fix missing texture bindings
The block to update the cached state needs to be run also when the texture parameters have changed. Change-Id: Ifa80c142c6ff31c95a718a1a900ff3db0bbfe4bc Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/rhi/qrhigles2.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index c9d92b4d71..bf473deefb 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -3093,8 +3093,9 @@ void QRhiGles2::bindShaderResources(QGles2CommandBuffer *cbD,
for (const QGles2SamplerDescription &shaderSampler : samplers) {
if (shaderSampler.binding == b->binding) {
const bool samplerStateValid = texD->samplerState == samplerD->d;
+ const bool cachedStateInRange = texUnit < 16;
bool updateTextureBinding = true;
- if (samplerStateValid && texUnit < 16) {
+ if (samplerStateValid && cachedStateInRange) {
// If we already encountered the same texture with
// the same pipeline for this texture unit in the
// current pass, then the shader program already
@@ -3107,10 +3108,6 @@ void QRhiGles2::bindShaderResources(QGles2CommandBuffer *cbD,
&& cbD->textureUnitState[texUnit].texture == texD->texture)
{
updateTextureBinding = false;
- } else {
- cbD->textureUnitState[texUnit].ps = ps;
- cbD->textureUnitState[texUnit].psGeneration = psGeneration;
- cbD->textureUnitState[texUnit].texture = texD->texture;
}
}
if (updateTextureBinding) {
@@ -3118,6 +3115,11 @@ void QRhiGles2::bindShaderResources(QGles2CommandBuffer *cbD,
activeTexUnitAltered = true;
f->glBindTexture(texD->target, texD->texture);
f->glUniform1i(shaderSampler.glslLocation + elem, texUnit);
+ if (cachedStateInRange) {
+ cbD->textureUnitState[texUnit].ps = ps;
+ cbD->textureUnitState[texUnit].psGeneration = psGeneration;
+ cbD->textureUnitState[texUnit].texture = texD->texture;
+ }
}
++texUnit;
if (!samplerStateValid) {