From: Thomas Huth <hidden> Date: 2015-07-28 10:19:53
Greg Kurz recently already did a great work by introducing the
invert-region helpers to speed up the drawing of the cursor.
This made the grub2 command prompt and editor mode usable.
However, the editor mode of grub2 is still sluggish - because
grub2 always redraws the whole line (with cursor enabled!) when
you enter a character, and since cursor and character drawing
is still not super-fast in SLOF, this sums up to a noticable delay.
So I tried to speed up the drawing a little bit and came up
with the following patches. I've used a little "benchmark"
in Forth to see how the patches improve the drawing:
1 buffer: etest-buf
: etest
erase-screen
41 etest-buf c!
1b emit 5b emit [char] H emit
cursor-on
milliseconds
20 0 do 3a 0 do etest-buf 1 terminal-write drop loop cr loop
milliseconds
swap -
." Duration: " .d ." ms" cr
;
Without my patches, the etest function takes 1.8 s to draw.
With the first patch applied, the function take ca. 1.2 s.
With both patches applied, the function only takes ca. 0.8 s !
The first patch changes invert-region to use a bigger
access width if possible. And the second patch simply
decreases the size of the cursor from a full-character
size rectangle to an underscore-like cursor instead...
not sure whether this is acceptable, but at least I
think it looks as good as the original cursor.
Apart from my patches, I think grub2 should also disable
the cursor when redrawing a whole line in the editor.
However, I do not have much clue about the grub2 sources
yet ... is anybody familiar with this and could give some
pointers?
Thomas Huth (2):
fbuffer: Improve invert-region helper
fbuffer: Use a smaller cursor
board-js2x/slof/helper.fs | 13 ++++++++-----
board-qemu/slof/helper.fs | 14 ++++++++++----
slof/fs/fbuffer.fs | 5 +++--
3 files changed, 21 insertions(+), 11 deletions(-)
--
1.8.3.1
From: Thomas Huth <hidden> Date: 2015-07-28 10:19:54
The introduction of invert-region already speeded up the cursor
drawing very much. But there is still space for improvement:
So far invert-region is accessing the memory only byte by byte,
but with some additional logic that checks the alignment of the
address and the length of the area, we can also make this function
to access the memory with half-word, word or long-word accesses.
With this additional logic, invert-region-x is also no longer
necessary and thus can be removed.
Signed-off-by: Thomas Huth <redacted>
---
board-js2x/slof/helper.fs | 13 ++++++++-----
board-qemu/slof/helper.fs | 14 ++++++++++----
slof/fs/fbuffer.fs | 2 +-
3 files changed, 19 insertions(+), 10 deletions(-)
From: Thomas Huth <hidden> Date: 2015-07-28 10:19:55
Drawing the cursor in the frame buffer memory is a very, very
slow operation. So let's simply switch to a "underscore" cursor
instead of the full block cursor to save some precious cycles.
Signed-off-by: Thomas Huth <redacted>
---
slof/fs/fbuffer.fs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Can you access device memory as 64 bits for all supported devices?
You can get a bigger speedup by writing some of the core blitting
functions in C, btw.
A small simplification:
2dup or 7 and CASE
0 OF 3 rshift 0 ?DO dup dup rx@ -1 xor swap rx! xa1+ LOOP ENDOF
4 OF 2 rshift 0 ?DO dup dup rl@ -1 xor swap rl! la1+ LOOP ENDOF
3 and
2 OF 1 rshift 0 ?DO dup dup rw@ -1 xor swap rw! wa1+ LOOP ENDOF
dup OF 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP ENDOF
ENDCASE
If this code is often called unaligned, it makes more sense to special-
case the begin and end probably.
Segher
You can get a bigger speedup by writing some of the core blitting
functions in C, btw.
Well, the above code is for js2x only ... so this is likely not worth
the effort anymore. The code for qemu-spapr calls into a hypercall
already, so this is already accelerated.
A small simplification:
2dup or 7 and CASE
0 OF 3 rshift 0 ?DO dup dup rx@ -1 xor swap rx! xa1+ LOOP ENDOF
4 OF 2 rshift 0 ?DO dup dup rl@ -1 xor swap rl! la1+ LOOP ENDOF
3 and
2 OF 1 rshift 0 ?DO dup dup rw@ -1 xor swap rw! wa1+ LOOP ENDOF
dup OF 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP ENDOF
ENDCASE
Ok, nice idea, makes sense! I'll include it in v2 (after waiting a little
bit to see if there's other feedback)
If this code is often called unaligned, it makes more sense to special-
case the begin and end probably.
It's only used for drawing the cursor, so it always should be aligned.
Thomas
Drawing the cursor in the frame buffer memory is a very, very
slow operation. So let's simply switch to a "underscore" cursor
instead of the full block cursor to save some precious cycles.
Signed-off-by: Thomas Huth <redacted>
---
slof/fs/fbuffer.fs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Why not just:
- char-height 0 ?DO
+ 1 0 ?DO
? What is this magic with screen-width about?
Thomas' patch draws the cursor as the bottom three lines of a
character cell; your suggestion would draw it as the top one line.
But indeed it could be
char-height dup 3 - ?DO ...
Segher
Why not just:
- char-height 0 ?DO
+ 1 0 ?DO
? What is this magic with screen-width about?
Thomas' patch draws the cursor as the bottom three lines of a
character cell; your suggestion would draw it as the top one line.
Right.
But indeed it could be
char-height dup 3 - ?DO ...
Since the loop body expects the framebuffer address on the stack, the
loop boundaries are just used to count the iterations ... so "3 0"
sounds like the easiest and most readable way to specify this IMHO.
Thomas