Temaran/UnrealEngineShaderPluginDemo

[UE4.24.1] Crash with Vulkan

Opened this issue · 1 comments

Hi Temaran,

Thanks a lot for your update to 4.24. I have also managed to update it myself but with just not much more than compatibility, then realized you published your change. However, I got a crash as running with Vulkan on my NVidia Geforce GTX 1600, driver version 440.14:

Assertion failed: !bInsideRealRenderPass [File:/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp] [Line: 223] 

Signal 11 caught.
Malloc Size=65538 LargeMemoryPoolOffset=65554 
CommonUnixCrashHandler: Signal=11
Malloc Size=65535 LargeMemoryPoolOffset=131119 
Malloc Size=781568 LargeMemoryPoolOffset=912704 
[2019.12.26-17.27.08:824][774]LogCore: === Critical error: ===
Unhandled Exception: SIGSEGV: invalid attempt to write memory at address 0x0000000000000003

[2019.12.26-17.27.08:824][774]LogCore: Assertion failed: !bInsideRealRenderPass [File:/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp] [Line: 223] 



0x00007f543e27f956 libUE4Editor-Core.so!FGenericPlatformMisc::RaiseException(unsigned int) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformMisc.cpp:477]
0x00007f543e493aa7 libUE4Editor-Core.so!FOutputDevice::LogfImpl(char16_t const*, ...) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/OutputDevice.cpp:71]
0x00007f543e41bef6 libUE4Editor-Core.so!AssertFailedImplV(char const*, char const*, int, char16_t const*, __va_list_tag*) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/AssertionMacros.cpp:105]
0x00007f543e41bd8b libUE4Editor-Core.so!FDebug::CheckVerifyFailedImpl(char const*, char const*, int, char16_t const*, ...) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/AssertionMacros.cpp:452]
0x00007f53f5da97e5 libUE4Editor-VulkanRHI.so!FTransitionAndLayoutManager::EndEmulatedRenderPass(FVulkanCmdBuffer*) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp:223]
0x00007f53f5dafb2a libUE4Editor-VulkanRHI.so!FVulkanCommandListContext::TransitionResources(FVulkanCommandListContext::FPendingTransition const&) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp:1426]
0x00007f53f5da962e libUE4Editor-VulkanRHI.so!FVulkanCommandListContext::RHITransitionResources(EResourceTransitionAccess, FRHITexture**, int) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp:1248]
0x00007f53f5dab754 libUE4Editor-VulkanRHI.so!FVulkanCommandListContext::RHICopyToResolveTarget(FRHITexture*, FRHITexture*, FResolveParams const&) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/VulkanRHI/Private/VulkanRenderTarget.cpp:670]
0x00007f53fec1f6b6 libUE4Editor-ShaderPlugin.so!FRHICommand<FRHICommandCopyToResolveTarget, FRHICommandCopyToResolveTargetString1430>::ExecuteAndDestruct(FRHICommandListBase&, FRHICommandListDebugContext&) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/RHI/Public/RHICommandList.h:726]
0x00007f543979d3ae libUE4Editor-RHI.so!FRHICommandListExecutor::ExecuteInner_DoExecute(FRHICommandListBase&) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:356]
0x00007f54398096db libUE4Editor-RHI.so!FExecuteRHIThreadTask::DoTask(ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:409]
0x00007f5439808db4 libUE4Editor-RHI.so!TGraphTask<FExecuteRHIThreadTask>::ExecuteTask(TArray<FBaseGraphTask*, TSizedDefaultAllocator<32> >&, ENamedThreads::Type) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Public/Async/TaskGraphInterfaces.h:847]
0x00007f543e25378b libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksNamedThread(int, bool) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:686]
0x00007f543e2524a3 libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksUntilQuit(int) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:582]
0x00007f5439954b96 libUE4Editor-RenderCore.so!FRHIThread::Run() [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp:288]
0x00007f543e2e9fa7 libUE4Editor-Core.so!FRunnableThreadPThread::Run() [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.cpp:25]
0x00007f543e2b1840 libUE4Editor-Core.so!FRunnableThreadPThread::_ThreadProc(void*) [/home/user/UNREAL/UnrealEngine/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.h:177]
0x00007f543edaa6db libpthread.so.0!UnknownFunction(0x76da)
0x00007f543594588f libc.so.6!clone(+0x3e)

Thanks a lot for the great demo! You should really ask for a PR to integrate this into UE at least as an example.

Besides, might I ask some questions as follows:

(1) You also updated from:
FComputeShaderUtils::AddPass, which dispatches a compute shader to render graph builder with its parameters. (as commented in UE source)
to
FComputeShaderUtils::Dispatch, which dispatches a compute shader to rhi command list with its parameters.

Sorry for me being inexperienced, but is there a specific gain for the change?

(2) Regarding the data being passed to GPU, then handled in the shader file, if the data is in array form, for your preference, would you use a FRHIStructuredBuffer or SHADER_PARAMETER_ARRAY?

(3) If I might use FRHIStructuredBuffer as a buffer holding both input and output data, could I create a FRHIUnorderedAccessView from that buffer then pass into your FComputeShaderExample::RunComputeShader_RenderThread.

Thanks in advance!