[WIP] State caching

Closes #315
Closes #164

TODO:
- [X] device reset
- [X] device direct GL access
- [X] render target caching (was already there mostly)
- [X] draw state caching
- [ ] mesh attribute caching
- [ ] program caching

Future goals:
  * re-use textures/blocks by tracking their bound points

cc @bvssvni @eddyb @kvark