Hello,
I’m trying to copy a directx12 texture (content of a backbuffer) to cuda memory.
So I 've followed the cuda sample and it works, but my algorithm can be more efficient
void* pData = nullptr;
cudaExternalMemoryBufferDesc buffDesc{};
memset(&buffDesc, 0, sizeof(buffDesc));
buffDesc.offset = 0;
buffDesc.size = d3d12Texture.memSize;
cudaExternalMemoryGetMappedBuffer(&pData, m_externalMemory, &buffDesc);
auto format = cv::directx::getTypeFromDXGI_FORMAT(31);//D3DFMT_A2B10G10R10 is the same as DXGI_FORMAT_R10G10B10A2_UNORM
cv::cuda::GpuMat(static_cast<int>(d3d12Texture.resource->GetDesc().Height),
static_cast<int>(d3d12Texture.resource->GetDesc().Width),
format, pData).copyTo(mat);
cudaFree(pData);
The code is called at each new frame. Does the memory pData can be mapped without freeing at every call ?
thanks.