switch protocol a bit
a frame is now [N tiles] then the whole framebuffer not great for bandwidth, but it's tolerable enough and the performance of it is vastly better. at some point we can use ivshmem to sidestep that and just make it a cpu->cpu copy I guess
This commit is contained in:
parent
9e1e9ddf02
commit
e0e78a92e9
2 changed files with 24 additions and 17 deletions
|
@ -122,6 +122,7 @@ class cStreamClient {
|
|||
for(auto& tile : tiles) {
|
||||
tTile tile_wire { tile.x, tile.y, tile.width, tile.height };
|
||||
|
||||
#if 0
|
||||
std::vector<u32> tileData;
|
||||
tileData.resize(tile.width * tile.height);
|
||||
|
||||
|
@ -129,10 +130,11 @@ class cStreamClient {
|
|||
auto* pTileLineStart = &pData[(tile.y + y) * width + tile.x];
|
||||
memcpy(&tileData[y * tile.width], pTileLineStart, tile.width * sizeof(u32));
|
||||
}
|
||||
#endif
|
||||
|
||||
// send header
|
||||
send(tcpSocket, (const char*)&tile_wire, (i32)sizeof(tile_wire), 0);
|
||||
send(tcpSocket, (const char*)&tileData[0], (i32)tileData.size() * 4, 0);
|
||||
// send(tcpSocket, (const char*)&tileData[0], (i32)tileData.size() * 4, 0);
|
||||
|
||||
// send data now
|
||||
/*for (auto y = tile.y; y < tile.y + tile.height; ++y) {
|
||||
|
@ -143,9 +145,10 @@ class cStreamClient {
|
|||
} else {
|
||||
tTile tDummyTile { 0, 0, width, height };
|
||||
send(tcpSocket, (const char*)&tDummyTile, sizeof(tDummyTile), 0);
|
||||
send(tcpSocket, (const char*)&pData[0], (i32)((width * height) * sizeof(u32)), 0);
|
||||
//send(tcpSocket, (const char*)&pData[0], (i32)((width * height) * sizeof(u32)), 0);
|
||||
}
|
||||
|
||||
send(tcpSocket, (const char*)&pData[0], (i32)((width * height) * sizeof(u32)), 0);
|
||||
// send(tcpSocket, (const char*)&data.data()[0], data.get_size() * sizeof(UINT32), 0);
|
||||
}
|
||||
};
|
||||
|
|
34
src/main.rs
34
src/main.rs
|
@ -16,7 +16,12 @@ enum Message {
|
|||
pub const MESSAGETYPE_RESIZE: u32 = 0;
|
||||
pub const MESSAGETYPE_DATA: u32 = 1;
|
||||
|
||||
fn read_message(stream: &mut TcpStream, argb_buffer: &mut Vec<u32>, width: u32) -> Option<Message> {
|
||||
fn read_message(
|
||||
stream: &mut TcpStream,
|
||||
argb_buffer: &mut Vec<u32>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> Option<Message> {
|
||||
let message_type = stream.read_u32::<LittleEndian>().expect("fuck");
|
||||
let message_len = stream.read_u32::<LittleEndian>().expect("fuck");
|
||||
|
||||
|
@ -46,7 +51,7 @@ fn read_message(stream: &mut TcpStream, argb_buffer: &mut Vec<u32>, width: u32)
|
|||
argb_buffer.len() * core::mem::size_of::<u32>(),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
for i in 0..tile_count {
|
||||
// tile rect
|
||||
let tile_x = stream.read_u32::<LittleEndian>().expect("fuck");
|
||||
|
@ -55,19 +60,16 @@ fn read_message(stream: &mut TcpStream, argb_buffer: &mut Vec<u32>, width: u32)
|
|||
let tile_height = stream.read_u32::<LittleEndian>().expect("fuck");
|
||||
|
||||
//println!("tile{i}: {tile_x} {tile_y} {tile_width}x{tile_height}");
|
||||
|
||||
|
||||
|
||||
for y in tile_y..tile_y + tile_height {
|
||||
//println!("{y} {tile_y} {tile_height}");
|
||||
//for x in tile_
|
||||
let dest_slice = &mut argb_slice[((y * width + tile_x) * 4) as usize
|
||||
..((y * width + (tile_x + tile_width)) * 4) as usize];
|
||||
|
||||
stream.read_exact(&mut dest_slice[..]).expect("FUCK");
|
||||
}
|
||||
}
|
||||
|
||||
for y in 0..height {
|
||||
//println!("{y} {tile_y} {tile_height}");
|
||||
//for x in tile_
|
||||
let dest_slice = &mut argb_slice
|
||||
[((y * width) * 4) as usize..((y * width + (width)) * 4) as usize];
|
||||
|
||||
stream.read_exact(&mut dest_slice[..]).expect("FUCK");
|
||||
}
|
||||
|
||||
Some(Message::Data {})
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ fn main() {
|
|||
let (mut socket, client_addr) = listener.accept().expect("FUCK!");
|
||||
|
||||
// disable nagles garbage bullshit
|
||||
socket.set_nodelay(true).expect("fuck tcp");
|
||||
//socket.set_nodelay(true).expect("fuck tcp");
|
||||
|
||||
let mut window = Window::new("FbcServer", 320, 200, WindowOptions::default())
|
||||
.expect("you banned forever: rules do not");
|
||||
|
@ -93,7 +95,9 @@ fn main() {
|
|||
let mut screen_height: u32 = 200;
|
||||
|
||||
loop {
|
||||
if let Some(message) = read_message(&mut socket, &mut argb_buffer, screen_width) {
|
||||
if let Some(message) =
|
||||
read_message(&mut socket, &mut argb_buffer, screen_width, screen_height)
|
||||
{
|
||||
match message {
|
||||
Message::Resize { width, height } => {
|
||||
println!("read message {:?}", message);
|
||||
|
|
Loading…
Reference in a new issue