Change binding auto-map to use provided offsets.

Previously, the binding auto-mapping facility was free to use any unused
binding.  This change makes auto-bindings use the same offset value as
explicit bindings.
This commit is contained in:
steve-lunarg
2016-10-01 11:27:43 -06:00
parent 074ced3e00
commit 088c59d7ea
5 changed files with 21 additions and 24 deletions

View File

@@ -151,8 +151,7 @@ class TIoMappingTraverser : public TBindingTraverser {
public:
TIoMappingTraverser(TIntermediate& i, TBindingMap& bindingMap, TUsedBindings& usedBindings,
bool traverseDeadCode) :
TBindingTraverser(i, bindingMap, usedBindings, traverseDeadCode),
nextBinding(1)
TBindingTraverser(i, bindingMap, usedBindings, traverseDeadCode)
{ }
protected:
@@ -172,7 +171,7 @@ protected:
if (intermediate.getAutoMapBindings()) {
// Otherwise, find a free spot for it.
const int freeBinding = getFreeBinding(base.getType());
const int freeBinding = getFreeBinding(base.getType(), getBindingBase(base.getType()));
markBinding(base, freeBinding);
base.getWritableType().getQualifier().layoutBinding = freeBinding;
@@ -190,14 +189,12 @@ protected:
}
// Find a free binding spot
int getFreeBinding(const TType&) {
int getFreeBinding(const TType&, int nextBinding) {
while (!hasNFreeSlots(nextBinding, 1))
++nextBinding;
return nextBinding;
}
int nextBinding;
};
// Map I/O variables to provided offsets, and make bindings for