根据这个连接 https://forums.developer.nvidia.com/t/nvdec-decoded-frame-trying-a-zero-copy-to-nv12-d3d11-texture/123291 , 这种方法是可行的
目前做了这些工作, 但是不知道顶点着色器和像素着色器应该怎么写
//将 R8G8 上的数据拷贝到 NV12 Texture 的 UⅣ部分 //创建目的 NV12 Texture 上 Uv 部分的 RenderTargetView uvRTVD3D11_RENDER_TARGET_VIEw_DESC rtDesc; rtDesc.Format = DXGI_FORMAT_R8G8_UNORM; rtDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;rtDesc.Texture2D.Mipslice = ; //D3D11 will map this render target view to the NV12 Chroma plane(U/v Interleave Plane) device->CreateRenderTargetView(nv12Texture.Get(),&rtDesc ,uvRTV.ReleaseAndGetAddress0f())); //创建源 R8G8 Texture 上的 SHADER_RESOURCE_VIEw uvSRV D3D11_SHADER_RESOURCE_VIEw_DESC srvDesc; srvDesc.Format = DXGI_FORMAT_R8G8_UNORM; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;srvDesc.Texture2D.MipLevels = 1; srvDesc.Texture2D.MostDetailedMip = 0; device->CreateShaderResourceView(r8g8texture.Get(),&srvDesc ,uvSRV.ReleaseAndGetAddressOf())); //将 uvSRV 绘制在 uvRTV context_->0MSetRenderTargets(1 ,uvRTV.ReleaseAndGetAddressOf(),NULL);context_->VSSetShader(vertexShader.Get(),NULL ,0); context_->PsSetShader( uvPixelShader.Get(),NULL,0); context_->pssetShaderResources(0 ,1 ,uvSRV.GetAddressOf( ));context_->Draw(4 ,0); context_->Flush();
![]() | 1 noErr 2023-08-28 15:43:33 +08:00 在同一个 NV12 上创建两个 SRV ,不同格式的一个 R8,一个 R8G8 ? |