any1 / neatvnc

A liberally licensed VNC server library with a clean interface
ISC License
118 stars 29 forks source link

use memcpy if pixel format is the same #32

Open agners opened 4 years ago

agners commented 4 years ago

Use memcpy if the pixel format of source and destination is the same. This improves performance of raw encoding significantly in my test case with Weston.

any1 commented 4 years ago

The problem here is that if bytes_per_cpixel = 3 and the pixel format is xRGB or xBGR big endian, then this breaks because VNC has this special "compact pixel" format that discards the unused byte when the depth = 24 bits and bits-per-pixel = 32 bits.

This function is written in such a way that it can be auto-vectorized. If you set --buildtype=release and with x86_64-simd in meson_options.txt set to avx2, you should get significant performance improvements.

However, keep in mind that it is fairly uncommon for clients to choose raw encoding, so optimising this particular function is probably not very good use of your time as it is definitely not going to be the tightest bottleneck when using tight or zrle encoding.

If you want to have a chat about performance and optimisation, drop by #wayvnc on freenode.