falahati/NvAPIWrapper

How to set custom resolution?

MACTEP434 opened this issue · 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

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.

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

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.

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)

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

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)

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.