private Device InitializeDevice() {
Debug.Assert(Initialized == false);
var device = new Device(DriverType.Hardware, DeviceCreationFlags.None);
if (device.FeatureLevel < FeatureLevel) {
throw new Exception($"Direct3D Feature {FeatureLevel} unsupported");
}
if (UseMsaa) {
var msaaQuality = device.CheckMultisampleQualityLevels(Format.R8G8B8A8_UNorm, 4);
SampleDescription = new SampleDescription(4, msaaQuality - 1);
}
return device;
}