Implement MeshRD for RenderingDevice buffers#117836
Conversation
fcf3140 to
e62fc91
Compare
e62fc91 to
dee164e
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
I think the exposed API needs some work, especially in light of godotengine/godot-proposals#14741. Right now the API suffers a few problems:
For the simplest case (dynamically modifying a Mesh, users can just retrieve the RD buffers and manipulate the mesh from a compute shader (once godotengine/godot-proposals#14741 is merged). So keep in mind that this API should be supporting a different workflow and a different subset of tradeoffs. As I mentioned in godotengine/godot-proposals#7209, I'm pretty sure the majority of users will be happy with just having access to the raw buffers godotengine/godot-proposals#14741. The users that need more likely need:
My gut feeling is that a MeshRD API should be a very thin API wrapping a few RD functions to create a mesh from existing buffers (vertex, index + indirect) and leaves the responsibility with managing the buffers to the user. I feel that building up all of this very high level "automagic" API is counter productive for a feature that already requires users to write very complex compute shaders. |
|
As someone whos been excitedly waiting for these kinds of features, i definitely agree with what clayjohn says; buffer access + indirect draw would be all that is needed in terms of API, any sort of further abstraction would be kind of unnecessary if not even a potential limitation |
dee164e to
a41cb5f
Compare
a41cb5f to
34273a5
Compare
|
Refactored this PR around the narrower indirect procedural GPU meshes use case.
Since #118973 already exposes RD buffer RIDs for existing mesh surfaces, I removed that overlapping workflow from this PR’s old code, and kept this focused on creating a mesh from caller-owned buffers. The demo project has also been updated to use the new API |
44bc38d to
7e77e04
Compare
7e77e04 to
46315bf
Compare
Closes (partially) godotengine/godot-proposals#7209.
This PR adds
MeshRD, a low-levelMeshresource for indirect procedural GPU meshes.The basic idea is simple: users create the
RenderingDevicebuffers themselves, pass those RIDs toMeshRD.add_surface(), then fill the buffers from compute shaders.MeshRDmakes the result usable as a normalMeshresource, so it can be assigned toMeshInstance3D.mesh.This avoids the GPU -> CPU -> GPU roundtrip that
ArrayMeshrequires, and keeps ownership clear:MeshRDdoes not allocate, own, free, expose, or serialize the buffers passed to it. The caller owns all RD buffers.Since #118973 already exposes existing mesh surface RD buffer RIDs, this PR no longer tries to cover that use case. It only focuses on creating a mesh from caller-owned buffers and drawing it indirectly.
Tested locally on macOS arm64.
Demo project:
https://github.com/maidopi-usagi/godot_meshrd_demo
Includes the following demos:
API Overview
MeshRDadd_surface(format, primitive, vertex_count, vertex_buffer, aabb, attribute_buffer, index_count, index_buffer, ...)surface_set_indirect_buffer(surf_idx, indirect_buffer, offset)clear_surfaces()/surface_remove(surf_idx)Minimal Usage
Disclaimer: AI was used to resolve the conflicts and update the example demo project. The core changes and documentations were written by hand.