MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CopyGpuToCpu

Method CopyGpuToCpu

GTE/Graphics/GL46/GL46Buffer.cpp:110–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110bool GL46Buffer::CopyGpuToCpu()
111{
112 if (!PreparedForCopy(GL_READ_ONLY))
113 {
114 return false;
115 }
116
117 Buffer* buffer = GetBuffer();
118 GLuint numActiveBytes = buffer->GetNumActiveBytes();
119 if (numActiveBytes > 0)
120 {
121 // Copy from GPU memory to CPU memory.
122 GLintptr offsetInBytes =
123 static_cast<GLintptr>(buffer->GetOffset()) *
124 static_cast<GLintptr>(buffer->GetElementSize());
125 char* target = buffer->GetData() + offsetInBytes;
126 glBindBuffer(mType, mGLHandle);
127 glGetBufferSubData(mType, offsetInBytes, numActiveBytes, target);
128 glBindBuffer(mType, 0);
129 }
130 return true;
131}
132
133

Callers

nothing calls this directly

Calls 6

glBindBufferFunction · 0.85
glGetBufferSubDataFunction · 0.85
GetNumActiveBytesMethod · 0.80
GetElementSizeMethod · 0.80
GetOffsetMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected