Use VHD to Accelerate DirectX 12 Development

Jianye Lu

DirectX 12 has been evolving rapidly, with new features and new tools released in each major Windows 10 OS upgrade. We also provide feature preview through the Windows Insider Program to encourage early adoption. For game developers who cannot upgrade their main dev machines frequently to take all those benefits, they can use VHD files to quickly set up a Windows 10 OS on their dev machine without changing the major OS partition.

 

Sample Scenario

Game developer has a dev machine on Windows 10 October 2018 Update (aka. RS5) but wants to use the latest DRED tool to diagnose GPU faults on the May 2019 Update (aka. 19H1).

  • Graphics developer has a local dev machine, with
    • C Drive: RS5 OS
    • D Drive: Visual studio, game project with all assets and binaries compiled
  • Developer runs the game and hits a TDR
  • Developer copies and sets up a VHDX file (based on 19H1 OS) on the local machine (see instructions below), reboots to the VHDX partition; now there is a new guest OS on the dev machine
    • E Drive: 19H1 OS
  • Developer runs the game with DRED on 19H1 and fixes the problem
  • Developer reboots to the main OS and continues development.

 

Instruction: How to create a VHDX file

Game developers can download an ISO file then convert it to VHDX. For example,

    1. Sign up for Windows Insider Program, then download ISO images from https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced
    2. Download the script of “Convert-WindowsImage.ps1” from https://gallery.technet.microsoft.com/scriptcenter/Convert-WindowsImageps1-0fe23a8f; you do need to apply fixes by “cryptonym” on Dec 6 2017 under the Q&A section;
    3. Create a new Powershell script of “ISO2VHDX.ps1”, copy the content below, customize it as needed, then run it to convert the ISO file to VHDX.
. .\Convert-WindowsImage.ps1 

$ConvertWindowsImageParam = @{ 
    SourcePath          = 'F:\VHD\Windows10_19H1.iso' 
    VHDPath             = 'F:\VHD\Windows10_19H1.vhdx'
    RemoteDesktopEnable = $True 
    Passthru            = $True 
    Edition             = "Enterprise"
    VHDFormat           = "VHDX"
    BCDinVHD            = "NativeBoot"
    SizeBytes           = 60GB
    WorkingDirectory    = 'F:\VHD'
    VHDPartitionStyle   = 'GPT'
}

$VHDx = Convert-WindowsImage @ConvertWindowsImageParam

 

Instruction: How to customize VHDX

Game studio can optionally customize a VHDX file before sharing it among the studio.

  • Resize VHDX
    • If you need extra space in VHDX to install visual studio and other components required to developer, debug, or run your game, (1) Use Resize-VHD in PowerShell to expand VHDX (before you attach the VHDX file); (2) After you set up the VHDX file as bootable (see steps below), run diskmgmt.msc , right click the newly attached drive, then select “Extent Volume” to take up all unallocated space.
  • Set up VHDX on a host PC (see instructions below), then install extra software for testing and debugging
    • For example, runtime dependency that must be installed on the OS driver; internal tools, etc.

 

Instruction: How to set up VHDX on host PC

You can manually set up new guest OS on a dev machine using the VHDX file.

  1. Copy a VHDX to a disk partition without Bitlock protection
  2. Run diskmgmt.msc  (Disk Management)
  3. From menu, choose “Action”/”Attach VHD” to attach the VHDX file
  4. Give it a driver letter (if it does not have one after attachment): with the VHDX selected, from menu, “Action”/”All Tasks”/”Change Driver Letter and Paths…”
  5. In an elevated command window, type bcdboot n:\windows  (where n is the VHDX’s driver letter). This will create a boot record for the VHDX and make it the default. It will also copy the right bootloader from the VHDX.
  6. (Optional) Give the new OS a friendly name, by typing bcdedit /set {id} DESCRIPTION 19H1, where {id} is the boot identifier, and “19H1” is the desired name. Running bcdboot n:\windows above marks the new record as {default}, so that’s likely what you’d use for {id} if following the steps above
  7. Run msconfig and on the boot tab set the boot entry that you actually want to be default. You can also delete stale boot entries there.
  8. Reboot and select the new 19H1 OS.

 

0 comments

Discussion is closed.

Feedback usabilla icon