Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compression of ImDrawData buffers #1

Open
1 of 4 tasks
ggerganov opened this issue Jul 1, 2019 · 0 comments
Open
1 of 4 tasks

Improve compression of ImDrawData buffers #1

ggerganov opened this issue Jul 1, 2019 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ggerganov
Copy link
Owner

ggerganov commented Jul 1, 2019

Description

It is essential for the successful application of this WebSocket approach to minimise the amount of network traffic between the server and the clients. The WebSocket spec allows for extensions that perform general compression on the transmitted data, but it can only do so much. A custom approach, handcrafted for ImDrawData could significantly reduce the network traffic.

Current implementation

The differences are calculated per ImDrawList. For each ImDrawList, we store the position of the first vertex and subtract this value from all vertices in the draw list. This makes the ImDrawList invariant to shifts. The client takes care to restore the position offset before rendering the data.

If the current ImDrawList curList has the same size as it had in the previous frame prevList - the binary contents of curList and prevList are xored and run-length encoded. Otherwise - we send the full curList.

Ideas to explore

  • Per DrawList differences
  • Deinterleave ImDrawVtx fields
  • Rate control of focused/hovered windows
  • Alternative ImDrawList structure
@ggerganov ggerganov added help wanted Extra attention is needed enhancement New feature or request labels Jul 1, 2019
@ggerganov ggerganov changed the title Improve compression of Dear Imgui's DrawData difference between consecutive frames Improve compression of Dear Imgui's DrawData buffers Jul 1, 2019
@ggerganov ggerganov changed the title Improve compression of Dear Imgui's DrawData buffers Improve compression of ImDrawData buffers Jul 1, 2019
@ggerganov ggerganov pinned this issue Jul 1, 2019
ggerganov added a commit that referenced this issue Jul 6, 2019
We store the offset for each command list and subtract it from all
vertex positions in that list. This makes the new vertex positions
constant when moving the windows around, which gets compressed by
the RLE very well.
ggerganov added a commit that referenced this issue Jul 6, 2019
Effectively, changing the content in a window does not trigger
update of the draw data for other windows. This reduces bandwidth
significantly in some cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant