Example #1
0
ID3D11View* CDXVAOutputBuffer::GetSRV(unsigned idx)
{
  if (!g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE))
    return nullptr;

  if (planes[idx])
    return planes[idx];

  ID3D11Resource* pResource = nullptr;
  D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC vpivd;

  ID3D11VideoDecoderOutputView *pView = reinterpret_cast<ID3D11VideoDecoderOutputView*>(view);
  pView->GetDesc(&vpivd);
  pView->GetResource(&pResource);

  DXGI_FORMAT plane_format = plane_formats[format - DXGI_FORMAT_NV12][idx];
  CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(D3D11_SRV_DIMENSION_TEXTURE2DARRAY, plane_format,
    0, 1, vpivd.Texture2D.ArraySlice, 1);

  HRESULT hr = g_Windowing.Get3D11Device()->CreateShaderResourceView(pResource, &srvDesc,
    reinterpret_cast<ID3D11ShaderResourceView**>(&planes[idx]));
  if (FAILED(hr))
    CLog::LogF(LOGERROR, "unable to create SRV for decoder surface (%d)", plane_format);

  SAFE_RELEASE(pResource);
  return planes[idx];
}
Example #2
0
ID3D11VideoProcessorInputView* CProcessorHD::GetInputView(ID3D11View* view) 
{
  ID3D11VideoProcessorInputView* inputView = nullptr;
  if (m_context) // we have own context so the view will be processor input view
  {
    inputView = reinterpret_cast<ID3D11VideoProcessorInputView*>(view);
    inputView->AddRef(); // it will be released in Render method

    return inputView;
  }

  // the view came from decoder
  ID3D11VideoDecoderOutputView* decoderView = reinterpret_cast<ID3D11VideoDecoderOutputView*>(view);
  if (!decoderView) 
  {
    CLog::Log(LOGERROR, __FUNCTION__" - cannot get view.");
    return nullptr;
  }

  ID3D11Resource* resource = nullptr;
  D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC vdovd;
  decoderView->GetDesc(&vdovd);
  decoderView->GetResource(&resource);

  D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC vpivd = { 0 };
  vpivd.FourCC = 0; // if zero, the driver uses the DXGI format; must be 0 on level 9.x
  vpivd.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D;
  vpivd.Texture2D.ArraySlice = vdovd.Texture2D.ArraySlice;
  vpivd.Texture2D.MipSlice = 0;

  if (FAILED(m_pVideoDevice->CreateVideoProcessorInputView(resource, m_pEnumerator, &vpivd, &inputView)))
  {
    CLog::Log(LOGERROR, __FUNCTION__" - cannot create processor view.");
  }
  resource->Release();

  return inputView;
}
Example #3
0
ID3D11VideoProcessorInputView* CProcessorHD::GetInputView(ID3D11View* view) 
{
  ID3D11VideoProcessorInputView* inputView = nullptr;
  if (m_eViewType == PROCESSOR_VIEW_TYPE_PROCESSOR)
  {
    inputView = reinterpret_cast<ID3D11VideoProcessorInputView*>(view);
    inputView->AddRef(); // it will be released later
  }
  else if (m_eViewType == PROCESSOR_VIEW_TYPE_DECODER)
  {
    // the view cames from decoder
    ID3D11VideoDecoderOutputView* decoderView = reinterpret_cast<ID3D11VideoDecoderOutputView*>(view);
    if (!decoderView)
    {
      CLog::Log(LOGERROR, "%s - cannot get view.", __FUNCTION__);
      return nullptr;
    }

    ID3D11Resource* resource = nullptr;
    D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC vdovd;
    decoderView->GetDesc(&vdovd);
    decoderView->GetResource(&resource);

    D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC vpivd = { { 0 } };
    vpivd.FourCC = 0;
    vpivd.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D;
    vpivd.Texture2D.ArraySlice = vdovd.Texture2D.ArraySlice;
    vpivd.Texture2D.MipSlice = 0;

    if (FAILED(m_pVideoDevice->CreateVideoProcessorInputView(resource, m_pEnumerator, &vpivd, &inputView)))
      CLog::Log(LOGERROR, "%s - cannot create processor view.", __FUNCTION__);

    resource->Release();
  }
  return inputView;
}
Example #4
0
ID3D11VideoProcessorInputView* CProcessorHD::GetInputView(CRenderBuffer* view) const
{
  ID3D11VideoProcessorInputView* inputView = nullptr;
  D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC vpivd = { 0, D3D11_VPIV_DIMENSION_TEXTURE2D,{ 0, 0 } };

  if (view->format == BUFFER_FMT_D3D11_BYPASS)
  {
    // the view cames from decoder
    ID3D11VideoDecoderOutputView* decoderView = reinterpret_cast<ID3D11VideoDecoderOutputView*>(view->GetHWView());
    if (!decoderView)
    {
      CLog::Log(LOGERROR, "%s: cannot get decoder view.", __FUNCTION__);
      return nullptr;
    }

    ID3D11Resource* resource = nullptr;
    D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC vdovd;
    decoderView->GetDesc(&vdovd);
    decoderView->GetResource(&resource);
    vpivd.Texture2D.ArraySlice = vdovd.Texture2D.ArraySlice;

    if (FAILED(m_pVideoDevice->CreateVideoProcessorInputView(resource, m_pEnumerator, &vpivd, &inputView)))
      CLog::Log(LOGERROR, "%s: cannot create processor input view.", __FUNCTION__);

    resource->Release();
  }
  else if (view->format == BUFFER_FMT_D3D11_NV12
        || view->format == BUFFER_FMT_D3D11_P010
        || view->format == BUFFER_FMT_D3D11_P016)
  {
    if (FAILED(m_pVideoDevice->CreateVideoProcessorInputView(view->GetResource(), m_pEnumerator, &vpivd, &inputView)))
      CLog::Log(LOGERROR, "%s: cannot create processor input view.", __FUNCTION__);
  }

  return inputView;
}