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

khronos_validation.printf_to_stdout seems not work #4074

Closed
Inori opened this issue May 3, 2022 · 6 comments
Closed

khronos_validation.printf_to_stdout seems not work #4074

Inori opened this issue May 3, 2022 · 6 comments
Assignees

Comments

@Inori
Copy link

Inori commented May 3, 2022

khronos_validation.printf_to_stdout seems not work on my machine.

The validation messages shows that I'm using the correct settings file and other options works right (like khronos_validation.enables).

Only the printf_to_stdout seems doesn't make sense.
Whether I set it to true or false, I got debug messages from both debug callback and stdout.

Vulkan SDK version: 1.3.211.0

printf_to_stdout = true:
QQ截图20220503095617

printf_to_stdout = false:
QQ截图20220503095328

I've already commented out std::cerr line in my debug callback (and yes I've registered it and it is getting called), I should expect no output, right?

Originally posted by @Inori in #2464 (comment)

@Inori
Copy link
Author

Inori commented May 3, 2022

OK, I figured it out.
I should remove 'VK_DBG_LAYER_ACTION_LOG_MSG' from khronos_validation.debug_action and this way I can control the stdout.
But a new problem occurs, when I removed VK_DBG_LAYER_ACTION_LOG_MSG, debug printf seems only work when printf_to_stdout is true.
When I set it to false, I got message saying buffer size that was too small, even I set printf_buffer_size = 65535

In short, printf_to_stdout=false only works when VK_DBG_LAYER_ACTION_LOG_MSG is set.

@TonyBarbour TonyBarbour self-assigned this May 3, 2022
@TonyBarbour
Copy link
Contributor

I'm not quite sure what you are seeing.

With everything set to default, you should see debug printf messages, among other messages, going to the Debug Utils callback. This looks like your second screenshot above - notice that the extra debug information when the printfs go through the callback.

With everything set to default, except for khronos_validation.printf_to_stdout = true you should see all but the debug printf messages going to the callback, and debug printf messages going to stdout This looks like your first screenshot where only the debug printf text is sent and no debug info is attached.

You shouldn't need to change khronos_validation.debug_action from it's default to see debug printf messages on stdout or in the callback.

I do see that some of your shaders are failing validation. Debug printf will not instrument shaders that fail validation, and you won't get any debug printf messages from them when they run.

The value of printf_to_stdout should have no effect on the buffer size required to receive debug printf messages.

Aside from validation messages being printed from your callback with your cerr line commented out, which I can't explain, it looks like everything is working as expected.

@Inori
Copy link
Author

Inori commented May 7, 2022

Ok, I see, thanks for your reply.

@Inori Inori closed this as completed May 7, 2022
@Inori
Copy link
Author

Inori commented Jun 8, 2022

@Tony-LunarG Hi Tony, sorry to disturb you again, I'm still suffering on similar issues.
I'm trying to print something from a compute shader, which local size is (10 x 10 x 1),
I got 2 problems:

  1. the validation layer still complains buffer size not enough, it seems the expect size is extremely big for this shader, and it crashes randomly on the memset at function end:
    QQ图片20220608182833

  2. I can't print more than one debug string, even if I emit 2 or 3 debug printf spir-v instructions, only the first one can be printed.

The spir-v bytecode is generated by my custom compiler, not compiled from glsl code, yet it can pass spirv-val check, for sure.
But I've compared the generated code, I didn't see any difference on debug printf instruction:

       OpExtension "SPV_KHR_non_semantic_info"
       %2249 = OpExtInstImport "NonSemantic.DebugPrintf"
       ...
       %2251 = OpString "exec %X
"
       %2253 = OpString "asuka %X
"
       ...
       %2250 = OpExtInst %void %2249 1 %2251 %2243
       %2252 = OpExtInst %void %2249 1 %2253 %2243

Can you give me some advice?

@Inori Inori reopened this Jun 8, 2022
@TonyBarbour
Copy link
Contributor

@Inori I'm on break this week but I should be able to more closely consider your first issue early next week.
One suggestion I have for now is that maybe you can limit the number of messages by conditionally using invocation ID to decide whether to print or not.
Also, you can increase memory available for debug printf using vkconfig or a layers settings file. The printf_buffer_size variable sets the size in bytes for each debug printf buffer (per draw / dispatch).

As for not receiving subsequent messages, there is only one debug printf buffer per draw, so if previous messages exhaust the available memory, subsequent messages will not appear - could that be what's happening?
Alternatively, are you sure that the subsequent messages are in a path executed by the shader invocation?

@Inori
Copy link
Author

Inori commented Jun 11, 2022

Limit message count using invocation ID together with a very big printf_buffer_size (over 65535) solves the problem.
Previously I though there must be something wrong, but it is really just not enough buffer size.
Thanks very much!

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

No branches or pull requests

2 participants