Download

Error update texture in 4.13

Hi forum,
I made this plugin long time ago: https://forums.unrealengine.com/showthread.php?117571-Plugin-Android-Camera, and I share with all, now I found one trouble when I update to 4.13 inside my texture update, I was using this method:



bool bFreeData = false;

	// call the RHIUpdateTexture2D to refresh the texture with new info
	ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
		UpdateTextureRegionsData,
		FUpdateTextureRegionsData*, RegionData, RegionData,
		bool, bFreeData, bFreeData,
		{
			for (uint32 RegionIndex = 0; RegionIndex < RegionData->NumRegions; ++RegionIndex)
			{
				int32 CurrentFirstMip = RegionData->Texture2DResource->GetCurrentFirstMip();
				if (RegionData->MipIndex >= CurrentFirstMip)
				{
					RHIUpdateTexture2D(
						RegionData->Texture2DResource->GetTexture2DRHI(),
						RegionData->MipIndex - CurrentFirstMip,
						RegionData->Regions[RegionIndex],
						RegionData->SrcPitch,
						RegionData->SrcData
						+ RegionData->Regions[RegionIndex].SrcY * RegionData->SrcPitch
						+ RegionData->Regions[RegionIndex].SrcX * RegionData->SrcBpp
						);
				}
			}
	if (bFreeData)
	{
		FMemory::Free(RegionData->Regions);
		FMemory::Free(RegionData->SrcData);
	}
	delete RegionData;
		});



For some reason it’s only works on shipping mode, not true for launch and development mode as well, my texture info is ok when I get my uchar8* convertion from android YUV format, I just test some pixel samples, anyway I change my update method for memcpy and is working for each mode, development and shipping also launch.



FTexture2DMipMap& Mip = texture->PlatformData->Mips[0];
	void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
	FMemory::Memcpy(Data, (uint8*)rgb, width * height * 4);
	Mip.BulkData.Unlock();
	texture->UpdateResource();


is this a bug for UE 4.13? how can I fix it?

update things is always a mess :frowning:

This is basically UTexture2D::UpdateTextureRegions() so I’d expect it to work.

Not working for me too -> Post

I had a problem with Lock/Memcpy/Unlock/Update (changes were not displayed in packaged game) and I switched to UpdateTextureRegions() (which is not WITH_EDITOR as it was in 4.10), which I already used in an old “Fog of War” project (4.10). However I get many crashes and I can’t tell why.
Did you solve your problem?