Search Unity

Latest Unity Standalone builds with XRSettings.enabled ONLY d3d11: failed to create buffer

Discussion in 'Windows' started by AVOlight, Aug 10, 2018.

  1. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    I'm creating textures on a separate device and then sharing them to the Unity device and passing the view made on the Unity device to Texture2D.CreateExternalTexture

    everything works in the editor with XRSettings.enabled true or false

    but in builds with XRSettings.enabled true after calling Texture2D.CreateExternalTexture, it hangs the graphics only, with output:

    d3d11: failed to create buffer (target 0x1 mode 1 size 240) [0x887A0005]
    d3d11: failed to create buffer (target 0x2 mode 1 size 12) [0x887A0005]
    d3d11: attempt to lock null buffer....

    the app still runs but the graphics are frozen
    the same app with XRSettings.enabled false before calling Texture2D.CreateExternalTexture works

    any ideas for a work around?
    tried sharing the texture in reverse gets HRESULT: 2005270523 "The GPU device instance has been suspended."

    the point in the texture sharing is so I can run this stuff in a background thread so it's non blocking
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Are you using D3D11 device from multiple threads?
     
  3. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    i use my separate device with ->SetMultithreadProtected(TRUE); on a background thread

    and only use the Unity device in the main thread
     
    Last edited: Aug 10, 2018
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Main thread? Or the render thread? Could you show how you call into a function that uses Unity device? Did you try enabling D3D11 debug layer?
     
    AVOlight likes this.
  5. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    in a coroutine i call an extern function directly and use the Unity device

    don't know how to enable the debug layer

    i'll try moving the function that gets my shader resource view from the Unity device into one of these things GL.IssuePluginEvent ?
     
  6. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    standalone build working with GL.IssuePluginEvent !!! weird that the other way works fine in the editor, and in the build with xr off..?

    Thank you very much @Tautvydas-Zilys :)
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You're probably getting lucky. You're only supposed to use the d3d11 device from the render thread, which you can get on through GL.IssuePluginEvent. Otherwise you'll run into all sorts of weird race conditions.
     
    AVOlight likes this.