+ for(auto i=texture_stack.end(); i!=texture_stack.begin(); )
+ if((--i)->tag==tag)
+ {
+ i->replaced = texture_stack.size();
+ break;
+ }
+
+ texture_stack.emplace_back();
+ BoundTexture &bound_tex = texture_stack.back();
+ bound_tex.tag = tag;
+ bound_tex.texture = tex;
+ bound_tex.sampler = samp;
+ bound_tex.level = level;
+ state.texture_count = texture_stack.size();