directx – Studying from a staging 2D texture array in DirectX10

directx – Studying from a staging 2D texture array in DirectX10

[ad_1]

You are forgetting to contemplate mipLevels.
When making a texture, normally miplevels shall be generated so you’ll not discover texture ingredient 2 at subresource 2 (there’s a mipLevel in it, which is half of unique texture and so forth).

Use this perform to get the appropriate subresource index.

    ID3D11Texture2D *cpuTexture = NULL;

    D3D11_TEXTURE2D_DESC cputextdesc;
    memset(&cputextdesc,0,sizeof(cputextdesc));

    cputextdesc.Width = cputextdesc.Peak = 16;
    cputextdesc.ArraySize = 3;
    cputextdesc.MipLevels = 1;
    cputextdesc.Format = DXGI_FORMAT_R32_FLOAT;
    cputextdesc.Utilization = D3D11_USAGE_STAGING;
    cputextdesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
    cputextdesc.SampleDesc.Depend = 1;
    cputextdesc.SampleDesc.High quality = 0;

    device->CreateTexture2D(&cputextdesc,NULL,&cpuTexture);

    int text1 = D3D11CalcSubresource(0,0,1);
    int text2 = D3D11CalcSubresource(0,1,1);
    int text3 = D3D11CalcSubresource(0,2,1);

    D3D11_MAPPED_SUBRESOURCE mres1,mres2,mres3;

    icontext->Map(cpuTexture,text1,D3D11_MAP_READ,0,&mres1);
    icontext->Map(cpuTexture,text2,D3D11_MAP_READ,0,&mres2);
    icontext->Map(cpuTexture,text3,D3D11_MAP_READ,0,&mres3);

    // (assert row and depth pitch are equals)

    icontext->Unmap(cpuTexture,text1);
    icontext->Unmap(cpuTexture,text2);
    icontext->Unmap(cpuTexture,text3);

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply