summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-10 14:40:01 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-10 15:15:17 -0700
commit02745f14a6b534f7a704ef3c512c9a0b4c999665 (patch)
tree5b9aa5b42981a8a2b962bca4a824eb5b506859dd
parent9f82732e1ece48772d0b1a532a69ff739c9dde16 (diff)
til_fb: fast-path til_fb_fragment_clear() a bit
What this really should have is a general memset32() implementation, but for now it's a small improvement at least for clearing since that's known to be a 0-pixel case where memset() is applicable. memset() isn't usable for actual RGBA pixels since it operates strictly on bytes. There's some hacks for using memmove() to get closer where you store the first four bytes, then memove the start of the buffer to the remaining, doubling the size of the move each time for log(n) calls to memmove. Maybe that makes sense as a stop-gap for the general case, it needs implementing+benchmarking first. This commit is dead simple though and an obvious little FPS gain for clearing.
-rw-r--r--src/til_fb.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/til_fb.h b/src/til_fb.h
index f6763e1..21699c2 100644
--- a/src/til_fb.h
+++ b/src/til_fb.h
@@ -162,9 +162,13 @@ static inline void _til_fb_fragment_fill(til_fb_fragment_t *fragment, uint32_t p
/* TODO: there should be a fast-path for non-divided fragments where there's no stride to skip */
for (int y = 0; y < fragment->height; y++, buf += fragment->pitch) {
- /* TODO: this should use something memset-like for perf */
- for (int x = 0; x < fragment->width; x++)
- buf[x] = pixel;
+ if (!pixel) {
+ memset(buf, pixel, fragment->width * sizeof(pixel));
+ } else {
+ /* TODO: this should use something memset-like for perf */
+ for (int x = 0; x < fragment->width; x++)
+ buf[x] = pixel;
+ }
}
}
© All Rights Reserved