Skip to content

Debugging XWA

Marcos Orallo edited this page Jul 2, 2023 · 7 revisions

Built-in logs

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: It's a mask. You can combine one or more if 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

In-flight statistics

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.

image

ddraw.dll and hooks OutputDebugString() messages

By default ddraw will output messages with OutputDebugString() with the prefix [DBG].

Some of the hooks may also output debug information through this channel.

They can be viewed in the debugging Output window of Visual Studio or with DebugView

Hook_diag

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.

image

It needs to be enabled in Hooks.ini

[hook_diag]
; ShowDiagMessages = 0 (no) or 1 (yes)`
ShowDiagMessages = 1

Crash dumps

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

OpenXR

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)

Frame analysis with Intel Graphics Performance Analyzer

There are several tools that allow to capture the process of rendering a frame, by hooking the graphics API:

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.

  1. Download and Install Intel GPA
  2. Run Graphics Monitor and configure XwingAlliance.exe in the Desktop Applications tab. Select Frame in the capture drop-down. image
  3. Start the game by clicking on the Start light blue icon.
  4. Capture a frame with Ctrl+Shift+S
  5. In Graphics Monitor, you will have a new thumbnail of the frame capture appear on the right hand side. Double-click it. This will open Intel 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).

image