Search Unity

Loading RenderDoc in editor crashes custom render plugin

Discussion in 'General Graphics' started by AlexPfaffe, Aug 4, 2021.

  1. AlexPfaffe

    AlexPfaffe

    Joined:
    Jul 2, 2021
    Posts:
    5
    I'm on Unity 2020.3.12f
    I have a custom native plugin to render and I am trying to load RenderDoc.
    This results in a crash in my plugin from the OnRender() code path, probably because the device is no longer valid.

    Should I expect to receive a UnityPluginUnload() call before this point?
    Or a call to OnGraphicsDeviceEvent(kUnityGfxDeviceEventShutdown)?
    I have attached a debugger and I am not able to catch these calls.
    How can I reinitialize my plugin for this event?
     
  2. AlexPfaffe

    AlexPfaffe

    Joined:
    Jul 2, 2021
    Posts:
    5
    It looks like the plugin is not unloaded in this case but the d3dDevice simply changes. What worked for me was to cache the d3dDevice pointer in my plugin objects and then check if d3dDevice has changed, if so I recreate the d3d resources for my plugin. You can catch this in the onPreRender and onRender codepaths.