I’m using DXD11 to render multi-layer per depth.

I want to save the TextureArray as an image file for debugging purposes.

But every save, it saves the first layer as an image.

Only the first layer was repeatedly saved during the save process, but the rendering worked fine.

Do you know how to save a TextureArray as a file?

Below is the simple code.

have excluded the parts that connect shaders, clear depth buffers, and set render targets.

    ID3D11Resource* Resource;

    for (int layer = 0; layer < N_LAYER; layer++)
    {
        ID3D11RenderTargetView* Layers_RTVs[] =
        {
            g_pColorMap_RenderingClass->ppRTVs[layer],
            g_pMotionVectorMap_RenderingClass->ppRTVs[layer],
        };

        pd3dImmediateContext->OMSetRenderTargets(2, Layers_RTVs, DepthBuffer);
        render(pd3dImmediateContext, g_pDepthPeelingTech, g_pDepthPeelingEffect);
    }
    
    for (int layer = 0; layer < N_LAYER; layer++) {
        g_pColorMap_RenderingClass->ppRTVs[layer]->GetResource(&Resource);
        //Layers_RTVs[0]->GetResource(&Resource); 

        CString sLayer;
        folder = "city/color/";
        sLayer.Format(_T("%d"), layer);
        LPCTSTR path = L"./Screenshots/" + folder + sLayer + L"Layer.bmp";
        D3DX11SaveTextureToFile(pd3dImmediateContext, Resource, D3DX11_IFF_BMP, path);
    }

Thanks.