Hi,
I try to modify the NvEncoderD3DInterop example in Nvidia Video_Codec_SDK_7.0.1. The example code is use DXVA2 to create surface, and then call nvEncRegisterResource to do register, it success and the returned registeredResource is not zero. But i want use D3D9 to create texture surface or rendertarget surface, but it failed to do register, the nvEncRegisterResource return NV_ENC_SUCCESS, but the returned registeredResource is zero. I don’t know why, can someone help me? Many Thanks. Here is my example code.
IDirect3DSurface9* pSurface = NULL;
//hr = m_pD3D9Device->CreateRenderTarget(uInputWidth, uInputHeight, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &pSurface, NULL);
IDirect3DTexture9 *pText = NULL;
hr = m_pD3D9Device->CreateTexture(uInputWidth, uInputHeight, 0, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pText, NULL);
hr = pText->GetSurfaceLevel(0, &pSurface);
nvStatus = m_pNvHWEncoder->NvEncRegisterResource(NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX, (void*)pSurface/pVPSurfaces[i]/,
uInputWidth, uInputHeight, uInputWidth*4/m_stEncodeBuffer[i].stInputBfr.uRGBStride/, &m_stEncodeBuffer[i].stInputBfr.nvRegisteredResource);
if (nvStatus != NV_ENC_SUCCESS)
return nvStatus;
Here return NV_ENC_SUCCESS, but nvRegisteredResource is zero.
Liming