summaryrefslogtreecommitdiff
path: root/src/wayland/buffer.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-11 23:30:21 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-11 23:30:21 +0300
commit5530c662bb53837d64a154e3b580d41adb6cc8b9 (patch)
tree20cdd971425e945eecd8d3b5fbe243a4bd779409 /src/wayland/buffer.c
parent472ed3e4e50a165638acecaf071ec3c2c13c451f (diff)
opt: compile-time locked LUTs and branchless SIMD/ALU primitives
- Replace buffer allocation branching loop with compile-time locked 24-byte LUT indexed by (cur & 3) - Use hardware lrint rounding and array-indexed pointer offsets for scroll axes - Replace press queue button/kind conditionals with branchless bitmasking and 1:1 identity casting - Make display_has_immediate_work evaluate state flags with bitwise ALU instead of short-circuit branches
Diffstat (limited to 'src/wayland/buffer.c')
-rw-r--r--src/wayland/buffer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wayland/buffer.c b/src/wayland/buffer.c
index 0d639e6..0b6b028 100644
--- a/src/wayland/buffer.c
+++ b/src/wayland/buffer.c
@@ -305,10 +305,11 @@ static void arm_frame(struct yasl_surface *w)
}
}
-static const int8_t free_buf_lut[3][8] = {
+static const int8_t free_buf_lut[4][8] = {
[0] = { 1, 1, 2, 2, 1, 1, 0, -1 },
[1] = { 0, 2, 0, 2, 0, 1, 0, -1 },
[2] = { 0, 1, 0, 2, 0, 1, 0, -1 },
+ [3] = { 0, 1, 0, 2, 0, 1, 0, -1 },
};
int buffer_pick_free_index(const struct buffer *bufs, int cur)
@@ -316,9 +317,7 @@ int buffer_pick_free_index(const struct buffer *bufs, int cur)
unsigned busy = ((unsigned)bufs[0].busy) |
(((unsigned)bufs[1].busy) << 1) |
(((unsigned)bufs[2].busy) << 2);
- unsigned c = (unsigned)cur;
- if (unlikely(c >= 3)) c = 0;
- return free_buf_lut[c][busy];
+ return free_buf_lut[(unsigned)cur & 3][busy];
}
struct latency_feedback {