citra-emu/citra — pull request #218 by neobrain (2014-11-23 14:33:25+00:00)
Title: Pica debugger improvements

This branch makes some major additions to the currently quite limited pica debugger.

* Breakpoints: There is now a list of graphics-related breakpoints which (if enabled in the corresponding widget) will halt emulation to allow for fixing the current console state. Other than being able to inspect the current state without it being modified all the time, this allows for controlled capturing of pica traces (e.g. to capture all commands belonging to a particular batch of triangles)
* Framebuffer viewing: This allows for visualization of active framebuffers (currently limited to Pica render targets, but planned to eventually also show LCD framebuffers). It allows for on-the-fly modification of the visualization parameters, so that you can e.g. view RGB8 framebuffer data as RGBA8, use different row strides, etc.
* Texture viewing: This is pretty much the same as the framebuffer view, apart from the fact that it nicely integrates into the command list widget. When highlighting a texturing related command in the command list, a small texture preview will be displayed inline. When double-clicking the command list item, a new tab will spawn which gives a full-size view and allows for on-the-fly visualization parameter modification.

Here is an example workflow for framebuffer inspection, using breakpoints:
* Start citra-qt, enable the "Pica Framebuffer" and "Pica Breakpoints" widgets from the View->Debugging menu.
* Run some application (for the example, I'm using 3dscraft, which currently doesn't render correctly in citra)
* Within the breakpoints widget, highlight "Finished Primitive Batch" and hit the "Enable" button. Almost immediately after that, a "Emulation halted at breakpoint" message should appear in the breakpoints widget. Also, some (probably broken) image will appear in the framebuffer widget
* Citra is currently hardcoded to store the render output as RGBA8 data, which is why the framebuffer image might be garbled. Hence, explicitly set the framebuffer format to RGBA8 in the framebuffer widget. You should now see an image which resembles garbage a bit less ;)
![](http://i.imgur.com/L3yaFBO.png)

Example workflow for texture inspection, using breakpoints:
* Start citra-qt, enable the "Pica Command List" and "Pica Breakpoints" widgets from the View->Debugging menu.
* Run some application (again, for the purpose of illustration I'm using 3dscraft - the textures of which don't load correct in citra currently, unfortunately)
* Within the breakpoints widget, highlight "Finished Primitive Batch" and hit the "Enable" button. Almost immediately after that, a "Emulation halted at breakpoint" message should appear in the breakpoints widget.
* Now, select "Start tracing" in the command list widget. Hit "Resume" in the breakpoints widget. Once it stops, select "Stop tracing" in the command list. The command list should now show you all Pica commands that have been processed between the two primitive batches.
* In the command list, look for the command name `texture0`. Highlight any such item to see a preview of the texture
* Double click the item to get a more powerful widget for visualizing the texture
![](http://i.imgur.com/TrZ4POW.png)
![](http://i.imgur.com/U6fjP8w.png)