/// <summary> /// Function to retrieve the video modes for the output. /// </summary> /// <param name="output">Output that owns the video modes.</param> /// <param name="D3DDevice">D3D device for filtering supported display modes.</param> /// <param name="giOutput">Output that contains the video modes.</param> private static void GetVideoModes(GorgonVideoOutput output, D3D.Device D3DDevice, Output giOutput) { var formats = (BufferFormat[])Enum.GetValues(typeof(BufferFormat)); Gorgon.Log.Print("Retrieving video modes for output '{0}'...", LoggingLevel.Simple, output.Name); Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); // Test each format for display compatibility. foreach (var format in formats) { var giFormat = (Format)format; ModeDescription[] modes = giOutput.GetDisplayModeList(giFormat, DisplayModeEnumerationFlags.Scaling | DisplayModeEnumerationFlags.Interlaced); if ((modes == null) || (modes.Length <= 0)) { continue; } GorgonVideoMode[] videoModes = (from mode in modes where (D3DDevice.CheckFormatSupport(giFormat) & D3D.FormatSupport.Display) == D3D.FormatSupport.Display select GorgonVideoMode.Convert(mode)).ToArray(); if (videoModes.Length > 0) { output.VideoModes = new ReadOnlyCollection <GorgonVideoMode>(videoModes); } } // Output to log. foreach (var videoMode in output.VideoModes) { Gorgon.Log.Print("Mode: {0}x{1}, Format: {2}, Refresh Rate: {3}/{4}", LoggingLevel.Verbose, videoMode.Width, videoMode.Height, videoMode.Format, videoMode.RefreshRateNumerator, videoMode.RefreshRateDenominator); } Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); Gorgon.Log.Print("Found {0} video modes for output '{1}'.", LoggingLevel.Simple, output.VideoModes.Count, output.Name); }
#pragma warning disable 0618 /// <summary> /// Function to retrieve the list of outputs for the video device. /// </summary> /// <param name="adapter">Adapter containing the outputs.</param> /// <param name="D3DDevice">D3D device to find closest matching mode.</param> /// <param name="device">Device used to filter video modes that aren't supported.</param> /// <param name="outputCount">The number of outputs attached to the device.</param> /// <param name="noOutputDevice">TRUE if the device has no outputs, FALSE if it does.</param> private static void GetOutputs(GorgonVideoDevice device, D3D.Device D3DDevice, Adapter adapter, int outputCount, bool noOutputDevice) { var outputs = new List <GorgonVideoOutput>(outputCount); // We need to fake outputs. // Windows 8 does not support outputs on WARP devices and ref rasterizer devices. if ((noOutputDevice) || (SystemInformation.TerminalServerSession)) { var output = new GorgonVideoOutput(); Gorgon.Log.Print("Found output {0}.", LoggingLevel.Simple, output.Name); Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); Gorgon.Log.Print("Output bounds: ({0}x{1})-({2}x{3})", LoggingLevel.Verbose, output.OutputBounds.Left, output.OutputBounds.Top, output.OutputBounds.Right, output.OutputBounds.Bottom); Gorgon.Log.Print("Monitor handle: 0x{0}", LoggingLevel.Verbose, output.Handle.FormatHex()); Gorgon.Log.Print("Attached to desktop: {0}", LoggingLevel.Verbose, output.IsAttachedToDesktop); Gorgon.Log.Print("Monitor rotation: {0}\u00B0", LoggingLevel.Verbose, output.Rotation); Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); outputs.Add(output); // No video modes for these devices. output.VideoModes = new GorgonVideoMode[0]; device.Outputs = new GorgonNamedObjectReadOnlyCollection <GorgonVideoOutput>(false, outputs); Gorgon.Log.Print("Output {0} on device {1} has no video modes.", LoggingLevel.Verbose, output.Name, device.Name); return; } // Get outputs. for (int i = 0; i < outputCount; i++) { using (Output giOutput = adapter.GetOutput(i)) { var output = new GorgonVideoOutput(giOutput, device, i); ModeDescription findMode = GorgonVideoMode.Convert(new GorgonVideoMode(output.OutputBounds.Width, output.OutputBounds.Height, BufferFormat.R8G8B8A8_UIntNormal, 60, 1)); ModeDescription result; // Get the default (desktop) video mode. giOutput.GetClosestMatchingMode(D3DDevice, findMode, out result); output.DefaultVideoMode = GorgonVideoMode.Convert(result); GetVideoModes(output, D3DDevice, giOutput); Gorgon.Log.Print("Found output {0}.", LoggingLevel.Simple, output.Name); Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); Gorgon.Log.Print("Output bounds: ({0}x{1})-({2}x{3})", LoggingLevel.Verbose, output.OutputBounds.Left, output.OutputBounds.Top, output.OutputBounds.Right, output.OutputBounds.Bottom); Gorgon.Log.Print("Monitor handle: 0x{0}", LoggingLevel.Verbose, output.Handle.FormatHex()); Gorgon.Log.Print("Attached to desktop: {0}", LoggingLevel.Verbose, output.IsAttachedToDesktop); Gorgon.Log.Print("Monitor rotation: {0}\u00B0", LoggingLevel.Verbose, output.Rotation); Gorgon.Log.Print("===================================================================", LoggingLevel.Verbose); if (output.VideoModes.Count > 0) { outputs.Add(output); } else { Gorgon.Log.Print("Output {0} on device {1} has no video modes!", LoggingLevel.Verbose, output.Name, device.Name); } } } device.Outputs = new GorgonNamedObjectReadOnlyCollection <GorgonVideoOutput>(false, outputs); }