-
Notifications
You must be signed in to change notification settings - Fork 0
Debugging XWA
Command Arguments: skipintro deusdbg 2 ffffffff
The deusdbg command line parameter enables the native logging from X-Wing Alliance.
Meaning of the first parameter:
- 1 means OutputDebugString and file (deusdbg.txt)
- 2 means OutputDebugString
- 3 means file (deusdbg.txt)
Meaning of the second parameter (click to expand)
It's a mask. You can combine one or more of the Following values: - 0 means None - 1 means Sfx - 2 means FFeedback - 4 means Music - 8 means MusicMem - 10 means MusicIMuse - 20 means HudText - 80 means SfxFlush - 100 means MusicStates - 200 means EscapePods - 400 means Backdrops - 800 means LargeDebris - 1000 means DamagePhysics - 4000 means Voices - 8000 means Stars - 10000 means D3dText - 20000 means Network - 40000 means GlobalLight - 80000 means Parser - ffffffff means All
Reference:
https://www.xwaupgrade.com/phpBB3/viewtopic.php?t=10516
The game executable includes functions to display framerate, number of vertices, triangles, texture changes, state changes, video memory usage in the HUD. However these functions can only be enabled by patching the .EXE.
XwaExePatcher includes patches to enable that.
By default ddraw will output messages with OutputDebugString() with the prefix [DBG].
Some of the hooks may also output debug information through this channel.
You can also enable native XWA debug messages as indicated in the Built-in logs
section above.
They can be viewed in the debugging Output window of Visual Studio or with DebugView
JeremyaFr created a hook to display relevant information in-game, both in the Concourse and InFlight: https://github.com/JeremyAnsel/xwa_hooks/blob/master/xwa_hook_diag/zip/readme.txt
It includes CPU and RAM usage, mission loading time measurements.
It needs to be enabled in Hooks.ini
[hook_diag]
; ShowDiagMessages = 0 (no) or 1 (yes)`
ShowDiagMessages = 1
Here is the reference for the different loading steps:
- step 0 is start.
- step 1 is mission file loading, global buffers initializing, and hangar sounds loading.
- step 2 is tactical officers and wingmen sounds loading.
- step 3 is 3d initializing, and OPTs loading.
- step 4 is dat images loading
- step 5 is ResData_LightingEffects initializing
- step 6 is nothing
- step 7 is backdrops initializing, and HUD initializing
- step 8 is starships debris initializing
There are several tools that allow to capture the process of rendering a frame, by hooking the graphics API:
- RenderDoc
- NVIDIA Nsight Graphics
- Intel Graphics Performance Analyzers
In my tests, neither RenderDoc nor NVIDIA Nsight Graphics are able to run X-Wing Alliance properly. With Intel GPA it's possible to capture a frame and re-play the rendering process in individual draw call steps.
- Download and Install Intel GPA
- Run
Graphics Monitor
and configure XwingAlliance.exe in the Desktop Applications tab. Select Frame in the capture drop-down. - Start the game by clicking on the
Start
light blue icon. - Capture a frame with Ctrl+Shift+C
- In
Graphics Monitor
, you will have a new thumbnail of the frame capture appear on the right hand side. Double-click it. This will openIntel Graphics Frame Analyzer
.
In Graphics Frame Analyzer, you will have a timeline of the frame, with each draw call represented by a bar/rectangle. with height and width proportional to the time spent by the GPU on it. This can give you a quick idea of the most expensive GPU operations.
Also, it's possible to display the results of each step of the rendering process by selecting the draw call on the left column. This can be very useful to debug graphical errors as it displays the inputs (constant buffers, shader resource views, geometry...), the render state and decompiled shaders, and the outputs (render target views, depth stencil view).
To troubleshoot DirectX errors that don't generate a crash dump, it can be useful to enable the Direct3D Debug Layer. This will provide debug messages with details on why a certain D3D API call is failing.
Follow this tutorial: https://www.tenforums.com/tutorials/7565-manage-optional-features-windows-10-a.html
- Windows Menu > Settings > Apps & Features > Optional Features > Add a Feature
- You need to enable the
Graphics Tools
feature (it may have a different name in your language, like "Herramientas de gráficos" in Spanish).
From this blog
- Open an elevated command-line prompt (right click over the
Command Line
menu entry, choose Run as Administrator) - Enter the following command:
DISM /online /add-capability /capabilityname:Tools.Graphics.DirectX~~~~0.0.1.0
- Run DirectX Control Panel
a. From Visual Studio (Debug > Graphics > DirectX Control Panel)
b. Run the
DXCpl.exe
command - Add xwingalliance.exe application in the Scope section
- Enable the Direct3D/DXGI Debug Layer
- Mute the Warning messages, as we are mostly interested in errors
- Apply
NOTE: Direct3D debug layer will have some impact on the performance. Make sure you disable it after your troubleshooting!!!
If the game exits to desktop without generating the error that you expect, you may need to disable the Break on
functionality in the Break Settings
tab:
Now, every time you run the game, Direct3D will generate debug messages as configured with DXCpl
or d3dconfig
.
The most powerful way to use the debug layer messages is by debugging the game with Visual Studio. This way, whenever there is an error message the game execution will pause and you will have access to the call stack, the values of the parameters etc.
However, you don't need a development environment to monitor the output of the debug layer. You can see the messages with DebugView.
Run DebugView
and filter for the process ID of X-Wing Alliance (17412 in the example below). Alternatively, look for lines starting with D3D11
[17412] D3D11: DeviceChild reference counter underflow. Release should not be called on objects with zero reference count.
[17412] Exception 0x0000087D at 76A8D8A2 in KERNELBASE
[17412] A crash dump has been generated at G:\juegos\XWA\XwingAlliance_20230702_183019448_KERNELBASE.dmp
[17412] D3D11: DeviceChild reference counter underflow. Release should not be called on objects with zero reference count.
- https://walbourn.github.io/direct3d-sdk-debug-layer-tricks/
- https://learn.microsoft.com/en-us/windows/win32/direct3d11/using-the-debug-layer-to-test-apps
In case of crash, hook_main will create a minidump in the XWA folder, that you can open with your tool of choice (for example Visual Studio) to understand the state of execution that led to the crash.
The files will be named something similar to this XwingAlliance_20230509_234528324_DDRAW.dmp
Command Arguments: skipintro 1>openxr_log.txt 2>&1
Environment = XR_LOADER_DEBUG=all; XR_RUNTIME_JSON=F:\Oculus\Support\oculus-runtime\oculus_openxr_32.json $(LocalDebuggerEnvironment)