falahati / NvAPIWrapper

NvAPIWrapper is a .Net wrapper for NVIDIA public API, capable of managing all aspects of a display setup using NVIDIA GPUs
GNU Lesser General Public License v3.0
313 stars 55 forks source link

Virtual custom resolution: reported and real refresh rate don't match #61

Closed FoLLgoTT closed 1 year ago

FoLLgoTT commented 2 years ago

I create virtual custom resolutions on trial which should only shrink the active desktop, but should use the current timing. This works fine with the following code:

NvAPIWrapper.Display.DisplayDevice display = NvAPIWrapper.Display.Display.GetDisplays().First().DisplayDevice; // use first display NvAPIWrapper.Display.CustomResolution customResolution = new NvAPIWrapper.Display.CustomResolution((uint)width, (uint)height, 32, display.CurrentTiming); display.TrialCustomResolution(customResolution);

The problem is that for refresh rates which are very near to each other (e.g. 59,94 Hz and 60 Hz) the nearest integer is reported from Windows and in NVIDIA control panel. In this case 60 Hz is selected in the combo box although 59 Hz should be selected. The real refresh rate is 59,94 Hz. I measured it with several applications (e.g. https://www.testufo.com/refreshrate).

I found out that "display.CurrentTiming" contains 60 Hz which is wrong. Any idea?

falahati commented 2 years ago

use FrequencyInMillihertz

if it is also 60Hz, I suppose NVAPI just returns this value for the frequency. what do you see in the NVIDIA Control Panel?

FoLLgoTT commented 2 years ago

FrequencyInMillihertz is also wrong. It shows 60 Hz instead of 59,94 Hz. Only the PixelClock seems to make the difference and so the real refresh rate is correct.

NVIDIA control panel shows 60 Hz in the combo box.

falahati commented 2 years ago

if NVIDIA CP shows as 60hz, so will we. this is just a wrapper around the nvidia's API which is also used by other tools.

regardless, it is possible that the card in fact outputs 60hz or something but is then limited by some other thing in the pipeline, like the monitor or a compatibility layer for old displays which might depend on how this monitor is connected.

in any case, I don't really think we can do much about this. if pixel clock gives you the correct info you can try figuring out the actual refresh rate from that. should be straightforward.

FoLLgoTT commented 2 years ago

Ok, I suspected that the cause is more inside Windows/drivers. Thank you for the answer.