Nnews

Deki 0.21: draw only what changed

A still screen now costs almost nothing, motion no longer stutters, scenes open in a blink, games can save files, and the demo's meadow plays itself.

posted
by
Jai
read
5 min
Four moments of the demo's new endless meadow on a T-Deck Plus: the alien runs, jumps onto platforms and collects coins, at 60 fps.

Deki 0.21 carries on where 0.20 left off: less work for every frame, and frames that arrive when the screen wants them. As before, every change was measured on a LilyGO T-Deck Plus and a T-Display S3 AMOLED, and the work is in Deki itself, so every board gets it.

Draw only what changed

Most of the time, most of a game’s screen stays the same: a menu waiting for a press, a HUD, a background. Until now Deki drew and sent the whole screen every frame anyway.

Turn on Redraw Changes in the project’s rendering settings, and before each frame Deki compares everything on screen with the frame before. Only the parts that changed are drawn and sent to the screen. A frame where nothing moved costs only that comparison. On the T-Deck Plus, the demo’s menu went from 7.6 ms of drawing and 3.4 ms of sending a frame to 2.0 ms and 0.1 ms.

When most of the screen changes, like a scrolling level, the frame is drawn whole as before, so a busy scene costs what it always did. It also works in the editor’s Play view. The old “dirty tile tracking” settings are gone: Redraw Changes does the same job and skips the drawing too.

Motion without the stutter

A screen redraws itself at its own pace, and that pace is never quite what it says on the box. The T-Deck Plus’s screen runs at 60.2 frames a second, while the game ran at exactly 60. The two drifted apart, and about every five seconds the screen showed the same frame twice: a small hitch in anything that scrolls, even with the counter saying 60.

Deki now lets the screen set the pace. When a screen shows each frame on its own redraw, Deki times every frame to it, so they never drift. Frame times are also measured in microseconds now instead of whole milliseconds, so something moving at a steady speed moves the same amount every frame. On the T-Deck Plus the repeats are gone.

Switching scenes on the T-Deck Plus took about 0.8 seconds. It now takes about 65 ms. Two things made the difference:

  • Gradients bake fast. A full-screen gradient background took 0.7 s to work out on the first frame of a scene. One that runs straight down or across is now kept as a single row or column and stretched, which takes well under a millisecond.
  • The game’s data has its own place in flash. It’s flashed as one block and read where it lies, so finding a file takes microseconds instead of 6 to 13 ms. Flashing the data takes seconds, too.

Leaving a scene now frees it before the next one loads, along with the assets nothing uses any more. Before, a visit to the meadow kept about 60 KB of memory after you left it.

Games can save files

A game can now write its own files, like saves and settings, under F:/. On a board they go to a separate part of the flash that updating the game never touches, so they survive a new version. The game’s own data can’t be overwritten by mistake. It works the same on the desktop and on Tactility.

Faster drawing

  • Turned sprites only look at the pixels that land inside them. The demo’s spinning gear takes 0.67 ms instead of 0.87 ms.
  • Sprites with soft edges fill their solid middles in one go and blend only the edges.
  • Tiled maps draw tiles the way sprites are drawn: the meadow, whose ground and hills are maps, draws in 6.0 ms instead of 6.9 ms.
  • Maps now draw on boards. Before, a Tiled map drew in the editor but not on a device, and its tilesets weren’t shipped with the game.

The second core

On a chip with two cores, Deki sends each frame to the screen from the second core while the first draws the next. That now covers frames where several things moved, not just whole frames: the demo’s effects scene sends in 3.5 ms instead of 4.3 ms. The second core never draws; it only sends, and it’s idle when nothing changes. The setting’s tooltip and theperformance guide now say what it costs, for games that want that core for themselves.

Boards

  • The first T-Deck is supported, as well as the Plus.
  • Colours on some T-Decks. Some T-Deck screens take each pixel’s bytes the other way round, which turned dark colours pink. The board sets the screen’s byte order now, and any screen has a Swap Bytes setting for the same problem.
  • Tactility: scenes open from the SD card again, and apps that use Tiled maps load.

A meadow that plays itself

The demo’s meadow is now an endless run that plays by itself: the camera scrolls, the alien jumps over rocks and onto platforms, collects coins, and flyers cross the sky. Everything on screen moves, every frame, so it’s the scene to try when you want to see how a board copes with a real game. The same seed always builds the same level, so you can compare one build with another.

Updating

Open your project in the new editor and it works as before. Packages are rebuilt for the new editor on their own. Update them from the Package Manager, or with DekiEditor --packages-update all <project>, to get the changes, then turn on Redraw Changes if your game’s screen is often still.

Everything else is in thechangelog.Download the editor here.

← all posts

Sponsors

all thanks →

Companies that provide hardware so Deki can run on it. Each board gets an official Deki package, kept maintained, with examples ready to run.

Friends

Projects whose work Deki uses or runs on.