locked
How to create ID3D11ShaderResourceView from ID3D11Texture2D that from MF engine ?

    Question

  • I'm working on a direct3d app that can play video as texture.

    But I met some problems.

    The following is my code.

    if (m_spMediaEngine->OnVideoStreamTick(&pts) == S_OK)
    {
    	ID3D11Texture2D* text2D;
    	MEDIA::ThrowIfFailed(
            swapChain->GetBuffer(0, IID_PPV_ARGS(&text2D)));
    	RECT m_rcTarget;
    	m_rcTarget.left = 0;
    	m_rcTarget.top = 0;
    	m_rcTarget.right = (LONG) m_window->Bounds.Width;
    	m_rcTarget.bottom = (LONG) m_window->Bounds.Height;
    	MFARGB m_bkgColor;
    	memset(&m_bkgColor, 0, sizeof(MFARGB));
    	MEDIA::ThrowIfFailed(
            m_spMediaEngine->TransferVideoFrame(
            text2D, nullptr, &m_rcTarget, &m_bkgColor));
    	D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
    	D3D11_TEXTURE2D_DESC desc;
    	text2D->GetDesc(&desc);
    	srvDesc.ViewDimension =
            D3D11_SRV_DIMENSION_TEXTURE2D;
    	srvDesc.Texture2D.MostDetailedMip = 0;
    	srvDesc.Texture2D.MipLevels = desc.MipLevels;
    	srvDesc.Format = DXGI_FORMAT_R32_FLOAT;
    	ID3D11ShaderResourceView* refRes;
    	HRESULT hr = 
            m_d3dDevice->CreateShaderResourceView(text2D, &srvDesc, &refRes);
    }

    I want to create shader resource view from ID3D11Texture2D, but CreateShaderResource View return "One or more arguments are invalid".

    Please help me.Thanks.



    • Edited by Y.H.King Monday, October 27, 2014 10:05 AM grammer error
    Monday, October 27, 2014 8:34 AM

Answers