Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug metal kernel of ios in Xcode?

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....

like image 229
Mohan Avatar asked Dec 04 '15 11:12

Mohan


People also ask

How do you debug a metal code?

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.

How do I run debug mode in Xcode?

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.

How do I debug in Xcode step by step?

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.

How do I debug Xcode on iPhone?

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.


1 Answers

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

like image 150
SurvivalMachine Avatar answered Oct 09 '22 12:10

SurvivalMachine