1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-03 04:53:35 +00:00

Fix some batching edge cases;

- Reduce size of vertex buffer by one to account for primitive restart.
- Always write to the draw ID buffer to prevent it from going out of sync with the vertex buffer and prevent a potential problem with geometry reuse.
This commit is contained in:
bjorn 2019-01-12 18:25:38 -08:00
parent bb9d354ac9
commit 5382bc3379

View file

@ -31,7 +31,7 @@ static void onResizeWindow(int width, int height) {
} }
static const size_t BUFFER_COUNTS[] = { static const size_t BUFFER_COUNTS[] = {
[STREAM_VERTEX] = 1 << 16, [STREAM_VERTEX] = 1 << 16 - 1,
[STREAM_INDEX] = 1 << 16, [STREAM_INDEX] = 1 << 16,
[STREAM_DRAW_ID] = 1 << 16, [STREAM_DRAW_ID] = 1 << 16,
[STREAM_DRAW_DATA] = 256 * MAX_BATCHES * 2 [STREAM_DRAW_DATA] = 256 * MAX_BATCHES * 2
@ -730,13 +730,11 @@ void lovrGraphicsFlush() {
batch->indexCount = cached->indexCount = indexCount * n; batch->indexCount = cached->indexCount = indexCount * n;
flushGeometry = true; flushGeometry = true;
if (!instanced) {
uint8_t* ids = lovrGraphicsMapBuffer(STREAM_DRAW_ID, batch->vertexCount); uint8_t* ids = lovrGraphicsMapBuffer(STREAM_DRAW_ID, batch->vertexCount);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
memset(ids, i, vertexCount * sizeof(uint8_t)); memset(ids, i, vertexCount * sizeof(uint8_t));
ids += vertexCount; ids += vertexCount;
} }
}
state.cursors[STREAM_VERTEX] += batch->vertexCount; state.cursors[STREAM_VERTEX] += batch->vertexCount;
state.cursors[STREAM_INDEX] += batch->indexCount; state.cursors[STREAM_INDEX] += batch->indexCount;