Prevent mapped buffers from being discarded;

We never try to do this anyway, and the unmapping code in discard
doesn't flush contents so it's better for people to unmap the
buffer themselves before calling discard.
This commit is contained in:
bjorn 2020-09-19 17:21:37 -07:00
parent 61e9c746a8
commit 2e65d71a74
1 changed files with 1 additions and 5 deletions

View File

@ -2291,16 +2291,12 @@ void lovrBufferUnmap(Buffer* buffer) {
void lovrBufferDiscard(Buffer* buffer) {
lovrAssert(!buffer->readable, "Readable Buffers can not be discarded");
lovrAssert(!buffer->mapped, "Mapped Buffers can not be discarded");
lovrGpuBindBuffer(buffer->type, buffer->id);
GLenum glType = convertBufferType(buffer->type);
#ifdef LOVR_WEBGL
glBufferData(glType, buffer->size, NULL, convertBufferUsage(buffer->usage));
#else
if (buffer->mapped) {
glUnmapBuffer(glType);
buffer->mapped = false;
}
GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
buffer->data = glMapBufferRange(glType, 0, buffer->size, flags);
buffer->mapped = true;