Repository navigation
Improve speed of http backend by avoiding data copy amd using '420' subsampling - #274
Conversation
|
This is great with the 420 encoding! |
| self._present_params = {} | ||
| # Params that steer the present process (only used for bitmap present). This is | ||
| # the "encoding" field of the present info dict, kept by reference, so the canvas | ||
| # can update it directly at runtime. |
There was a problem hiding this comment.
if this only is used by the bitmap context. could it be moved to BitmapContext?
There was a problem hiding this comment.
Not it's only used by the bitmap present method, so by BitmapContextToBitmap and WgpuContextToBitmap. I get the confusion though :)
There was a problem hiding this comment.
So a canvas can add this subdict as part of the result of _rc_get_present_info(), e.g.:
return {
"method": "bitmap",
"formats": ["rgba-u8"],
"encoding": self._encoding_params,
}And then it can change the encoding at runtime. Like dynamically lower the quality etc.
There was a problem hiding this comment.
My.type checker complainted that this could be None
So I was wondering if I could find such a situation, and if not why it still complained. Maybe the solution would be a ToBitmap mixin but that feels convoluted too
There was a problem hiding this comment.
The encoding params are not None if present_info["method"] == "bitmap", which is always the case here. But the type checker cannot see that I guess. If we want to please mypy we can define the type, maybe?
Vipitis
left a comment
There was a problem hiding this comment.
just one question but not an issue.
looks good to me

What this PR does
Architectual changes:
_rc_present_xxfor future present methods. That is solved through 'encodings'.Practical changes:
Prior and future work
Benchmarks
So it looks like avooding a data-copy shaves of a few ms, while moving from 444 to 420 yuv subsampling has the biggest effect. I also looked into reducing the quality, but that does not have such a great performance improvement, while at some point artifacts become visible. From what i found, 75-80 is a good default.
On my laptop screen:
mainOn a 4k screen (canvas size close to 4k):
Moving from 27 fps to 43 fps also means a big difference in the perceived delay in interactive applications.