Vulkan RHI causing regular engine crash. Assertion failed error.

Hey guys,

So I’m working with Vulkan in a Source build of Unreal, and I get a reoccuring crash with the same error whenever I’m doing pretty much anything with a very high poly (~3 Milllion Triangles) static mesh, the crash may occur. Namely changing the amount of triangles in the static mesh editor, and when moving very high poly objects in the editor viewport.

Here’s the Crash Report:

Assertion failed: Layout->AreAllSubresourcesSameLayout() [File:C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanBarriers.h] [Line: 184]

UE4Editor_Core!AssertFailedImplV() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]

UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]

UE4Editor_VulkanRHI!FVulkanLayoutManager::FindOrAddLayoutRW() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanBarriers.h:184]

UE4Editor_VulkanRHI!FVulkanSurface::MoveSurface() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanTexture.cpp:743]

UE4Editor_VulkanRHI!FVulkanTextureBase::Move() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanTexture.cpp:2451]

UE4Editor_VulkanRHI!VulkanRHI::FVulkanSubresourceAllocator::DefragTick() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanMemory.cpp:4227]

UE4Editor_VulkanRHI!VulkanRHI::FVulkanResourceHeap::DefragTick() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanMemory.cpp:1890]

UE4Editor_VulkanRHI!VulkanRHI::FMemoryManager::ReleaseFreedPages() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanMemory.cpp:2455]

UE4Editor_VulkanRHI!FVulkanCommandListContext::RHIEndFrame() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\VulkanRHI\Private\VulkanRHI.cpp:903]

UE4Editor_RHI!FRHICommand<FRHICommandEndFrame,FRHICommandEndFrameString1826>::ExecuteAndDestruct() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\RHI\Public\RHICommandList.h:763]

UE4Editor_RHI!FRHICommandListExecutor::ExecuteInner_DoExecute() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\RHI\Private\RHICommandList.cpp:368]

UE4Editor_RHI!FExecuteRHIThreadTask::DoTask() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\RHI\Private\RHICommandList.cpp:429]

UE4Editor_RHI!TGraphTask<FExecuteRHIThreadTask>::ExecuteTask() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]

UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:709]

UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:601]

UE4Editor_RenderCore!FRHIThread::Run() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:320]

UE4Editor_Core!FRunnableThreadWin::Run() [C:\Unreal Engine\SourceUnreal\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

I’ve tried commenting out the check on Layout->AreAllSubresourcesSameLayout() at line 184 in VulkanBarries.h

VULKANRHI_API VkImageLayout& FindOrAddLayoutRW(VkImage Image, VkImageLayout LayoutIfNotFound, uint32 NumMips, uint32 NumLayers)
{
	FVulkanImageLayout* Layout = Layouts.Find(Image);
	if (Layout)
	{
        /* Problem occurs here */
		// check(Layout->AreAllSubresourcesSameLayout());
		return Layout->MainLayout;
	}

	Layout = &Layouts.Add(Image, FVulkanImageLayout(LayoutIfNotFound, NumMips, NumLayers));
	return Layout->MainLayout;
}

Which just results in the engine eventually freezing, but less often than it would crash.

The AreAllSubresourcesSameLayout() function at line 52 in the same file is this:

// Explicit subresource layouts. Always NumLayers*NumMips elements.
TArray<VkImageLayout> SubresLayouts;

bool AreAllSubresourcesSameLayout() const
{
	return SubresLayouts.Num() == 0;
}

Have the exact same problem (error message, same file, same line etc) on Ubuntu with UE 4.26.1 (nvidia driver 460), non-stop, not possible to work like that at all. takes about a minute of unreal editor being open and it crashes. I was creating a mobile game with reduced quality settings and it was working fine, now I wanted to do something with raytracing etc enabled for desktop and the engine crashes as soon as i open it… i have to feeling it was either the hair/groom i had added to the project or some lighting or other rendering setting… i just created a project from scratch and so far absolutely nothing, haven’t touched the project settings yet, so I’ll keep an eye out on when this happens again next :slight_smile:

I’m also hitting this. Seems to be triggered only by vulkan memory defrag, which is new to 4.26.
If i turn off SSGI it doesn’t seem to happen anymore (but I haven’t tested for an extended period yet)

I was wrong, it still happens. Looks like the only workaround is to turn off vulkan defrag with
r.Vulkan.EnableDefrag=0

1 Like

Same problem here. The Defrag algorithm caused a lot of crashes.

i have same problem! help me!

I might have found a solution (at least my projects are not crashing anymore)
I tried r.Vulkan.EnableDefrag=0 but both engine and game were still crashing a lot. Mostly upon opening a level.
then I set r.Vulkan.WaitForIdleOnSubmit=1 and I had no more crashes since.
I noticed that the performance went down, but since the crashes only happen when opening the map, I set the variable to 1 before loading the level and then back to 0 after some delay. That way I prevent the crash and also get the performance back once everything is up and running.

1 Like

Thank you so much for this command! r.Vulkan.WaitForIdleOnSubmit=1