gpu/gl: explicitly clear buffers before replacing their content

The iOS GL implementation doesn't optimize BufferSubData of the entire
buffer, leading to GPU stalls. The workaround is to explicitly clear the
buffer before replacing it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-02-01 13:53:52 +01:00
parent 5dd3ce9923
commit e0033ce871
+6
View File
@@ -676,6 +676,12 @@ func (b *gpuBuffer) Upload(data []byte) {
if b.hasBuffer {
firstBinding := firstBufferType(b.typ)
b.backend.funcs.BindBuffer(firstBinding, b.obj)
if len(data) == b.size {
// the iOS GL implementation doesn't recognize when BufferSubData
// clears the entire buffer. Tell it and avoid GPU stalls.
// See also https://github.com/godotengine/godot/issues/23956.
b.backend.funcs.BufferData(firstBinding, b.size, glimpl.DYNAMIC_DRAW)
}
b.backend.funcs.BufferSubData(firstBinding, 0, data)
}
}