Download

RHILockTexture2D returns garbage data with Vulkan on Linux

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



FRHITexture2D *fast_cap_texture = fast_rt_resource_->TextureRHI->GetTexture2D();
uint32 stride;
auto *src = (const unsigned char*)RHILockTexture2D(fast_cap_texture, 0, RLM_ReadOnly, stride, false);

if (src)
    FMemory::BigBlockMemcpy(latest_result_.pixels->data(), src, height * stride);


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!
Thanks!

Did you find a solution to this? I just ran into the same issue, seems to be still broken. I found this issue, but it is still not fixed: Unreal Engine Issues and Bug Tracker (UE-85306)