Replies: 2 comments 9 replies
-
It's hard for me to say. I think it depends on where time is being spent in drawing. The code I see in that linked discussion, render . vBox . map hBox . chunksOf w . map (renderCoord . Cosmic (vr ^. subworld)) $ ixs could render individual 1x1 world map cells with I guess if it were me, my instinct would be to try hard to avoid using boxes at all to render the world map unless I could keep the number of boxes to a minimum, such as by constructing a Vty image directly rather than using the built-in boxes. The built-in box functions are meant for more general layout situations and are a much bigger hammer than you probably need for rendering the world, at least at an individual row or cell level, which by the sound of it is just a concatenation of 1x1 Vty images. The more you can just go straight to using Vty and skip brick functions for those small renderings, the more overhead you'll save. With that said, avoiding Another idea is to combine these two approaches in a way: rather than caching and invalidating at a 1x1 grid cell level and using boxes to lay out those tiny cells (costing more overhead), you could cache and invalidate at a larger chunk size (e.g. 5 rows x 20 columns). If you can know which chunk to invalidate based on changes at an individual cell level, that would make it possible to keep using the box layout functions to concatenate larger chunks at render time, but use fewer box cells (reducing overhead) at the cost of rendering a bit more unnecessarily (a whole chunk or maybe a few chunks). But I don't know how will that would work practically since I don't know how often whole chunks would be likely to get cache-invalidated as a consequence of small changes in the map. |
Beta Was this translation helpful? Give feedback.
-
Just a follow-up to note that I have now also implemented caching/invalidating at a larger chunk size, so that we can avoid redrawing the entire world every frame but also not pay too much overhead for assembling lots of 1x1 widgets. I am happy to report that this makes a huge difference - I can now run at 30fps at full-screen resolution, even when scrolling the world (before it was only like 7 fps)! swarm-game/swarm#2515 @jtdaugherty , quick question - am I correct in assuming that the brick widget cache will never kick old things out of the cache --- so if e.g. I want the cache to be limited to a max number of entries, I will have to keep track and invalidate old entries myself? I imagine this would hardly ever be relevant for most brick applications. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Curious if anyone has thoughts on the best way to accomplish this with Brick. For context, see swarm-game/swarm#2510 . Should we wrap each individual 1x1 widget in its own cache and invalidate the ones we want to redraw? And how do we draw/lay out the grid of widgets so that brick doesn't have to re-process the entire grid every time a single 1x1 widget updates?
I realize this may be an abuse of brick. 😄 Also open to hearing about ways that we could e.g. use some escape hatch to render/draw our grid at a lower level in order to achieve what we want.
Beta Was this translation helpful? Give feedback.
All reactions