Thanks for the information 6by9. I'm also trying to go down the zero-copy route as we're already pushing the Pi's GPU quite heavily - the possibility of displaying the texture through DMA-buf sharing without touching the GPU at all is very appealing.
I haven't got as far as you dividuum and I'm not sure if this would help, but I can suggest you try creating the DMA-buf directly using the CMA instead of using eglExport DMA. You can then use eglImportDMAbuf to have GL access to the DMA backed texture memory. This might create a dmabuf that drmPrimeFDToHandle is happy to use.
CMA allocation code is basically this:
I haven't got as far as you dividuum and I'm not sure if this would help, but I can suggest you try creating the DMA-buf directly using the CMA instead of using eglExport DMA. You can then use eglImportDMAbuf to have GL access to the DMA backed texture memory. This might create a dmabuf that drmPrimeFDToHandle is happy to use.
CMA allocation code is basically this:
Code:
DMA::DMA(): m_handle(open("/dev/dma_heap/linux,cma")){}DMA::~DMA(){close(m_handle);}int DMA::AllocateFd(const std::string& Name, std::size_t Size, eDMAHostAccess HostAccess){struct dma_heap_allocation_data Alloc = {};Alloc.len = Size;switch (HostAccess) {case eDMAHostAccess::Read:Alloc.fd_flags = O_CLOEXEC | O_RDONLY;break;case eDMAHostAccess::Write:case eDMAHostAccess::ReadWrite:Alloc.fd_flags = O_CLOEXEC | O_RDWR;break;}auto ret = ::ioctl(m_handle, DMA_HEAP_IOCTL_ALLOC, &Alloc);if (ret < 0) {return -1;}ret = ::ioctl(Alloc.fd, DMA_BUF_SET_NAME, Name.c_str());if (ret < 0) {return -1;}return Alloc.fd;}
Statistics: Posted by PeartreeStudios — Sun Apr 07, 2024 1:42 pm