-
Notifications
You must be signed in to change notification settings - Fork 781
Add sample demonstrating VK_KHR_shader_relaxed_extended_instruction #1420
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
base: main
Are you sure you want to change the base?
Add sample demonstrating VK_KHR_shader_relaxed_extended_instruction #1420
Conversation
|
I'm not really sure what I'm expecting to see with this sample. What I'm currently seeing is that I seem to have some seemingly random framebuffers begin displayed, and a bunch of these being printed to the console: |
|
Hello! I don't know if GLSL emits those, but you can have a HLSL shader doing the same thing with the following code: // RUN: %dxc %s -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -E main -fspv-debug=vulkan-with-source -O3
class A {
void foo(uint3 gid) {
printf("relaxed-ext-inst demo: gid = %u", gid.x);
}
};
[numthreads(1, 1, 1)]
void main(uint3 gid : SV_DispatchThreadID)
{
A a;
a.foo(tid);
}Here, one |
# Conflicts: # samples/extensions/README.adoc
… and update copyrights to 2026
|
Great thanks for the validation of HLSL. I went ahead and switched from GLSL to Slang and validated that it does emit the OpExtInstWithForwardRef instruction. This Sample should now be ready (also merged the latest master and fixed merge conflicts.) |
… with debug info to trigger OpExtInstWithForwardRef
samples/extensions/shader_relaxed_extended_instruction/README.adoc
Outdated
Show resolved
Hide resolved
shaders/shader_relaxed_extended_instruction/slang/relaxed_demo.comp.slang
Outdated
Show resolved
Hide resolved
|
I'm still just seeing three random garbage frames cycling on the display. Will need some investigation. |
|
On my platform And then an endless list of The actual sample windows stays black. Is that to be expected? |
…/DXC with UI-driven dispatch and message capture Replaces Slang shader with HLSL variant using DXC that reliably emits OpExtInstWithForwardRef patterns. Adds interactive UI with value slider and manual dispatch button, captures debugPrintf messages via debug utils callback, and eliminates per-frame dispatch to avoid console spam. Updates to Vulkan 1.3 target and pre-records UI render pass commands.
|
I implemented a GUI and allow user to send a number that will be printed out from the shader and routed back to the GUI. I also am displaying in the GUI if the sample is supporting the extension being used. As our framework already enables vkdebugprintf in shaders, you will see the print outs even if you don't have the extension supported. However, in the case that the user were to implement this on a system that supports it, then they can use the relaxed extended instruction to not need to do extra work and see their shader print out. |
gary-sweet
left a comment
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 am seeing the debug messages appear in the UI, but only if I build in debug mode, is that expected? In release mode, no messages ever appear.
| { | ||
| if (drawer.header("VK_KHR_shader_relaxed_extended_instruction")) | ||
| { | ||
| const bool has_ext = get_instance().is_enabled(VK_KHR_SHADER_RELAXED_EXTENDED_INSTRUCTION_EXTENSION_NAME); |
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.
get_instance().is_enabled doesn't appear to report device extensions. I see OFF for both extensions when they are both actually supported.
|
The messages in the UI will appear in the case that Validation Layers and debugprintf are enabled, that happens in the framework when we do a debug build. So, artifact of that. |
Should we make it obvious somewhere that this only works fully in debug mode? I can just see people (like me) thinking that it just doesn't work. |
|
This one, technically is more technical. See, the point of the extension is if you don't enable debugprintf for the shader in your code, you can still use it as it's a relaxed extended instruction. Thus, the real bug is on your system that does support the extension you're getting it behaving like the extension doesn't exist. In Release and Debug with the extension you'll get it behaving properly. Without the extension's help, you'll get it behaving "properly" due to us making that a convenient call. |
|
actually found the bug... I'm an idiot. device extension not instance extension. |
…tensions The VK_KHR_shader_relaxed_extended_instruction and VK_KHR_shader_non_semantic_info are device extensions, not instance extensions. Update the check to use `get_device().is_extension_enabled()` instead of `get_instance().is_enabled()`.
Keenuts
left a comment
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.
Shader in the latest revision LGTM (demonstrated opcodes are present) Thanks!
|
Does compile and run for me (Win 11, RTX 4070), but I do get several warnings. First these: And at a later point these: |
Description
Add a sample that shows how to use VK_KHR_shader_relaxed_extended_instruction and tutorial for it.
Fixes #
General Checklist:
Please ensure the following points are checked:
Note: The Samples CI runs a number of checks including:
If this PR contains framework changes:
batchcommand line argument to make sure all samples still work properlySample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: