KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
777 stars 407 forks source link

Best practice coverage #8933

Open JoseEmilio-ARM opened 1 day ago

JoseEmilio-ARM commented 1 day ago

Could not find a list of existing best practice checks in https://vulkan.lunarg.com/doc/sdk/latest/windows/validation_error_database.html, is this because they do not have VUIDs?

Would it be possible to generate a similar list to see at a glance the available best practice checks?

Thank you!

spencer-lunarg commented 1 day ago

so about 4 years ago I created this https://gitlab.khronos.org/vulkan/vulkan/-/issues/2743

It was an idea to make BPID (Best Practice IDs) to act like VUID

The core issue with best practice (for non-vendor specific things) it is not realistic for us as the Validation Layers engineer to decide by ourselves "what is best for Vulkan" and we would want the Working Group companies opinions.

As for something like the database, yes I "could" list all the current things like "BestPractices-vkCreateImage-sharing-mode-exclusive" but this provides you zero information what the check is checking and more importantly, what you should be doing instead

If you grep "BestPractices- you will be able to find them all in the code, but will then be required to read the code/message to understand what it is doing... not ideal at all

JoseEmilio-ARM commented 1 day ago

Thank you very much @spencer-lunarg!

Agree on the limitations of that proposal. Indeed I was looking for a simple list, I thought just the name and messages (formatted nicely) one could get a sense of what is checked/missing, and compare across releases?

From some example output, messages do contain a "MessageID", are these BPIDs? Vendors could maybe use these to provide their own database with more resources for each check?

spencer-lunarg commented 1 day ago

so yes, for the Vendor related checks, I went through and tried to label them so if you search "BestPractices-Arm- you should find them all (there "might" be a few that are missing because they are shared, so searching VendorSpecificTag(kBPVendorArm) will find those)

messages do contain a "MessageID", are these BPIDs?

Yes, I am calling these BPID but unofficial term

Vendors could maybe use these to provide their own database with more resources for each check?

I am more than happy to accommodate anyone who wants to put energy into the Best Practice layers! If you (as ARM) want to be the first to set a system, happy to maintain it!

One idea is you start every Arm based ID as "BestPractices-Arm- (and if multi-vendor maybe go "BestPractices-OtherVendor-Arm so it is still searchable

We currently have layers/vulkan/generated/vk_validation_error_messages.h which is generated from validusage.json in the Vulkan-Headers. That validusage.json is also used to generate the Database you see.

For the short term, the Validation Layers could contain a best_practice_id.json file that would list out things like

{
    "bpid" : "BestPractices-Arm-vkCreateImage-non-transient-ms-image",
    "vendors" : ["Arm"],
    "suggestion" : "some information about why this is a best practice"
}

then we print the error message it looks more like

skip |= LogWarning("BestPractice-Arm-...", "Here are the values that caused this error %s %d", value_0, value_1);                                   

and we pull the suggestion from the JSON (generated to the header) to print the detailed information about "why" and "what" the user should do

Again, happy to help set this up, but would need someone to spend time (at least for one vendor's worth of checks) to go through them all