From the manual https://keith.github.io/xcode-man-pages/MetalValidation.1.html, I figure out that, when I launch my app with thos environment variables, It may work.
this is my current environment variables
And I really get the API Validation Message from the logs like this:
This is my another test , I do not set the Metal_DEBUG_ERROR_MODE, METAL_ERROR_MODE and METAL_ERROR_CHECK_EXTENDED_MODE, just let it as the default value, then I got these results: 1.the app trigger a crash when met with API Validation Failure 2.the Failure message is too simple to fix the bug:
Here is my **problem: Can I trigger a crash when the API Validation Fail, and get the API Validation detail message by setting the environment variables? **
By default when enabling Metal API Validation, when validation issues occurs it causes an assert and crashes your program, which I believe is what you want.
According to man MetalValidation I think you should set MTL_DEBUG_LAYER=1. MTL_DEBUG_LAYER_ERROR_MODE already should default to assert. However I don't think you want to set METAL_DEBUG_ERROR_MODE=5 (this is an older environment variable) -- I believe that value of 5 uses NSLog instead of asserts. I don't think METAL_ERROR_MODE should be used too. Please check the manual page and I suggest try only starting with MTL_DEBUG_LAYER=1, then add others that we document as needed to debug your issue.