-
Notifications
You must be signed in to change notification settings - Fork 307
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
headers are too large #1325
Comments
Perhaps it is time to think about using C++20 modules in a near future. |
This is already possible by defining VULKAN_HPP_NO_SMART_HANDLE. If you see more candidates for features to be opted out, please let me know!
I think, I don't get what you mean... more like those defines listed?
What compile errors did you get? Maybe I can do something to make life easier in such situations? |
Thanks for your comment,
Yes I found out about this flag after posting. So taking my words back. Regarding more features - I think that documenting the hpp generator code and allowing generation of thinner headers could be helpful.
I mean separate sets of headers where the corresponding code is not even contained. I think it could make IDEs and compiler much happier. Also, making the implementation code in separate headers / sections could also do good instead of having the implementations in the headers themselves. For instance, AMD memory allocator takes this approach.
The compiler errors I got emanated from a bug in the MSVC compiler / cmake. I was using precompiled headers that was shared (reused) among multiple cmake targets. When I included vulkan_raii, the generated precompiled header compiled just fine but got corrupted when copied by other targets that use it. |
Totally agree.
You mean for those "power users" that generate their set of vulkan.hpp headers on their own, instead of just use what they get with the vulkan sdk? Might be a good approach. The minimal headers could be pretty small then!
Is noted, and I will give that a try... might take a while, though. |
@asuessenbach Thank You! |
Would it be possible to add an option to the generator to create headers that contain only the declarations |
This thread really expresses my concerns. vulkan.hpp really slows down compilation by number of seconds for each compiled file where it is included. The problem became so big that I started to look for alternatives. Not sure what is slowing down the compiler (template magic, or something else). If there is some feature I am still looking for, it is the speed of compilation. All other new features makes me scared that the compilation will be even slower. |
Probably the easiest way to generate a custom trimmed version of the header is to create a custom vk.xml as this is used as the basis for the generator. One could filter the vk.xml to only include extensions used in the own project or only used struct+their dependencies. Filtering extensions with a allow+block list for the generator would maybe be a possibility for customization. Maybe it would be useful to put extensions into separate headers? Pairs of StructExtends alone takes 4924 lines of the header of the 14k vulkan.hpp header. They are only for additional compile time validation. |
Extensions could maybe also be gated by optionally gated by |
I've conducted a couple of compile-time experiments now, and conclude a couple of things:
That is, if someone would identify a feature that should be removable, that is should be guarded by some define, I'd be happy to add that. |
@RYDB3RG Thanks a lot for your investigations! |
As a side note: using vulkan.hpp (or vulkan_raii.hpp) as a precompiled header substantially reduces compile time. |
Are there any plans to support C++ modules? This would reduce compile times without having to use vulkan.hpp as a precompiled header. Visual Studio 2022 already supports modules and clang16 will be released with modules support. A big limitation would be that selecting features with macros would no longer be possible and macros like |
Nice, there is now a vulkan.cppm in this repo! |
Plus 1. The version I'm using (which is a bit old compared to the repo) has a I've actually made some design decisions around the size issue, which is to say that I've confined my use of vkhpp to only my core rendering library. The per-compile file time overhead of this header is just too much so any code or functionality I need outside of that library either uses my own wrappers or I don't expect the size issue to get fixed just due to the nature of the vkhpp, although I do like the idea of a custom vkhpp build for my project that eliminates features I don't use. I don't have time however to dig into the generation code, but if I had a generation executable with command line parameters to control the output I'd make time for that. |
Interesting idea. This might help to speed up compilation time.
Hm. Actually, I am just on opposite side :-) . My IDE is fast enough to show big files. So, splitting vulkan.hpp into subheaders or sub-subheaders just complicates the things to me. If I look for something particular in the headers, I have to think first which file is it located instead of just typing Ctrl-F and the keyword. I also need to keep number of files open instead of single one. So, for me personally, it is just annoyance to have vulkan.hpp split into multiple files. But I understand that others might have different preferences. |
Right @pc-john... the appeal of splitting the giant headers down depends on how we each use the header. For me, I mostly just hit my "go to definition" key over one of the structs so I can take a quick look at methods and parameters. I hop right to the struct in the vkhpp header, look around, and then I'm usually done. I very rarely scroll through the vkhpp headers. But for others, if there are scanning the header in a broader sense, then yes a split out header would be a pain. I'll see how it goes for me in the future... If I get frustrated enough I may just take a few hours and write a script to split them out locally. |
@pc-john This is kind of funny... I just went looking for this GitHub project via google search of "GitHub vkhpp" and the first link was this: https://github.com/skyline-emu/vkhpp
The project is defunct for years, just kind of funny that I found it unintentionally after having this discussion haha. |
Nice there is already solution! In broader sense, it seems like having customizable generator that could generate customized headers for each project might be interesting idea. I know this one: https://github.com/Vulkan-FIT/vkcpp-gen. It includes GUI for selecting your options. You can skip unused extensions/generate core headers only, customize generated API and other things. This might reduce file size and compilation time. Not sure if this might be an idea for Vulkan-HPP as well (?). |
I know that pre-compiled headers provide an advantage for MSVC. But for clang/gcc they actually took longer than not using precompiled headers for Vulkan-hpp. Of course |
I really like using vulkan-hpp. But I think the generated headers are way too large for most users.
This has significant productivity implications:
Another issue I encountered is that when I tried putting vulkan_raii.hpp as an include file in my precompiled headers, I got the weirdest compile errors about incompatible precompiled headers (this is probably an MSVC issue, but still - it took a long time to figure out that vulkan_raii.hpp is the issue).
I think there should be an option to generate "lighter" headers:
The text was updated successfully, but these errors were encountered: