<commit_before>(in-package :cepl.transform-feedback)

(defun make-transform-feedback-stream (&rest buffer-backed-gpu-arrays)
  (assert (every (lambda (arr) (typep arr 'gpu-array-bb))
                 buffer-backed-gpu-arrays)
          (buffer-backed-gpu-arrays) 'invalid-args-in-make-tfs
          :args buffer-backed-gpu-arrays)
  (assert (every (lambda (arr)
                   (gpu-array-bb-element-type arr)
                   (= (mod (gpu-array-bb-byte-size arr) 4)
                      0))
                 buffer-backed-gpu-arrays)
          (buffer-backed-gpu-arrays) 'invalid-sizes-in-make-tfs
          :args buffer-backed-gpu-arrays)
  (let ((arrs (make-array (length buffer-backed-gpu-arrays)
                          :element-type 'gpu-array-bb
                          :initial-contents buffer-backed-gpu-arrays)))
    (%make-tfs :arrays arrs)))

(defmacro with-transform-feedback ((transform-feedback-stream) &body body)
  (alexandria:with-gensyms (ctx old-tfs new-tfs)
    `(with-cepl-context (,ctx)
       (%with-cepl-context-slots (default-framebuffer current-tfs)
           ,ctx
         (assert (not current-tfs) () 'nested-with-transform-feedback)
         (let ((,new-tfs ,transform-feedback-stream)
               (,old-tfs current-tfs))
           (setf current-tfs ,new-tfs)
           (setf (%tfs-bound ,new-tfs) t)
           (%bind-tfs-arrays ,ctx ,new-tfs)
           (release-unwind-protect (progn ,@body)
             (when (/= (%tfs-current-prog-id ,new-tfs) +unknown-gl-id+)
               (setf (%tfs-current-prog-id ,new-tfs) +unknown-gl-id+)<commit_msg>dont set current-tfs until binding succeeded<commit_after>(in-package :cepl.transform-feedback)

(defun make-transform-feedback-stream (&rest buffer-backed-gpu-arrays)
  (assert (every (lambda (arr) (typep arr 'gpu-array-bb))
                 buffer-backed-gpu-arrays)
          (buffer-backed-gpu-arrays) 'invalid-args-in-make-tfs
          :args buffer-backed-gpu-arrays)
  (assert (every (lambda (arr)
                   (gpu-array-bb-element-type arr)
                   (= (mod (gpu-array-bb-byte-size arr) 4)
                      0))
                 buffer-backed-gpu-arrays)
          (buffer-backed-gpu-arrays) 'invalid-sizes-in-make-tfs
          :args buffer-backed-gpu-arrays)
  (let ((arrs (make-array (length buffer-backed-gpu-arrays)
                          :element-type 'gpu-array-bb
                          :initial-contents buffer-backed-gpu-arrays)))
    (%make-tfs :arrays arrs)))

(defmacro with-transform-feedback ((transform-feedback-stream) &body body)
  (alexandria:with-gensyms (ctx old-tfs new-tfs)
    `(with-cepl-context (,ctx)
       (%with-cepl-context-slots (default-framebuffer current-tfs)
           ,ctx
         (assert (not current-tfs) () 'nested-with-transform-feedback)
         (let ((,new-tfs ,transform-feedback-stream)
               (,old-tfs current-tfs))
           (%bind-tfs-arrays ,ctx ,new-tfs)
           (setf current-tfs ,new-tfs)
           (setf (%tfs-bound ,new-tfs) t)
           (release-unwind-protect (progn ,@body)
             (when (/= (%tfs-current-prog-id ,new-tfs) +unknown-gl-id+)
               (setf (%tfs-current-prog-id ,new-tfs) +unknown-gl-id+)
{'fraction_non_alphanumeric': 0.14942528735632185, 'fraction_numerical': 0.0012426219322771047, 'mean_word_length': 2.0637488106565174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '926672', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1043, 'n_words': 186}