Allow batching ShaderEffects without atlas samplers
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>
Tue, 9 Dec 2014 15:32:48 +0000 (16:32 +0100)
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>
Thu, 18 Dec 2014 17:57:52 +0000 (18:57 +0100)
commit38cab579a0c5398b7621221fd8609bc43cf1f3c5
treeb177c8d76e7133f625b49dc00525d35b25e40428
parent5a7b256a62ebc520d0bd13ff5dd1c5fae4138bf7
Allow batching ShaderEffects without atlas samplers

It is currently necessary to set supportsAtlasTextures to enable
batching of all ShaderEffect, even if they sample a
ShaderEffectSource or have no sampler uniform at all.

After fccbe57258c10e18ccdbbec405f5522dbd97af66 it is not necessary to
set the RequiresFullMatrix flag based on supportsAtlasTextures since
this now prevents batching altogether. Limiting batching should
however also first verify that there are any sampler of the atlas
used on that ShaderEffect in QQuickShaderEffectMaterial::compare,
since that check wouldn't have any effect in
QQuickShaderEffect::updatePaintNode through RequiresFullMatrix.

Also make sure that using texture()->normalizedTextureSubRect()
as the texture coordinate attribute is synchronized with calls to
removedFromAtlas for all samplers and make sure that this only
applies when the texture count == 1. This fixes a bug where
setting supportsAtlasTextures on a ShaderEffect with more that
one sampler would incorrectly use the texture coordinates of the
first atlas texture in the geometry.

This patch also removes:
- The unneeded check for the RequiresFullMatrix in compare; the same
  program can be used in batched geometries and the renderer itself
  will prevent merging in that case.
- The possibly heavy string comparison of m_source;
  QQuickShaderEffectMaterial::type() and QQuickShaderEffectMaterialKey
  are doing that for us more efficiently.

I updated the documentation to clarify the 1-texture rule and
explain the difference with qt_SubRect uniforms and when one or
the other should be used.

Change-Id: I85a86b8e7cb76f1536d5fcd369c7889f22537846
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/quick/items/qquickshadereffect.cpp
src/quick/items/qquickshadereffectnode.cpp
src/quick/items/qquickshadereffectnode_p.h