summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-01-08 11:15:42 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-01-09 20:57:08 +0100
commite4d0187edc8aa5c70d181728b18630c1749ca288 (patch)
treeac6b9dd617c1712282cdad03386177cdc9690516
parent2671fb27773fa318cde486d310dcf853a8290639 (diff)
rhi: metal: Fix incorrect native res. binding map check
Checking for nullptr is insufficient: just because there is an empty map present, it does not mean it is valid. The two cases must be handled identically. This fixes a regression when using QShaders that do not have an associated native resource binding map. Amends 4639660dedceba7c16e1a8110bba16eff30be312 Change-Id: Icb239bf9a9261ed32f2cb7b22c60b608195618fc Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/gui/rhi/qrhimetal.mm6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index ef2de8c994..53422470e8 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -664,15 +664,15 @@ static inline int mapBinding(int binding,
BindingType type)
{
const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex];
- if (!map)
+ if (!map || map->isEmpty())
return binding; // old QShader versions do not have this map, assume 1:1 mapping then
auto it = map->constFind(binding);
if (it != map->cend())
return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive
- // Hitting this path is normal too, is not given that the resource (e.g. a
- // uniform block) is really present in the shaders for all the stages
+ // Hitting this path is normal too. It is not given that the resource (for
+ // example, a uniform block) is present in the shaders for all the stages
// specified by the visibility mask in the QRhiShaderResourceBinding.
return -1;
}