more faster
This commit is contained in:
parent
5b8ce3781c
commit
ee414035de
5 changed files with 779 additions and 112 deletions
55
pixelflut.h
Normal file
55
pixelflut.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Pixelflut binary UDP protocol, shared by the renderer and the benchmark.
|
||||
*
|
||||
* Packet layout (little-endian on the wire):
|
||||
*
|
||||
* +------+---------+ pixelflut_packet
|
||||
* | cmd | subcmd | 2-byte header
|
||||
* +------+---------+---------+----+----+----+ pixelflut_pixel[0]
|
||||
* | x (u16) | y (u16) | r | g | b | 7 bytes
|
||||
* +----------------+---------+----+----+----+
|
||||
* | ... | PIXELS_PER_PACKET pixels
|
||||
* +----------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PIXELFLUT_H
|
||||
#define PIXELFLUT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Header bytes. */
|
||||
#define PIXELFLUT_CMD_SET 0x00 /* "set pixels" command ... */
|
||||
#define PIXELFLUT_SUBCMD_RGB 0x01 /* ... with 3-byte RGB colours */
|
||||
|
||||
/* Pixels batched into a single UDP datagram. Bigger datagrams amortize the
|
||||
* per-message send cost over more pixels; keep the packet within the path MTU
|
||||
* to avoid IP fragmentation (e.g. 207 pixels ~= 1451 B fits a 1500 B link).
|
||||
* Override at build time with -DPIXELS_PER_PACKET=N. */
|
||||
#ifndef PIXELS_PER_PACKET
|
||||
# define PIXELS_PER_PACKET 120
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/* A single pixel as it appears on the wire. */
|
||||
struct pixelflut_pixel {
|
||||
uint16_t x; /* little-endian */
|
||||
uint16_t y; /* little-endian */
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
/* A full datagram: header followed by a batch of pixels. */
|
||||
struct pixelflut_packet {
|
||||
uint8_t cmd;
|
||||
uint8_t subcmd;
|
||||
struct pixelflut_pixel pixels[PIXELS_PER_PACKET];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
_Static_assert(sizeof(struct pixelflut_pixel) == 7,
|
||||
"pixel must be exactly 7 bytes on the wire");
|
||||
_Static_assert(sizeof(struct pixelflut_packet) == 2 + 7 * PIXELS_PER_PACKET,
|
||||
"packet must be header + PIXELS_PER_PACKET pixels, no padding");
|
||||
|
||||
#endif /* PIXELFLUT_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue