Skip to content

mgras: decode a PIO readback pixel once, not once per byte - #802

Open
jamesbraid wants to merge 1 commit into
mainfrom
perf/mgras-readback
Open

jamesbraid wants to merge 1 commit into
mainfrom
perf/mgras-readback

Conversation

@jamesbraid

Copy link
Copy Markdown
Collaborator

pio_doubleword built each doubleword from eight line_byte calls. Each
call re-read and re-decoded its pixel, and for RGB(A) PIO order and the
generic formats it also allocated a Vec to pick one byte out of it. An
RGBA pixel was decoded four times with four allocations.

Decode a pixel into a stack buffer (pixel_bytes) and serve the
doubleword's bytes from it, re-decoding only when the doubleword moves
to the next pixel. get_line shares pixel_bytes for the non-generic
formats; host_comp and host_pixel write into a caller's array instead of
pushing onto a Vec. The largest pixel is four 32-bit components, 16
bytes.

Per doubleword, best of five over a 1280x1024 block, ignored test
bench_pio_readback, release build with the default (loop) profile, same
machine, before -> after:

RGBA, GL order 468 ns -> 112 ns (307 ms -> 73 ms per frame)
RGBA, X server order 150 ns -> 55 ns ( 98 ms -> 36 ms per frame)
CI8 147 ns -> 158 ns ( 24 ms -> 26 ms per frame)

RGBA readback is about 4x faster in GL order and 2.7x in X server order.
CI8 decodes one byte per pixel either way and is about 6% slower (an
independent rerun, 14 paired rounds, gave +5 to 6%: about 2 ms a frame,
against 230 ms saved on an RGBA frame); a CI8 fast path gained nothing.
The loop profile is not timing evidence for absolute numbers.

readback_bytes_are_stable_for_every_format pins the bytes: it reads a
known framebuffer back by PIO and DMA in every format and type, both
RGB orders, both 12-bit and 24-bit pixels, and with row padding, and
hashes the lot. The hash was taken on the code before this change and
is unchanged after it.

Fixes: c673ae3 ("mgras: GE pixel pipeline HLE; raster transfer formats by type")

pio_doubleword built each doubleword from eight line_byte calls. Each
call re-read and re-decoded its pixel, and for RGB(A) PIO order and the
generic formats it also allocated a Vec to pick one byte out of it. An
RGBA pixel was decoded four times with four allocations.

Decode a pixel into a stack buffer (pixel_bytes) and serve the
doubleword's bytes from it, re-decoding only when the doubleword moves
to the next pixel. get_line shares pixel_bytes for the non-generic
formats; host_comp and host_pixel write into a caller's array instead of
pushing onto a Vec. The largest pixel is four 32-bit components, 16
bytes.

Per doubleword, best of five over a 1280x1024 block, ignored test
bench_pio_readback, release build with the default (loop) profile, same
machine, before -> after:

  RGBA, GL order       468 ns -> 112 ns   (307 ms -> 73 ms per frame)
  RGBA, X server order 150 ns ->  55 ns   ( 98 ms -> 36 ms per frame)
  CI8                  147 ns -> 158 ns   ( 24 ms -> 26 ms per frame)

RGBA readback is about 4x faster in GL order and 2.7x in X server order.
CI8 decodes one byte per pixel either way and is about 6% slower (an
independent rerun, 14 paired rounds, gave +5 to 6%: about 2 ms a frame,
against 230 ms saved on an RGBA frame); a CI8 fast path gained nothing.
The loop profile is not timing evidence for absolute numbers.

readback_bytes_are_stable_for_every_format pins the bytes: it reads a
known framebuffer back by PIO and DMA in every format and type, both
RGB orders, both 12-bit and 24-bit pixels, and with row padding, and
hashes the lot. The hash was taken on the code before this change and
is unchanged after it.

Fixes: c673ae3 ("mgras: GE pixel pipeline HLE; raster transfer formats by type")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant