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

spirv-opt: --inst-debug-printf produces "Definition is not registered" #4908

Open
natevm opened this issue Aug 23, 2022 · 5 comments · May be fixed by #5184
Open

spirv-opt: --inst-debug-printf produces "Definition is not registered" #4908

natevm opened this issue Aug 23, 2022 · 5 comments · May be fixed by #5184

Comments

@natevm
Copy link

natevm commented Aug 23, 2022

I ran into this issue while adding support for some mixed shader stages when instrumenting debug printf.

Given the following code (HLSL -> SPV via dxc):

void commonFunction() {
  printf("Common function!\n");
}

[shader("miss")]
void MissProg(inout int tmp) {
    commonFunction();
}

I can produce the following unoptimized SPV
deviceCode_unoptimized_as.spv.txt:

Sending this .spv file through spirv-opt with the following passes:
--inline-entry-points-exhaustive
--inst-debug-printf

produces the following error:
Assertion failed: def && "Definition is not registered.", file SPIRV-Tools\source\opt\def_use_manager.cpp, line 56

@natevm
Copy link
Author

natevm commented Aug 25, 2022

@greg-lunarg any ideas what might be going wrong here? Perhaps it’s not expected for —inst-debug-printf to be used from the command line?

@greg-lunarg
Copy link
Contributor

Sorry. Missed this when it first came in. Hopefully you will have figured out how to use debug printf by this time. If not, please read on.

--inst-debug-printf is not a supported option for spirv-opt. It is not documented in the spirv-opt usage. The command line option was created as a debug aid for the developer (me) during the initial development of the debug printf capability. I will remove it.

Please refer to the following URL for help on how to use debug printf in Vulkan: https://vulkan.lunarg.com/doc/sdk/1.3.243.0/windows/debug_printf.html

greg-lunarg added a commit to greg-lunarg/SPIRV-Tools that referenced this issue Mar 29, 2023
@greg-lunarg greg-lunarg linked a pull request Mar 29, 2023 that will close this issue
@greg-lunarg
Copy link
Contributor

The command line option was created as a debug aid for the developer (me) during the initial development of the debug printf capability. I will remove it.

I have been persuaded to keep this in the CLI to facilitate debugging and fixing the instrumentation. I will instead add comments to warn users to use VVL to access debug printf.

@natevm BTW, I ran your SPIR-V through the latest version of --inst-debug-printf and it processes cleanly and generates valid SPIR-V. Once again, I apologize for the tardy response.

@natevm
Copy link
Author

natevm commented Mar 30, 2023

It’s been so long I have a hard time remembering, but I believe this issue was a blocker for issue/PR #4893 which was on enabling prints to work in mixed shader entry point environments. That PR unfortunately closed without resolution. Maybe we could open that up again now? Unless things have changed?

My ultimate goal was to achieve a similar power to OptiX and allow prints throughout a ray tracing pipeline without requiring users break up their program into separate shader compilation units.

Times have changed, and I’m bogged down on other tasks at the moment. But yeah, hopefully having this issue resolved will fix some growing pains.

@greg-lunarg
Copy link
Contributor

It looks like #4893 can move ahead by adding tests as requested by @s-perron .

greg-lunarg added a commit to greg-lunarg/SPIRV-Tools that referenced this issue Mar 31, 2023
This option is only for debugging/fixing debug printf instrumentation.
Users who wish to utilize debug printf should see the white paper at
vulkan.lunarg.com/doc.

Fixes KhronosGroup#4908
greg-lunarg added a commit to greg-lunarg/SPIRV-Tools that referenced this issue Mar 31, 2023
This option is only for debugging/fixing debug printf instrumentation.
Users who wish to utilize debug printf should see the white paper at
vulkan.lunarg.com/doc.

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

Successfully merging a pull request may close this issue.

5 participants
@greg-lunarg @natevm @s-perron @jeremyg-lunarg and others