No transfer conversion from Planar NCV_BGR/NVCV_F32 to DX11 textures

NvCVImage_Transfer doesn’t appear to be able to transfer back from planar 32-bit BGR (used by the Super Resolution and Artifact Reduction effects) to any DXGI texture format I can find. The transfer from DirectX textures works fine, but not back.

The following code always returns 104/NVCV_ERR_PIXELFORMAT regardless of the DXGI_FORMAT used to create the DirectX texture:

        ID3D11Device* device = nullptr;
        if (FAILED(D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &device, nullptr, nullptr)))
            return 96;
        CUstream cuStream;
        if (NvVFX_CudaStreamCreate(&cuStream) != NVCV_SUCCESS)
            return 97;
        uint32_t width = 1920;
        uint32_t height = 1080;
        ID3D11Texture2D* resource = nullptr;
        D3D11_TEXTURE2D_DESC rtDesc;
        ZeroMemory(&rtDesc, sizeof(D3D11_TEXTURE2D_DESC));
        rtDesc.Width = width;
        rtDesc.Height = height;
        rtDesc.MipLevels = 1;
        rtDesc.ArraySize = 1;
        rtDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
        rtDesc.SampleDesc.Count = 1;
        rtDesc.Usage = D3D11_USAGE_DEFAULT;
        rtDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
        rtDesc.CPUAccessFlags = 0;
        rtDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
        if (FAILED(device->CreateTexture2D(&rtDesc, nullptr, &resource)))
            return 98;
        NvCVImage texture;
        if (NvCVImage_InitFromD3D11Texture(&texture, resource) != NVCV_SUCCESS)
            return 99;
        NvCVImage image(width, height, NVCV_BGR, NVCV_F32, NVCV_PLANAR, NVCV_GPU, 1);
        NvCVImage temporary;
        if (NvCVImage_MapResource(&texture, cuStream) != NVCV_SUCCESS)
            return 100;
        if (NvCVImage_Transfer(&texture, &image, 1, cuStream, &temporary) != NVCV_SUCCESS)
            return 101;
        if (NvCVImage_UnmapResource(&texture, cuStream) != NVCV_SUCCESS)
            return 102;
        if (NvCVImage_MapResource(&texture, cuStream) != NVCV_SUCCESS)
            return 103;
        if (NvCVImage_Transfer(&image, &texture, 1, cuStream, &temporary) != NVCV_SUCCESS)
            return 104;
        if (NvCVImage_UnmapResource(&texture, cuStream) != NVCV_SUCCESS)
            return 105;

Do I need to manually transfer to another format before transferring to the DX11 texture or am I doing something wrong?

@alt You are correct. At the moment, you need to manually transfer to another format before transferring to the DX11 texture.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.