Intro

I am playing around with the Bevy engine again and I ran into an issue with program crashes when rendering anything in a graphics window (Which is everything for a graphical computer game).

Software Versions

The following software version were used in this post:

  • Bevy - 0.15.1
  • Windows 11

Stop! It's Error Time

I was hitting multiple errors relating to the GPU. For example:

error
ERROR wgpu_hal::auxil::dxgi::exception:
error
error: process didn't exit successfully: `target\debug\examples\breakout.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

By default the Vulkan graphics backend is used by Bevy and this was the source of the problem. Windows 11 by default uses DirectX for graphics. To change it to DirectX you can add an envrionment variable to your $PROFILE.

Fix Me

Setting the WGPU environment variable in your $PROFILE will ensure DirectX is always used.

file
# File: Microsoft.PowerShell_profile.ps1
# To find the path to the profile file `Microsoft.PowerShell_profile.ps1` run this from powershell:
# echo $PROFILE

# Add this environment variable
$Env:WGPU_BACKEND="dx12"

Thank you to this legendary person.

Outro

✌️ Peace out nerds. Stay weird! ✌️