Serialise newer parts of the GLPipelineState
Check index is in valid range for pipeline arrays.
64bit compile fixes
As a slight hack, reference glXWaitGL to pull in libGL in the right order

* Basically we want libGL to be loaded second, after librenderdoc. This is
  in order to make sure dlsym(RTLD_NEXT) can work.
* This can be done just by order in the ld command. Unfortunately since
  renderdoccmd links directly against librenderdoc (rather than LD_PRELOAD)
  any symbols exported by librenderdoc resolve, so unless we reference a
  function that isn't exported by librenderdoc, libGL won't be linked in
  at all.
* I realise this is probably a horrible hack, but it works for now.