Closed pc-john closed 2 years ago
So if I add this code to the end of the VkDebugPrintfTest.GpuDebugPrintf test in this repository, I do get a "Hello" message in the debug callback:
compute_test:
auto c_queue = m_device->GetDefaultComputeQueue();
char const *csSource =
"#version 450\n"
"#extension GL_EXT_debug_printf : enable\n"
"void main() {\n"
" debugPrintfEXT(\"Hello\");\n"
"}\n";
VkShaderObj shader_module(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this);
VkPipelineShaderStageCreateInfo stage;
stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stage.pNext = nullptr;
stage.flags = 0;
stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
stage.module = shader_module.handle();
stage.pName = "main";
stage.pSpecializationInfo = nullptr;
VkPipelineLayoutObj compute_pipeline_layout(m_device);
VkComputePipelineCreateInfo pipeline_info = {};
pipeline_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
pipeline_info.pNext = nullptr;
pipeline_info.flags = 0;
pipeline_info.layout = compute_pipeline_layout.handle();
pipeline_info.basePipelineHandle = VK_NULL_HANDLE;
pipeline_info.basePipelineIndex = -1;
pipeline_info.stage = stage;
pipeline_info.flags = VK_PIPELINE_CREATE_DISPATCH_BASE;
VkPipeline c_pipeline;
vk::CreateComputePipelines(device(), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &c_pipeline);
hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
begin_info.pInheritanceInfo = &hinfo;
m_commandBuffer->begin(&begin_info);
vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_COMPUTE, c_pipeline);
vk::CmdDispatchBase(m_commandBuffer->handle(), 1, 1, 1, 1, 1, 1);
m_commandBuffer->end();
vk::QueueSubmit(c_queue->handle(), 1, &submit_info, VK_NULL_HANDLE);
vk::QueueWaitIdle(m_device->m_queue);
vk::DestroyPipeline(device(), c_pipeline, nullptr);
@pc-john Are you sure that your compute shader is running and that the path with the debug printf is being taken? Could you provide some reasonably small reproduction code?
@Tony-LunarG I created minimal example. One problem I reached: Validation layers cause the crash of the application if Vulkan 1.0 is requested by instance. The correct way would be to print validation warning (?) that vkCmdDispatchBase is available only since Vulkan 1.1.
The second observation is that vkCmdDispatch really works as expected. The debugPrintfEXT prints the text. The third observation: vkCmdDispatchBase(0,0,0,...) does not print anything, neither vkCmdDispatchBase(1,1,1,...).
Relevant places in the code:
One more thing comes to my mind: I am on the latest SDK 1.2.189. If you are on the latest git sources, it might possibly make the difference (?).
Just what I was about to ask. Any SDK beyond 1.2.154 should be working. Latest master works for me for all 3 dispatches (thanks for the repro case - it helps a lot). Are you getting the debug printf message in a callback? Are you using / have you tried the DEBUG_PRINTF_TO_STDOUT=1 environment variable? I'm still thinking through possible causes.
Also, what OS / GPU / driver are you using?
In your real code, I assume that the dispatchBase does more than debug printf - can you see that other stuff happen when the debug printf does not? Are you positive that the shader is being executed?
My system: Windows 10, i7-10875H, Intel UHD graphics + Quadro RTX 3000 (Optimus).
I double-checked that I am on SDK 1.2.189, both with source compilation and with VulkanConfigurator. I have to admit that I was using VulkanConfigurator of SDK 1.2.170 before by a mistake in Start menu. So, I verified what works and does not work once again, without seeing much of difference. It still does not work. The results:
Remaining settings of VulkanConfigurator: Printf verbose false, DebugAction/Log message false, Debug output true, Break true, Message severity all checked. If you see some asserts fired up on Windows during app tear down, it is a bug in VulkanHPP - already fixed in git.
Anyway, I found out this "Redirect Printf messages to stdout" rather confusing because it has side effects. It renders Break option as ineffective for shader printf messages and the same for debug output. I would rather see three check boxes in "Debug printf" section instead: break on printf, debug output of printf, and stdout output of printf. Or just break, debug output and stdout output.
It would be also very nice to have "Do not break on createinstance startup info". I can put it in ignore messages, but having it there without break would be the most nice in my opinion (?). Anyway, it is not a bug, just personal preference.
To be precise with my recent comment: "with/without stdout redirect" I mean Vulkan Configurator GUI option in Validation Areas -> Shader-Based -> Debug Printf -> Redirect Printf messages to stdout . Then, I am running the application in debug from Visual C++ 2019. If you would not be able to reproduce it, we can look in more detail.
Reproduced it with the 1.2.189 SDK. It appears the debug printf + vkCmdDispatchBase issue is fixed with https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/3478 I still need to figure out the Vulkan 1.0 crash in vkCmdDispatchBase, so this is only partially fixed in the SDK that should be available next week.
Confirming that the debug printf + vkCmdDispatchBase is fixed in SDK 1.2.198.0 . So, only Vulkan 1.0 crash in vkCmdDispatchBase in validation layers remains unfixed.
The 1.0 crash in vkCmdDispatchBase is logged in #3579, so closing this
Thanks!
debugPrintfEXT() does not print anything when using vkCmdDispatchBase (and probably vkCmdDispatchBaseKHR as well). When I change the code to use vkCmdDispatch, all works as expected with the following message:
UNASSIGNED-DEBUG-PRINTF(INFO / SPEC): msgNum: -1841738615 - Validation Information: [ UNASSIGNED-DEBUG-PRINTF ] Object 0: handle = 0x1fcc0aef058, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x92394c89 | [... shader text ...]
I use the latest SDK (1.2.189.2) on MSVC 2019.