vk: pipe.lisp

graphics pipelines: the state a pipeline bakes in, and binding it.

vkCreateGraphicsPipelines source

(defvk vkCreateGraphicsPipelines (device cache count infos allocator pipelines)
  (:cost :create)
  (dotimes (i count)
    (vk-out pipelines i (vk-pipeline-bake vk (vk-elt VkGraphicsPipelineCreateInfo infos i))))
  (vk-value VK_SUCCESS))

vkCmdBindPipeline source

(defvk vkCmdBindPipeline (bind-point pipeline)
  (:cost :pipeline)
  (when (= bind-point (vk-value VK_PIPELINE_BIND_POINT_GRAPHICS))
    (setf (gs pipeline handle) pipeline)
    (vk-pipeline-apply vk pipeline)))

Other definitions

(defun vk-chain-find) source
(defun vk-chain-find (m addr stype)
  "the struct with sType STYPE in the pNext chain of the struct at ADDR, or 0"
  (declare (type vk-arena m) (type (unsigned-byte 64) addr) (type (unsigned-byte 32) stype))
  (let ((p (vk-read m VkBaseInStructure addr :p-next)))
    (loop
      (when (or (= p 0) (= (vk-read m VkBaseInStructure p :s-type) stype))
        (return p))
      (setq p (vk-read m VkBaseInStructure p :p-next)))))
(defmacro vk-chain) source
(defmacro vk-chain (m addr type)
  "the struct of TYPE in the pNext chain of the struct at ADDR, or 0"
  `(vk-chain-find ,m ,addr ,(vk-find-value (vkt-stype (vk-find-type type)))))
(defmacro define-pipeline-bake) source
(defmacro define-pipeline-bake (name params &body body)
  `(progn
     (eval-when (:compile-toplevel :load-toplevel :execute)
       (setq *vk-pipeline-writes* (gfx-collect-writes ',body)))
     (defun ,name ,params ,@body)))
(defmacro define-pipeline-apply) source
(defmacro define-pipeline-apply ()
  `(defun vk-pipeline-apply (vk handle)
     "Bind pipeline HANDLE: its baked fields replace the state's, except the dynamic ones"
     (declare (type vk-model vk) (type (unsigned-byte 64) handle))
     (when (and (> handle 0) (<= handle (vkm-pipe-count vk)))
       (let ((src (aref (vkm-pipes vk) (- handle 1)))
             (dynamic (aref (vkm-pipe-dynamic vk) (- handle 1)))
             (gfx (vkm-gfx vk)))
         (declare (ignorable dynamic))
         ,@(mapcar (lambda (f)
                     (let* ((acc (gfx-sym 'gfx (gff-slot f)))
                            (copy (if (and (gff-index f) (not (gff-count f)))
                                      `(dotimes (i ,(gff-index f))
                                         (setf (aref (,acc gfx) i) (aref (,acc src) i)))
                                      `(setf (,acc gfx) (,acc src))))
                            (mask (vk-field-dynamic-mask f)))
                       (if (= mask 0) copy `(when (= (logand dynamic ,mask) 0) ,copy))))
                   (gfx-baked-fields))))
     nil))

Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.