mirror of https://github.com/bjornbytes/lovr.git
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:
parent
bb9d354ac9
commit
5382bc3379
|
@ -31,7 +31,7 @@ static void onResizeWindow(int width, int height) {
|
|||
}
|
||||
|
||||
static const size_t BUFFER_COUNTS[] = {
|
||||
[STREAM_VERTEX] = 1 << 16,
|
||||
[STREAM_VERTEX] = 1 << 16 - 1,
|
||||
[STREAM_INDEX] = 1 << 16,
|
||||
[STREAM_DRAW_ID] = 1 << 16,
|
||||
[STREAM_DRAW_DATA] = 256 * MAX_BATCHES * 2
|
||||
|
@ -730,13 +730,11 @@ void lovrGraphicsFlush() {
|
|||
batch->indexCount = cached->indexCount = indexCount * n;
|
||||
flushGeometry = true;
|
||||
|
||||
if (!instanced) {
|
||||
uint8_t* ids = lovrGraphicsMapBuffer(STREAM_DRAW_ID, batch->vertexCount);
|
||||
for (int i = 0; i < n; i++) {
|
||||
memset(ids, i, vertexCount * sizeof(uint8_t));
|
||||
ids += vertexCount;
|
||||
}
|
||||
}
|
||||
|
||||
state.cursors[STREAM_VERTEX] += batch->vertexCount;
|
||||
state.cursors[STREAM_INDEX] += batch->indexCount;
|
||||
|
|
Loading…
Reference in New Issue