message: Fix corruption when buffer is deleted after resize mid-frame
diff: @@ -2397,6 +2397,13 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
  m_State = CaptureState::BackgroundCapturing;
  + for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  + {
  + r.first->AddChunk(r.second);
  + r.first->SetDataPtr(r.second->GetData());
  + }
  + m_BufferResizes.clear();
  +
  GetResourceManager()->ResetLastWriteTimes();
  GetResourceManager()->MarkUnwrittenResources();
  @@ -2412,13 +2419,6 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
  record->FreeShadowStorage();
  }
  - for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  - {
  - r.first->AddChunk(r.second);
  - r.first->SetDataPtr(r.second->GetData());
  - }
  - m_BufferResizes.clear();
  -
  // if we changed contexts above, pop back to where we were
  if(pushChildSaved)
  {
  @@ -2462,6 +2462,13 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
  m_CapturedFrames.back().frameNumber = m_AppControlledCapture ? ~0U : m_FrameCounter;
  + for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  + {
  + r.first->AddChunk(r.second);
  + r.first->SetDataPtr(r.second->GetData());
  + }
  + m_BufferResizes.clear();
  +
  CleanupCapture();
  GetResourceManager()->ClearReferencedResources();
  @@ -2475,13 +2482,6 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
  record->FreeShadowStorage();
  }
  - for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  - {
  - r.first->AddChunk(r.second);
  - r.first->SetDataPtr(r.second->GetData());
  - }
  - m_BufferResizes.clear();
  -
  // if it's a capture triggered from application code, immediately
  // give up as it's not reasonable to expect applications to detect and retry.
  // otherwise we can retry in case the next frame works.
  @@ -2541,6 +2541,13 @@ bool WrappedOpenGL::DiscardFrameCapture(void *dev, void *wnd)
  RenderDoc::Inst().FinishCaptureWriting(NULL, m_CapturedFrames.back().frameNumber);
  + for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  + {
  + r.first->AddChunk(r.second);
  + r.first->SetDataPtr(r.second->GetData());
  + }
  + m_BufferResizes.clear();
  +
  CleanupCapture();
  GetResourceManager()->ClearReferencedResources();
  @@ -2556,13 +2563,6 @@ bool WrappedOpenGL::DiscardFrameCapture(void *dev, void *wnd)
  record->FreeShadowStorage();
  }
  - for(const rdcpair<GLResourceRecord *, Chunk *> &r : m_BufferResizes)
  - {
  - r.first->AddChunk(r.second);
  - r.first->SetDataPtr(r.second->GetData());
  - }
  - m_BufferResizes.clear();
  -
  m_CapturedFrames.pop_back();
  FreeCaptureData();
  