KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.36k stars 648 forks source link

Unify vkb::allocated::Allocated and vkb::allocated::HPPAllocated into vkb::allocated::Allocated<bindingType> #1193

Open asuessenbach opened 1 month ago

asuessenbach commented 1 month ago

Description

Next class unified between C- and C++-bindings.

Build tested on Win10 with VS2022. Run tested on Win10 with NVidia GPU.

General Checklist:

Please ensure the following points are checked:

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

SaschaWillems commented 4 weeks ago

Could you add some comments to the allocated class? I'm having a hard time understand what it does and why we need it (instead of e.g. simply using a buffer class). Having some comment for the class would make things easier to understand.

asuessenbach commented 3 weeks ago

Could you add some comments to the allocated class?

I think, I have not removed any comment for this class. Maybe @jherico can add some comments, as he introduced that class with #906.

SaschaWillems commented 3 weeks ago

Yeah, that class never was properly commented, so it's up to the original author. As someone who is not doing C++ on a professional basis it's getting harder and harder for me to understand and use the framework, and having proper code comments would really help.

jherico commented 3 weeks ago

I can create a PR improving the comments for the the allocated class and it's children. Should I create it against the main branch or against your branch @asuessenbach ?

asuessenbach commented 3 weeks ago

@jherico Would be great, if you would comment against my branch. But commenting against main would be ok as well, I'd rebase my PR then.

jherico commented 3 weeks ago

@asuessenbach so, the purpose behind breaking up Allocated and AllocatedBase was that AllocatedBase wasn't templated and therefore most of the implementation could be put in the CPP file. This was beneficial when I was working on this code base because modifying ANYTHING in the class triggered a rebuild of basically everything else in the project.

If AllocatedBase is going to require a template argument and therefore have its implementation line in the header, there's no real reason to have it a distinct class from Allocated.

I can try to merge the two classes in the header in my PR, or I can just leave it as is (likely with a note in the AllocatedBase class description that the original reason for the distinction is gone and some future work could be done to merge them.

jherico commented 3 weeks ago

I also see the builder base class has been moved to its own file, but even in that file it should probably still be in the allocated namespace since many of the methods are still very much tied to the VMA. If the intent is to use the builder pattern elsewhere with additional Vulkan types, then it should be broken into multiple classes, one of which should be focused on the VMA allocated resources and remain in the allocated namespace.

asuessenbach commented 2 weeks ago

I can try to merge the two classes in the header in my PR

Would be great, if you would. But that could also be done after this PR has been merged.

I also see the builder base class has been moved to its own file, but even in that file it should probably still be in the allocated namespace since many of the methods are still very much tied to the VMA

If you think, it's worth to move the builder base class into the allocated namespace, I'm fine with it.