-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Backend of rendy #13
Comments
Worth mentioning that we are using Rendy in wgpu implementation, and now forced to look for a replacement (with one of the options - to refresh gfx-memory). @omni-viral
Let me provide some more details. HAL API is based on iterators, and Vulkan API needs slices of low-level objects. All that the Vulkan backend needs is basically collecting the necessary data in memory before issuing the low-level calls. This is just copying a few bits of data, it's not that much of an overhead. Moreover, our expectation is that the user doesn't have the data laid out sequentially anyway: they typically have their own wrappers carrying more accompanying data, and these may be in elaborate data structures, not just vectors. In this (expected) case there isn't any more work happening when going "user -> gfx-hal -> gfx-backend-vulkan" than the user would do with "user -> vulkan". |
Please note: Amethyst people hardly discussed this backend issue so far. We haven't agreed on anything. It's generally problematic who owns |
(Disclaimer, I may not be the most qualified to talk about this, but regardless...) I think that we should continue to support both backends. The reasoning being that is since we want rendy to be Vulkan based, that's simply easier to accomplish by using a "pure" Vulkan API. However, I do think hal is the way forward eventually and getting feedback from what we find in doing rendy might prove to be beneficial to the gfx team in the long run. The problem here is that it's (very understandably) difficult for @omni-viral to figure out all the abstractions and keep the implementations up to date for both backends while still trying to be productive. Amethyst is long overdue for a renderer revamp and having our main developer of that new renderer not being able to efficiently iterate on it is a pretty bad scenario as you can probably imagine. That's where my "proposal" comes in. I'm personally completely willing to put in the work required to keep both backends alive. They will both after all be needed eventually anyway. I think missing out on the cooperation between Amethyst and the gfx team would be very unfortunate so if @omni-viral is okay with it, I would like for us to keep the abstractions we have made and continue improving on them in order to support both ash and hal. I'm not completely sure how much this will help the productivity problem, but I think that this is regardless the best way forward for all parties. |
Can you (or Viral) elaborate on that? |
@torkleyy I just saw that I got pinged, thank you for the ping, I will try to make a useful braindump below. The main thing that stands out to me from the side-lines is that I think tighter collaboration, more communication, between the Amethyst and gfx-rs team would be great for both projects and possibly for the Rust ecosystem as a whole. I'm confident that you guys can produce amazing results if you establish more and better communication. I added a confused emoji to the original thread because it looked like you were dumping gfx-rs, which would be very unfortunate and would duplicate a massive amount of work. Please reconsider and leverage gfx-rs fully by collaborating tightly with the gfx-rs team. The rust ecosystem is quite small and fragmentation hurts productivity as well as quality. Collaborate more, reinvent fewer wheels. ❤️ |
First of all I'd like to state that for me PR is a form of proposal, not something cemented. @kvark Rendy's memory crate in particular benefits almost nothing from using Ash instead of original abstract API because it has next to zero trade-offs. Even less since abstract API allows mock implementation for testing. If someone (@magnonellie) feels ready to support both crates I have no objections. Maybe the best course of actions would be to move hal closer to ash. Make it more flexible. Considering iterators in API. Having concrete type in signature of a function you plan to call few thousand times per second encourages you to store data in that type and call a function without any conversions. Moving bits costs when you do it a lot. I totally would like to discuss it further. |
Is there any reason for using ash other than the potential performance advantage (why would we be able to gain a significant performance improvement by doing a part of the abstraction on our own instead of focusing on one layer?) and the documentation? The step to use pure ash seems more like a convenient one to me than anything we want mid or long term. I'm not sure if it makes sense to delay (potentially necessary, idk) documentation work on hal to get rendy done sooner, since that will just require more work later. |
By making it zero-cost for ash. I don't want to make another abstraction layer (I was wrong thinking otherwise).
What we want mid or long term? |
Not to duplicate efforts. What if gfx gets low level optimizations, debugging facilities, etc? Maintaining two backends is a lot more work, and it's hard to believe for me that a high-level rendering API can be zero-cost. |
@omni-viral
I don't know what to think of that, tbh. The last sentence reads half obvious and half inappropriately offensive.
This general direction has been considered in full: gfx-rs/gfx#2206
I've made an RFC about this recently - gfx-rs/gfx#2457, and got some positive feedback, but nothing constructive so far. You are welcome to express the views on the issue.
I don't think it matters much given that you are the only one working on the rendering subsystem. I agree that generating the docs locally adds a tiny bit of friction, but it's not a showstopper.
We are discussing this in gfx-rs/gfx#2453 . I don't see how this affects you, tbh. You can just treat all gfx-hal as unsafe on your side today, especially since that's what you do for Ash already.
Are you sure that you are optimizing the right thing here? Do you have a hotspot in mind that uses iterators in gfx-hal and that would be improved by you storing the data in the arrays?
Has Amethyst team actually sit together and put a priority on Vulkan as a backend? I still remember the old good times when Unreal came out and we had this wonderful multiple choice window at start, asking to pick D3D/GL/Glide/MeTaL/software, and I couldn't have guessed which one would work best until I benchmarked all of them, considering all of performance, quality, and stability. And these were the times when everyone could theoretically write GL-only apps (like Id software did) and run on all the platforms, much unlike today where Vulkan support is very limited (no Intel Haswell/Broadwell and below on Win10, no MacOS, poor debugging experience, very small Android user base, etc). If I were you, I'd want to give users more choice, support more platforms, and... ideally have this beauty back: |
No. It can't.
Low-level optimizations are done when implementing higher level API. Debug facilities exists in Vulkan and not exposed by gfx. |
Didn't mean to. I was refering to rendys abstraction traits you can find in master as worthless. |
I already mentioned this in discord, but I don't think that it matters. Just stick with the the library that works the best for you right now, or where you have spent to most time. You should probably abstract over the various APIs anyway. Create a backend like If you went with hal, you get the other backends for free, although I am not sure how stable all the backends are right now. If you went wish ash, you get Vulkan and Dx12/Metal etc though the portability lib or Metal with MoltenVk. I am not sure how much overhead there will be compared to hal. You can also still create custom backends like I don't think maintaining multiple backends will be that much work. Remember you only need a subset of the various APIs, and rendy appears to expose at least some low level things like memory, which means a lot of optimization can happen in the higher level layer. Also hal and ash are still very similar. So it should be straight forward to add another Vulkan backend if anyone wants to maintain it. |
@MaikKlein thank you for input. I just think it's weird to have multiple Vulkan backends. |
It could make sense, but only in the context of performance. Yes, if you have a nicely defined higher level model of interacting with GPU, you can probably take more advantage of mapping it to the low-level APIs directly. Is this really what you want to do though? This task would require enormous effort to implement, test, and maintain. Not to mention the arguable benefit to Rust community, given that you'd be doing everything from scratch. It's also unclear if you are planning to expose the rendering model for non-Amethyst apps, and what advantage it would have versus things like wgpu-rs or even three-rs. |
I am somewhat confused by the iterator performance issue. rustc is pretty good at optimizing them, do you have a specific example where it would not be equivalent? |
No, unless someone would need that additional performance. You were telling that you want this nice window where one can choose from different available backends to see which is most performant on target machine. But I highly doubt if all those backends are hidden behind vulkan API that vulkan backend will be outperformed (if available ofc). Hence I think it makes sense to focus on the vulkan backend. @Moxinilian they are optimized. Yes. But when you compare iteration with storing result in array of some sort versus having this array in the first place then the only way it can be equal is iterating through same array. Which is not the case since types are different. @kvark suggests that overhead is negligible and I have no benchmarks to prove otherwise. So let's just agree with @kvark on the matter. |
I have one crazy idea. What if instead of accepting tons of iterators to the methods Same can go with resources. That's even two crazy ideas. |
@omni-viral unfortunately, this would mean even more generic types that gfx-hal would expose and the backends would have to implement. In general, we'd like to reduce this type zoo, not grow it. I think the clone-ability discussion in gfx-rs/gfx#2457 will yield results, and we'll make sure to take Amethyst interests into account. But for iterators, I strongly believe there is no action required until we see a performance hit. Take the pipeline barriers into account: if you aren't re-using the command buffer and instead re-recording it, the time spent copying the barriers when iterating is going to be negligible comparing to the time spent on recording the command buffer. Let's not worry about it at this point. |
Why you'd want to reduce type zoo? Is it even possible? |
We were settled on gfx-hal |
This issue shall discuss which backend(s) rendy is going to use.
Discussion so far:
@kvark
@omni-viral
@Moxinilian
@kvark
@Moxinilian
@kvark
@Moxinilian
@Moxinilian
@omni-viral
Also pinging:
(please ignore if you're not interested)
The text was updated successfully, but these errors were encountered: