[client/idd] input: reduce network latency

Route input through a dedicated high-priority stream, send pointer
motion as cumulative datagrams, and recover suspected loss reliably.

Reduce downstream input queuing with age-aware coalescing and input
thread scheduling.
This commit is contained in:
Geoffrey McRae
2026-10-08 20:34:04 +11:00
parent e30afaca2d
commit 1af2f13440
17 changed files with 3359 additions and 759 deletions

View File

@@ -58,6 +58,7 @@
#define NETWORK_FILE_MAX_PAYLOAD \
(LG_NET_FILE_CHUNK_HEADER_WIRE_SIZE + NETWORK_TRANSFER_CHUNK)
#define NETWORK_VIDEO_MAX_PAYLOAD LG_NET_MAX_PAYLOAD_LENGTH
#define NETWORK_INPUT_MAX_PAYLOAD LG_NET_INPUT_ABSOLUTE_WIRE_SIZE
static const LGNetCapability NETWORK_CAPABILITIES[] =
{
@@ -91,9 +92,9 @@ static const LGNetCapability NETWORK_CAPABILITIES[] =
.flags = LG_NET_CAPABILITY_RELIABLE |
LG_NET_CAPABILITY_DATAGRAM,
.features = 0,
.maxPayloadLength = NETWORK_MAX_PAYLOAD,
.maxDatagramPayload = NETWORK_MAX_DATAGRAM,
.maxBidirectionalStreams = 0,
.maxPayloadLength = NETWORK_INPUT_MAX_PAYLOAD,
.maxDatagramPayload = NETWORK_INPUT_MAX_PAYLOAD,
.maxBidirectionalStreams = 1,
.maxUnidirectionalStreams = 0,
},
{
@@ -473,6 +474,8 @@ static void networkSendReady(void * opaque, LGNetService service,
LG_Transport * this = opaque;
const bool datagram =
delivery == NETWORK_PACKET_DELIVERY_DATAGRAM;
if (service == LG_NET_SERVICE_INPUT)
networkInputSendReady(this->input, delivery);
if (service == LG_NET_SERVICE_AUDIO &&
delivery != NETWORK_PACKET_DELIVERY_BULK)
networkAudioSendReady(this->audio, datagram);
@@ -484,6 +487,15 @@ static void networkSendReady(void * opaque, LGNetService service,
networkVideoSendReady(this->video, datagram);
}
static void networkDatagramLost(void * opaque, LGNetService service,
uint64_t componentEpoch, uint64_t applicationSequence)
{
LG_Transport * this = opaque;
if (service == LG_NET_SERVICE_INPUT)
networkInputDatagramLost(
this->input, componentEpoch, applicationSequence);
}
static bool networkCreate(LG_Transport ** result)
{
if (!result)
@@ -552,6 +564,7 @@ static bool networkCreate(LG_Transport ** result)
.packet = networkPacket,
.state = networkConnectionState,
.sendReady = networkSendReady,
.datagramLost = networkDatagramLost,
.capabilities = NETWORK_CAPABILITIES,
.capabilityCount = sizeof(NETWORK_CAPABILITIES) /
sizeof(NETWORK_CAPABILITIES[0]),