Closed jeroenbakker-atmind closed 3 months ago
Response from @charles-lunarg
A couple of things:
1. The repo Api Dump lives in is `LunarG/VulkanTools`, not `KhronosGroup/Vulkan-Tools`. Extremely confusing and easy to get wrong. 2. Api dump doesn't print the parameters before calling down because it has no effective way to know which parameters are "input" and which are "output". Not to mention that the actual order of the parameters is mixed together. The general logic of API dump is "print function header, call down, print parameter values" 3. A couple of solutions * Add an option to print parameters before calling down. Will print out parameters wrong (ie before they are filled out). And if its an option, it has to be enabled which isn't very helpful if you don't know about the option * Add a crash handler that writes out the parameters in case of a crash? Maybe API Dump would store the data of the last called command and could read that upon a crash? * Actually figure out a way to distinguish input and output parameters from vk.xml. That could make API dump a bit smarter and print commands with only "input". It wouldn't do anything for the return value but that would help in this exact case.
Agree option 1 is confusing. A crash handler or extracting from vk.xml can work.
I think the extracting from vk.xml would be the best as a break signal can be continued/ignored. So splicing it into input/output parameters makes most sense. But it would change the print order in the log. I can imagine that some tools use the api dump for unit tests validation or any other reason. We don't as we have our own wrapper for it.
Wait wait wait.
returnedonly="true"
is an attribute of vk.xml in the structs & unions.
From https://github.com/KhronosGroup/Vulkan-Docs/blob/043260d06e96c8586492be41cc109945e92a69ff/registry.adoc#attributes-of-tagtype-tags
returnedonly - only applicable if "category" is struct or union. Notes that this struct/union is going to be filled in by the API, rather than an application filling it out and passing it to the API.
When was this added ????? TWENTY TWENTY????
Well that makes this a LOT easier to implement.
Okay in my exitement over the vk.xml having the necessary attributes, it wasn't clear that this isn't as simple as I thought.
The spec only declares the structs that are "only ever used as outputs" to be returnedOnly="true", which means structs that have dual purpose (like VkPhysicalDeviceFeatures2
) to lack the returnedOnly="true".
And since its per-struct and not per-command, the code generator will need to make sure to recursively check structs for their read-only-ness, rather than just checking the top level members of a command.
A bit of history: The initial version of api dump always printed the parameters after calling down (and coming back up) the chain. This resulted in the 'last command' being lost when a crash occurs. The decision was made to split the printing such that the function header was printed before calling down the chain, so users could at least see the 'last' command called, rather than be shown a command which did succeed but isn't where the crash occurred. This worked by printing the function name, the names of the input parameters (not their values), and the type of the return value. Then after calling down the chain, the return value would be printed if it existed, along with the parameters passed in.
So the main issue I have is that the current format is that only functions which return void can print their parameters before calling down the chain. In the case of vkCmdPipelineBarrier, that is the case, but I'm sure there are plenty of other functions which could have their parameters printed, just not their return values.
To fix the above issue, I believe the output format would need to be altered to put the return value after the parameters. Stashing the parameters so that the current print order would be maintained is no better since its still printing 'after' calling down the chain, where a crash could occur.
Or just accept that some functions which could print parameters before calling down wont and thats that.
Original issue: https://github.com/KhronosGroup/Vulkan-Tools/issues/1009
For debugging synchronization issues I enable via vkconfig both
VK_LAYER_LUNARG_api_dump
andVK_LAYER_KHRONOS_validation
with the next configuration.Notice I enabled the
Output to File->Log Flush After Write
andDebug Action->Break
options as I want to directly take action and see check stack frames. I don't write to file, but directly to the console.The issue is that
VK_LAYER_LUNARG_api_dump
doesn't report the parameter values before the synchronization log even when the layer is "closest to the vulkan application".I expected to see the parameters, before the synchronization issue and break signal so there is more information to check. Currently as the debugger is open I need to go back and forth to the stack frame that contains the information.
Expected log: