RHILockTexture2D returns garbage data with Vulkan on Linux


I’m trying to capture a coloured image from a camera using RHILockTexture2D like this -

FRHITexture2D *fast_cap_texture = fast_rt_resource_->TextureRHI->GetTexture2D();
EPixelFormat pixelFormat = fast_cap_texture->GetFormat();
uint32 width = fast_cap_texture->GetSizeX();
uint32 height = fast_cap_texture->GetSizeY();
uint32 stride;
auto *src = (const unsigned char*)RHILockTexture2D(fast_cap_texture, 0, RLM_ReadOnly, stride, false);

This is working correctly on Windows, however, on Linux, it’s crashing due to an assert (trace is here - Assertion failed: LockMode == RLM_WriteOnly [File:/home/rajat/UnrealEngine/UE_4. - Pastebin.com, it’s for 4.25 but similar for 4.24 as well)

I tried commenting out the assert in the Engine code, and it didn’t crash, however, I’m getting garbage data. Using RLM_WriteOnly rather than changing the Engine code gives garbage data on both Win & Linux

RLM_ReadOnly works correctly on Win & with OpenGL on Linux (-opengl on cmdline) gives correct data. Crash is happening on 4.25 as well. I’m not sure but seems like a bug in Vulkan on Linux.

Background: Working on a UE4 based simulator AirSim, entire code - Faster Image Capture by rajat2004 · Pull Request #2713 · microsoft/AirSim · GitHub

This is my first time posting a question here, so please let me know if any info is required, etc. Any comments or suggestions would be great!


got some similar results with the RHILockTexture2D function with RLM_ReadOnly: https://answers.unrealengine.com/questions/960969/view.html

edit: this solution does crash for me on DirectX12 though