Ejemplo n.º 1
0
        /// <summary>
        ///     This API gets information about the given setting.
        /// </summary>
        /// <param name="sessionHandle">Input to the session handle.</param>
        /// <param name="profileHandle">Input profile handle.</param>
        /// <param name="settingId">Input settingId.</param>
        /// <returns>An instance of <see cref="DRSSettingV1" /> describing the setting if found; otherwise <see langword="null" />.</returns>
        public static DRSSettingV1?GetSetting(
            DRSSessionHandle sessionHandle,
            DRSProfileHandle profileHandle,
            uint settingId)
        {
            var instance = typeof(DRSSettingV1).Instantiate <DRSSettingV1>();

            using (var settingReference = ValueTypeReference.FromValueType(instance, typeof(DRSSettingV1)))
            {
                var status = DelegateFactory.GetDelegate <Delegates.DRS.NvAPI_DRS_GetSetting>()(
                    sessionHandle,
                    profileHandle,
                    settingId,
                    settingReference
                    );

                if (status == Status.IncompatibleStructureVersion)
                {
                    throw new NVIDIANotSupportedException("This operation is not supported.");
                }

                if (status == Status.SettingNotFound)
                {
                    return(null);
                }

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(settingReference.ToValueType <DRSSettingV1>(typeof(DRSSettingV1)));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     This API returns information on the topologies and display resolutions supported by Mosaic mode.
        ///     NOTE: Not all topologies returned can be set immediately. Some of the topologies returned might not be valid for
        ///     one reason or another.  It could be due to mismatched or missing displays.  It could also be because the required
        ///     number of GPUs is not found.
        ///     Once you get the list of supported topologies, you can call GetTopologyGroup() with one of the Mosaic topologies if
        ///     you need more information about it.
        ///     It is possible for this function to return NVAPI_OK with no topologies listed in the return structure.  If this is
        ///     the case, it means that the current hardware DOES support Mosaic, but with the given configuration no valid
        ///     topologies were found.  This most likely means that SLI was not enabled for the hardware. Once enabled, you should
        ///     see valid topologies returned from this function.
        /// </summary>
        /// <param name="topologyType">The type of topologies the caller is interested in getting.</param>
        /// <returns>Information about what topologies and display resolutions are supported for Mosaic.</returns>
        /// <exception cref="NVIDIAApiException">Status.NotSupported: Mosaic is not supported with the existing hardware.</exception>
        /// <exception cref="NVIDIAApiException">Status.InvalidArgument: TopologyType is 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>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static ISupportedTopologiesInfo GetSupportedTopologiesInfo(TopologyType topologyType)
        {
            var mosaicGetSupportedTopoInfo =
                DelegateFactory.GetDelegate <Delegates.Mosaic.NvAPI_Mosaic_GetSupportedTopoInfo>();

            foreach (var acceptType in mosaicGetSupportedTopoInfo.Accepts())
            {
                var instance = acceptType.Instantiate <ISupportedTopologiesInfo>();

                using (var supportedTopologiesInfoByRef = ValueTypeReference.FromValueType(instance, acceptType))
                {
                    var status = mosaicGetSupportedTopoInfo(supportedTopologiesInfoByRef, topologyType);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(supportedTopologiesInfoByRef.ToValueType <ISupportedTopologiesInfo>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     This API adds an executable name to a profile.
        /// </summary>
        /// <param name="sessionHandle">Input to the session handle.</param>
        /// <param name="profileHandle">Input profile handle.</param>
        /// <param name="application">Input <see cref="IDRSApplication" /> instance containing the executable name.</param>
        /// <returns>The newly created instance of <see cref="IDRSApplication" />.</returns>
        public static IDRSApplication CreateApplication(
            DRSSessionHandle sessionHandle,
            DRSProfileHandle profileHandle,
            IDRSApplication application)
        {
            using (var applicationReference = ValueTypeReference.FromValueType(application, application.GetType()))
            {
                var status = DelegateFactory.GetDelegate <Delegates.DRS.NvAPI_DRS_CreateApplication>()(
                    sessionHandle,
                    profileHandle,
                    applicationReference
                    );

                if (status == Status.IncompatibleStructureVersion)
                {
                    throw new NVIDIANotSupportedException("This operation is not supported.");
                }

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(applicationReference.ToValueType <IDRSApplication>(application.GetType()));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     This function returns information about the system's chipset.
        /// </summary>
        /// <returns>Information about the system's chipset</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">Status.InvalidArgument: Invalid argument</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IChipsetInfo GetChipsetInfo()
        {
            var getChipSetInfo = DelegateFactory.GetDelegate <Delegates.General.NvAPI_SYS_GetChipSetInfo>();

            foreach (var acceptType in getChipSetInfo.Accepts())
            {
                var instance = acceptType.Instantiate <IChipsetInfo>();

                using (var chipsetInfoReference = ValueTypeReference.FromValueType(instance, acceptType))
                {
                    var status = getChipSetInfo(chipsetInfoReference);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(chipsetInfoReference.ToValueType <IChipsetInfo>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     This function returns the EDID data for the specified GPU handle and connection bit mask.
        ///     outputId should have exactly 1 bit set to indicate a single display.
        /// </summary>
        /// <param name="gpuHandle">Physical GPU handle to check outputs</param>
        /// <param name="outputId">Output identification</param>
        /// <returns>Whole or a part of the EDID data</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">
        ///     Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits
        ///     set
        /// </exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="NVIDIAApiException">Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle.</exception>
        /// <exception cref="NVIDIAApiException">Status.DataNotFound: The requested display does not contain an EDID.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IEDID GetEDID(PhysicalGPUHandle gpuHandle, OutputId outputId)
        {
            var gpuGetEDID = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetEDID>();

            foreach (var acceptType in gpuGetEDID.Accepts())
            {
                using (var edidReference = ValueTypeReference.FromValueType(acceptType.Instantiate <IEDID>(), acceptType)
                       )
                {
                    var status = gpuGetEDID(gpuHandle, outputId, edidReference);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(edidReference.ToValueType <IEDID>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     [PRIVATE]
        ///     Gets the cooler policy table for the passed GPU handle.
        /// </summary>
        /// <param name="gpuHandle">The handle of the GPU to perform the operation on.</param>
        /// <param name="policy">The cooler policy to get the table for.</param>
        /// <param name="index">The cooler index.</param>
        /// <param name="count">Number of policy table entries retrieved.</param>
        /// <returns>The cooler policy table for the GPU.</returns>
        // ReSharper disable once TooManyArguments
        public static PrivateCoolerPolicyTableV1 GetCoolerPolicyTable(
            PhysicalGPUHandle gpuHandle,
            CoolerPolicy policy,
            uint index,
            out uint count)
        {
            var instance = typeof(PrivateCoolerPolicyTableV1).Instantiate <PrivateCoolerPolicyTableV1>();

            instance._Policy = policy;

            using (var policyTableReference = ValueTypeReference.FromValueType(instance))
            {
                var status = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetCoolerPolicyTable>()(
                    gpuHandle,
                    index,
                    policyTableReference,
                    out count
                    );

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(policyTableReference.ToValueType <PrivateCoolerPolicyTableV1>(typeof(PrivateCoolerPolicyTableV1)));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     This API sets the Mosaic topology and performs a mode switch using the given display settings.
        /// </summary>
        /// <param name="topoBrief">
        ///     The topology to set. This must be one of the topologies returned from GetSupportedTopoInfo(),
        ///     and it must have an isPossible value of true.
        /// </param>
        /// <param name="displaySettings">
        ///     The per display settings to be used in the Mosaic mode. This must be one of the settings
        ///     returned from GetSupportedTopoInfo().
        /// </param>
        /// <param name="overlapX">
        ///     The pixel overlap to use between horizontal displays (use positive a number for overlap, or a
        ///     negative number to create a gap.) If the overlap is out of bounds for what is possible given the topo and display
        ///     setting, the overlap will be clamped.
        /// </param>
        /// <param name="overlapY">
        ///     The pixel overlap to use between vertical displays (use positive a number for overlap, or a
        ///     negative number to create a gap.) If the overlap is out of bounds for what is possible given the topo and display
        ///     setting, the overlap will be clamped.
        /// </param>
        /// <param name="enable">
        ///     If true, the topology being set will also be enabled, meaning that the mode set will occur. If
        ///     false, you don't want to be in Mosaic mode right now, but want to set the current Mosaic topology so you can enable
        ///     it later with EnableCurrentTopo()
        /// </param>
        /// <exception cref="ArgumentException">displaySettings is of invalid type.</exception>
        /// <exception cref="NVIDIAApiException">Status.NotSupported: Mosaic is not supported with the existing hardware.</exception>
        /// <exception cref="NVIDIAApiException">Status.InvalidArgument: One or more arguments 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>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        // ReSharper disable once TooManyArguments
        public static void SetCurrentTopology(
            TopologyBrief topoBrief,
            IDisplaySettings displaySettings,
            int overlapX,
            int overlapY,
            bool enable)
        {
            var mosaicSetCurrentTopo = DelegateFactory.GetDelegate <Delegates.Mosaic.NvAPI_Mosaic_SetCurrentTopo>();

            if (!mosaicSetCurrentTopo.Accepts().Contains(displaySettings.GetType()))
            {
                throw new ArgumentException("Parameter type is not supported.", nameof(displaySettings));
            }

            using (
                var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, displaySettings.GetType()))
            {
                var status = mosaicSetCurrentTopo(topoBrief, displaySettingsByRef, overlapX, overlapY,
                                                  (uint)(enable ? 1 : 0));

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     This function retrieves the available driver memory footprint for the specified GPU.
        ///     If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned.
        /// </summary>
        /// <param name="physicalGPUHandle">Handle of the physical GPU for which the memory information is to be extracted.</param>
        /// <returns>The memory footprint available in the driver.</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IDisplayDriverMemoryInfo GetMemoryInfo(PhysicalGPUHandle physicalGPUHandle)
        {
            var getMemoryInfo = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetMemoryInfo>();

            foreach (var acceptType in getMemoryInfo.Accepts())
            {
                var instance = acceptType.Instantiate <IDisplayDriverMemoryInfo>();

                using (var displayDriverMemoryInfo = ValueTypeReference.FromValueType(instance, acceptType))
                {
                    var status = getMemoryInfo(physicalGPUHandle, displayDriverMemoryInfo);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(displayDriverMemoryInfo.ToValueType <IDisplayDriverMemoryInfo>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     This function returns the EDID data for the specified GPU handle and connection bit mask.
        ///     outputId should have exactly 1 bit set to indicate a single display.
        /// </summary>
        /// <param name="gpuHandle">Physical GPU handle to check outputs</param>
        /// <param name="outputId">Output identification</param>
        /// <param name="offset">EDID offset</param>
        /// <param name="readIdentification">EDID read identification for multi part read, or zero for first run</param>
        /// <returns>Whole or a part of the EDID data</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">
        ///     Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits
        ///     set
        /// </exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="NVIDIAApiException">Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle.</exception>
        /// <exception cref="NVIDIAApiException">Status.DataNotFound: The requested display does not contain an EDID.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        // ReSharper disable once TooManyArguments
        public static EDIDV3 GetEDID(
            PhysicalGPUHandle gpuHandle,
            OutputId outputId,
            int offset,
            int readIdentification = 0)
        {
            var gpuGetEDID = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetEDID>();

            if (!gpuGetEDID.Accepts().Contains(typeof(EDIDV3)))
            {
                throw new NVIDIANotSupportedException("This operation is not supported.");
            }

            var instance = EDIDV3.CreateWithOffset((uint)readIdentification, (uint)offset);

            using (var edidReference = ValueTypeReference.FromValueType(instance))
            {
                var status = gpuGetEDID(gpuHandle, outputId, edidReference);

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(edidReference.ToValueType <EDIDV3>().GetValueOrDefault());
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     This API returns the X and Y overlap limits required if the given Mosaic topology and display settings are to be
        ///     used.
        /// </summary>
        /// <param name="topoBrief">
        ///     The topology for getting limits This must be one of the topo briefs returned from
        ///     GetSupportedTopoInfo().
        /// </param>
        /// <param name="displaySettings">
        ///     The display settings for getting the limits. This must be one of the settings returned
        ///     from GetSupportedTopoInfo().
        /// </param>
        /// <param name="minOverlapX">X overlap minimum</param>
        /// <param name="maxOverlapX">X overlap maximum</param>
        /// <param name="minOverlapY">Y overlap minimum</param>
        /// <param name="maxOverlapY">Y overlap maximum</param>
        /// <exception cref="ArgumentException">displaySettings is of invalid type.</exception>
        /// <exception cref="NVIDIAApiException">Status.NotSupported: Mosaic is not supported with the existing hardware.</exception>
        /// <exception cref="NVIDIAApiException">Status.InvalidArgument: One or more arguments 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>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        // ReSharper disable once TooManyArguments
        public static void GetOverlapLimits(
            TopologyBrief topoBrief,
            IDisplaySettings displaySettings,
            out int minOverlapX,
            out int maxOverlapX,
            out int minOverlapY,
            out int maxOverlapY)
        {
            var mosaicGetOverlapLimits = DelegateFactory.GetDelegate <Delegates.Mosaic.NvAPI_Mosaic_GetOverlapLimits>();

            if (!mosaicGetOverlapLimits.Accepts().Contains(displaySettings.GetType()))
            {
                throw new ArgumentException("Parameter type is not supported.", nameof(displaySettings));
            }

            using (
                var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, displaySettings.GetType()))
            {
                var status = mosaicGetOverlapLimits(topoBrief, displaySettingsByRef, out minOverlapX, out maxOverlapX,
                                                    out minOverlapY, out maxOverlapY);

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     This API enumerates all available setting values for a given setting.
        /// </summary>
        /// <param name="settingId">Input settingId.</param>
        /// <returns>All available setting values.</returns>
        public static DRSSettingValues EnumAvailableSettingValues(uint settingId)
        {
            var settingValuesCount = (uint)DRSSettingValues.MaximumNumberOfValues;
            var settingValues      = typeof(DRSSettingValues).Instantiate <DRSSettingValues>();

            using (var settingValuesReference = ValueTypeReference.FromValueType(settingValues))
            {
                var status = DelegateFactory.GetDelegate <Delegates.DRS.NvAPI_DRS_EnumAvailableSettingValues>()(
                    settingId,
                    ref settingValuesCount,
                    settingValuesReference
                    );

                if (status == Status.IncompatibleStructureVersion)
                {
                    throw new NVIDIANotSupportedException("This operation is not supported.");
                }

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(settingValuesReference.ToValueType <DRSSettingValues>(typeof(DRSSettingValues)));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     This function retrieves the thermal information of all thermal sensors or specific thermal sensor associated with
        ///     the selected GPU. To retrieve info for all sensors, set sensorTarget to ThermalSettingsTarget.All.
        /// </summary>
        /// <param name="physicalGPUHandle">Handle of the physical GPU for which the memory information is to be extracted.</param>
        /// <param name="sensorTarget">Specifies the requested thermal sensor target.</param>
        /// <returns>The device thermal sensors information.</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IThermalSettings GetThermalSettings(
            PhysicalGPUHandle physicalGPUHandle,
            ThermalSettingsTarget sensorTarget = ThermalSettingsTarget.All)
        {
            var getThermalSettings = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetThermalSettings>();

            foreach (var acceptType in getThermalSettings.Accepts())
            {
                var instance = acceptType.Instantiate <IThermalSettings>();

                using (var gpuThermalSettings = ValueTypeReference.FromValueType(instance, acceptType))
                {
                    var status = getThermalSettings(physicalGPUHandle, sensorTarget, gpuThermalSettings);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(gpuThermalSettings.ToValueType <IThermalSettings>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     This API returns information for the current Mosaic topology.
        ///     This includes topology, display settings, and overlap values.
        ///     You can call NvAPI_Mosaic_GetTopoGroup() with the topology if you require more information.
        ///     If there isn't a current topology, then TopologyBrief.Topology will be Topology.None.
        /// </summary>
        /// <param name="topoBrief">The current Mosaic topology</param>
        /// <param name="displaySettings">The current per-display settings</param>
        /// <param name="overlapX">The pixel overlap between horizontal displays</param>
        /// <param name="overlapY">The pixel overlap between vertical displays</param>
        /// <exception cref="NVIDIAApiException">Status.NotSupported: Mosaic is not supported with the existing hardware.</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>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        public static void GetCurrentTopology(out TopologyBrief topoBrief, out IDisplaySettings displaySettings,
                                              out int overlapX, out int overlapY)
        {
            var mosaicGetCurrentTopo = DelegateFactory.Get <Delegates.Mosaic.NvAPI_Mosaic_GetCurrentTopo>();

            topoBrief = typeof(TopologyBrief).Instantiate <TopologyBrief>();
            foreach (var acceptType in mosaicGetCurrentTopo.Accepts())
            {
                displaySettings = acceptType.Instantiate <IDisplaySettings>();
                using (var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, acceptType))
                {
                    var status = mosaicGetCurrentTopo(ref topoBrief, displaySettingsByRef, out overlapX, out overlapY);
                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }
                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }
                    displaySettings = displaySettingsByRef.ToValueType <IDisplaySettings>(acceptType);
                    return;
                }
            }
            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     This API enables and sets up per-pixel intensity feature on the specified display.
        /// </summary>
        /// <param name="displayId">Combined physical display and GPU identifier of the display to apply the intensity control.</param>
        /// <param name="scanOutIntensity">The intensity texture info.</param>
        /// <param name="isSticky">Indicates whether the settings will be kept over a reboot.</param>
        public static void SetScanOutIntensity(uint displayId, IScanOutIntensity scanOutIntensity, out bool isSticky)
        {
            Status status;
            int    isStickyInt;

            if (scanOutIntensity == null)
            {
                status = DelegateFactory.GetDelegate <Delegates.Display.NvAPI_GPU_SetScanOutIntensity>()(
                    displayId,
                    ValueTypeReference.Null,
                    out isStickyInt
                    );
            }
            else
            {
                using (var scanOutWarpingReference =
                           ValueTypeReference.FromValueType(scanOutIntensity, scanOutIntensity.GetType()))
                {
                    status = DelegateFactory.GetDelegate <Delegates.Display.NvAPI_GPU_SetScanOutIntensity>()(
                        displayId,
                        scanOutWarpingReference,
                        out isStickyInt
                        );
                }
            }

            if (status != Status.Ok)
            {
                throw new NVIDIAApiException(status);
            }

            isSticky = isStickyInt > 0;
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     This API queries the desktop and scan-out portion of the specified display.
        /// </summary>
        /// <param name="displayId">Combined physical display and GPU identifier of the display to query the configuration.</param>
        /// <param name="desktopRectangle">Desktop area of the display in desktop coordinates.</param>
        /// <param name="scanOutRectangle">Scan-out area of the display relative to desktopRect.</param>
        public static void GetScanOutConfiguration(
            uint displayId,
            out Rectangle desktopRectangle,
            out Rectangle scanOutRectangle)
        {
            var instance1 = typeof(Rectangle).Instantiate <Rectangle>();
            var instance2 = typeof(Rectangle).Instantiate <Rectangle>();

            using (var desktopRectangleReference = ValueTypeReference.FromValueType(instance1))
            {
                using (var scanOutRectangleReference = ValueTypeReference.FromValueType(instance2))
                {
                    var status = DelegateFactory.GetDelegate <Delegates.Display.NvAPI_GPU_GetScanOutConfiguration>()(
                        displayId,
                        desktopRectangleReference,
                        scanOutRectangleReference
                        );

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    desktopRectangle = desktopRectangleReference.ToValueType <Rectangle>().GetValueOrDefault();
                    scanOutRectangle = scanOutRectangleReference.ToValueType <Rectangle>().GetValueOrDefault();
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     This function retrieves the dynamic performance states information from specific GPU
        /// </summary>
        /// <param name="physicalGPUHandle">Handle of the physical GPU for which the memory information is to be extracted.</param>
        /// <returns>The device utilizations information array.</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static DynamicPerformanceStatesInfoV1 GetDynamicPerformanceStatesInfoEx(
            PhysicalGPUHandle physicalGPUHandle)
        {
            var getDynamicPerformanceStatesInfoEx =
                DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetDynamicPStatesInfoEx>();

            foreach (var acceptType in getDynamicPerformanceStatesInfoEx.Accepts())
            {
                var instance = acceptType.Instantiate <DynamicPerformanceStatesInfoV1>();

                using (var gpuDynamicPStateInfo = ValueTypeReference.FromValueType(instance, acceptType))
                {
                    var status = getDynamicPerformanceStatesInfoEx(physicalGPUHandle, gpuDynamicPStateInfo);

                    if (status == Status.IncompatibleStructureVersion)
                    {
                        continue;
                    }

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(gpuDynamicPStateInfo.ToValueType <DynamicPerformanceStatesInfoV1>(acceptType));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 17
0
 /// <summary>
 ///     Creates a new PathInfoV2
 /// </summary>
 /// <param name="sourceId">Source Id, can be zero</param>
 public PathInfoV2(uint sourceId)
 {
     this             = typeof(PathInfoV2).Instantiate <PathInfoV2>();
     _TargetInfoCount = 0;
     _TargetsInfo     = ValueTypeArray <PathTargetInfoV2> .Null;
     _SourceModeInfo  = ValueTypeReference <SourceModeInfo> .Null;
     _SourceId        = sourceId;
 }
Ejemplo n.º 18
0
 void IAllocatable.Allocate()
 {
     if (_Details.IsNull)
     {
         var detail = typeof(PathAdvancedTargetInfo).Instantiate <PathAdvancedTargetInfo>();
         _Details = ValueTypeReference <PathAdvancedTargetInfo> .FromValueType(detail);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        ///     Creates a new PathInfoV2
        /// </summary>
        /// <param name="targetInformations">Information about path targets</param>
        /// <param name="sourceId">Source Id, can be zero</param>
        public PathInfoV2(PathTargetInfoV2[] targetInformations, uint sourceId = 0)
        {
            this             = typeof(PathInfoV2).Instantiate <PathInfoV2>();
            _TargetInfoCount = (uint)targetInformations.Length;
            _TargetsInfo     = ValueTypeArray <PathTargetInfoV2> .FromArray(targetInformations);

            _SourceModeInfo = ValueTypeReference <SourceModeInfo> .Null;
            _SourceId       = sourceId;
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Creates a new PathInfoV1
        /// </summary>
        /// <param name="sourceModeInfo">Source mode information</param>
        /// <param name="sourceId">Source Id, can be zero</param>
        public PathInfoV1(SourceModeInfo sourceModeInfo, uint sourceId)
        {
            this             = typeof(PathInfoV1).Instantiate <PathInfoV1>();
            _TargetInfoCount = 0;
            _TargetsInfo     = ValueTypeArray <PathTargetInfoV1> .Null;
            _SourceModeInfo  = ValueTypeReference <SourceModeInfo> .FromValueType(sourceModeInfo);

            _ReservedSourceId = sourceId;
        }
Ejemplo n.º 21
0
            /// <summary>
            /// Computes the target partition for each item in the ReadOnlyDataBlock
            /// </summary>
            /// <param name="table">Table where values will be added</param>
            /// <param name="values">DataBlock containing values to be added to the table</param>
            /// <param name="idColumnIndex">Index of the id column</param>
            /// <param name="partitionIds">[Out] array of the partition ids for each element</param>
            public void ComputePartition(Table table, DataBlock.ReadOnlyDataBlock values, int idColumnIndex, out int[] partitionIds, out TargetPartitionInfo[] partitionInfo)
            {
                int rowCount = values.RowCount;

                // TODO: [danny chen] it would be nice if I could get rid of this tunneling of GetColumn
                // from the ReadOnlyDataBlock (and avoid the special casing for non-projected blocks)
                // but I can't see a way to allow strongly types random access without a bunch of work
                // incurred on each access (fetch, cast the array).
                T[] idColumn = (T[])values.GetColumn(idColumnIndex);

                int[] localPartitionIds = new int[rowCount];
                TargetPartitionInfo[] localPartitionInfo = new TargetPartitionInfo[table.PartitionCount];

                var rangePartitioner = Partitioner.Create(0, rowCount);

                Parallel.ForEach(rangePartitioner,
                                 delegate(Tuple <int, int> range, ParallelLoopState unused)
                {
                    ValueTypeReference <T> vtr = new ValueTypeReference <T>();
                    Value v = Value.Create(null);
                    for (int i = range.Item1; i < range.Item2; ++i)
                    {
                        // Hash the ID for each item and compute the partition that the item belongs to
                        vtr.Value = idColumn[i];
                        v.Assign(vtr);
                        int idHash      = v.GetHashCode();
                        int partitionId = PartitionMask.IndexOfHash(idHash, table._partitionBits);

                        localPartitionIds[i] = partitionId;
                        Interlocked.Increment(ref localPartitionInfo[partitionId].Count);
                    }
                });

                int nextStartIndex = 0;

                for (int i = 0; i < table.PartitionCount; ++i)
                {
                    if (localPartitionInfo[i].Count == 0)
                    {
                        localPartitionInfo[i].StartIndex = -1;
                    }
                    else
                    {
                        localPartitionInfo[i].StartIndex = nextStartIndex;
                        nextStartIndex += localPartitionInfo[i].Count;

                        // NOTE: Count field is cleared here because it is
                        //   reused to track per-partition indexes when
                        //   building up the sort key data
                        localPartitionInfo[i].Count = 0;
                    }
                }

                partitionIds  = localPartitionIds;
                partitionInfo = localPartitionInfo;
            }
Ejemplo n.º 22
0
        /// <summary>
        ///     Creates a new PathInfoV1
        /// </summary>
        /// <param name="targetInformations">Information about path targets</param>
        /// <param name="sourceModeInfo">Source mode information</param>
        /// <param name="sourceId">Source Id, can be zero</param>
        public PathInfoV1(PathTargetInfoV1[] targetInformations, SourceModeInfo sourceModeInfo, uint sourceId = 0)
        {
            this             = typeof(PathInfoV1).Instantiate <PathInfoV1>();
            _TargetInfoCount = (uint)targetInformations.Length;
            _TargetsInfo     = ValueTypeArray <PathTargetInfoV1> .FromArray(targetInformations);

            _SourceModeInfo = ValueTypeReference <SourceModeInfo> .FromValueType(sourceModeInfo);

            _ReservedSourceId = sourceId;
        }
Ejemplo n.º 23
0
 void IAllocatable.Allocate()
 {
     if ((_TargetInfoCount > 0) && _TargetsInfo.IsNull)
     {
         var targetInfo     = typeof(PathTargetInfoV2).Instantiate <PathTargetInfoV2>();
         var targetInfoList = targetInfo.Repeat((int)_TargetInfoCount).AllocateAll();
         _TargetsInfo = ValueTypeArray <PathTargetInfoV2> .FromArray(targetInfoList.ToArray());
     }
     if (_SourceModeInfo.IsNull)
     {
         var sourceModeInfo = typeof(SourceModeInfo).Instantiate <SourceModeInfo>();
         _SourceModeInfo = ValueTypeReference <SourceModeInfo> .FromValueType(sourceModeInfo);
     }
 }
Ejemplo n.º 24
0
        public static void SetClientFanCoolersControl(PhysicalGPUHandle gpuHandle, PrivateFanCoolersControlV1 control)
        {
            using (var coolerLevelsReference = ValueTypeReference.FromValueType(control))
            {
                var status = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_ClientFanCoolersSetControl>()(
                    gpuHandle,
                    coolerLevelsReference
                    );

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        ///     [PRIVATE] - [Pascal Only]
        ///     Sets the clock boost table for the passed GPU handle.
        /// </summary>
        /// <param name="gpuHandle">The handle of the GPU to perform the operation on.</param>
        /// <param name="clockBoostTable">The new clock table.</param>
        public static void SetClockBoostTable(PhysicalGPUHandle gpuHandle, PrivateClockBoostTableV1 clockBoostTable)
        {
            using (var clockTableReference = ValueTypeReference.FromValueType(clockBoostTable))
            {
                var status = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_SetClockBoostTable>()(
                    gpuHandle,
                    clockTableReference
                    );

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     This function retrieves the clock frequencies information from an specific physical GPU and fills the structure
        /// </summary>
        /// <param name="physicalGPUHandle">
        ///     Handle of the physical GPU for which the clock frequency information is to be
        ///     retrieved.
        /// </param>
        /// <param name="clockFrequencyOptions">
        ///     The structure that holds options for the operations and should be filled with the
        ///     results, use null to return current clock frequencies
        /// </param>
        /// <returns>The device clock frequencies information.</returns>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="NVIDIAApiException">Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IClockFrequencies GetAllClockFrequencies(
            PhysicalGPUHandle physicalGPUHandle,
            IClockFrequencies clockFrequencyOptions = null)
        {
            var getClocksInfo = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetAllClockFrequencies>();

            if (clockFrequencyOptions == null)
            {
                foreach (var acceptType in getClocksInfo.Accepts())
                {
                    var instance = acceptType.Instantiate <IClockFrequencies>();

                    using (var clockFrequenciesInfo = ValueTypeReference.FromValueType(instance, acceptType))
                    {
                        var status = getClocksInfo(physicalGPUHandle, clockFrequenciesInfo);

                        if (status == Status.IncompatibleStructureVersion)
                        {
                            continue;
                        }

                        if (status != Status.Ok)
                        {
                            throw new NVIDIAApiException(status);
                        }

                        return(clockFrequenciesInfo.ToValueType <IClockFrequencies>(acceptType));
                    }
                }
            }
            else
            {
                using (var clockFrequenciesInfo =
                           ValueTypeReference.FromValueType(clockFrequencyOptions, clockFrequencyOptions.GetType()))
                {
                    var status = getClocksInfo(physicalGPUHandle, clockFrequenciesInfo);

                    if (status != Status.Ok)
                    {
                        throw new NVIDIAApiException(status);
                    }

                    return(clockFrequenciesInfo.ToValueType <IClockFrequencies>(clockFrequencyOptions.GetType()));
                }
            }

            throw new NVIDIANotSupportedException("This operation is not supported.");
        }
Ejemplo n.º 27
0
        /// <summary>
        ///     Determines the set of available display modes for a given grid topology.
        /// </summary>
        /// <param name="gridTopology">The grid topology to use.</param>
        /// <returns></returns>
        /// <exception cref="NVIDIAApiException">Status.InvalidArgument: One or more arguments 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>
        /// <exception cref="NVIDIANotSupportedException">This operation is not supported.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static IDisplaySettings[] EnumDisplayModes(IGridTopology gridTopology)
        {
            var mosaicEnumDisplayModes = DelegateFactory.GetDelegate <Delegates.Mosaic.NvAPI_Mosaic_EnumDisplayModes>();

            using (var gridTopologyByRef = ValueTypeReference.FromValueType(gridTopology, gridTopology.GetType()))
            {
                var totalAvailable = 0u;
                var status         = mosaicEnumDisplayModes(gridTopologyByRef, ValueTypeArray.Null, ref totalAvailable);

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                if (totalAvailable == 0)
                {
                    return(new IDisplaySettings[0]);
                }

                foreach (var acceptType in mosaicEnumDisplayModes.Accepts(2))
                {
                    var counts   = totalAvailable;
                    var instance = acceptType.Instantiate <IDisplaySettings>();

                    using (
                        var displaySettingByRef =
                            ValueTypeArray.FromArray(instance.Repeat((int)counts).AsEnumerable()))
                    {
                        status = mosaicEnumDisplayModes(gridTopologyByRef, displaySettingByRef, ref counts);

                        if (status == Status.IncompatibleStructureVersion)
                        {
                            continue;
                        }

                        if (status != Status.Ok)
                        {
                            throw new NVIDIAApiException(status);
                        }

                        return(displaySettingByRef.ToArray <IDisplaySettings>((int)counts, acceptType));
                    }
                }

                throw new NVIDIANotSupportedException("This operation is not supported.");
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        ///     [PRIVATE]
        ///     Sets the thermal policies status for the passed GPU handle.
        /// </summary>
        /// <param name="gpuHandle">The handle of the GPU to perform the operation on.</param>
        /// <param name="thermalPoliciesStatus">The new thermal limiter policy to apply.</param>
        public static void SetThermalPoliciesStatus(
            PhysicalGPUHandle gpuHandle,
            PrivateThermalPoliciesStatusV2 thermalPoliciesStatus)
        {
            using (var policiesStatusReference = ValueTypeReference.FromValueType(thermalPoliciesStatus))
            {
                var status = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_SetThermalPoliciesStatus>()(
                    gpuHandle,
                    policiesStatusReference
                    );

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        ///     [PRIVATE]
        ///     Gets additional information about the PCIe interface and configuration for the passed GPU handle.
        /// </summary>
        /// <param name="gpuHandle">The handle of the GPU to perform the operation on.</param>
        /// <returns>PCIe information and configurations.</returns>
        public static PrivatePCIeInfoV2 GetPCIEInfo(PhysicalGPUHandle gpuHandle)
        {
            var instance = typeof(PrivatePCIeInfoV2).Instantiate <PrivatePCIeInfoV2>();

            using (var pcieInfoReference = ValueTypeReference.FromValueType(instance))
            {
                var status =
                    DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_GetPCIEInfo>()(gpuHandle, pcieInfoReference);

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }

                return(pcieInfoReference.ToValueType <PrivatePCIeInfoV2>(typeof(PrivatePCIeInfoV2)));
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        ///     Sets the control information about illumination devices on the given GPU.
        /// </summary>
        /// <param name="gpuHandle">The physical GPU handle.</param>
        /// <param name="deviceControlParameters">The new control illumination devices control information.</param>
        public static void ClientIlluminationDevicesSetControl(
            PhysicalGPUHandle gpuHandle,
            IlluminationDeviceControlParametersV1 deviceControlParameters)
        {
            using (var deviceControlParametersReference = ValueTypeReference.FromValueType(deviceControlParameters))
            {
                var status = DelegateFactory.GetDelegate <Delegates.GPU.NvAPI_GPU_ClientIlluminationDevicesSetControl>()(
                    gpuHandle,
                    deviceControlParametersReference
                    );

                if (status != Status.Ok)
                {
                    throw new NVIDIAApiException(status);
                }
            }
        }