Skip to content

Conversation

@gpx1000
Copy link
Collaborator

@gpx1000 gpx1000 commented Oct 16, 2025

Description

Introduce a new Vulkan sample demonstrating VK_KHR_pipeline_binary usage. It includes querying pipeline keys, capturing pipeline binaries, and managing them explicitly. The sample is accompanied by documentation, CMake lists, shaders, and updates to the Vulkan framework mapping.

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

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

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 readme of the folder that the sample belongs to e.g. api 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

Introduce a new Vulkan sample demonstrating VK_KHR_pipeline_binary usage. It includes querying pipeline keys, capturing pipeline binaries, and managing them explicitly. The sample is accompanied by documentation, CMake lists, shaders, and updates to the Vulkan framework mapping.
- Add detailed logging for pipeline binary operations.
- Introduce UI overlay in `PipelineBinary` to display aggregated log information.
- General code clean-up and formatting adjustments.
Copy link
Contributor

@gary-sweet gary-sweet left a comment

Choose a reason for hiding this comment

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

I can only really say that this builds ok as we don't currently support pipeline binaries.

Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

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

Nice little sample. Just a few comments...

# Conflicts:
#	framework/vulkan_type_mapping.h
#	samples/extensions/README.adoc
…etrics

Add interactive GUI to demonstrate pipeline recreation from scratch vs. from cached binaries with timing measurements. Implement binary persistence (save/load to disk) and display performance statistics including speedup calculations. Update documentation to reflect new interactive features and workflow.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need a new volk version?
Shouldn't that be done by a separate PR?

Replace C-style string formatting (snprintf with char buffers) with std::format for cleaner, more modern C++ code. Use vk::to_string for VkResult enum values instead of casting to int. Consolidate duplicate LOGI/LOGW calls and log_text_ updates into single operations per message.
@asuessenbach
Copy link
Contributor

You might need to #include <format>.

@gary-sweet
Copy link
Contributor

I see a bunch of compilation errors:

samples/extensions/pipeline_binary/pipeline_binary.cpp: In member function 'void PipelineBinary::log_pipeline_binary_support()':
samples/extensions/pipeline_binary/pipeline_binary.cpp:195:36: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
195 | std::string message = std::format("VK_KHR_pipeline_binary support: pipelineBinaries = {}", !!features.pipelineBinaries);
| ^~~~~~
In file included from /build/gsweet/vc5_git/thirdparty_vulkan/Vulkan-Samples/components/core/include/core/util/error.hpp:54,
from framework/common/error.h:24,
from framework/camera.h:20,
from framework/api_vulkan_sample.h:34,
from samples/extensions/pipeline_binary/pipeline_binary.h:20,
from samples/extensions/pipeline_binary/pipeline_binary.cpp:18:
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:199:24: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
199 | message = std::format(
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp: In member function 'void PipelineBinary::demo_pipeline_key_and_binary()':
samples/extensions/pipeline_binary/pipeline_binary.cpp:224:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
224 | std::string message = std::format("vkGetPipelineKeyKHR failed ({}); skipping binary capture", vk::to_string(static_cast<vk::Result>(res)));
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:232:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
232 | std::string message = std::format("Got pipeline key ({} bytes)", key.keySize);
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:251:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
251 | std::string message = std::format("vkCreatePipelineBinariesKHR failed ({}); driver may not support capturing binaries in this context",
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:267:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
267 | std::string message = std::format("vkGetPipelineBinaryDataKHR size query failed ({}); skipping data fetch", vk::to_string(static_cast<vk::Result>(res)));
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:287:52: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
287 | std::string message = std::format("Binary signature: {} {} {} {} ...", binary_data_[0], binary_data_[1], binary_data_[2], binary_data_[3]);
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~
samples/extensions/pipeline_binary/pipeline_binary.cpp:296:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
296 | std::string message = std::format("vkGetPipelineBinaryDataKHR failed ({}); data not available", vk::to_string(static_cast<vk::Result>(res)));
| ^~~~~~
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 7, 2026

hmm... Issue here. std format was introduced in C++20. I don't think we've updated this project to require C++20 yet. @asuessenbach are you okay if I revert back to the original version?

@SaschaWillems
Copy link
Collaborator

We did update to C++20 in march 2025, see #1257

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 7, 2026

ahh... right, I forgot thanks! Okay, fixing CI to allow for format.

Configure clang-tidy to use C++20 standard and reformat command for readability. Fix include order in pipeline_binary.cpp to follow conventions (standard headers alphabetically).
…lchain path

Install g++-13 to provide libstdc++ headers and configure clang-tidy to use GCC 13 toolchain via --gcc-toolchain flag to resolve C++20 standard library compatibility issues.
Remove Docker container dependency and install steps. Detect and use available run-clang-tidy version (18, 17, or default) from the system. Remove GCC 13 toolchain configuration as it's no longer needed.
Install libxcb1-dev to satisfy CMake dependencies and remove GLFW_BUILD_X11=OFF flag to restore default X11 support.
@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 7, 2026

Alright, the clang-tidy check in CI finally passed. I might recommend we take this PR before we take any other PRs that use C++20 so the CI has a chance to stay green.

@gary-sweet
Copy link
Contributor

I'm still seeing one build error sadly:

samples/extensions/pipeline_binary/pipeline_binary.cpp:26:10: fatal error: format: No such file or directory
26 | #include <format>
| ^~~~~~~~

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 8, 2026

That's what I was talking about with regards to do we want to use C++20 everywhere. format is the C++20 header. You might need to see if you can't get a newer STL. clang-tidy had the same issues which is what I fixed with the CI check.yml file if you want to review it.

@gary-sweet
Copy link
Contributor

That's what I was talking about with regards to do we want to use C++20 everywhere. format is the C++20 header. You might need to see if you can't get a newer STL. clang-tidy had the same issues which is what I fixed with the CI check.yml file if you want to review it.

Hmm. Well we (as in the GPU group) don't have any control over the toolchain that is required to be used for our set-top boxes unfortunately. We're currently forced to use gcc12. If that's the problem here we won't be able to build anything at all after this.

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 8, 2026

Let's discuss on the next Samples call. We can targeted only rely upon things that also exist in gcc12 in my opinion as I don't think we get anything but syntactic sugar with std::format instead of what I had previously; also I really don't want to exclude any devices or people that are actively helping if we can help it :)

@gary-sweet
Copy link
Contributor

Let's discuss on the next Samples call. We can targeted only rely upon things that also exist in gcc12 in my opinion as I don't think we get anything but syntactic sugar with std::format instead of what I had previously; also I really don't want to exclude any devices or people that are actively helping if we can help it :)

Agreed. We literally wouldn't be able to run anything if we're forced down that route.

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 8, 2026

For this sample, I'll go ahead and revert the std format requirement (if that's okay @asuessenbach). I'll do that in the morning though, it's my 1am.

@gary-sweet
Copy link
Contributor

For this sample, I'll go ahead and revert the std format requirement (if that's okay @asuessenbach). I'll do that in the morning though, it's my 1am.

My advice - go to bed!

@asuessenbach
Copy link
Contributor

I think, I don't get that: we're on C++20 and gcc12 supports that nicely. But it doesn't have that format header?

@asuessenbach
Copy link
Contributor

asuessenbach commented Jan 8, 2026

I'll go ahead and revert the std format requirement (if that's okay @asuessenbach).

I really don't like that snprintf-technique. But maybe that's just me.
Maybe you could as well just concatenate std::strings?
Like
std::string message = std::string( "VK_KHR_pipeline_binary support: pipelineBinaries = " ) + features.pipelineBinaries ? "true" : "false";

@gary-sweet
Copy link
Contributor

I think, I don't get that: we're on C++20 and gcc12 supports that nicely. But it doesn't have that format header?

This is what AI has to say about it (believe as much of it as you dare):

While GCC 12 supports many C++20 features, it does not have a full implementation of <format>.

Full support for the std::format library in GCC didn't arrive until GCC 13. If you try to include <format> in GCC 12, you will likely run into a "file not found" error or find that the std::format namespace is missing.

@SaschaWillems
Copy link
Collaborator

We do include fmt as a formatting library that's already used in the framework and samples. Why not use that instead of std::format?

Switch from C++20 std::format to fmt library for broader compiler compatibility.
Fix formatting and indentation inconsistencies introduced in previous refactoring.
@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 8, 2026

Excellent suggestion Sascha. fmt seems to be a good direct replacement.

@gary-sweet
Copy link
Contributor

More build errors I'm afraid:

samples/extensions/pipeline_binary/pipeline_binary.cpp: In member function 'void PipelineBinary::demo_pipeline_key_and_binary()':
samples/extensions/pipeline_binary/pipeline_binary.cpp:296:44: error: 'format' is not a member of 'std'; did you mean 'fmt::v11::format'?
296 | std::string message = std::format("vkGetPipelineBinaryDataKHR failed ({}); data not available", vk::to_string(static_cast<vk::Result>(res)));
| ^~~~~~
In file included from /build/gsweet/vc5_git/thirdparty_vulkan/Vulkan-Samples/components/core/include/core/util/error.hpp:54,
from framework/common/error.h:24,
from framework/camera.h:20,
from framework/api_vulkan_sample.h:34,
from samples/extensions/pipeline_binary/pipeline_binary.h:20,
from samples/extensions/pipeline_binary/pipeline_binary.cpp:18:
third_party/fmt/include/fmt/format.h:4198:31: note: 'fmt::v11::format' declared here
4198 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
| ^~~~~~

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Jan 9, 2026

Ah... I missed one... simply replacing std to fmt will fix it. I'll push a fix just a sec.

@gary-sweet
Copy link
Contributor

Thanks, this does now build for me, and correctly reports that we don't support the extension.

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.

5 participants