mesa: use Elements() as limit in loops over texture/program matrix stacks