Fix source indexing with modulo

This commit is contained in:
giles
2026-02-04 10:22:23 +00:00
parent 92f8e8a98c
commit dd169635ca

View File

@@ -110,9 +110,10 @@
;; === OPTIMIZED PROCESS-PAIR MACRO === ;; === OPTIMIZED PROCESS-PAIR MACRO ===
;; Uses fused-pipeline to batch rotate+hue+invert into single kernel ;; Uses fused-pipeline to batch rotate+hue+invert into single kernel
(defmacro process-pair-fast (idx) (defmacro process-pair-fast (idx)
(let [;; Get sources for this pair (let [;; Get sources for this pair (with safe modulo indexing)
src-a (nth sources (* idx 2)) num-sources (len sources)
src-b (nth sources (+ (* idx 2) 1)) src-a (nth sources (mod (* idx 2) num-sources))
src-b (nth sources (mod (+ (* idx 2) 1) num-sources))
cfg (nth pair-configs idx) cfg (nth pair-configs idx)
pstate (nth (bind pairs :states) idx) pstate (nth (bind pairs :states) idx)