RHIGetAvailableResolutions return duplication

Hi

Windows 7 64-bit

Binary Unreal engine 4.9.0

Laptop with external monitor pluged-in.

Method RHIGetAvailableResolutions return duplication of all resolutions (all for laptop and none for external monitor, laptop monitor seted as main).

Why?

Hello Alanir,

I have a few questions for you about this issue.

  1. When you say “dublication”, do you mean duplication? As in something being shown twice?
  2. Is this something that is new to 4.9.0 or did it happen in previous versions of the engine as well?
  3. Does this only happen when the external monitor is plugged in?
  4. How are you reading the output of this function to see the duplication?
  1. Yeah, sorry “duplication”

  2. I don’t know, I’m just working with 4.9

  3. No. I’ve just disconnected second monitor and result is the same.

  4. Snapping a code to get things more clearly:

    if (RHIGetAvailableResolutions(resolutions, false))
    {
    	FStarfallResolution newResolution;
    	FIntPoint currentResolution = GEngine->GameViewport->Viewport->GetSizeXY();
    
    	for (const FScreenResolutionRHI& resolution : resolutions)
    	{
    		newResolution.caption = FString::Printf(TEXT("%dx%d"), resolution.Width, resolution.Height);
    		newResolution.resolution.X = resolution.Width;
    		newResolution.resolution.Y = resolution.Height;
    
    		m_Resolutions.Add(newResolution);
    	}
    }
    

I’ve checked foreach loop. Double elements in resolution array, I’m not calling my method twice.

Hello Alanir,

It seems that the reason you’re receiving duplicates is due to the arguments you’re using for the function call. Please take a look at this page: FNullDynamicRHI::RHIGetAvailableResolutions | Unreal Engine Documentation

The boolean argument determines whether the function should ignore refresh rates or not. In this case, as you have it set to false, it was checking for all resolutions including ones using different refresh rates. When it goes to output, it’ll output a lot of resolutions twice as one may be 59hz while the other is 60hz (This will vary on the monitor’s available refresh rates). If you wish to only have a single entry for each, please change this argument to true and you should be fine.

Hope this helps!

Matthew Clark

Hi, thanks for suggestion. That was my first thought. Every resolution returns refresh rate equal to 60.

Ah I see, I changed it to output the refresh rate as well and noticed that. It seems like an error with how the function is written. I’ve placed a bug in for the issue and it seems like a simple fix so hopefully it’ll be fixed soon. For your reference, the bug number is UE-21188.

Have a nice day!

Thank you!