Streamline icon indicating copy to clipboard operation
Streamline copied to clipboard

If cameraMotionIncluded is set to false, dangling pointer occurs.

Open BobAndBooBoo opened this issue 1 year ago • 0 comments

Version and Platform:

  • streamline v2.4.10
  • GPU: RTX4070Ti Super
  • Driver: 560.94

In order to run DLSS on a custom engine, I set cameraMotionIncluded to false and tried to calculate camera motion inside dlssEntry.cpp, but it didn’t work. It seems dangling pointer occurs because viewport.mvec is not nullptr in dlssBeginEvent() in dlssEntry.cpp.

if (viewport.handle)
{
    SL_LOG_INFO("Detected resize, recreating DLSSContext feature");
    // Errors logged by sl.common
    ctx.ngxContext->releaseFeature(viewport.handle, "sl.dlss");
    viewport.handle = {};
    ctx.compute->destroyResource(viewport.mvec);   <------ viewport.mvec IS NOT nullptr
}

When dlssEndEvent() is executed in this state, an access violation occurs in the following part:

if (ctx.viewport->mvec)
{
    chi::ResourceDescription desc;
    ctx.compute->getResourceDescription(ctx.viewport->mvec, desc);   <--- ACCESS VIOLATION HERE
    if (desc.width != renderWidth || desc.height != renderHeight)
    {
        ctx.compute->destroyResource(ctx.viewport->mvec);
        ctx.viewport->mvec = nullptr;
    }
}

Also, in generic.cpp, in the Generic::destroyResource() function, it seems that nullptr is not assigned after delete resource, which could lead to dangling.

I tried setting cameraMotionIncluded to false to see if it could be reproduced in the StreamlineSample, but when changing AntiAliasingMode from NONE to DLSS, it crashed in StreamlineSample.cpp at GetDevice()->executeCommandList(m_CommandList);, so I was unable to cause dangling pointer.

BobAndBooBoo avatar Sep 13 '24 01:09 BobAndBooBoo