VertexBuffer cleanup and simplification.#3775
Conversation
| updateVertexArrayObject(rp, vb); | ||
| } | ||
| const GLVertexBuffer* vb = handle_cast<GLVertexBuffer*>(vbwo); | ||
| if (UTILS_UNLIKELY(rp->gl.vertexBufferVersion != vb->bufferObjectsVersion)) { |
There was a problem hiding this comment.
we're sure that vb can't be nullptr here? by construction?
There was a problem hiding this comment.
That's a good point, it's possible for Filament to create a render primitive and never set it up with a vertex buffer and index buffer. However I would argue that calling draw() with an uninitialized render primitive is a mis-use of the Driver API.
Maybe this is a good candidate for assert_invariant.
There was a problem hiding this comment.
No I think it make more sense to do nothing in that case. It's like drawing an empty draw call.
There was a problem hiding this comment.
Ok, added an 'if unlikely" for the empty draw call case.
| } | ||
| buffers.push_back(buffer); | ||
| } | ||
| buffers.resize(bufferCount); |
There was a problem hiding this comment.
I think we can remove the call to buffers.reserve here.
There was a problem hiding this comment.
Good catch, removed.
This includes changes to OpenGL, Metal, and Vulkan backends. At the backend level, vertex buffers are now always composed of buffer objects. This lets us simplify the Driver API and some bookkeeping in the backends. This change also splits MAX_VERTEX_ATTRIBUTE_COUNT into two constants because the maximum number of bound buffers is a separate concept from the maximum number of attribute semantics (e.g. consider interleaving). For now these two constants are set to the same value. We also now store a byte count in HwBufferObject, which allows us to remove the byte count from the Metal-specific handle, and to add some asserts to debug builds to prevent size overflow.
This leak was introduced in the following PR on April 7. #3775 The guilty party has been contacted and properly admonished for his transgression.
This leak was introduced in the following PR on April 7. #3775 The guilty party has been contacted and properly admonished for his transgression.
This leak was introduced in the following PR on April 7. #3775 The guilty party has been contacted and properly admonished for his transgression. This was tested by adding the following code after applyAnimation in gltf_viewer.cpp static int nframes = 0; if (!gpath.empty() && nframes++ > 100) { static int count = 0; printf("reloading %d\n", count++); nframes = 0; app.resourceLoader->asyncCancelLoad(); app.resourceLoader->evictResourceData(); app.viewer->removeAsset(); app.assetLoader->destroyAsset(app.asset); loadAsset(gpath, app); loadResources(gpath, app); }
This leak was introduced in the following PR on April 7. #3775 The guilty party has been contacted and properly admonished for his transgression. This was tested by adding the following code after applyAnimation in gltf_viewer.cpp static int nframes = 0; if (!gpath.empty() && nframes++ > 100) { static int count = 0; printf("reloading %d\n", count++); nframes = 0; app.resourceLoader->asyncCancelLoad(); app.resourceLoader->evictResourceData(); app.viewer->removeAsset(); app.assetLoader->destroyAsset(app.asset); loadAsset(gpath, app); loadResources(gpath, app); }
This leak was introduced in the following PR on April 7. #3775 The guilty party has been contacted and properly admonished for his transgression. This was tested by adding the following code after applyAnimation in gltf_viewer.cpp static int nframes = 0; if (!gpath.empty() && nframes++ > 100) { static int count = 0; printf("reloading %d\n", count++); nframes = 0; app.resourceLoader->asyncCancelLoad(); app.resourceLoader->evictResourceData(); app.viewer->removeAsset(); app.assetLoader->destroyAsset(app.asset); loadAsset(gpath, app); loadResources(gpath, app); }
This leak was introduced in the following PR on April 7. google#3775 The guilty party has been contacted and properly admonished for his transgression. This was tested by adding the following code after applyAnimation in gltf_viewer.cpp static int nframes = 0; if (!gpath.empty() && nframes++ > 100) { static int count = 0; printf("reloading %d\n", count++); nframes = 0; app.resourceLoader->asyncCancelLoad(); app.resourceLoader->evictResourceData(); app.viewer->removeAsset(); app.assetLoader->destroyAsset(app.asset); loadAsset(gpath, app); loadResources(gpath, app); }
This includes changes to OpenGL, Metal, and Vulkan backends.
At the backend level, vertex buffers are now always composed of buffer
objects. This lets us simplify the Driver API and some bookkeeping in
the backends.
This change also splits MAX_VERTEX_ATTRIBUTE_COUNT into two constants
because the maximum number of bound buffers is a separate concept from
the maximum number of attribute semantics (e.g. consider interleaving).
For now these two constants are set to the same value.
We also now store a byte count in HwBufferObject, which allows us to
remove the byte count from the Metal-specific handle, and to add some
asserts to debug builds to prevent size overflow.