/// <summary> /// Validates a list of grid topologies /// </summary> /// <param name="grids">An array of grid topologies to validate</param> /// <param name="flags">SetDisplayTopologyFlag flag</param> /// <returns>An array of DisplayTopologyStatus object containing the result of the validation</returns> public static DisplayTopologyStatus[] ValidateGridTopologies( GridTopology[] grids, SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.AllowInvalid) { var gridTopologyV2 = grids.Select(grid => grid.GetGridTopologyV2()).Cast <IGridTopology>().ToArray(); try { return(MosaicApi.ValidateDisplayGrids(gridTopologyV2, flags)); } catch (NVIDIAApiException ex) { if (ex.Status != Status.IncompatibleStructureVersion) { throw; } } catch (NVIDIANotSupportedException) { // ignore } var gridTopologyV1 = grids.Select(grid => grid.GetGridTopologyV1()).Cast <IGridTopology>().ToArray(); return(MosaicApi.ValidateDisplayGrids(gridTopologyV1, flags)); }
/// <summary> /// Applies the requested grid topologies /// </summary> /// <param name="grids">An array of grid topologies to apply</param> /// <param name="flags">SetDisplayTopologyFlag flag</param> public static void SetGridTopologies( GridTopology[] grids, SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.NoFlag) { var gridTopologyV2 = grids.Select(grid => grid.GetGridTopologyV2()).Cast <IGridTopology>().ToArray(); try { MosaicApi.SetDisplayGrids(gridTopologyV2, flags); } catch (NVIDIAApiException ex) { if (ex.Status != Status.IncompatibleStructureVersion) { throw; } } catch (NVIDIANotSupportedException) { // ignore } var gridTopologyV1 = grids.Select(grid => grid.GetGridTopologyV1()).Cast <IGridTopology>().ToArray(); MosaicApi.SetDisplayGrids(gridTopologyV1, flags); }
/// <summary> /// Sets a new display topology, replacing any existing topologies that use the same displays. /// This function will look for an SLI configuration that will allow the display topology to work. /// To revert to a single display, specify that display as a 1x1 grid. /// </summary> /// <param name="gridTopologies">The topology details to set.</param> /// <param name="flags">One of the SetDisplayTopologyFlag flags</param> /// <exception cref="NVIDIAApiException">Status.TopologyNotPossible: One or more of the display grids are not valid.</exception> /// <exception cref="NVIDIAApiException">Status.NoActiveSLITopology: No matching GPU topologies could be found.</exception> /// <exception cref="NVIDIAApiException">Status.InvalidArgument: One or more argumentss passed in are invalid.</exception> /// <exception cref="NVIDIAApiException">Status.ApiNotInitialized: The NvAPI API needs to be initialized first.</exception> /// <exception cref="NVIDIAApiException">Status.NoImplementation: This entry point not available.</exception> /// <exception cref="NVIDIAApiException">Status.Error: Miscellaneous error occurred.</exception> public static void SetDisplayGrids(IGridTopology[] gridTopologies, SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.NoFlag) { using (var gridTopologiesByRef = ValueTypeArray.FromArray(gridTopologies.AsEnumerable())) { var status = DelegateFactory.Get <Delegates.Mosaic.NvAPI_Mosaic_SetDisplayGrids>()(gridTopologiesByRef, (uint)gridTopologies.Length, flags); if (status != Status.Ok) { throw new NVIDIAApiException(status); } } }
/// <summary> /// Determines if a list of grid topologies is valid. It will choose an SLI configuration in the same way that /// SetDisplayGrids() does. /// On return, each element in the pTopoStatus array will contain any errors or warnings about each grid topology. If /// any error flags are set, then the topology is not valid. If any warning flags are set, then the topology is valid, /// but sub-optimal. /// If the ALLOW_INVALID flag is set, then it will continue to validate the grids even if no SLI configuration will /// allow all of the grids. In this case, a grid grid with no matching GPU topology will have the error flags /// NO_GPU_TOPOLOGY or NOT_SUPPORTED set. /// If the ALLOW_INVALID flag is not set and no matching SLI configuration is found, then it will skip the rest of the /// validation and throws a NVIDIAApiException with Status.NoActiveSLITopology. /// </summary> /// <param name="gridTopologies">The array of grid topologies to verify.</param> /// <param name="flags">One of the SetDisplayTopologyFlag flags</param> /// <exception cref="NVIDIAApiException">Status.NoActiveSLITopology: No matching GPU topologies could be found.</exception> /// <exception cref="NVIDIAApiException">Status.InvalidArgument: One or more argumentss passed in are invalid.</exception> /// <exception cref="NVIDIAApiException">Status.ApiNotInitialized: The NvAPI API needs to be initialized first.</exception> /// <exception cref="NVIDIAApiException">Status.NoImplementation: This entry point not available.</exception> /// <exception cref="NVIDIAApiException">Status.Error: Miscellaneous error occurred.</exception> public static DisplayTopologyStatus[] ValidateDisplayGrids(IGridTopology[] gridTopologies, SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.NoFlag) { using (var gridTopologiesByRef = ValueTypeArray.FromArray(gridTopologies.AsEnumerable())) { var statuses = typeof(DisplayTopologyStatus).Instantiate <DisplayTopologyStatus>().Repeat(gridTopologies.Length); var status = DelegateFactory.Get <Delegates.Mosaic.NvAPI_Mosaic_ValidateDisplayGrids>()(flags, gridTopologiesByRef, ref statuses, (uint)gridTopologies.Length); if (status != Status.Ok) { throw new NVIDIAApiException(status); } return(statuses); } }