{"id":2345,"date":"2019-07-03T17:44:32","date_gmt":"2019-07-04T00:44:32","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/directx\/?p=2345"},"modified":"2019-07-03T17:44:32","modified_gmt":"2019-07-04T00:44:32","slug":"use-vhd-to-accelerate-directx-12-development","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/directx\/use-vhd-to-accelerate-directx-12-development\/","title":{"rendered":"Use VHD to Accelerate DirectX 12 Development"},"content":{"rendered":"<p>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 <a href=\"https:\/\/insider.windows.com\/en-us\/\">Windows Insider Program<\/a> 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.<\/p>\n<p>&nbsp;<\/p>\n<h4>Sample Scenario<\/h4>\n<p>Game developer has a dev machine on Windows 10 October 2018 Update (aka. RS5) but wants to use the latest <a href=\"https:\/\/devblogs.microsoft.com\/directx\/dred\/\">DRED tool to diagnose GPU faults<\/a> on the May 2019 Update (aka. 19H1).<\/p>\n<ul>\n<li>Graphics developer has a local dev machine, with\n<ul>\n<li>C Drive: RS5 OS<\/li>\n<li>D Drive: Visual studio, game project with all assets and binaries compiled<\/li>\n<\/ul>\n<\/li>\n<li>Developer runs the game and hits a TDR<\/li>\n<li>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\n<ul>\n<li>E Drive: 19H1 OS<\/li>\n<\/ul>\n<\/li>\n<li>Developer runs the game with DRED on 19H1 and fixes the problem<\/li>\n<li>Developer reboots to the main OS and continues development.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Instruction: How to create a VHDX file<\/h4>\n<p>Game developers can download an ISO file then convert it to VHDX. For example,<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Sign up for Windows Insider Program, then download ISO images from <a href=\"https:\/\/www.microsoft.com\/en-us\/software-download\/windowsinsiderpreviewadvanced\">https:\/\/www.microsoft.com\/en-us\/software-download\/windowsinsiderpreviewadvanced<\/a><\/li>\n<li>Download the script of &#8220;Convert-WindowsImage.ps1&#8221; from <a href=\"https:\/\/gallery.technet.microsoft.com\/scriptcenter\/Convert-WindowsImageps1-0fe23a8f\">https:\/\/gallery.technet.microsoft.com\/scriptcenter\/Convert-WindowsImageps1-0fe23a8f<\/a>; you do need to apply fixes by &#8220;cryptonym&#8221; on Dec 6 2017 under the Q&amp;A section;<\/li>\n<li>Create a new Powershell script of \u201cISO2VHDX.ps1\u201d, copy the content below, customize it as needed, then run it to convert the ISO file to VHDX.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<pre class=\"theme:powershell lang:ps highlight:0 decode:true\">. .\\Convert-WindowsImage.ps1 \r\n\r\n$ConvertWindowsImageParam = @{ \r\n    SourcePath          = 'F:\\VHD\\Windows10_19H1.iso' \r\n    VHDPath             = 'F:\\VHD\\Windows10_19H1.vhdx'\r\n    RemoteDesktopEnable = $True \r\n    Passthru            = $True \r\n    Edition             = \"Enterprise\"\r\n    VHDFormat           = \"VHDX\"\r\n    BCDinVHD            = \"NativeBoot\"\r\n    SizeBytes           = 60GB\r\n    WorkingDirectory    = 'F:\\VHD'\r\n    VHDPartitionStyle   = 'GPT'\r\n}\r\n\r\n$VHDx = Convert-WindowsImage @ConvertWindowsImageParam\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4>Instruction: How to customize VHDX<\/h4>\n<p>Game studio can optionally customize a VHDX file before sharing it among the studio.<\/p>\n<ul>\n<li>Resize VHDX\n<ul>\n<li>If you need extra space in VHDX to install visual studio and other components required to developer, debug, or run your game, (1) Use <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/hyper-v\/resize-vhd\">Resize-VHD<\/a> 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 <span class=\"lang:default decode:true crayon-inline\">diskmgmt.msc<\/span> , right click the newly attached drive, then select \u201cExtent Volume\u201d to take up all unallocated space.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>Set up VHDX on a host PC (see instructions below), then install extra software for testing and debugging\n<ul>\n<li>For example, runtime dependency that must be installed on the OS driver; internal tools, etc.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Instruction: How to set up VHDX on host PC<\/h4>\n<p>You can manually set up new guest OS on a dev machine using the VHDX file.<\/p>\n<ol>\n<li>Copy a VHDX to a disk partition <strong>without<\/strong> Bitlock protection<\/li>\n<li>Run <span class=\"lang:default decode:true crayon-inline \">diskmgmt.msc<\/span>\u00a0 (Disk Management)<\/li>\n<li>From menu, choose &#8220;Action&#8221;\/&#8221;Attach VHD&#8221; to attach the VHDX file<\/li>\n<li>Give it a driver letter (if it does not have one after attachment): with the VHDX selected, from menu, &#8220;Action&#8221;\/&#8221;All Tasks&#8221;\/&#8221;Change Driver Letter and Paths&#8230;&#8221;<\/li>\n<li>In an elevated command window, type <span class=\"lang:default decode:true crayon-inline\">bcdboot n:\\windows<\/span>\u00a0 (where n is the VHDX\u2019s 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.<\/li>\n<li>(Optional) Give the new OS a friendly name, by typing <span class=\"lang:default highlight:0 decode:true crayon-inline\">bcdedit \/set {id} DESCRIPTION 19H1<\/span>, where {id} is the boot identifier, and \u201c19H1\u201d is the desired name. Running <span class=\"lang:default decode:true crayon-inline\">bcdboot n:\\windows<\/span> above marks the new record as {default}, so that&#8217;s likely what you&#8217;d use for {id} if following the steps above<\/li>\n<li>Run <span class=\"lang:default decode:true crayon-inline\">msconfig<\/span> and on the boot tab set the boot entry that you actually want to be default. You can also delete stale boot entries there.<\/li>\n<li>Reboot and select the new 19H1 OS.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In case game developers are limited on how frequently they can upgrade Windows 10 on their dev machines, they can use VHD files to quickly set up a new Windows 10 OS partition and to access new or preview features from DirectX 12.<\/p>\n","protected":false},"author":2003,"featured_media":12651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[21,494,52],"class_list":["post-2345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-directx","tag-directx12","tag-vhd","tag-windows-update"],"acf":[],"blog_post_summary":"<p>In case game developers are limited on how frequently they can upgrade Windows 10 on their dev machines, they can use VHD files to quickly set up a new Windows 10 OS partition and to access new or preview features from DirectX 12.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/2345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/users\/2003"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/comments?post=2345"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/2345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media\/12651"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media?parent=2345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/categories?post=2345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/tags?post=2345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}