Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
dmabuf_mapping.h File Reference

Persistent CPU mappings of DMA-BUFs, and a copy suited to reading them. More...

#include <algorithm>
#include <cerrno>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
Include dependency graph for dmabuf_mapping.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  platf::dmabuf::mapping_cache_t

Functions

void platf::dmabuf::copy_rows (std::uint8_t *dst, std::size_t dst_pitch, const std::uint8_t *src, std::size_t src_pitch, std::size_t row_bytes, std::size_t rows, std::size_t block_bytes=copy_block_bytes)

Variables

constexpr std::size_t platf::dmabuf::copy_block_bytes = std::size_t {2} << 20

Detailed Description

Persistent CPU mappings of DMA-BUFs, and a copy suited to reading them.

Definition in file dmabuf_mapping.h.

Function Documentation

◆ copy_rows()

void platf::dmabuf::copy_rows ( std::uint8_t * dst,
std::size_t dst_pitch,
const std::uint8_t * src,
std::size_t src_pitch,
std::size_t row_bytes,
std::size_t rows,
std::size_t block_bytes = copy_block_bytes )
inline

Copy rows rows of row_bytes from a pitched source to a pitched destination, never in a single memcpy larger than block_bytes.

Definition at line 142 of file dmabuf_mapping.h.

Variable Documentation

◆ copy_block_bytes

std::size_t platf::dmabuf::copy_block_bytes = std::size_t {2} << 20
constexpr

Largest single memcpy used when copying a contiguous image. One glibc memcpy of a whole 4K frame (31.6 MiB) switches to its large-copy strategy, which reads a VM_PFNMAP DMA-BUF mapping at a third of the speed: 9 ms instead of 3 ms on a Ryzen 7 5700X. Blocks from 1 to 16 MiB all avoid it; 2 MiB stays under the threshold on CPUs with a smaller L3 as well.

Definition at line 136 of file dmabuf_mapping.h.