Search Unity

One X support in UWP

Discussion in 'Windows' started by Gaspar, Aug 21, 2017.

  1. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    Hello! Its great that Unity now supports One X in XDK.

    Does Unity UWP supports Xbox One X? What Unity version we need for that? Do we need to tune something to support 4K and HDR?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    As far as we know, there are no issues with UWP support in Unity and Xbox One X. 4K is supported on all Unity versions on UWP (just because on PC you had 4K since forever), but we do not support HDR today.
     
  3. ladron

    ladron

    Joined:
    Mar 16, 2012
    Posts:
    47
    What will happen currently if someone runs a Unity UWP app on an Xbox with a 4K screen? Will the game just run at 4K resolution? If so, is there a way to force 1080p instead?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Original Xbox One and Xbox One S cannot output resolutions higher than 1080p afaik, so they will default to that. Xbox One X will default to 4k if appropriate screen is connected.
     
  5. pixel8me

    pixel8me

    Joined:
    Jan 8, 2018
    Posts:
    1
    Unless I'm mistaken, UWP on Xbox One X is rendered at 1080p (with or without Unity). I have been attempting to get a UWP app to run at true 2160p.

    If I check the UnityEngine.Screen.Width property in a script at runtime, on the Xbox One X it returns 1920. Attempting to change the resolution using UnityEngine.Screen.SetResolution(3840,2160,true) doesn't seem to work when done in a script, and crashes the app when done directly in the VS project built by Unity.

    Please bear in mind I know almost nothing about Unity or UWP, I am literally just seeing if I can get an app (of any kind!) that I've written, running on the One X at 4k. So far, I haven't had any luck. If any of what I've said makes no sense, is misguided, or plain wrong, please let me know and if possible, point me in the right direction.

    Otherwise, if it is really a limitation of UWP itself, and the One X is always seeing a 1080p resolution despite the system actually running at 2160p, then we'll have to wait for Microsoft to update UWP support on the One X to support true 4k.

    Any thoughts/assistance would be greatly appreciated!
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The crash when you do it from VS project is probably due to calling that API from the wrong thread. Let me see if I can find out more information about rendering 4k on UWP on Xbox One X.
     
    v01pe_ and Peter77 like this.
  7. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    I have an Xbox One X hooked up to a 4K TV.

    I haven't played with UWP deployment to it yet but I noticed that the "Developer Mode" app automatically installed when I setup the console.

    When I get some time this weekend, I'll deploy a test Unity UWP app using the Advanced FPS Counter asset, which will display the detected full screen resolution.

    I'll post a screenshot here with the results.
     
  8. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    I'm currently working on 4k integration for our game and can not confirm, that 4k on an Xbox One X with the appropriate screen will work out of the box.

    My setup:
    Unity 2017.6.f1 (2017.4.2f2 before)
    Building for UWP, build type: D3D
    SDK 10.0.17134.0, VS 2017
    IL2CPP backend,
    Scripting Runtime Version .NET 4.6 Equivalent,
    API compatibility Level .NET 4.6
    Xbox One X Dev Kit w/ OS version 10.0.17134.3036​

    When starting the game it displays at 1080p
    Logging
    Screen.resolutions
    gives me this:
    Available resolutions:
    1920 x 1080 @ 0Hz
    2880 x 1440 @ 0Hz
    3840 x 2160 @ 0Hz
    I can switch to 4k by calling
    Screen.SetResolution(3840, 2160, true)
    what outputs
    Resolution: Switching to 3840 x 2160 Fullscreen: True
    Resolution: ApplicationView::IsFullScreenMode = True
    Resolution: Resizing swapchain to 3840 x 2160 Fullscreen: True
    Resolution: Done.​

    But when I log this
    Debug.LogFormat("Current res: {0}; Width x Height: {1} x {2}", Screen.currentResolution, Screen.width, Screen.height)
    I get:
    Current res: 1920 x 1080 @ 0Hz; Width x Height: 3840 x 2160​

    This seems like a bug and also UI elements aren't reacting properly to clicks - I can only click on the left half (full height tho), but nothing right of the imaginary middle line. Simmilarly if I set the resolution to 2880 x 1440, I can only click on elements on the left 2/3rds of the screen, but not on the right 3rd (full height clicikable again).
    This behavior also persists after unloading and loading scene again.
    The UI elements I'm talking about are on a Canvas (Screen Space - Overlay) with a Canvas Scaler (reference resolution: 3840x2160; Screen Match Mode: width/height; Match: 1 - height) and it works as expected on any other platform.

    Also interesting is, that p.e. the Development Console will shrink in size (as expected on a higher resolution), but the font is very jagged - not smooth at all). The game seems to be in a strange mixed state between 1080p and 4k.

    EDIT: Doing some closer inspection/ comparison with the PS4 version:
    It seems, that when I set the resolution to 4k, Unity internally renders everything in 4k, but ultimately when rendered to the screen it seems to be displayed in 1080p. The render quality of the textures slightly increases, but it's by far not as crisp and detailed as it should be.

    Is there something I might do wrong, or is this a bug/ the lack of 4k support on UWP?
     
    Last edited: Jul 3, 2018
  9. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Looks like I forgot to follow up on this from my prior post.

    When I tested 4K support with my Xbox One X in January, I could not get it to work.

    The same test UWP app worked fine in 4K on my PC but would render in 1080P on my Xbox One.

    I seem to remember adding code to explicitly set the resolution to 4K, which also worked on my PC but not on my Xbox.

    I think I have some screenshots on my phone. I'll try to dig them up.

    I know that since then, Microsoft has increased the system resources available to UWP apps on Xbox One.

    So, it's possible that something changed in this regard.

    I'm currently in the middle of re-arranging my work space.

    I'll try to do some more testing of this in the next few days.

    Edit: I've uploaded a screenshot from my testing at the time (the blue dot on the bottom left is my TV's power/status LED).

    UWP on Xbox One X - January 2018.jpg

    I have another screenshot (that I didn't upload) that shows that my TV was in 4K mode, even though the UWP app was reporting 1080P.

    So it must have been running in 1080P internally and being upscaled to 4K resolution outside of the UWP sandbox.

    Again, these tests were done prior to Microsoft expanding the resources available to UWP on Xbox One. I'll do some more testing on this issue soon.
     
    Last edited: Jul 3, 2018
  10. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    Thanks for sharing your findings! I'm afraid, the 1080p cap is still happening tho!
    Is your test app a native written app, or through Unity? I've not yet managed to get the TV resolution, other than listing `Screen.resolutions` - which may be the same values regardless of TV?
     
  11. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    This seems not to be the case unfortunately. (At least not as UWP)
    In my case the game crashed b/c it had too little resources (I guess b/c of the bigger frame buffers needed) when I set a higher resolution. With the expanded resources this now works w/o any problem - I haven't mentioned that in my other post. Here's how to do that: https://forum.unity.com/threads/uwp-xbox-one-poor-performance-enhanced-access.504884/#post-3312304

    My findings were, that you can internally switch the resolution in Unity (manually), but on the screen it still shows up rendered at 1080p (see post above). Is this a limit of Unity w/ UWP or a limit of UWP itself?
     
    Last edited: Jul 4, 2018
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'll ask Microsoft about this. Unity doesn't handle this in any special way - it just resizes the DXGI swapchain to the size you requested.
     
    schmosef likes this.
  13. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    It's a Unity app. I use the Advanced FPS Counter asset to get the device/resolution info.
     
  14. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    Here's a screenshot of how it looks If I display a 4k testimage on the xBox w/ a 4k display. This is a UWP game built with Unity:
    Testimage in action.png
    Here's the original image:
    4K Test Image.png
    Either display them fullscreen on a 4k display or zoom in to 100%. The test image contains interleaved black and white pixels and on the Xbox One X dev kit with a 4k resolution set it's just sold gray - not rendered in 4k.

    is it a bug of the Unity Input System then, that I can only click buttons on the left half of the screen if I `Screen.SetResolution(3840, 2160)`? The full height is clickable, but right side cut off at 1080 pixels.
    It's a full screen Canvas, that resizes with the height. See my original post:
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Possibly. Can we get a bug report on this?
     
  16. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    Filed a bug with a detailed repro project: `Case 1059813`
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Thanks, we'll take a look.
     
    schmosef likes this.
  18. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    EDIT: THIS IS WRONG - SEE POST BELOW Meanwhile, I asked in the Xbox Developer Forums about UWP games and 4k resolution and this currently is NOT supported on the Xbox One (X/S).

    Still Unity can internally render in 4k when using `Screen.SetResolution()`. This slightly increases the quality, but the UI event system is confused.

    I'll also add this to the bug report.
     
    Last edited: Jul 17, 2018
    schmosef and Peter77 like this.
  19. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    OK, just received a message, that this info was wrong! UWP games can in fact render in 4k, but not in 4K HDR (which we don't use). This was where the confusion about the feature came from. I was given this link with more details about the capabilities:
    https://blogs.msdn.microsoft.com/chuckw/2017/12/15/directx-and-uwp-on-xbox-one/

    Now the question stays, why Unity doesn't properly switch into 4K at startup, nor does it behave correctly when the resolution is set, or if there are any workarounds for this problem.

    We're very close to submitting a build to cert, so it would be awesome if we can tackle this somehow!

    Kind regards,
    Jan
     
    Peter77 likes this.
  20. IQpierce

    IQpierce

    Joined:
    Jan 24, 2011
    Posts:
    43
    My project is also interested in 4K support on UWP.

    The blog post in the previous thread has details on how to set up the swapchain for this on the Xbox One X. But it sounds like Unity doesn't support doing that.

    If Unity has (or adds) support for out-of-the-box 4K support on UWP apps running on Xbox One X, my team would also be very interested in this feature!
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Unity will default to the native resolution of the screen (well, whatever DXGI tells us it is) but it does not have any restrictions on what you can set it to manually. If the latter thing doesn’t work, report a bug and we’ll investigate.
     
  22. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    I'm sorry, but that's simply not true! I debugged this for days and tried out a dozen different things and never got the game running in 4K!! I also reported this as a bug:
    Maybe this works different for XDK titles, but for UWP it doesn't.
     
  23. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I’m not saying that Unity does render in 4K automatically. I’m saying that we’re doing what DXGI tells us to. Nowhere in Unity do we hardcore 1080p. We will investigate that bug report.
     
  24. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    71
    OK sorry, I misunderstood your answer as "there is no issue".
    Glad to hear that.
     
  25. Kriszo91

    Kriszo91

    Joined:
    Mar 26, 2015
    Posts:
    181
    Hello,

    Where i can find unity generated swapchain? any idea what settings are the best on X 4k? i would like to increase my fps but i can't do nothing :/
     
  26. Kriszo91

    Kriszo91

    Joined:
    Mar 26, 2015
    Posts:
    181
    another little thing... i can deploy to X but i can't deploy to Xbox one.. i always got boostrap error, 1-2 motnhs ago worked
     
  27. mahdi-po

    mahdi-po

    Joined:
    Jan 18, 2016
    Posts:
    7
    hi
    im using unity 2018.1.2.f1
    i have problem with mouse input it cant be recognize with xbox one x both in XAML and D3D mode
    but it work on visual studio run on localmachine
    joystick and keyboard work on xbox d3d mod and xaml but mouse not detecting
    i checked the event system force to enable true but didn't help for mouse detection...
    i need mouse in my xbox app and app must be fullscreen(d3d mode as i know)
    please help me
    any solution would be grate appreciated.
    thanks alot
     
  28. mahdi-po

    mahdi-po

    Joined:
    Jan 18, 2016
    Posts:
    7
    actually in developer mode i can see the mouse cursor and i can control it with my physical mouse so xbox one can recognize mouse device but it banned to use it in app right?
    is there any way to active the mouse in app too?
     
  29. Kriszo91

    Kriszo91

    Joined:
    Mar 26, 2015
    Posts:
    181
    Hello!

    Any news? Everspace released native 4k @ 30fps on Xbox one X UWP with Unreal engine..
     
  30. Kriszo91

    Kriszo91

    Joined:
    Mar 26, 2015
    Posts:
    181
  31. darren_unity135

    darren_unity135

    Joined:
    Nov 11, 2021
    Posts:
    4
    Hello,

    We are still experiencing this issue in Unity 2022.2.6. Is there any fix for this issue?
     
  32. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    This is apparently by design: https://github.com/walbourn/walbour...sts/2017-12-15-directx-and-uwp-on-xbox-one.md

    Code (csharp):
    1. For UWP on Xbox One apps, the system always indicates a window size of 1920 x 1080 (i.e. 1080p). If the TV is running as 4K on an Xbox One S or Xbox One X, the swapchain content is automatically scaled up by the display hardware.
    2.  
    3. It is also possible to create a native 4k swapchain, but it's recommended you only do this while running on an Xbox One X. You can check which device the UWP is running on via a new Windows 10 Fall Creators Update SDK (16299) API:
    So if you want, you can call Screen.SetResolution if you detect you're running on a compatible Xbox.