# RHILockTexture2D returns garbage data with Vulkan on Linux

**URL:** <https://forums.unrealengine.com/t/rhilocktexture2d-returns-garbage-data-with-vulkan-on-linux/465824>\
**Category:** Platform & Builds\
**Tags:** opengl, vulkan, Linux, unreal-engine, question\
**Created:** [May 26, 2020, 10:13am UTC](https://forums.unrealengine.com/t/rhilocktexture2d-returns-garbage-data-with-vulkan-on-linux/465824 "2020-05-26T10:13:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_cf7dc2f8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cf7dc2f8](https://forums.unrealengine.com/u/anonymous_user_cf7dc2f8)\
**Post date:** [May 26, 2020, 10:13am UTC](https://forums.unrealengine.com/t/rhilocktexture2d-returns-garbage-data-with-vulkan-on-linux/465824/1 "2020-05-26T10:13:56Z")

</div>

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();
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](https://pastebin.com/J4wa6tXS), 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](https://github.com/microsoft/AirSim/pull/2713)

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!

---

<div class="post-metadata">

**Author:** ![ThD\_ManiaC](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thd_maniac/32/1194665_2.png) [@ThD\_ManiaC](https://forums.unrealengine.com/u/ThD_ManiaC)\
**Post date:** [June 8, 2020, 1:17pm UTC](https://forums.unrealengine.com/t/rhilocktexture2d-returns-garbage-data-with-vulkan-on-linux/465824/2 "2020-06-08T13:17:45Z")

</div>

got some similar results with the RHILockTexture2D function with RLM\_ReadOnly: [https://answers.unrealengine.com/questions/960969/view.html](https://answers.unrealengine.com/questions/960969/view.html)

edit: this solution does crash for me on DirectX12 though
