message: Detect read-only GL persistent maps & skip intercepting them. Refs
diff: @@ -449,7 +449,8 @@ void WrappedOpenGL::Common_glNamedBufferStorageEXT(ResourceId id, GLsizeiptr siz
  // because the user code isn't writing into them anyway and we're inserting invisible sync
  // points - so there's no need for it to be coherently mapped (and there's no requirement
  // that a buffer declared as coherent must ALWAYS be mapped as coherent).
  - if(flags & GL_MAP_PERSISTENT_BIT)
  + uint32_t persistentWriteFlags = GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT;
  + if((flags & persistentWriteFlags) == persistentWriteFlags)
  {
  record->Map.persistentPtr = (byte *)GL.glMapNamedBufferRangeEXT(
  record->Resource.name, 0, size,
  @@ -1900,14 +1901,20 @@ void *WrappedOpenGL::glMapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GL
  IsBackgroundCapturing(m_State))
  directMap = true;
  - // persistent maps must ALWAYS be intercepted
  - if((access & GL_MAP_PERSISTENT_BIT) || record->Map.persistentPtr)
  + // read-only persistent maps can also be made directly
  + uint32_t persistentReadFlags = GL_MAP_PERSISTENT_BIT | GL_MAP_READ_BIT;
  + if((access & persistentReadFlags) == persistentReadFlags)
  + directMap = true;
  +
  + // persistent maps must ALWAYS be intercepted if they are writeable. if it's a read-only
  + // persistent map we never allocated a persistent pointer so we can skip this
  + if(record->Map.persistentPtr)
  directMap = false;
  bool verifyWrite = (RenderDoc::Inst().GetCaptureOptions().verifyMapWrites != 0);
  // must also intercept to verify writes
  - if(verifyWrite)
  + if(verifyWrite && (access & GL_MAP_WRITE_BIT))
  directMap = false;
  if(directMap)
  @@ -1922,8 +1929,9 @@ void *WrappedOpenGL::glMapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GL
  record->Map.invalidate = invalidateMap;
  record->Map.verifyWrite = verifyWrite;
  - // store a list of all persistent maps, and subset of all coherent maps
  - if(access & GL_MAP_PERSISTENT_BIT)
  + // store a list of all persistent writing maps, and subset of all coherent maps
  + uint32_t persistentWriteFlags = GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT;
  + if((access & persistentWriteFlags) == persistentWriteFlags)
  {
  Atomic::Inc64(&record->Map.persistentMaps);
  m_PersistentMaps.insert(record);
  