stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.61k stars 953 forks source link

Fullscreen is broken (sometimes?) #2413

Open NicusorN5 opened 2 months ago

NicusorN5 commented 2 months ago

Release Type: Github + Official

Version: Github latest commit + Latest 4.2.0.2188

Platform(s): Windows, DX11 Level 11_1

Describe the bug When enabling fullscreen, a DXGI_ERROR_INVALID_CALL/InvalidCall error is thrown, otherwise (very rarely) a black screen is being presented.

Can't seem to reproduce using a empty project. :(

To Reproduce Steps to reproduce the behavior:

  1. Create a project
  2. Use this function and call it inside a Start() method of a StartupScript

    public void ChangeScreen(bool fullscreen, int width, int height)
    {
    Game.Window.Visible = false;
    
    var size = new Int2(width, height);
    
    if (fullscreen)
        Game.Window.PreferredFullscreenSize = size;
    else
    {
        Game.Window.SetSize(size);
        Game.Window.PreferredWindowedSize = size;
    }
    
    Game.Window.IsFullscreen = fullscreen;
    
    Game.Window.Visible = true;
    }

    Expected behavior Crash bad.

Log and callstacks

[Game]: Error: Unexpected exception. Stride.Graphics.GraphicsException: Unexpected error on Present (device status: Normal)
 ---> SharpDX.SharpDXException: HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.

   at Stride.Graphics.SwapChainGraphicsPresenter.Present()
   --- End of inner exception stack trace ---
   at Stride.Graphics.SwapChainGraphicsPresenter.Present()
   at Stride.Games.GraphicsDeviceManager.Stride.Games.IGraphicsDeviceManager.EndDraw(Boolean present)
   at Stride.Games.GameBase.EndDraw(Boolean present)
   at Stride.Engine.Game.EndDraw(Boolean present) in D:\Projects\stride\sources\engine\Stride.Engine\Engine\Game.cs:line 445
   at Stride.Games.GameBase.RawTick(TimeSpan elapsedTimePerUpdate, Int32 updateCount, Single drawInterpolationFactor, Boolean drawFrame)
   at Stride.Games.GameBase.RawTickProducer()
Stride.Graphics.GraphicsException: Unexpected error on Present (device status: Normal)
 ---> SharpDX.SharpDXException: HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.

   at Stride.Graphics.SwapChainGraphicsPresenter.Present()
   --- End of inner exception stack trace ---
   at Stride.Graphics.SwapChainGraphicsPresenter.Present()
   at Stride.Games.GraphicsDeviceManager.Stride.Games.IGraphicsDeviceManager.EndDraw(Boolean present)
   at Stride.Games.GameBase.EndDraw(Boolean present)
   at Stride.Engine.Game.EndDraw(Boolean present) in D:\Projects\stride\sources\engine\Stride.Engine\Engine\Game.cs:line 445
   at Stride.Games.GameBase.RawTick(TimeSpan elapsedTimePerUpdate, Int32 updateCount, Single drawInterpolationFactor, Boolean drawFrame)
   at Stride.Games.GameBase.RawTickProducer()

Workaround Use borderless fullscreen, like so:

Game.Window.SetSize(new Int2(1920, 1080));
Game.Window.Position = new Int2(0, 0);
meriaizen86 commented 1 month ago

got the same issue here:

SharpDX.SharpDXException
  HResult=0x80070005
  Mensaje = HRESULT: [0x80070005], Module: [General], ApiCode: [E_ACCESSDENIED/General access denied error], Message: Acceso denegado.

  Origen = SharpDX
  Seguimiento de la pila:
   en SharpDX.Result.CheckError() en C:\projects\sharpdx\Source\SharpDX\Result.cs: línea 195
   en SharpDX.DXGI.Factory.CreateSwapChain(IUnknown deviceRef, SwapChainDescription& descRef, SwapChain swapChainOut) en C:\projects\sharpdx\Source\SharpDX.DXGI\Generated\REFERENCE\Interfaces.cs: línea 1519
   en SharpDX.DXGI.SwapChain..ctor(Factory factory, ComObject device, SwapChainDescription description) en C:\projects\sharpdx\Source\SharpDX.DXGI\SwapChain.cs: línea 43
   en Stride.Graphics.SwapChainGraphicsPresenter.CreateSwapChainForDesktop(IntPtr handle)
   en Stride.Graphics.SwapChainGraphicsPresenter.CreateSwapChainForWindows()
   en Stride.Graphics.SwapChainGraphicsPresenter.CreateSwapChain()
   en Stride.Graphics.SwapChainGraphicsPresenter.OnRecreated()
   en Stride.Graphics.ResumeManager.OnRecreate()
   en Stride.Games.GameBase.GraphicsDeviceService_DeviceReset(Object sender, EventArgs e)
   en Stride.Games.GraphicsDeviceManager.OnDeviceReset(Object sender, EventArgs args)
   en Stride.Games.GraphicsDeviceManager.CreateDevice(GraphicsDeviceInformation newInfo)
   en Stride.Games.GraphicsDeviceManager.ChangeOrCreateDevice(Boolean forceCreate)
   en Stride.Games.GraphicsDeviceManager.ApplyChanges()
   en Stride.Games.GraphicsDeviceManager.Window_FullscreenChanged(Object sender, EventArgs eventArgs)
   en Stride.Games.GameWindow.set_IsFullscreen(Boolean value)
   en Stride.Games.GameWindow.OnDisableFullScreen(Object source, EventArgs e)
   en Stride.Games.GameForm.OnDisableFullScreen(EventArgs e)
   en Stride.Games.GameForm.WndProc(Message& m)
   en System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
   en Stride.Games.Win32Native.CallWindowProc(IntPtr wndProc, IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   en Stride.Input.InputSourceWinforms.WndProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)

Stride 4.2.0.2232 Graphics api: d3d 11.1 Windows 10 build 19045.4894