The previous version would break when the state changes from (cube=true,mipmap=false) -> (cube=true,mipmap=true)