Fix for tearing when VMR exclusive mode isn't checked. (1 Viewer)

zeflash

Portal Pro
July 7, 2005
199
16
Home Country
France France
Had this error for a long time (at least with NVidia cards, somehow the ATI I had before wasn't showing up that bug).

I checked the source. In d3dapp.cs, BuildPresentParamsFromSettings function:
Code:
      if (windowed)
      {
        presentParams.MultiSample = graphicsSettings.WindowedMultisampleType;
        presentParams.MultiSampleQuality = graphicsSettings.WindowedMultisampleQuality;
        presentParams.AutoDepthStencilFormat = graphicsSettings.WindowedDepthStencilBufferFormat;
        presentParams.BackBufferWidth = ourRenderTarget.ClientRectangle.Right - ourRenderTarget.ClientRectangle.Left;
        presentParams.BackBufferHeight = ourRenderTarget.ClientRectangle.Bottom - ourRenderTarget.ClientRectangle.Top;
        presentParams.BackBufferFormat = graphicsSettings.BackBufferFormat;
        presentParams.PresentationInterval = PresentInterval.Immediate;
        presentParams.FullScreenRefreshRateInHz = 0;
        presentParams.SwapEffect = SwapEffect.Discard;
        presentParams.PresentFlag = PresentFlag.Video; //PresentFlag.LockableBackBuffer;
        presentParams.DeviceWindow = ourRenderTarget;
        presentParams.Windowed = true;
        //presentParams.PresentationInterval = PresentInterval.Immediate;
      }
      else
      {
        presentParams.MultiSample = graphicsSettings.FullscreenMultisampleType;
        presentParams.MultiSampleQuality = graphicsSettings.FullscreenMultisampleQuality;
        presentParams.AutoDepthStencilFormat = graphicsSettings.FullscreenDepthStencilBufferFormat;

        presentParams.BackBufferWidth = graphicsSettings.DisplayMode.Width;
        presentParams.BackBufferHeight = graphicsSettings.DisplayMode.Height;
        presentParams.BackBufferFormat = graphicsSettings.DeviceCombo.BackBufferFormat;
        presentParams.PresentationInterval = PresentInterval.Default;
        presentParams.FullScreenRefreshRateInHz = graphicsSettings.DisplayMode.RefreshRate;
        presentParams.SwapEffect = SwapEffect.Discard;
        presentParams.PresentFlag = PresentFlag.Video; //|PresentFlag.LockableBackBuffer;
        presentParams.DeviceWindow = this;
        presentParams.Windowed = false;
      }

even though I'm starting MP fullscreen, windowed is true. Therefore, the presentation used is PresentInterval.Immediate, which causes tearing as it's not waiting the vsync to present the backbuffers.
PresentInterval.Default should be used instead, to preserve vsync at all time.

Should be this way instead (and I tested it, it works fine):
Code:
      if (windowed)
      {
        presentParams.MultiSample = graphicsSettings.WindowedMultisampleType;
        presentParams.MultiSampleQuality = graphicsSettings.WindowedMultisampleQuality;
        presentParams.AutoDepthStencilFormat = graphicsSettings.WindowedDepthStencilBufferFormat;
        presentParams.BackBufferWidth = ourRenderTarget.ClientRectangle.Right - ourRenderTarget.ClientRectangle.Left;
        presentParams.BackBufferHeight = ourRenderTarget.ClientRectangle.Bottom - ourRenderTarget.ClientRectangle.Top;
        presentParams.BackBufferFormat = graphicsSettings.BackBufferFormat;
        presentParams.PresentationInterval = PresentInterval.Default;
        presentParams.FullScreenRefreshRateInHz = 0;
        presentParams.SwapEffect = SwapEffect.Discard;
        presentParams.PresentFlag = PresentFlag.Video; //PresentFlag.LockableBackBuffer;
        presentParams.DeviceWindow = ourRenderTarget;
        presentParams.Windowed = true;
        //presentParams.PresentationInterval = PresentInterval.Immediate;
      }
      else
      {
        presentParams.MultiSample = graphicsSettings.FullscreenMultisampleType;
        presentParams.MultiSampleQuality = graphicsSettings.FullscreenMultisampleQuality;
        presentParams.AutoDepthStencilFormat = graphicsSettings.FullscreenDepthStencilBufferFormat;

        presentParams.BackBufferWidth = graphicsSettings.DisplayMode.Width;
        presentParams.BackBufferHeight = graphicsSettings.DisplayMode.Height;
        presentParams.BackBufferFormat = graphicsSettings.DeviceCombo.BackBufferFormat;
        presentParams.PresentationInterval = PresentInterval.Default;
        presentParams.FullScreenRefreshRateInHz = graphicsSettings.DisplayMode.RefreshRate;
        presentParams.SwapEffect = SwapEffect.Discard;
        presentParams.PresentFlag = PresentFlag.Video; //|PresentFlag.LockableBackBuffer;
        presentParams.DeviceWindow = this;
        presentParams.Windowed = false;
      }

Please put that fix in, it's going to make a lot of people happy.
 

patricon

Portal Pro
June 16, 2007
543
18
Home Country
Spain Spain
amazing zeflash!! all this time having issues with VMR... and now you did the trick. if it really works, could be incredible... many thanks!
 

level20peon

MP Donator
  • Premium Supporter
  • January 4, 2007
    1,082
    102
    43
    Aachen
    Home Country
    Germany Germany
    OK - I'm stupid: This is useful when one is NOT using VMR exclusive, right? :confused:

    No difference if it is used?

    I think this is what the change intends to do. I however still have tearing when I do not use exclusive mode (I activated V-Sync in my Videocards control panel) running @ Nvidia.


    -level20peon
     

    andreavb

    Portal Pro
    December 26, 2006
    140
    4
    50
    Home Country
    Italy Italy
    I also tested to run MP without exclusive mode because somtimes it seems to lock video when exiting TV or recorded TV...the problem with exclusive mode disabled is tearing. I tested this with an old SVN maybe before zeflash fix. Is possible with this fix to run MediaPortal with exclusive mode off without having tearing? Do I have to enable VSync in my NVidia video card before doing this anyway (or can I leave it "Application selection")? When I disable exclusive mode there aren't strobe effects anymore when changing from MP interface to fullscreen video...

    Thanks
     

    level20peon

    MP Donator
  • Premium Supporter
  • January 4, 2007
    1,082
    102
    43
    Aachen
    Home Country
    Germany Germany
    I also tested to run MP without exclusive mode because somtimes it seems to lock video when exiting TV or recorded TV

    I have opened a bug report on this behaviour here.


    Is possible with this fix to run MediaPortal with exclusive mode off without having tearing? Do I have to enable VSync in my NVidia video card before doing this anyway (or can I leave it "Application selection")?

    You have to enable VSync explicitly. I think this reduces tearing kind of in my subjective opinion. However it doesn't completely remove tearing at all. I don't know if this is an Nvidia issue but there seem to be some persons posting in this thread who don't have the tearing issue anymore after this fix. It does not work up to this date's SVN for me at all.


    -level20peon
     

    andreavb

    Portal Pro
    December 26, 2006
    140
    4
    50
    Home Country
    Italy Italy
    I've also read about a filter called ReClock...does it produce some good result? someone tested it? some hints about the settings? I'm going to test it this evening...
     

    Paranoid Delusion

    Moderation Manager
  • Premium Supporter
  • June 13, 2005
    13,062
    2,978
    Cheshire
    Home Country
    United Kingdom United Kingdom
    Also running MP in "High Priority" mode can reduce tearing, all you can suggest is whatever works for you.

    Which driver whether ati or nvidia you are using also seems to affect this.

    AMD dualcore optimiser can rectify this as well.

    Would be great if there was a definitive answer that solved this for everyone.
     

    Users who are viewing this thread

    Top Bottom