XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Readback of volume texture into sysmem (DirectX 9)

Last post 29/06/2009 15:17 by legalize. 1 replies.
  • 19/05/2009 10:00

    Readback of volume texture into sysmem (DirectX 9)

    Hi,

    I am trying to readback a volume texture into sysmem to be able to save it to file of my own format. I have to use DirectX 9. Some code:

    --
    IDirect3DVolumeTexture9 *sysTexture    = 0;
    IDirect3DVolumeTexture9 *inputTexture  = 0;
    IDirect3DVolumeTexture9 *outputTexture  = 0;

    HRESULT hr;
    hr = D3DXCreateVolumeTexture(pDevice, sizeX, sizeY, sizeZ, 1, 0, D3DFMT_A8, D3DPOOL_SYSTEMMEM, &sysTexture);
    hr = D3DXCreateVolumeTexture(pDevice, sizeX, sizeY, sizeZ, 1, 0, D3DFMT_A8, D3DPOOL_DEFAULT, &inputTexture);
    hr = D3DXCreateVolumeTexture(pDevice, sizeX, sizeY, sizeZ, 1, 0, D3DFMT_A8, D3DPOOL_DEFAULT, &outputTexture);

    // Upload texture
    LoadMyVolumeToSysTexture(sysTexture, (unsigned char *)pData, sizeX, sizeY, sizeZ);
    hr = pDevice->UpdateTexture(sysTexture, inputTexture);

    MyOwnProcessing(inputTexture, outputTexture);
    --

    Now, does anyone know how I can readback outputTexture to the CPU again? Any help would be highly appreciated. I have looked around in the forums for quite some time now without success. I see that people are using GetRenderTargetData(), but isn't that function only for 2D?

    Best regards,
    Andy
  • 29/06/2009 15:17 In reply to

    Re: Readback of volume texture into sysmem (DirectX 9)

    You use GetRenderTargetData to get data from a render target created by the GPU into the CPU.

    You use UpdateTexture to get data from the CPU into the GPU.

    You can't render to a volume texture in D3D9, so the only way that data gets into a volume texture in D3D9 is for you to put it there from the CPU.  Since you put it there, you already have a copy on the CPU.

Page 1 of 1 (2 items) Previous Next