Debugging
Trial includes a variety of tools to aid in the inevitable debugging process.
Inspection
Many of Trial's objects can be inspected using the standard print and describe functions. In particular the following object types will offer extra presentations to make their contents easier to read:
animation-controllerLists available and active clipsassetDescribes its documentation and available resourcescontainerPrints a tree graph of its nodescontextGives an overview of the OpenGL context capabilitiesfade-controllerLists any active fade targetsgl-struct-classPrints the exact memory layout of all membersik-controllerDescribes the active IK systems and their statesik-solverShows the IK chain and constraints along the chainlayer-controllerLists any active animation layerspipelined-sceneShows the passes in the pipelinepoolDescribes its documentation and available assetsshader-entity-classPrints the effective shaders attached to this classshader-programShows the attached buffers and shadersskeletonPrints a tree graph of its bone hierarchystandard-render-passLists the active lights and materials
For instance, it can frequently be useful to describe the current scene to get an idea of the scene graph, via (describe (scene +main+)).
Logging
Trial relies on the Verbose logger framework to print various status messages to its log. You can, of course, make use of all of Verbose's features yourself as well. You should add a local nickname for org.shirakumo.verbose (as v) to your package definitions for that.
When deployed, Trial will also automatically capture Verbose's log to a logfile that can be used for debugging crashes and other issues.
Trial also offers a number of useful shorthand macros:
with-error-logging
Will log any unhandled error that is signalled within the body.with-ignored-errors-on-release
Does the same aswith-error-loggingbut ignoring the error in release mode and propagating it to the debugger with acontinuerestart in development mode.with-timing-report
Logs a report on the time taken to execute the body.
Watches
You can add a watchpoint for the result of a function with the observe function, or of an expression with the observe! macro. To remove the watchpoint again, you can use stop-observing.
In order for the watches to show up, you must have a display-controller in your scene. Typically you'll want to do this by using (enter (make-instance 'display-controller) scene) in your setup-scene.
You can also use an fps-counter instance to only observe the frame count. The fps-counter in particular is written to be as low latency as possible, and should have almost zero overhead.
Drawing
In order to debug visual information, you can use the following functions:
debug-point
Draws a point at the specified coordinate.debug-line
Draws a line between the specified points.debug-text
Shows the text at the specified point. The text can only contain ASCII characters.debug-triangles
Draw a set of triangles as a line mesh.debug-vertex-array
Draw a vertex array as a line mesh. This should work regardless of primitive shape used.debug-clear
Clear all debug draws.debug-draw
Generic version that dispatches to the above depending on the argument.
All of these are copying, meaning they won't update if their arguments are modified and they'll stick around until cleared away. All of the functions also accept the following arguments:
:color
The color of the lines or point.:debug-draw
Thedebug-drawinstance used to draw the elements. Defaults to using an entity nameddebug-drawand will create one if it doesn't exist yet.:update
Whether the data should be uploaded to the GPU immediately. You may want to set this to NIL if you intend on drawing a large batch of debug info.:instance
The debug instance to update, if any. Eachdebug-*function returns an instance ID that you can use to clear or update that debug draw instance with new data.
Note that all drawing calls are synchronised to the render thread. Meaning that if the call occurs outside of the render thread, it is scheduled asynchronously to run on it.
Renderdoc
Special mention should be made of the Renderdoc tool. While Trial allows redefinition of shaders at runtime, sometimes being able to capture the entire pipeline state and inspect it can be invaluable to figure out weird graphical issues. Renderdoc is ideal for this situation and works fine with Trial, as long as the underlying lisp process is called via Renderdoc.
You can configure your implementation as a launch option in Rendedoc:
Executable PathEg:/usr/bin/sbclCommand-line ArgumentsEg:--load /path/to/trial/renderdoc.lisp
Launching it like that should allow you to connect via Slime on port 4005, and capture snapshots of the running process via Renderdoc.