I have written metal kernel (.metal) in shader language. But it's not working as I expected so I thought about debugging and I am following Metal Tips and Techniques for debugging. I have called the insertDebugCaptureBoundary
method of MTLCommandQueue
to inform Xcode about debugging.
But still not able to debug GPU part of code like we do in CPU. While doing step debugging in CPU part of code how I will be get prompted to GPU code(.metal file) ? Is it possible to debug the step by step code of GPU ?
If I am asking something meaningless please tell me how to do debugging of GPU code(.metal file) in Xcode ?
Thanks for reading....
Press and hold an area within the attachment, and Xcode displays the targeting reticle. Adjust the location of the targeting reticle to the pixel you want to debug, and click the Debug button. The shader debugger starts and displays the fragment function that rendered the selected pixel in the source code view.
When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.
To try to debug it, set your active scheme in Xcode to be AppName > iPhone 11 Pro Max. Then using the simulator alone (not Xcode) click on the AppName to let it run. Then go into Xcode and do Debug > Attach to process by PID. Then type in the name of your App, and click Attach.
Plug your iPhone into your computer. You can select your device from the top of the list. Unlock your device and (⌘R) run the application. You'll see Xcode install the app and then attach the debugger.
You need to configure the build to use a recent iOS target version and set the Metal compiler options to include source code. Open "Build Settings" -> "Metal Compiler - Build Options" - "Produce Debugging Information".
More information here: https://developer.apple.com/documentation/metal/shader_authoring/developing_and_debugging_metal_shaders
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With