-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom vertex formats #158
Conversation
Oops. I accidentally transitioned out of draft mode. I put it back for now. I will eventually learn how to use Github. |
I want to capture some of the ideas that came up in Discord for how to improve the structure of this change.
|
Can you rebase this on master? Format checking was enabled, and the CI doesn't yet check for it at the commit you're at |
…nce pipeline layouts should always be available for changed meshes
…atten the mesh module
I implemented the I also went ahead and deleted the Instead of implementing the map from descriptor to pipelines, I figured that could maybe happen in a separate PR. It's only an issue for scaling to many pipelines, which is probably not a huge concern yet. |
Sorry for the delay. Just finished a first pass over the code. First, lets answer some questions:
Its there to provide consistent VertexBufferDescriptors across pipelines, even when shaders don't list identical vertex attributes. Your changes result in multiple copies of mesh buffers for each pipeline layout used. For example, a pipeline with the layout [ Given how expensive syncing buffers is (and the potential for shaders to have many different permutations of attributes), it made sense to me to allow configuring shared VertexBufferDescriptors that give shaders a common set of attributes.
See the above rationale. It allows pipelines to be configured to share mesh buffers. I think this is a valuable property worth preserving.
I think you ended up not using LoadingMeshes and opted to add pipeline compilation to the render graph. I think i'd like pipeline compilation to remain a system, as it isn't involved in the creation of command encoders.
Dang. We should work around that, but I think i would prefer it if we worked around it at a higher level (ex: in our mesh allocation code). I'd prefer it if the backend buffer logic was "what you ask for is what you get".
Yeah I'd also prefer it if we didn't do this. Lets solve this after we decide the best way to handle "mesh buffer sharing".
We need to store the mapping between "original descriptor + specialization" to "specialized descriptor" somewhere. Given that the PipelineCompiler is what operates on that data, it made sense to me to store it there. I'm open to suggestions if you have better ideas.
I know I'm the one that suggested that mesh_resource_provider_system gets moved to a graph node, but I'm (regrettably) having second thoughts about that. In general the purpose of the render graph is to generate command buffers in parallel. mesh_resource_provider_system doesn't need to generate command buffers and fits quite nicely into normal system constraints. I think I'm actually going to push for things to move out of the graph that dont relate to command
Yeah the current solution is quite expensive. We should work out ways to optimize it. Summary / High Level Thoughts
@aclysma and @lachlansneff: you are both pretty deep into the bevy renderer at this point, so I'd love to hear your thoughts here too. |
Oops didnt answer all of the questions. I'll edit the message above to fill them in. |
Hey @cart thanks for the detailed feedback. I think I agree with all of your points, and I wasn't aware that there was an intent to share vertex buffers between pipelines with different descriptors, but that makes sense. In that case, I think the existing shader reflection logic that generates And concerning the graph nodes, I was mostly just trying it out because it seemed to fit the dependency model, but after seeing how the other graph nodes are used, I agree that it's just causing more boilerplate for this particular use case. |
Some general thoughts not necessarily related to this PR (most of which you have probably already though through for yourself!):
|
Closing in favor of the direction we're taking in #599 (and future follow up prs) |
I don't think this code is very good. I just wanted to hack this functionality in as easily as I could.
I encountered a little confusion and some obstacles to make this work:
VertexBufferDescriptors
resourcePipelineLayout::sync_vertex_buffer_descriptors
PipelineCompiler
in theDRAW
stage, but we want to use the layout during theRENDER_RESOURCE
stage. So when an entity is created with aMesh
and aRenderPipelines
, the layout isn't ready yet to create the vertex buffer. I just added theLoadingMeshes
resource to fix this, but I don't think that's the right final solution.VertexBufferDescriptor
s every frame even in frames where vertex buffers don't need to be created. Not sure what the best way to handle this is.PipelineDescriptor
we need is stored inside of thePipelineCompiler
. Maybe there is a better place for it.Also, what's the bar for writing tests? I'm happy to add some. Not sure if there are any particular test patterns I should follow.