NvAPIWrapper icon indicating copy to clipboard operation
NvAPIWrapper copied to clipboard

How to set custom resolution?

Open MACTEP434 opened this issue 2 years ago • 7 comments

Hi! This part of code doesn't work

var displayTest = new DisplayDevice(2147881091);
var timing = displayTest.CalculateTiming(800, 600, 60, false); var res1 = new CustomResolution(800, 600, NvAPIWrapper.Native.Display.ColorFormat.P8, timing); displayTest.TrialCustomResolution(res1); displayTest.SaveCustomResolution();

Crashed on TrialCustomResolution (NvAPI error). Help please

MACTEP434 avatar Nov 30 '21 17:11 MACTEP434

usually, it's a timing problem. Change the color format to A8R8G8B8 and try again; otherwise, play with other variables; get the current timing and compare it with the one you have to see if you have to copy something over.

falahati avatar Nov 30 '21 20:11 falahati

usually, it's a timing problem. Change the color format to A8R8G8B8 and try again; otherwise, play with other variables; get the current timing and compare it with the one you have to see if you have to copy something over.

Maybe my var displayTest = new DisplayDevice(2147881091); - is single display? Im trying to set custom resolution before bulid mosiac.

Stacktrace: at NvAPIWrapper.Native.DisplayApi.TryCustomDisplay(IDictionary```2 displayIdCustomDisplayPairs) at CrodMosaic.NET.Program.Main(String[] args) in C:\CobraDev\NvAPI\CrodMosaic.NET\CrodMosaic.NET\Program.cs:line 32

MACTEP434 avatar Dec 01 '21 06:12 MACTEP434

these files might be useful as an example for grid management (mosaic v2) set of APIs: https://github.com/falahati/HeliosDisplayManagement/tree/master/HeliosDisplayManagement.Shared/NVIDIA

otherwise, I have no new input here; the driver can reject a timing for absolutely any reason and NVAPI is not great with error messages. so my guess is the same as before.

Maybe my `var displayTest = new DisplayDevice(2147881091);` - is single display?

DisplayDevice represents a single physical display device. I don't like the fact that you are using a const for the id, would rather see a code to get all display devices and find the right one. but yeah if the number is correct, it is a display device. also, I don't think you add a custom resolution while in the surround mode.

falahati avatar Dec 01 '21 10:12 falahati

There is six types of display in NVAPI:

  1. DisplayDevice: Represents a physical display, your own monitor
  2. Display: A logical connected display
  3. UnattachedDisplay: A logical disconnected display
  4. GridTopologyDisplay: A physical display used in the mosaic arrangement
  5. PathTargetInfo: A logical display device presented to windows (could be a physical device or Nvidia Surround virtual device)
  6. PathInfo: A logical screen created by windows (contains one or more PathTargetInfo that contains one Display)

falahati avatar Dec 01 '21 10:12 falahati

I need a beer on this weekend, and try again.....

MACTEP434 avatar Dec 02 '21 14:12 MACTEP434

Hello, I'm also facing issues setting a custom resolution using this library.

var displays = Display.GetDisplays(); foreach (var display in displays) { DisplayDevice displayTest = display.DisplayDevice; var timing = displayTest.CalculateTiming(1920, 1080, 60, false); var res1 = new CustomResolution(1920, 1080, NvAPIWrapper.Native.Display.ColorFormat.A8R8G8B8, timing); try{ displayTest.TrialCustomResolution(res1); displayTest.SaveCustomResolution(); .LogInformation(display.Name); }catch(Exception e){ _logger.LogError(e, "Error"); } }

Error NVAPI_ERROR: at NvAPIWrapper.Native.DisplayApi.TryCustomDisplay(IDictionary`2 displayIdCustomDisplayPairs) at NvAPIWrapper.Display.DisplayDevice.TrialCustomResolution(CustomResolution customResolution, UInt32[] displayIds, Boolean hardwareModeSetOnly) at NvAPIWrapper.Display.DisplayDevice.TrialCustomResolution(CustomResolution customResolution, Boolean hardwareModeSetOnly)

coccoalberto97 avatar Apr 04 '22 14:04 coccoalberto97

I got the same problem. But when I use the overload with refreshRate of CustomResolution() it works. With ColorFormat I never got it to work.

FoLLgoTT avatar May 15 '22 18:05 FoLLgoTT