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