OGRE Frequency Settings Config Does Not Match Monitor Freqs

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

OGRE Frequency Settings Config Does Not Match Monitor Freqs

Post by OGREHEAD » Tue Jan 10, 2017 7:57 pm

When I run my application and the OGRE renderings config box comes up the frequencies I can choose between does not match my monitor frequencies.

Like my monitor is at 1920x1080 and 60Hz
But the OGRE config box only has 50Hz and 53Hz listed to choose between.

Should I not have 60Hz as an option to select???

I also get tearing quite a bit when running my own application, but the samples that come with ogre have less tearing, even though they are also running at the "wrong" frequencies.

Application is running on linux with ogre 1.10 installed.
Any ideas how to solve the frequency and tearing issue?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3810
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 139
Contact:

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dark_sylinc » Tue Jan 10, 2017 8:26 pm

OS, driver (vendor, version, Open Source or Proprietary), X11 version and distro?
Any ideas how to solve (...) tearing issue?
Tearing is impossible to fix on X; only alleviated (enable VSync, make sure you can render your frame in way less time than 16.66ms, disable the compositor, then pray). The best hope is Wayland.
0 x

OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by OGREHEAD » Wed Jan 11, 2017 3:25 pm

OS: KUBUNTU 16.10 64
KERNEL: 4.8.0-32
NVIDIA: 367.57 DEB package
X: VersionNumber 11.0 / VendorVersion 1.18.4

But I have had this problem for a while with older versions as well.
Last edited by OGREHEAD on Wed Jan 11, 2017 4:21 pm, edited 3 times in total.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3810
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 139
Contact:

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dark_sylinc » Wed Jan 11, 2017 4:18 pm

I suspected it was NVIDIA, since they use their own drivers.

The best (which is not much) thing I can say is look into GLXGLSupport::GLXGLSupport constructor where the video modes are enumerated:

Code: Select all

screenConfig = XRRGetScreenInfo(mXDisplay, DefaultRootWindow(mXDisplay));

if (screenConfig)
{
    XRRScreenSize *screenSizes;
    int nSizes = 0;
    Rotation currentRotation;
    int currentSizeID = XRRConfigCurrentConfiguration(screenConfig, &currentRotation);

    screenSizes = XRRConfigSizes(screenConfig, &nSizes);

    mCurrentMode.first.first = screenSizes[currentSizeID].width;
    mCurrentMode.first.second = screenSizes[currentSizeID].height;
    mCurrentMode.second = XRRConfigCurrentRate(screenConfig);

    mOriginalMode = mCurrentMode;

    for(int sizeID = 0; sizeID < nSizes; sizeID++)
    {
        short *rates;
        int nRates = 0;

        rates = XRRConfigRates(screenConfig, sizeID, &nRates);

        for (int rate = 0; rate < nRates; rate++)
        {
            VideoMode mode;

            mode.first.first = screenSizes[sizeID].width;
            mode.first.second = screenSizes[sizeID].height;
            mode.second = rates[rate];

            mVideoModes.push_back(mode);
        }
    }
    XRRFreeScreenConfigInfo(screenConfig);
}
XRRConfigRates returns the refresh rates. If these values are correct (i.e. 60 is among the results) then something is happening by the time we display these values in the config dialog (see GLXGLSupport::refreshConfig); If these values are wrong, then RandR is behaving erratically or your X may be configured incorrectly.

What is the output of xrand?
Mine looks like this:

Code: Select all

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DVI-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 510mm x 290mm
   1920x1080     60.00*+
   1680x1050     59.88  
   1400x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1440x900      59.90  
   1280x800      59.91  
   1152x864      75.00  
   1280x720      60.00  
   1024x768      75.03    60.00  
   832x624       74.55  
   800x600       75.00    60.32    56.25  
   640x480       75.00    59.94  
   720x400       70.08  
DVI-1 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   832x624       74.55  
   800x600       75.00    60.32    56.25  
   640x480       75.00    59.94  
   720x400       70.08  
HDMI2 disconnected
HDMI3 disconnected
VGA1 disconnected
VIRTUAL1 disconnected
0 x

OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by OGREHEAD » Wed Jan 11, 2017 4:22 pm

I tried disabling the compositor and that worked better along with vsync, I guess this is pretty much as good as it gets then.
The frequency is worng still however.

A small additional problem however is when the camera is moved around object gets "ghosted" like if I have a green cone and moved the camera around, mostly around the edges of the cone I can see a purple transparent cone. When the camera is not moving the cone looks fine, but the ghosting happens to all objects and even the skybox has this distortion when the camera is moved, like a transparent image is having trouble keeping up or a delayed view or something, mostly visible at high movement rates?

I am not able to screenshot this problem.

Output of xrandr:
3840x2160 60.00 +
2560x1440 59.95
1920x1080 60.00* 59.94
1680x1050 59.95
1600x900 60.00
1440x900 59.89
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00
1152x864 75.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
640x480 75.00 72.81 59.94

I will try to mess around with the glx stuff.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3810
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 139
Contact:

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dark_sylinc » Wed Jan 11, 2017 4:31 pm

OK I just noticed the display on the config of Hz values is totally messed up. Fixing...

Edit: **Sigh** it was not messed up. My bad. Turns out that for frequency to make sense, Fullscreen must be set to Yes.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3810
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 139
Contact:

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dark_sylinc » Wed Jan 11, 2017 5:11 pm

Try again after this fix.
My hopes are not very high though.
0 x

dermont
Orc Shaman
Posts: 770
Joined: Thu Dec 09, 2004 2:51 am
x 8

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dermont » Wed Jan 11, 2017 5:31 pm

I think the problem is that Ogre still uses an old version of xrandr.

http://www.ogre3d.org/forums/viewtopic. ... &start=200

You can simulate with xrandr --q1. For example:

Code: Select all

 xrandr --q1
 SZ:    Pixels          Physical       Refresh
*0   1920 x 1080   ( 513mm x 291mm )  *50  

./nv-control-dpy --print-used-modelines
MetaMode: id=50, switchable=yes, source=xconfig :: DPY-0: nvidia-auto-select @1920x1080 +0+0 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0}
  DPY-0: source=edid :: "nvidia-auto-select"  148.500  1920 2008 2052 2200  1080 1084 1089 1125   +HSync +VSync

xrandr
1920x1080     60.00*+
So in your case the "50Hz" frequency is actually the Metadode ID=50 where you can calculate the rate from to give 60MHz.

In the past you disable this with TwinView but with more recent drivers you can't.


You can obtain the rates via xrandr 1.2 with something like:

Code: Select all

#include <X11/X.h>
#include <GL/glx.h>
#include <X11/Xatom.h>
#include<X11/extensions/Xrandr.h>

#include <iostream>
#include <cstdio>
using namespace std;

// g++ -o xres main.cpp `pkg-config --cflags --libs x11 xrandr`

// Randr versions
#define EXTENSION_VERSION(major,minor)\
    (major << 16) | minor;

// Randr versions
#define RANDR_1_1 ((1 << 16) | 1)
#define RANDR_1_2 ((1 << 16) | 2)
#define RANDR_1_3 ((1 << 16) | 3)
#define RANDR_1_4 ((1 << 16) | 4)

int main(int argc, char **argv)
{
    Display* mDisplay = XOpenDisplay(":0");
    int screen = DefaultScreen(mDisplay);

    int error=0;
    long mEventMask;
    int  mEventBase;
    int mOpCode;

    //if (!XQueryExtension(mDisplay, "RANDR",&mOpCode, &mEventBase, &error) {
    //   printf("RandR extension not supported\n");
    //}


    int mVersion=0;
    int mVersionMajor,mVersionMinor;

    if ( XRRQueryExtension( mDisplay, &mEventBase, &error ) ) {

        XRRQueryVersion(mDisplay, &mVersionMajor, &mVersionMinor);
        mVersion = EXTENSION_VERSION(mVersionMajor, mVersionMinor);
    }

    if (mVersion==0) {
        printf("RandR extension not supported\n");
        XCloseDisplay(mDisplay);
        return 1;
    }


    mEventMask =
        RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask |
        RROutputChangeNotifyMask | RROutputPropertyNotifyMask;

    if (1==1) {

    //if (mVersion < RANDR_1_2) {
        // retrieve monitor extents from RandR1.1
        std::cout << "------------------------------" << std::endl;
        std::cout << "Using XRandR 1.1              " << std::endl;
        std::cout << "------------------------------" << std::endl;


        XRRScreenConfiguration *screenConfig = NULL;
        screenConfig = XRRGetScreenInfo(mDisplay, DefaultRootWindow(mDisplay));
	    if (screenConfig) 
	    {
		    XRRScreenSize *screenSizes;
		    int nSizes = 0;
		    Rotation currentRotation;
		    int currentSizeID = XRRConfigCurrentConfiguration(screenConfig, &currentRotation);
		    screenSizes = XRRConfigSizes(screenConfig, &nSizes);
            printf("Num Screens %d \n",nSizes);
		    for(int sizeID = 0; sizeID < nSizes; sizeID++) {
                short *rates;
                int nRates = 0;
                    
                rates = XRRConfigRates(screenConfig, sizeID, &nRates);
                printf("\nID :%i %ix%i", sizeID,screenSizes[sizeID].width,screenSizes[sizeID].height);
    
                for (int rate = 0; rate < nRates; rate++)
                {
                    printf(" %i ", rates[rate] );
                }

            } 
            printf("\n");
	        XRRFreeScreenConfigInfo(screenConfig);
        }
    }



    if (1==1) /*(mVersion >= RANDR_1_2)*/ {

        std::cout << "------------------------------" << std::endl;
        std::cout << "Using XRandR 1.2+             " << std::endl;
        std::cout << "------------------------------" << std::endl;

	    XRRScreenResources *mScreenResources = XRRGetScreenResources(mDisplay, DefaultRootWindow(mDisplay));

        for (int crtID = 0; crtID < mScreenResources->ncrtc; crtID++) {
            XRRCrtcInfo *ci = XRRGetCrtcInfo(mDisplay, mScreenResources, mScreenResources->crtcs[crtID]);
            if (!ci) break;
            if (ci->noutput==0) break;

            printf("Current Mode :%lu\nScreen x: %i, y: %i, width: %i, height: %i \nNum Outputs: %i \nNum Possibles: %i Rotation :%i Rotations :%i\n",
	            ci->mode,
                ci->x,  ci->y, 
                ci->width, ci->height,
                ci->noutput, ci->npossible,
                ci->rotation, ci->rotations);

            for (int outputID=0;outputID<ci->noutput;outputID++) {
                std::string s;
                XRROutputInfo *outputInfo = 
                    XRRGetOutputInfo (mDisplay, mScreenResources, ci->outputs[outputID]);
                s.assign(outputInfo->name, outputInfo->nameLen + 1);
                std::cout << "Name " << s << std::endl;

                XRRModeInfo* modeInfo=0;
                for (int modeID = 0; modeID < outputInfo->nmode; modeID++) {
                    for (int m = 0;  mScreenResources->nmode;m++) {
                        modeInfo = &mScreenResources->modes[m];
                        if (modeInfo->id == outputInfo->modes[modeID])
                            break;
                    }
                    if (modeInfo) {
                        unsigned int vTotal = modeInfo->vTotal;
                        vTotal = (modeInfo->modeFlags & RR_DoubleScan) ? vTotal*2:vTotal;
                        vTotal = (modeInfo->modeFlags & RR_Interlace)  ? vTotal/2:vTotal;

                        double rate = ((double) modeInfo->dotClock /((double) modeInfo->hTotal * (double)vTotal));
                        printf("Mode id: %lu name: %9s width: %4i height: %4i rate: %4.2f\n",
                                //"x",//outputInfo->npreferred>0?"*":" ",
                                modeInfo->id,
	                            modeInfo->name,
		                        modeInfo->width, 
                                modeInfo->height,
	                            rate);
                        std::string s;
                        s.assign(modeInfo->name, modeInfo->nameLength);
                    }
                }
                XRRFreeOutputInfo(outputInfo);
            } 
            if (ci) XRRFreeCrtcInfo (ci);
        }

        XRRFreeScreenResources(mScreenResources);
    }


    XCloseDisplay(mDisplay);
    return 0;
}
0 x

OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by OGREHEAD » Wed Jan 11, 2017 7:25 pm

The frequency list works now with the code fix you posted or I had to change a few lines a bit, maybe since I have 1.10 , but the list now has all frequencies to choose between, not sure if this was the intend but this might be because I have not changed code to match completely.

My glxwindow.cpp had this already

Code: Select all

        if (! mIsExternalGLControl)
        {
            if (GLXEW_MESA_swap_control)
                glXSwapIntervalMESA (vsync ? mVSyncInterval : 0);
            else if (GLXEW_EXT_swap_control)
                glXSwapIntervalEXT (mGLSupport->getGLDisplay(), glXGetCurrentDrawable(),
                                    vsync ? mVSyncInterval : 0);
            else if (GLXEW_SGI_swap_control)
                if (vsync && mVSyncInterval)
                    glXSwapIntervalSGI (mVSyncInterval);
        }
        
But the list appeared by just changing in the GLXGLSupport file.

So now I guess I have the correct frequency and almost no tearing when I enable vsync.
Thanks for the fix and the help.

Last Issue with ghosting pixels when moving around I have no idea what is the cause of...???

I have run the same project on laptop however and there is no ghosting, so I guess it is the nvidia driver or something.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3810
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 139
Contact:

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by dark_sylinc » Wed Jan 11, 2017 9:22 pm

So just to clarify: it works now?!?!?!

I'm surprised.
0 x

OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

Re: OGRE Frequency Settings Config Does Not Match Monitor Fr

Post by OGREHEAD » Sat Jan 14, 2017 11:51 am

The compositor helped a lot on the tearing issue, it is just strange the samples would run without tearing when compositor was still enabled.

It works so far as I get a long list of frequencies, not only the ones that are valid, like I get a list with all frequencies from 50 - 100, where most of them shouldn't be there, only the ones that belong to certain resolutions.
But if I just choose the resolution I want I guess it is what I want.

So I have minimized tearing and the frequency should be as I wanted.

The only problem I have now is the problem with camera movement, where the screen is a bit fuzzy and there is a kind of a ghost image when moving, so I have a transparent image trailing the actual image. Like putting two images on top of each other and the top one is very transparent and a little behind the other, thereby creating ghost edges on objects when moving and making the picture a bit blurry.
It is just slightly, but more than enough to be noticeable and it should not be there...
Maybe I need to do something in my ogre application, but it is just a very basic ogre example I have set up and test with and tried out a lot of different settings with.
I do not know how to solve this, do not know if it is ogre or something else.
I have tried another monitor and it is still there, but I am unable to solve this and do not know how to eliminate the ghosting problem.
0 x

OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm

Re: Solved - Tearing / Ghosting / Frequencies

Post by OGREHEAD » Sat Jan 21, 2017 4:22 pm

I figured out what the problem was.

My monitor was set to response time fastest. I switched it to normal and it worked perfectly, like I would expect that it should look.

So now I have no tearing and no ghosting...

Thanks for helping out with the tearing and frequency issues.
0 x

Post Reply