A Niagara VT in use. Switching quality levels. Notice crash in SetShaderParameters trying to access a released VT.
[Attachment Removed]
A Niagara VT in use. Switching quality levels. Notice crash in SetShaderParameters trying to access a released VT.
[Attachment Removed]
Steps to Reproduce
We are experiencing a crash when switching quality levels. I narrowed this down to void UNiagaraDataInterfaceVirtualTextureSample::SetShaderParameters(const FNiagaraDataInterfaceSetShaderParametersContext& Context) const. Looks like a virtual texture is being accessed after being marked for batch release. I have a band aid fix by checking the resource state, but I do not think that is the most robust solution. Seems like their is a timing dependency situation between the resource release and quality level switch.
void UNiagaraDataInterfaceVirtualTextureSample::SetShaderParameters(const FNiagaraDataInterfaceSetShaderParametersContext& Context) const
{
FNiagaraDataInterfaceProxyVirtualTextureSample& TextureProxy = Context.GetProxy<FNiagaraDataInterfaceProxyVirtualTextureSample>();
FNDIVirtualTextureSampleInstanceData_RenderThread* InstanceData = TextureProxy.InstanceData_RT.Find(Context.GetSystemInstanceID());
FRDGBuilder& GraphBuilder = Context.GetGraphBuilder();
bool IsValid = false;
FShaderParameters* Parameters = Context.GetParameterNestedStruct<FShaderParameters>();
if (InstanceData)
{
FVirtualTexture2DResource* VirtualTextureResource = InstanceData->VirtualTextureResource;
// adding batch release resource check below
if (VirtualTextureResource && VirtualTextureResource->IsInitialized() && !EnumHasAnyFlags(VirtualTextureResource->ResourceState, ERenderResourceState::BatchReleased))
{
[Attachment Removed]
Hey
Thanks for the report, and I agree that this is a bandaid.
It looks like this data interface wasn’t updated when we moved to more of a copy out to avoid exactly the problem your seeing here, where the resource can go out of scope before we have flushed the simulation commands.
I’ve enclosed an updated version of the file, I’ve done some basic testing locally but if you have a chance to test our your end that would be much appreciated.
Thanks,
Stu
[Attachment Removed]
Awesome thanks for confirming so fast.
Thanks,
Stu
[Attachment Removed]
Just tested this out and it works as expected. No more crashing when switching quality levels. Thanks! I’ll get this submitted to our repo.
[Attachment Removed]