-
Notifications
You must be signed in to change notification settings - Fork 15
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
Advanced vertex format support #56
base: master
Are you sure you want to change the base?
Conversation
I added an implementation of the derive macro. Currently the user has to provide the number of locations a type requires (if it requires more than 1), e.g. https://github.com/trevex/screen-13/blob/vertex-layout/src/driver/vertex.rs#L141 This could be automated and checked for correctness if more information about the formats is available. For example if the following were to exist: https://android.googlesource.com/platform/external/vulkan-validation-layers/+/HEAD/layers/vk_format_utils.cpp#40 Currently still missing from this PR:
|
I'm watching this with interest however I do have concern about the macro-based design. For users who decide they need advanced vertex layouts, they should provide bindings/attributes directly as the data is pretty simple. If they manually provide erroneous data I would prefer they rely on validation layers for debugging. One tiny issue is that two I'll throw together my thoughts into a different branch and see if that makes sense. |
Hmm, interesting, if I understand you correctly, I agree that The idea of the I will leave the validation out for now, as you said the validation layers already provide this information. So the scope of this PR will be to ease the creation of Let me know what you think. |
Okay I finished the basic implementation, but it is not yet used by Creating the let pipeline = Arc::new(GraphicPipeline::create(
&event_loop.device,
GraphicPipelineInfo::with_explicit_vertex_layout([
MyVertex::layout(vk::VertexInputRate::VERTEX), // explicit `VertexInputState` can be used as `VertexLayout` as well
MyInstanceData::layout(vk::VertexInputRate::INSTANCE),
]),
[
Shader::new_vertex(
// ...
),
Shader::new_fragment(
// ...
),
],
)?); I will hold off on further changes to this PR for now to hear your thoughts. |
Thanks - I'll look at what you did! Here is my idea as to how to implement this; I just give users the ability to specify those Vulkan structs. Unfortunately my example has got some sort of problem; I see the data come out correctly in RenderDoc but it fails to transform properly and instead of I will try this example on your branch and see if I can reproduce the issue or a fix. |
Okay as for my branch - I fixed the issue in the example. It was just that we need to use I'm going to merge #57 for the base functionality desired by this PR/issue; but I don't want to stop the creativity or throw this effort away. I think it provides value on top of the "manual" way for some cases; such as the one you mention where one model might have a shadow pass and PBR pass which use the same buffer but different layouts. The I think this This is where
|
Ok, let me rework the code then into a The current names of this PR (mainly This would also save me the time to think of new alternative names. |
Good change; the concept is "vertex layout" but the Vulkan term is "vertex input". I dropped "state" from the user-accessible function because the rest of the code generally doesn't surface helper words and also a conflict with the |
PR was automatically closed when I force pushed current master to start porting code from scratch to |
@attackgoat Okay, integrating the code from The current implementation extends I added a triangle example to illustrate the usage: https://github.com/trevex/screen-13/blob/vertex-layout/contrib/screen-13-macros/examples/triangle.rs I also tried defining As mentioned in the beginning it would be great to get some feedback. Maybe there is another way to integrate all-together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came out fantastic. I love that it adds something useful without forcing users through a macro they don't understand at first. The ramp of difficulty on vertex input is now automatic -> manual -> magic with each level giving the user more power.
I admit I don't fully understand the macro yet, and I would like to test it for two vertex bindings with different rates, but this is definitely mergable now and I would say it could improve in future changes if needed.
An instanced rendering example would be a good thing some day.
…cations are properly incrementes for formats exceeding single location
Thanks for the feedback. I now fixed all the to dos I still left as comments in the code, so the macro should handle the following cases as well:
I believe the code is in a good state now, so I will work on the following next:
|
As described in #54, this draft PR tries to illustrate the basic idea.
Fixes #54