-
Notifications
You must be signed in to change notification settings - Fork 638
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
Add new sample for shader debugprintf #945
Add new sample for shader debugprintf #945
Conversation
Work-in-progress
Minor cleanup
Use VK 1.2 to avoid a bug with recent Vulkan SDKs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support debugPrintfEXT but I'm still seeing a couple of issues when I run this PR.
I get a validation error at the start:
VUID-vkCreateInstance-ppEnabledExtensionNames-01388(ERROR / SPEC): msgNum: -437968512 - Validation Error: [ VUID-vkCreateInstance-ppEnabledExtensionNames-01388 ] | MessageID = 0xe5e52180 | vkCreateInstance(): pCreateInfo->ppEnabledExtensionNames[0] Missing extension required by the instance extension VK_KHR_display: VK_KHR_surface. The Vulkan spec states: All required extensions for each extension in the VkInstanceCreateInfo::ppEnabledExtensionNames list must also be present in that list (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCreateInstance-ppEnabledExtensionNames-01388)
It terminates with an error about VK_KHR_get_physical_device_properties2
:
[error] [framework/platform/platform.cpp:169] Error Message: Couldn't request feature from device as VK_KHR_get_physical_device_properties2 isn't enabled!
[error] [framework/platform/platform.cpp:170] Failed when running application shader_debugprintf
Segmentation fault
and then segfaults in vkDestroySurfaceKHR()
called from VulkanSample::~VulkanSample()
Thanks for noticing. The framework seems to add |
I have added a tutorial for this sample. It's now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great description on how to use it.
For some unknown reason, this sample "runs" incredibly slow on my machine (multiple seconds per frame). But when the Vulkan Configurator is running as well, I don't get any output anymore and the speed is as expected. Any idea on that?
That seems to be a bug with the validation layers. I noticed this too, but couldn't reproduce :( |
This no longer crashes for me, but I'm still seeing:
|
Thank you very much for testing :) I guess that error is caused by #938 Currently the framework will always enable all features of an extension at the time it's requested. I'll see if I can do a workaround for that. |
I think, @gary-sweet's issue here is, that |
We do support VK_KHR_get_physical_device_properties2, so it's not obvious what the issue is. I'll do some degugging. |
It looks like this sample is creating its own VkInstance which it then constructs the Instance() object from. This appears to bypass a bunch of the extension enabling that happens in the Instance main constructor (all the enable_extension() stuff). The end result is that the Instance object doesn't think the extension is enabled, even though it actually is in the contained VkInstance. |
Yeah, it's similar to the profiles example. The framework assumes some stuff, even if you create your own instance, which in turn causes problems like these. It also tries to enable all features of an ext structure (see #928). But since I don't want to change anything about the framework in this PR (would be out of it's scope) I'll see if I can workaround this. |
This is kinda hard to debug, and I feel like this is platform-specific. The only place where this error is thrown is in (hpp_)phyiscal_device.h and at least on Windows I never even enter that code when running my sample. So we probably do something different/specific when running on your platform that causes the assert to trigger. I'll somehow try to reproduce this on Windows. I guess it's caused by this part of device creation: https://github.com/KhronosGroup/Vulkan-Samples/blob/main/framework/core/device.cpp#L109 It'll implicitly enable some extensions for all samples if they're supported. Sometimes I wish our framework wouldn't do so much implicit stuff. Often feels like the exact opposite of Vulkan :/ |
Sorry, this currently fails after merging main. Lots of framework changes and at least something missing for me to continue working on this, see #985, |
…ed in a sample will be marked as enabled in the instance class This is required to make other parts of the framework properly work with samples that do custom instance creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is now missing an entry in samples/CMakeLists.txt. This means the sample isn't currently runnable and doesn't appear in the samples lists in the help.
Welp, probably happened while merging with main. Thanks for letting me know, will fix. |
Can you check again? Afair the list in that cmake file is purely optional. I'm actually not sure why that list of samples in there even exist. CMake should do a folder traversal and adds all samples it can find, no matter if the sample is explicitly added in that list or not. |
Well that's odd then, because the sample didn't exist for me unless I hacked it into that file. |
That's interesting. I just reran cmake and deleted the cache beforehand and the sample is somehow picked up. Will have to investigate. |
Added it to the CMake file anyway. Can't hurt ;) |
Hmm. So I trashed my build folders completely and rebuilt and then it appeared, without the entry in cmake. It's possible that the cmake generate hadn't run, which is what I was seeing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that shader-printf 'just works' (provided that you support VK_KHR_shader_non_semantic_info) had kind of passed me by and I had to scratch my head for a little bit when I saw it working with my driver to figure out why!
What a very useful thing, and an excellent sample.
[If I had an extra button to auto-rotate the model it would be even better (since I have no other way to rotate API samples), but I can always add one later on.]
* Added new shader debzgprrintf sample Work-in-progress * Note on descriptor size Minor cleanup * Display shaderdebutprintf output in UI * Proper extension structure chaining * Restructure code Use VK 1.2 to avoid a bug with recent Vulkan SDKs * Minor adjustments * Use VK 1.1, clean up messages for UI display * Enable instance extensions * Started working on documentation/tutorial * Fixed link * Minor reordering Easier to document * Tutorial fpr shader printf * Update tutorial * Code adjustments based on review * Clang-format... * Add new argument to custom instance creation so that extensions enabled in a sample will be marked as enabled in the instance class This is required to make other parts of the framework properly work with samples that do custom instance creation * Add function to check if sample has a valid instance Fixes KhronosGroup#985 * Adjust to recent framework changes * Doc fix * Typo * Add sample to cmake ordered list
Description
This PR adds a new sample showing how to use debugprintf in shaders. It also includes a tutorial.
Note: This also does some changes to the framework required for samples that do custom instance creation.
Tested on Windows 11 with an NVIDIA RTX 4070
Fixes #926
Fixes #985
General Checklist:
Please ensure the following points are checked:
Note: The Samples CI runs a number of checks including:
Sample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: