Ahhh fix everything;

- If you have an instanced batch, it will use the instanced mesh.  That
  has a drawID attribute that uses the identity buffer, which has a vertex
  divisor.  BUT if you only have one instance, then we won't emit an
  instanced draw, and the use of a divisor'd attribute w/ a non-instanced
  draw is causing mega problems on macOS.
- This also fixes observed macOS bugs like:
  - Needing to have a small UBO
  - Flickering at startup
  - Flicker when writing to the last byte of a UBO
  - etc.
- Also make the generic attribute value for lovrDrawID more correct (scalar instead of vector).
This commit is contained in:
bjorn 2019-06-29 20:24:36 -07:00
parent afe4d8c0e3
commit 6256acfc6d
2 changed files with 7 additions and 3 deletions

View File

@ -128,7 +128,7 @@ static const uint32_t bufferCount[] = {
[STREAM_VERTEX] = (1 << 16) - 1,
[STREAM_DRAWID] = (1 << 16) - 1,
[STREAM_INDEX] = 1 << 16,
#if defined(LOVR_WEBGL) || defined(__APPLE__) // Work around bugs where big UBOs don't work
#if defined(LOVR_WEBGL) // Work around bugs where big UBOs don't work
[STREAM_MODEL] = MAX_DRAWS,
[STREAM_COLOR] = MAX_DRAWS,
#else
@ -592,7 +592,7 @@ next:
}
// Start a new batch
if (!batch) {
if (!batch || state.batchCount == 0) {
if (state.batchCount >= MAX_BATCHES) {
lovrGraphicsFlush();
}
@ -707,6 +707,10 @@ void lovrGraphicsFlush() {
} else {
lovrMeshSetIndexBuffer(batch->draw.mesh, NULL, 0, 0, 0);
}
if (batch->draw.mesh == state.instancedMesh && batch->draw.instances <= 1) {
batch->draw.mesh = state.mesh;
}
}
lovrGpuDraw(&batch->draw);

View File

@ -2089,7 +2089,7 @@ Shader* lovrShaderInitGraphics(Shader* shader, const char* vertexSource, const c
glVertexAttrib4fv(LOVR_SHADER_VERTEX_COLOR, (float[4]) { 1., 1., 1., 1. });
glVertexAttribI4uiv(LOVR_SHADER_BONES, (uint32_t[4]) { 0., 0., 0., 0. });
glVertexAttrib4fv(LOVR_SHADER_BONE_WEIGHTS, (float[4]) { 1., 0., 0., 0. });
glVertexAttribI4ui(LOVR_SHADER_DRAW_ID, 0, 0, 0, 0);
glVertexAttribI1ui(LOVR_SHADER_DRAW_ID, 0);
lovrShaderSetupUniforms(shader);