# RHICreateTexture2D is not available in UE 5.3?

**URL:** <https://forums.unrealengine.com/t/rhicreatetexture2d-is-not-available-in-ue-5-3/1777425>\
**Category:** C++\
**Tags:** rhi, unreal-engine, CPP, question\
**Created:** [March 29, 2024, 12:03pm UTC](https://forums.unrealengine.com/t/rhicreatetexture2d-is-not-available-in-ue-5-3/1777425 "2024-03-29T12:03:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IAmNoBody2we](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IAmNoBody2we](https://forums.unrealengine.com/u/IAmNoBody2we)\
**Post date:** [March 29, 2024, 12:03pm UTC](https://forums.unrealengine.com/t/rhicreatetexture2d-is-not-available-in-ue-5-3/1777425/1 "2024-03-29T12:03:38Z")

</div>

It seems `RHICreateTexture2D` does not exist any more in UE5.3? I cannot find it in doc.  
How should I update the following code to UE5?

```auto
void ASceneVideoCapture::OnBackBufferReady_RenderThread(SWindow& SlateWindow, const FTexture2DRHIRef& BackBuffer)
{
	FTexture2DRHIRef GameBuffer = BackBuffer;

	FRHIResourceCreateInfo CreateInfo(TEXT("Texture"));
	FRHITextureCreateDesc TextureCreateDesc = FRHITextureCreateDesc::Create2D(TEXT("TextureOfCopy"), GameBuffer->GetSizeX(), GameBuffer->GetSizeY(), GameBuffer->GetFormat());
	FTexture2DRHIRef CopiedTexture = RHICreateTexture2D(
		GameBuffer->GetSizeX(),
		GameBuffer->GetSizeY(),
		GameBuffer->GetFormat(),
		GameBuffer->GetNumMips(),
		GameBuffer->GetNumSamples(),
		ETextureCreateFlags::CPUReadback,
		CreateInfo
	);
	FRHICommandListImmediate& RHICmdList = FRHICommandListExecutor::GetImmediateCommandList();
	RHICmdList.CopyTexture(GameBuffer, CopiedTexture, FRHICopyTextureInfo{});

	void* RawData = nullptr;
	int32 Width = 0, Height = 0;
	RHICmdList.MapStagingSurface(CopiedTexture, RawData, Width, Height);

       // ...
	RHICmdList.UnmapStagingSurface(CopiedTexture);
}

```

---

<div class="post-metadata">

**Author:** ![IAmNoBody2we](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IAmNoBody2we](https://forums.unrealengine.com/u/IAmNoBody2we)\
**Post date:** [March 30, 2024, 12:49am UTC](https://forums.unrealengine.com/t/rhicreatetexture2d-is-not-available-in-ue-5-3/1777425/2 "2024-03-30T00:49:52Z")

</div>

Ok, I find the answer by myself.

```auto
FTexture2DRHIRef GameBuffer = BackBuffer;
FRHICommandListImmediate& RHICmdList = FRHICommandListExecutor::GetImmediateCommandList();

FRHITextureCreateDesc TextureCreateDesc = FRHITextureCreateDesc::Create2D(TEXT("CopiedTexture"),
	GameBuffer->GetSizeX(),
	GameBuffer->GetSizeY(),
	GameBuffer->GetFormat());
TextureCreateDesc.SetNumMips(GameBuffer->GetNumMips());
TextureCreateDesc.SetNumSamples(GameBuffer->GetNumSamples());
TextureCreateDesc.SetInitialState(ERHIAccess::CPURead);
TextureCreateDesc.SetFlags(ETextureCreateFlags::CPUReadback);
FTextureRHIRef CopiedTexture = GDynamicRHI->RHICreateTexture_RenderThread(RHICmdList, TextureCreateDesc);

RHICmdList.CopyTexture(GameBuffer, CopiedTexture, FRHICopyTextureInfo{});

void* RawData = nullptr;
int32 Width = 0, Height = 0;

RHICmdList.MapStagingSurface(CopiedTexture, RawData, Width, Height);

RHICmdList.UnmapStagingSurface(CopiedTexture);

```
