diff --git a/core/internals.lisp b/core/internals.lisp index 84eb2b41..eb4843d6 100644 --- a/core/internals.lisp +++ b/core/internals.lisp @@ -19,9 +19,13 @@ (let ((type (or (varjo.internals::try-type-spec->type array-type nil) (error 'bad-type-for-buffer-stream-data :type array-type)))) (if (and (varjo:core-typep type) (not (varjo:v-typep type 'v-sampler))) - (let ((slot-layout (cepl.types::expand-slot-to-layout - nil type normalized)) - (stride 0)) + (let* ((slot-layout (cepl.types::expand-slot-to-layout + nil type normalized)) + (stride (reduce (lambda (accum attr) + (incf accum (* (first attr) + (gl-type-size (second attr))))) + slot-layout + :initial-value 0))) (loop :for attr :in slot-layout :for i :from 0 :with offset = 0 diff --git a/core/types/structs.lisp b/core/types/structs.lisp index 46bbda1f..a969324c 100644 --- a/core/types/structs.lisp +++ b/core/types/structs.lisp @@ -260,7 +260,7 @@ (defun+ make-varjo-struct-def (name slots) (let ((hidden-name (symb-package (symbol-package name) - 'v_ name ))) + 'v_ name))) `(v-defstruct (,name :shadowing ,hidden-name) () @@ -465,11 +465,16 @@ (defun+ make-struct-attrib-assigner (type-name slots) (when (every #'buffer-stream-compatible-typep slots) - (let* ((stride (if (> (length slots) 1) + (let* ((def-sets (mapcat #'expand-slot-to-layout slots)) + (stride (if (> (length slots) 1) `(cepl.internals:gl-type-size ',type-name) - 0)) + (reduce (lambda (accum attr) + (incf accum (* (first attr) + (cepl.internals:gl-type-size + (second attr))))) + def-sets + :initial-value 0))) (stride-sym (gensym "stride")) - (def-sets (mapcat #'expand-slot-to-layout slots)) (definitions (loop :for (len cffi-type normalized gl-type) :in def-sets