Skip to content
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

Unify class VulkanSample and HPPVulkanSample. #910

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

asuessenbach
Copy link
Contributor

@asuessenbach asuessenbach commented Feb 13, 2024

Description

First step to unifying C- and C++-bindings of vulkan in the framework: Unify the central classes VulkanSample and HPPVulkanSample.
Conceptually does the following:

  • replaces VulkanSample and HPPVulkanSample by a templated class template <bool CppBindings> VulkanSample.
  • internally, that new class uses the C++-bindings.
  • controlled by the bool template parameter CppBindings, it provides some interface functions using the C-bindings data types or the C++-bindings data types.
  • for now, all the other classes with two flavors (Device and HPPDevice, ...) still exist and their usage in this class' interface are also controlled by the bool template parameter CppBindings.
  • to gracefully handle that dichotomy, all members of that class are private now, and some accessor functions are provided.
  • especially due to that latest bullet point, literally all samples needed to be touched to use those accessor functions!

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

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

Sample Checklist

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

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

framework/vulkan_sample.h Outdated Show resolved Hide resolved
framework/vulkan_sample.h Outdated Show resolved Hide resolved
framework/CMakeLists.txt Outdated Show resolved Hide resolved
framework/hpp_api_vulkan_sample.h Outdated Show resolved Hide resolved
framework/hpp_vulkan_sample.h Outdated Show resolved Hide resolved
framework/vulkan_sample.h Show resolved Hide resolved
framework/vulkan_sample.h Outdated Show resolved Hide resolved
framework/vulkan_sample.h Outdated Show resolved Hide resolved
@asuessenbach asuessenbach marked this pull request as ready for review February 19, 2024 14:25
@asuessenbach
Copy link
Contributor Author

Somehow other peoples changes has sneaked into this one. Maybe due to some rebasing?
And I don't know, how to get them out of the PR again. Can anybody help me with that?

@tomadamatkinson
Copy link
Collaborator

Somehow other peoples changes has sneaked into this one. Maybe due to some rebasing?
And I don't know, how to get them out of the PR again. Can anybody help me with that?

@asuessenbach as it has been a few days it likely wont be achievable with git reflog. Something you might try is

  • Checkout your branch
  • Checkout a new branch (temp to test the changes without editing your current work)
  • Squash your commits
  • Rebase again on main - override any changes present in your branch with those in main

I tend to be able to fix these changes locally if it happens to me but its quite hard to recall the precise steps i normally take. The steps above may not work for you but its something to try at least

@tomadamatkinson
Copy link
Collaborator

I will take a more thorough review once the rebase issues are sorted. I reviewed vulkan_sample.h and the sample changes. Unsure which changes have leaked in from other commits.

Im happy with the overall interface. I would have suggested something like get_device and get_c_device to keep things ultra simple, but I didn't realise just how large the VulkanSample interface had grown. Is the idea to slowly phase out the C interfaces using this same technique?

@asuessenbach
Copy link
Contributor Author

asuessenbach commented Mar 4, 2024

I will take a more thorough review once the rebase issues are sorted. I reviewed vulkan_sample.h and the sample changes. Unsure which changes have leaked in from other commits.

It seems, all the alien changes have gone with my latest force-push. So feel free to review in more depth ;)

Copy link
Collaborator

@tomadamatkinson tomadamatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general very happy with the change. Following this pattern in the future should let us condense a lot of the duplicate interfaces. In time this should help simplify things again but also mean that we transition to the C++ api seamlessly.

Will approve when ive tested locally. Hopefully tomorrow! If i don't end up reviewing soon please @ me

SaschaWillems
SaschaWillems previously approved these changes Mar 5, 2024
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on Windows 11 with an RTX 4070 and on Android 13 with a Google Pixel 4a (build from Windows 11). Compiles and runs fine on both.

I'm not much of a C+++ expert, but this looks like a nice solution and a step in the right direction and gets a thumbs up from me :)

Thank you very much for this PR!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this updated intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was intentional.
For some unknown reason, one of the compiler in the CI complained about some template magic in Vulkan-Hpp. Updating that to a newer version resolved that.

JoseEmilio-ARM
JoseEmilio-ARM previously approved these changes Mar 6, 2024
Copy link
Collaborator

@tomadamatkinson tomadamatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for all the work on this

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Unify class VulkanSample and HPPVulkanSample.

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Fix typo.

Adjust hpp_timestamp_queries and oit_depth_peeling.

Fix color_write_enable.

Fix validation errors in timeline_semaphores sample (KhronosGroup#927)

* Fix validation errors in timeline_semaphores sample

The command buffer was being implicitly reset, but wasn't resettable.

* Review feedback addressed

Used a much simpler approach to resolve the error

Allow explicit skips in batch mode (KhronosGroup#914)

* Allow explicit skips in batch mode

* Fix bug in CLI11 wrapper that inhibits multi-value flag parsing

Unify class VulkanSample and HPPVulkanSample.

Unify class VulkanSample and HPPVulkanSample.

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Introduce enum class vkb::BindingType to select between C- and C++-bindings of vulkan; replaces the boolean template parameter of VulkanSample.

Adjustments after rebasing.

Update vulkan

Adjustments due to rebasing.

Unify class VulkanSample and HPPVulkanSample.

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Unify class VulkanSample and HPPVulkanSample.

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Fix typo.

Adjust hpp_timestamp_queries and oit_depth_peeling.

Fix color_write_enable.

Fix validation errors in timeline_semaphores sample (KhronosGroup#927)

* Fix validation errors in timeline_semaphores sample

The command buffer was being implicitly reset, but wasn't resettable.

* Review feedback addressed

Used a much simpler approach to resolve the error

Allow explicit skips in batch mode (KhronosGroup#914)

* Allow explicit skips in batch mode

* Fix bug in CLI11 wrapper that inhibits multi-value flag parsing

Unify class VulkanSample and HPPVulkanSample.

Unify class VulkanSample and HPPVulkanSample.

Introduce type aliases on conditional types; refactor dual interface functions to single ones using those conditional types.

Plus slightly adjust a few functions in VulkanSample for consistency.

Fix indentation in CMakeLists.txt; simplify body of VulkanSample::create_instance; fix device usage in profiles sample

Introduce Parent for class VulkanSample.

Introduce enum class vkb::BindingType to select between C- and C++-bindings of vulkan; replaces the boolean template parameter of VulkanSample.

Adjustments after rebasing.

Update vulkan
@marty-johnson59
Copy link
Contributor

Merging per agreement on the call - now that conflicts are resolved..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants