Windows Sandbox provides a disposable, hypervisor-isolated desktop environment in Windows 11 for executing untrusted executables, evaluating scripts, and debugging graphics software. By default, Windows Sandbox leverages GPU virtualization (vGPU) to share host graphics hardware acceleration with the container. In enterprise graphics testing and software QA, developers frequently need to restrict or enforce specific Direct3D 12 Feature Levels (such as Feature Level 11_0, 12_0, or 12_1) to validate rendering pipeline fallbacks. This behaviour is configured through custom Windows Sandbox configuration (.wsb) XML profiles.
Understanding Windows Sandbox vGPU and Direct3D Virtualization
The graphics pipeline inside Windows Sandbox operates via the Microsoft Hyper-V Virtual GPU (vGPU) driver:
<vGPU>Enable</vGPU>: Routes Direct3D and DXGI API calls from the guest container directly to the host physical GPU driver via hypervisor channels, granting near-native graphics performance.<vGPU>Disable</vGPU>: Forces the sandbox to utilize the CPU-based Microsoft Basic Render Driver (WARP), restricting rendering to software emulation.- Direct3D Feature Levels: Direct3D 12 exposes discrete feature levels (
D3D_FEATURE_LEVEL_11_0throughD3D_FEATURE_LEVEL_12_2). Using startup logon commands inside the WSB file, administrators can force DirectX runtime overrides via registry policies before testing applications.
Authoring the Windows Sandbox WSB XML Configuration
Create a dedicated configuration file named D3D12_Test_Environment.wsb. This script configures GPU pass-through, mounts testing binaries as read-only, and executes a bootstrap script to lock DirectX to the designated Direct3D 12 Feature Level:
<Configuration>
<VGpu>Enable</VGpu>
<Networking>Disable</Networking>
<MemoryInMB>8192</MemoryInMB>
<MappedFolders>
<MappedFolder>
<HostFolder>C:DirectX_QA_Builds</HostFolder>
<SandboxFolder>C:QA_Builds</SandboxFolder>
<ReadOnly>true</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:QA_BuildsSet-D3DFeatureLevel.ps1 -FeatureLevel 12_0</Command>
</LogonCommand>
</Configuration>
Authoring the PowerShell Direct3D Override Script
In the host folder C:DirectX_QA_Builds, create the accompanying Set-D3DFeatureLevel.ps1 script to configure the DirectX runtime environment inside the sandbox:
param (
[string]$FeatureLevel = "12_0"
)
Write-Host "Configuring Windows Sandbox Direct3D 12 Environment..." -ForegroundColor Cyan
# Configure DirectX Control Panel software overrides via Registry
$D3DPath = "HKLM:SOFTWAREMicrosoftDirect3D"
if (!(Test-Path $D3DPath)) {
New-Item -Path $D3DPath -Force | Out-Null
}
switch ($FeatureLevel) {
"11_0" {
Set-ItemProperty -Path $D3DPath -Name "MaxFeatureLevel" -Value 0xb000 -Type DWord
Write-Host "Direct3D 12 Feature Level clamped to 11_0 (0xB000)." -ForegroundColor Yellow
}
"12_0" {
Set-ItemProperty -Path $D3DPath -Name "MaxFeatureLevel" -Value 0xc000 -Type DWord
Write-Host "Direct3D 12 Feature Level clamped to 12_0 (0xC000)." -ForegroundColor Green
}
"12_1" {
Set-ItemProperty -Path $D3DPath -Name "MaxFeatureLevel" -Value 0xc100 -Type DWord
Write-Host "Direct3D 12 Feature Level clamped to 12_1 (0xC100)." -ForegroundColor Green
}
default {
Write-Warning "Unrecognised Feature Level specified. Defaulting to native driver capabilities."
}
}
# Run dxdiag verification command
Write-Host "Exporting DirectX diagnostics..." -ForegroundColor Cyan
Start-Process "dxdiag.exe" -ArgumentList "/t C:QA_Buildsdxdiag_report.txt" -Wait
Get-Content -Path "C:QA_Buildsdxdiag_report.txt" | Select-String "D3D12 Feature Levels" | Write-Host
Executing and Verifying the Isolated Sandbox Environment
- Double-click
D3D12_Test_Environment.wsbon your Windows 11 host. - Windows Sandbox spins up in approximately 5 seconds using your physical graphics card while strictly enforcing network isolation.
- The PowerShell window opens automatically upon logon, setting the Direct3D runtime registry parameters and exporting the diagnostics report.
- Launch your compiled 3D game engine or rendering pipeline from
C:QA_Buildsto verify that fallback shaders execute properly under the forced Direct3D 12 feature constraints. - Upon closing Windows Sandbox, all modified registry settings, temporary logs, and generated shader caches are instantly wiped without touching the host operating system.