Create2DArray() + MSAA bind by slices to RT

Okey, its look like i’m first who use Create2DArray() func in UE4 sources, because Visual Code dont find any references in sources.

I want to create Texture2DArray of MSAA textures with TexCreate_TargetArraySlicesIndependently flag to being able bind each slice of array as RTV separately.

So, I wrote this code:

FRDGTextureDesc Desc(FRDGTextureDesc::Create2DArray(SceneTextureExtent, PF_B8G8R8A8, FClearValueBinding::White, TexCreate_RenderTargetable | TexCreate_TargetArraySlicesIndependently | TexCreate_ShaderResource, ArraySize));

Desc.NumSamples = SceneDepthTexture->Desc.NumSamples;

Textures = CreateTextureMSAA(GraphBuilder, Desc, TEXT("MyTexture"), GFastVRamConfig.Texture);

But when I try to bind i-slice to RTV i got assert error from D3D11Resources.h:

if (bCreatedRTVsPerSlice)
{
    check(ArraySliceIndex >= 0);
    ArrayIndex = MipIndex * RTVArraySize + ArraySliceIndex;
}
else 
{
    // Catch attempts to use a specific slice without having created the texture to support it
    check(ArraySliceIndex == -1 || ArraySliceIndex == 0); <- here
}

So flag don’t work, and don’t create RTV for each slice or?

Also i set breakpoint into D3D11Texture.cpp:

if ((Flags & TexCreate_TargetArraySlicesIndependently) && (bTextureArray || bCubeTexture))

For some reason bTextureArray is false :frowning:

Maybe issue in CreateTextureMSAA(). Then which func I need to use to create MSAA Texture Array?