Is it possible to test Metal API Validation without XCode?

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? **

Accepted Reply

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.

  • By only set MTL_DEBUG_LAYER=1, It just tirgger a crash without helpfull error messages

  • The assert message might also be accompanied in the crash log file under "Application Specific Information". If you're attached to the process with the debugger, you might also see the assert message there. In both those cases, you can also check the backtrace to see where your program asserted.

Add a Comment

Replies

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.

  • By only set MTL_DEBUG_LAYER=1, It just tirgger a crash without helpfull error messages

  • The assert message might also be accompanied in the crash log file under "Application Specific Information". If you're attached to the process with the debugger, you might also see the assert message there. In both those cases, you can also check the backtrace to see where your program asserted.

Add a Comment

When I only set MTL_DEBUG_LAYER=1, I got the validation crash report, but the report is so simple like this:

Missing some important detailed error messages to help locate the problem,I hope there are other configurations or methods to output Validation error messages?