├── .gitignore ├── LICENSE ├── README.md ├── cl-vulkan.asd ├── examples └── vkinfo.lisp ├── spec └── vk.xml ├── tools └── generate.lisp └── vk ├── bindings-package.lisp ├── bindings.lisp ├── extra-types.lisp ├── funcs.lisp ├── package.lisp ├── translators.lisp ├── types.lisp └── wrappers.lisp /.gitignore: -------------------------------------------------------------------------------- 1 | *.FASL 2 | *.fasl 3 | *.lisp-temp 4 | *~ 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 3b 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cl-vulkan 2 | low- to mid-level Common Lisp/CFFI bindings for Vulkan API 3 | 4 | ## TODO: low-level bindings 5 | 6 | `%VK:` package, autogenerated from [vk.xml](https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0/src/spec/vk.xml) 7 | 8 | Partially done, doesn't handle extensions yet. Exports and names of things subject to change. 9 | 10 | ## TODO: mid-level wrappers 11 | 12 | `VK:` package, probably CLOS wrappers for the various objects in vulkan API, utilities for filling buffers, etc 13 | 14 | ## TODO: examples 15 | 16 | vkinfo 17 | 18 | triangle 19 | -------------------------------------------------------------------------------- /cl-vulkan.asd: -------------------------------------------------------------------------------- 1 | (defsystem cl-vulkan 2 | :description "Common Lisp bindings for Vulkan API." 3 | :depends-on (cffi alexandria) 4 | :license "MIT" 5 | :author "Bart Botta <00003b at gmail.com>" 6 | :components 7 | ((:module "vk" 8 | :serial t 9 | :components ((:file "bindings-package") 10 | (:file "bindings") 11 | (:file "types") 12 | (:file "extra-types") 13 | (:file "funcs") 14 | (:file "translators") 15 | (:file "package") 16 | (:file "wrappers"))))) 17 | -------------------------------------------------------------------------------- /examples/vkinfo.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:vk) 2 | 3 | (vk:with-instance (instance) 4 | (when instance 5 | (let ((devices (enumerate-physical-devices instance))) 6 | (format t "~&instance layers: ~s~%" 7 | (enumerate-instance-layer-properties)) 8 | (format t "~&instance extensions: ~s~%" 9 | (enumerate-instance-extension-properties "")) 10 | (format t "~&got ~d devices~%" (length devices)) 11 | (loop for device in devices 12 | for i from 0 13 | for props = (get-physical-device-properties device) 14 | do (format t "device ~d: ~a~%" 15 | i (getf props :device-name)) 16 | (format t "device layers: ~s~%" 17 | (enumerate-device-layer-properties device)) 18 | (format t "device extensions: ~s~%" 19 | (enumerate-device-extension-properties device "")) 20 | (format t "queue families: ~s~%" 21 | (get-physical-device-queue-family-properties device)) 22 | (format t " limits:~% ~{~s ~s~^~% ~}~%" (getf props :limits)) 23 | (remf props :limits) 24 | (format t " properties:~% ~{~s ~s~^~% ~}~%" props) 25 | (format t " features:~% ~{~s ~S~^~% ~}~%" 26 | (get-physical-device-features device)) 27 | (let ((format :r8-snorm)) 28 | (format t " properties of format ~s :~%~{ ~s ~s~%~}" format 29 | (get-physical-device-format-properties device format))) 30 | (format t " physical device memory properties:~%~{ ~s ~s~%~}" 31 | (get-physical-device-memory-properties device)))))) 32 | -------------------------------------------------------------------------------- /tools/generate.lisp: -------------------------------------------------------------------------------- 1 | ;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- 2 | ;;; 3 | ;;; generate.lisp --- generate CFFI bindings from vk.xml file. 4 | ;;; 5 | ;;; Copyright (c) 2016, Bart Botta <00003b@gmail.com> 6 | ;;; All rights reserved. 7 | ;;; 8 | ;;; Permission is hereby granted, free of charge, to any person 9 | ;;; obtaining a copy of this software and associated documentation 10 | ;;; files (the "Software"), to deal in the Software without 11 | ;;; restriction, including without limitation the rights to use, copy, 12 | ;;; modify, merge, publish, distribute, sublicense, and/or sell copies 13 | ;;; of the Software, and to permit persons to whom the Software is 14 | ;;; furnished to do so, subject to the following conditions: 15 | ;;; 16 | ;;; The above copyright notice and this permission notice shall be 17 | ;;; included in all copies or substantial portions of the Software. 18 | ;;; 19 | ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 | ;;; DEALINGS IN THE SOFTWARE. 27 | ;;; 28 | (require :asdf) 29 | 30 | (eval-when (:compile-toplevel :load-toplevel :execute) 31 | (asdf:load-systems 'alexandria 'cl-ppcre 'split-sequence 32 | 'cxml 'xpath 'cxml-stp 'cffi)) 33 | 34 | 35 | (defvar *base-dir* (make-pathname :directory (pathname-directory 36 | (or *compile-file-pathname* 37 | *load-pathname*)))) 38 | 39 | (defparameter *in-package-name* "cl-vulkan-bindings") 40 | (defparameter *package-nicknames* "#:%vk") 41 | (defparameter *core-definer* "defvkfun") 42 | (defparameter *ext-definer* "defvkextfun") 43 | 44 | ;; from generator.py 45 | (defparameter *ext-base* 1000000000) 46 | (defparameter *ext-block-size* 1000) 47 | 48 | (defparameter *vk-api-version* nil) ;; (major minor patch) 49 | (defparameter *vk-last-updated* nil) 50 | ;; should we store a git hash or something like the svn version in cl-opengl? 51 | 52 | (defparameter *api-constants* (make-hash-table :test 'equal)) 53 | 54 | (defparameter *foo* nil) 55 | 56 | (defparameter *vk-platform* 57 | (alexandria:plist-hash-table '("void" :void 58 | "char" :char 59 | "float" :float 60 | "uint8_t" :uint8 61 | "uint32_t" :uint32 62 | "uint64_t" :uint64 63 | "int32_t" :int32 64 | "int" :int 65 | "size_t" size-t) 66 | :test 'equal)) 67 | (defparameter *opaque-types* 68 | '("a-native-window" "mir-connection" "mir-surface" 69 | "xcb_connection_t" "display")) 70 | (defparameter *opaque-struct-types* 71 | '("wl_display" "wl_surface" "SECURITY_ATTRIBUTES")) 72 | (defparameter *misc-os-types* 73 | '("hinstance" (:pointer :void) 74 | "hwnd" (:pointer :void) 75 | "HANDLE" (:pointer :void) 76 | "DWORD" :uint32 77 | "LPCWSTR" (:pointer :void) 78 | "RROutput" :ulong 79 | "xcb_window_t" :uint32 80 | "xcb_visualid_t" :uint32 81 | "window" :ulong 82 | "visual-id" :ulong)) 83 | (defvar *handle-types*) 84 | 85 | (defparameter *vendor-ids* '("KHX")) 86 | (defparameter *special-words* '("Bool32" "Win32" 87 | "16" "32" "64" 88 | "3d" "2d" "1d" 89 | "3D" "2D" "1D" 90 | "ID" "UUID" 91 | "HINSTANCE" "HWND" "HANDLE" "DWORD" "LPCWSTR" "SECURITY_ATTRIBUTES" 92 | "ETC2" "ASTC" "ASTC_" "LDR" "BC" "RR")) 93 | 94 | (defparameter *fix-must-be* 95 | (alexandria:alist-hash-table 96 | '((:pipeline-iinput-assembly-state-create-info 97 | . :pipeline-input-assembly-state-create-info) 98 | (:debug-report-callback-create-info 99 | . :debug-report-create-info-ext)))) 100 | ;; not sure if we should remove the type prefixes in struct members or 101 | ;; not? 102 | ;;(defparameter *type-prefixes* '("s-" "p-" "pfn-" "pp-")) 103 | 104 | (defun xps (node) 105 | (let ((s (string-trim '(#\space #\tab) (xpath:string-value node)))) 106 | (unless (string= s "") s))) 107 | 108 | (defun numeric-value (str) 109 | (cond 110 | ((not str) nil) 111 | ((alexandria:starts-with-subseq "0x" str) 112 | (parse-integer str :start 2 :radix 16)) 113 | ((ignore-errors (parse-integer str))) 114 | ((and (alexandria:ends-with #\f str) 115 | (ignore-errors (parse-number:parse-number str :end (1- (length str)))))) 116 | ((multiple-value-bind (m matches) 117 | (ppcre:scan-to-strings "\\(~0U(LL)?(-1)?\\)" str) 118 | (when m 119 | ;; fixme: is this right on all platforms? (or any for that matter?) 120 | (let ((off (if (aref matches 1) -2 -1))) 121 | (if (aref matches 0) 122 | (ldb (byte 64 0) off) 123 | (if (= 4 (cffi:foreign-type-size :uint)) 124 | (ldb (byte 32 0) off) 125 | (ldb (byte 64 0) off))))))) 126 | (t 127 | (error "~s" str)))) 128 | 129 | (defun fix-type-name (name) 130 | (if (not (stringp name)) 131 | name 132 | (let* ((start (if (alexandria:starts-with-subseq "Vk" name) 2 0))) 133 | (when (zerop start) 134 | (setf name (ppcre:regex-replace-all "PFN_vk" name "Pfn"))) 135 | (cffi:translate-camelcase-name (subseq name start) 136 | :special-words (append *special-words* 137 | *vendor-ids*))))) 138 | 139 | (defun fix-function-name (name) 140 | (let* ((start (if (alexandria:starts-with-subseq "vk" name) 2 0))) 141 | (cffi:translate-camelcase-name (subseq name start) 142 | :special-words (append *special-words* 143 | *vendor-ids*)))) 144 | 145 | (defun parse-arg-type (node gt &key stringify) 146 | (let* ((type-node (xpath:evaluate "type" node)) 147 | (.type (xps type-node)) 148 | (values (xps (xpath:evaluate "@values" node))) 149 | (len (xps (xpath:evaluate "@len" node))) 150 | (optional (xps (xpath:evaluate "@optional" node))) 151 | (name (cffi:translate-camelcase-name 152 | (xps (xpath:evaluate "name" node)) 153 | :special-words *special-words*)) 154 | (type (or (gethash .type *vk-platform*) (fix-type-name .type))) 155 | (prefix (xps (xpath:evaluate "type/preceding-sibling::text()" node))) 156 | (suffix (xps (xpath:evaluate "type/following-sibling::text()" node))) 157 | (namesuf (xps (xpath:evaluate "name/following-sibling::text()" node))) 158 | (enum (xps (xpath:evaluate "enum" node))) 159 | (following (xps (xpath:evaluate "following-sibling::comment()" node))) 160 | (desc)) 161 | (assert (not (set-difference (attrib-names node) 162 | '("len" "optional" "values" 163 | ;; todo: 164 | "noautovalidity" "externsync" "validextensionstructs") 165 | :test 'string=))) 166 | ;; just hard coding the const/pointer stuff for 167 | ;; now. adjust as the spec changes... 168 | (when prefix 169 | (assert (member prefix '("struct" "const") :test 'string=))) 170 | (when suffix 171 | (assert (member suffix '("*" "**" "* const*") :test 'string=))) 172 | ;; fixme: do something with the const? (generate comment if nothing else) 173 | (when gt 174 | (format t "@@@~s/~s (~s ~s)~% -> ~s~%" 175 | name .type prefix suffix 176 | (funcall gt type))) 177 | (flet ((struct-type () 178 | (if (and gt 179 | (member (funcall gt type) 180 | '(:struct :union))) 181 | (list (funcall gt type) type) 182 | type))) 183 | (cond 184 | ((and (or (not prefix) 185 | (string= prefix "const")) 186 | (not suffix)) 187 | (setf desc (list name (struct-type)))) 188 | ((and (string= prefix "struct") 189 | (string= suffix "*")) 190 | (setf desc `(,name (:pointer (:struct ,type))))) 191 | ((and (or (not prefix) 192 | (string= prefix "const")) 193 | (string= suffix "*")) 194 | (setf desc `(,name (:pointer ,(struct-type))))) 195 | ((and (string= prefix "const") 196 | (string= suffix "* const*")) 197 | (setf desc `(,name (:pointer (:pointer ,(struct-type)))))) 198 | ((and (not prefix) 199 | (string= suffix "**")) 200 | (setf desc `(,name (:pointer (:pointer ,(struct-type)))))) 201 | (t 202 | (error "failed to translate type ~s ~s ~s?" prefix type suffix) 203 | #++(setf desc (list :??? name type prefix suffix))))) 204 | (cond 205 | ((and stringify 206 | (equalp (second desc) '(:pointer :char)) 207 | (string= len "null-terminated")) 208 | (setf (second desc) :string)) 209 | #++((string= len "null-terminated") 210 | (error "unhandled len=~s" len))) 211 | (cond 212 | ((and values (alexandria:starts-with-subseq "VK_STRUCTURE_TYPE_" values)) 213 | (let ((k (make-keyword 214 | (substitute #\- #\_ (subseq values (length "VK_STRUCTURE_TYPE_")))))) 215 | (setf (getf (cddr desc) :must-be) (gethash k *fix-must-be* k))))) 216 | (when (or (find type *opaque-types* :test 'string-equal) 217 | (find type *opaque-struct-types* :test 'string-equal) 218 | (gethash .type *handle-types*) 219 | (eql type :void)) 220 | (format t " opaque!~%") 221 | (setf (getf (cddr desc) :opaque) t)) 222 | (when len 223 | (setf (getf (cddr desc) :len) 224 | (mapcar (lambda (a) 225 | (cond 226 | ((string= a "null-terminated") 227 | :null-terminated) 228 | ((alexandria:starts-with-subseq "latexmath:" a) 229 | a) 230 | ;; try to catch unmarked equations 231 | ((ppcre:scan "[:+-/*]" a) 232 | a) 233 | (t 234 | (make-keyword 235 | (cffi:translate-camelcase-name 236 | a :special-words *special-words*))))) 237 | (split-sequence:split-sequence #\, len)))) 238 | (when optional 239 | (setf (getf (cddr desc) :optional) 240 | (mapcar 'make-keyword 241 | (split-sequence:split-sequence #\, optional)))) 242 | (when enum 243 | (assert (gethash enum *api-constants*))) 244 | (if enum 245 | (push (gethash enum *api-constants*) (cddr desc)) 246 | (push nil (cddr desc))) 247 | (ppcre:register-groups-bind (x) ("\\[(\\d+)\\]" namesuf) 248 | (when x 249 | (setf (caddr desc) (parse-integer x)))) 250 | desc)) 251 | 252 | (defun attrib-names (node) 253 | (mapcar 'cxml-stp:local-name (cxml-stp:list-attributes node))) 254 | 255 | (defun make-keyword (name) 256 | (alexandria:make-keyword (string-upcase name))) 257 | 258 | (defun make-const-keyword (name) 259 | (let ((start (if (alexandria:starts-with-subseq "VK_" name) 3 0))) 260 | (alexandria:make-keyword 261 | (subseq (substitute #\- #\_ name) start)))) 262 | 263 | (defun fix-bit-name (name &key (prefix "VK_")) 264 | ;; fixme: cache compiled regex instead of rebuilding from string on every call 265 | (substitute #\- #\_ 266 | (ppcre:regex-replace-all (format nil "(^~a|_BIT(~{_~a~^|~})?$)" 267 | prefix *vendor-ids*) 268 | name ""))) 269 | 270 | ;; read from data files 271 | (let* ((this-dir *base-dir*) 272 | (relative-vk (make-pathname :directory '(:relative :up "vk"))) 273 | (vk-dir (merge-pathnames relative-vk this-dir)) 274 | (relative-spec (make-pathname :directory '(:relative :up "spec"))) 275 | (spec-dir (merge-pathnames relative-spec this-dir)) 276 | (binding-package-file (merge-pathnames "bindings-package.lisp" vk-dir)) 277 | (translators-file (merge-pathnames "translators.lisp" vk-dir)) 278 | (types-file (merge-pathnames "types.lisp" vk-dir)) 279 | (funcs-file (merge-pathnames "funcs.lisp" vk-dir)) 280 | #++(name-map (read-name-map vk-dir)) 281 | #++(types (read-known-types vk-dir)) 282 | (vk.xml (cxml:parse-file (merge-pathnames "vk.xml" spec-dir) 283 | (cxml:make-whitespace-normalizer 284 | (stp:make-builder)))) 285 | (copyright (xpath:string-value 286 | (xpath:evaluate "/registry/comment" vk.xml))) 287 | (bitfields (make-hash-table :test 'equal)) 288 | #++(types (alexandria:copy-hash-table *vk-platform* :test 'equal)) 289 | (types nil) ;; structs are ordered, so use an alist (actually need to order by hand anyway, so probably should switch back to hash) 290 | (enums (make-hash-table :test 'equal)) 291 | (structs (make-hash-table :test 'equal)) 292 | (funcs (make-hash-table :test 'equal)) 293 | (function-apis (make-hash-table :test 'equal)) 294 | (extension-names (make-hash-table :test 'equal)) 295 | (*handle-types* (make-hash-table :test 'equal)) 296 | #++(old-bindings (load-bindings vk-dir)) 297 | #++(old-enums (load-enums vk-dir))) 298 | (flet ((get-type (name) 299 | (cdr (assoc name types :test 'string=))) 300 | (get-type/f (name) 301 | (cdr (assoc name types :test (lambda (a b) 302 | (equalp 303 | (fix-type-name a) 304 | (fix-type-name b))))))) 305 | ;; remove some other text from the comment if present 306 | (let ((s (search "This file, vk.xml, is the " copyright))) 307 | (when s (setf copyright (string-trim '(#\space #\tab #\newline #\return) 308 | (subseq copyright 0 s))))) 309 | ;; make sure we still have a copyright notice 310 | (assert (search "Copyright" copyright)) 311 | 312 | ;; extract version info 313 | (let ((api (xpath:string-value 314 | (xpath:evaluate "/registry/types/type/name[.=\"VK_API_VERSION\"]/.." vk.xml)))) 315 | ;; #define VK_API_VERSION VK_MAKE_VERSION(1, 0, 3) 316 | (setf *vk-api-version* (map 'list 'parse-integer 317 | (nth-value 1 (ppcre::scan-to-strings "\\((\\d+),\\W*(\\d+),\\W*(\\d+)\\)" api))))) 318 | 319 | ;; TODO:? extract vendorids 320 | ;; extract tags 321 | (xpath:do-node-set (node (xpath:evaluate "/registry/tags/tag" vk.xml)) 322 | (let ((name (xps (xpath:evaluate "@name" node)))) 323 | (push name *vendor-ids*))) 324 | 325 | ;; extra pass to find struct/unions so we can mark them correctly 326 | ;; in member types 327 | (xpath:do-node-set (node (xpath:evaluate "/registry/types/type[(@category=\"struct\") or (@category=\"union\")]" vk.xml)) 328 | (let ((name (xps (xpath:evaluate "@name" node))) 329 | (category (xps (xpath:evaluate "@category" node)))) 330 | (setf (gethash (fix-type-name name) structs) 331 | (make-keyword category)))) 332 | 333 | ;; and extract "API constants" enum first too for member array sizes 334 | (xpath:do-node-set (enum (xpath:evaluate "/registry/enums[(@name=\"API Constants\")]/enum" vk.xml)) 335 | (let ((name (xps (xpath:evaluate "@name" enum))) 336 | (value (numeric-value (xps (xpath:evaluate "@value" enum))))) 337 | (when (gethash name *api-constants*) 338 | (assert (= value (gethash name *api-constants*)))) 339 | (setf (gethash name *api-constants*) value))) 340 | 341 | ;; extract handle types so we can mark them as pointers for translators 342 | (xpath:do-node-set (node (xpath:evaluate "/registry/types/type[(@category=\"handle\")]" vk.xml)) 343 | (let ((name (xps (xpath:evaluate "name" node)))) 344 | (setf (gethash name *handle-types*) t))) 345 | 346 | ;; extract types 347 | ;; todo:? VK_DEFINE_HANDLE VK_DEFINE_NON_DISPATCHABLE_HANDLE 348 | ;; #define VK_NULL_HANDLE 0 349 | (xpath:do-node-set (node (xpath:evaluate "/registry/types/type[not(apientry) and not(@category=\"include\") and not(@category=\"define\")]" vk.xml)) 350 | (let ((name (xps (xpath:evaluate "name" node))) 351 | (@name (xps (xpath:evaluate "@name" node))) 352 | (type (xps (xpath:evaluate "type" node))) 353 | (type* (mapcar 'xpath:string-value (xpath:all-nodes (xpath:evaluate "type" node)))) 354 | (category (xps (xpath:evaluate "@category" node))) 355 | (parent (xps (xpath:evaluate "@parent" node))) 356 | (requires (xps (xpath:evaluate "@requires" node))) 357 | (comment (xps (xpath:evaluate "@comment" node))) 358 | (returnedonly (xps (xpath:evaluate "@returnedonly" node))) 359 | (attribs (attrib-names node))) 360 | ;; make sure nobody added any attributes we might care about 361 | (assert (not (set-difference attribs 362 | '("name" "category" "parent" "requires" 363 | "comment" 364 | ;; todo: 365 | "returnedonly") 366 | :test 'string=))) 367 | (flet ((set-type (value) 368 | (let ((name (or name @name))) 369 | (if (get-type name) 370 | (assert (equalp value (get-type name))) 371 | (push (cons name value) types))))) 372 | (cond 373 | ((string= requires "vk_platform") 374 | ;; make sure we have a mapping for everything in vk_platform.h 375 | (assert (gethash @name *vk-platform*))) 376 | ((and requires (search ".h" requires)) 377 | ;; and make a note of other missing types 378 | ;; (not sure if we will need definitions for these or not?) 379 | (unless (gethash @name *vk-platform*) 380 | (format t "Unknown platform type ~s from ~s (~s)?~%" @name requires name))) 381 | ((string= category "basetype") 382 | ;; type alias 383 | (assert (and name type)) 384 | (format t "new base type ~s -> ~s~%" name type) 385 | (set-type (list :alias (or (gethash type *vk-platform*) 386 | (fix-type-name type))))) 387 | ((string= category "bitmask") 388 | (format t "new bitmask ~s -> ~s~% ~s~%" name type 389 | (mapcar 'xps (xpath:all-nodes (xpath:evaluate "@*" node)))) 390 | (setf (gethash name bitfields) (list requires :type type)) 391 | (set-type (list :bitmask type))) 392 | ((string= category "handle") 393 | (let ((dispatch (cond 394 | ((string= type "VK_DEFINE_HANDLE") 395 | :handle) 396 | ((string= type "VK_DEFINE_NON_DISPATCHABLE_HANDLE") 397 | :non-dispatch-handle) 398 | (t 399 | (error "unknown handle type ~s?" type))))) 400 | (format t "new handle ~s / ~s ~s~%" parent name type) 401 | (set-type (list dispatch type)))) 402 | ((string= category "enum") 403 | (assert (not (or requires type name parent))) 404 | (format t "new enum type ~s~%" @name) 405 | (set-type (list :enum type))) 406 | ((string= category "funcpointer") 407 | (format t "new function pointer type ~s ~s~%" name type*) 408 | (let* ((types (mapcar 'xps (xpath:all-nodes (xpath:evaluate "type" node)))) 409 | (before-name (xps (xpath:evaluate "name/preceding-sibling::text()" node))) 410 | (rt (ppcre:regex-replace-all "(^typedef | \\(VKAPI_PTR \\*$)" 411 | before-name "")) 412 | (before (xpath:all-nodes (xpath:evaluate "type/preceding-sibling::text()" node))) 413 | (after (xpath:all-nodes (xpath:evaluate "type/following-sibling::text()" node))) 414 | (args (loop for at in types 415 | for a in after 416 | for b in before 417 | for star = (count #\* (xps a)) 418 | for const = (search "const" (xps b)) 419 | for an = (ppcre:regex-replace-all "(\\*|\\W|,|const|\\)|;)" (xps a) "") 420 | when (plusp star) do (assert (= star 1)) 421 | collect (list (format nil "~a~@[/const~]" 422 | an const) 423 | (if (plusp star) 424 | `(:pointer ,(fix-type-name at)) 425 | (fix-type-name at)))))) 426 | (let ((c (count #\* rt))) 427 | (setf rt (fix-type-name (string-right-trim '(#\*) rt))) 428 | (setf rt (or (gethash rt *vk-platform*) rt)) 429 | (loop repeat c do (setf rt (list :pointer rt)))) 430 | (set-type (list :func :type (list rt args))))) 431 | ((or (string= category "struct") 432 | (string= category "union")) 433 | (let ((members nil)) 434 | (xpath:do-node-set (member (xpath:evaluate "member" node)) 435 | (push (parse-arg-type member (lambda (a) (gethash a structs)) 436 | :stringify returnedonly) 437 | members)) 438 | (setf members (nreverse members)) 439 | (format t "new ~s ~s: ~%~{ ~s~^~%~}~%" 440 | category @name members) 441 | (set-type `(,(if (string= category "struct") 442 | :struct 443 | :union) 444 | , @name 445 | :members ,members 446 | :returned-only ,returnedonly 447 | ,@(when comment (list :comment comment)))))) 448 | (t 449 | (format t "unknown type category ~s for name ~s~%" 450 | category (or name @name))))))) 451 | 452 | ;;; enums* 453 | (xpath:do-node-set (node (xpath:evaluate "/registry/enums" vk.xml)) 454 | (let* ((name (xps (xpath:evaluate "@name" node))) 455 | (comment (xps (xpath:evaluate "@comment" node))) 456 | (type (xps (xpath:evaluate "@type" node))) 457 | (expand (xps (xpath:evaluate "@expand" node))) 458 | (namespace (xps (xpath:evaluate "@namespace" node))) 459 | (attribs (attrib-names node)) 460 | (enums (xpath:all-nodes (xpath:evaluate "enum" node))) 461 | (enum-type (get-type name))) 462 | ;; make sure nobody added any attributes we might care about 463 | (assert (not (set-difference attribs 464 | '("namespace" "name" 465 | "type" "expand" "comment") 466 | :test 'string=))) 467 | (unless (string= name "API Constants") 468 | (assert (get-type name))) 469 | (assert (not (second enum-type))) 470 | (loop for enum in enums 471 | for name2 = (xps (xpath:evaluate "@name" enum)) 472 | for value = (numeric-value (xps (xpath:evaluate "@value" enum))) 473 | for bitpos = (numeric-value (xps (xpath:evaluate "@bitpos" enum))) 474 | for comment2 = (xps (xpath:evaluate "@comment" enum)) 475 | unless (string= name "API Constants") 476 | do (assert (not (and bitpos value))) 477 | (assert (or bitpos value)) 478 | (push `(,name2 ,(or value (ash 1 bitpos)) 479 | ,@(when comment2 (list :comment comment2))) 480 | (second enum-type))) 481 | (when (second enum-type) 482 | (setf (second enum-type) 483 | (nreverse (second enum-type)))) 484 | (when type 485 | (setf (getf (cddr enum-type) :type) (make-keyword type)) 486 | (format t "add bitmask ~s ~s~%" name type) 487 | (when (and (string= type "bitmask") 488 | (not (gethash name bitfields))) 489 | (setf (gethash name bitfields) 490 | (list nil :type nil)))) 491 | (when expand 492 | (setf (getf (cddr enum-type) :expand) expand)) 493 | (when namespace 494 | (setf (getf (cddr enum-type) :namespace) namespace)))) 495 | ;;; commands 496 | (xpath:do-node-set (node (xpath:evaluate "/registry/commands/command" vk.xml)) 497 | (let* ((name (xps (xpath:evaluate "proto/name" node))) 498 | (type (xps (xpath:evaluate "proto/type" node))) 499 | #++(proto (xpath:evaluate "proto" node)) 500 | (.params (xpath:all-nodes (xpath:evaluate "param" node))) 501 | (successcodes (xps (xpath:evaluate "@successcodes" node))) 502 | (errorcodes (xps (xpath:evaluate "@errorcodes" node))) 503 | (queues (xps (xpath:evaluate "@queues" node))) 504 | (cmdbufferlevel (xps (xpath:evaluate "@cmdbufferlevel" node))) 505 | (renderpass (xps (xpath:evaluate "@renderpass" node))) 506 | (pipeline (xps (xpath:evaluate "@pipeline" node))) 507 | (attribs (attrib-names node))) 508 | ;; make sure nobody added any attributes we might care about 509 | (assert (not (set-difference attribs 510 | '("successcodes" "errorcodes" "queues" 511 | "cmdbufferlevel" "renderpass" 512 | ;; todo: 513 | "pipeline" "comment") 514 | :test 'string=))) 515 | (let ((params 516 | (loop for p in .params 517 | for optional = (xps (xpath:evaluate "@optional" p)) 518 | for externsync = (xps (xpath:evaluate "@externsync" p)) 519 | for len = (xps (xpath:evaluate "@len" p)) 520 | for noautovalidity = (xps (xpath:evaluate "@noautovalidity" p)) 521 | for desc = (parse-arg-type p (lambda (a) 522 | (gethash a structs)) 523 | :stringify t) 524 | for attribs = (attrib-names p) 525 | do 526 | (assert (not (set-difference attribs 527 | '("optional" "externsync" 528 | "len" "noautovalidity") 529 | :test 'string=))) 530 | collect `(,desc 531 | ,@(when optional (list :optional optional)) 532 | ,@(when len (list :len len)) 533 | ,@(when noautovalidity (list :noautovalidity noautovalidity)) 534 | ,@(when externsync (list :externsync externsync)))))) 535 | (flet ((kw-list (x &key (translate #'make-keyword)) 536 | (mapcar translate 537 | (split-sequence:split-sequence #\, x :remove-empty-subseqs t)))) 538 | (setf (gethash name funcs) 539 | (list (or (gethash type *vk-platform*) type) 540 | params 541 | :success (kw-list successcodes 542 | :translate 'make-const-keyword) 543 | :errors (kw-list errorcodes 544 | :translate 'make-const-keyword) 545 | :queues (kw-list queues) 546 | :command-buffer-level (kw-list cmdbufferlevel) 547 | :renderpass (kw-list renderpass))))))) 548 | 549 | ;;; TODO: feature 550 | ;;; extensions 551 | ;; mostly just expanding the enums, since the new struct/functions 552 | ;; definitions are included with core definitions earlier. 553 | ;; probably will eventually want to mark which names go with which 554 | ;; version/extension though. 555 | (xpath:do-node-set (node (xpath:evaluate "/registry/extensions/extension/require/enum" vk.xml)) 556 | (let* ((ext (xps (xpath:evaluate "../../@name" node))) 557 | (ext-number (parse-integer 558 | (xps (xpath:evaluate "../../@number" node)))) 559 | (api (xps (xpath:evaluate "../../@supported" node))) 560 | (value (xps (xpath:evaluate "@value" node))) 561 | (.name (xps (xpath:evaluate "@name" node))) 562 | (name (make-const-keyword .name)) 563 | (extends (xps (xpath:evaluate "@extends" node))) 564 | (offset (xps (xpath:evaluate "@offset" node))) 565 | (bitpos (xps (xpath:evaluate "@bitpos" node))) 566 | (dir (xps (xpath:evaluate "@dir" node))) 567 | (attribs (attrib-names node))) 568 | (assert (not (set-difference attribs 569 | '("value" "name" "extends" "offset" "dir" "bitpos" 570 | ;; todo: 571 | "comment") 572 | :test 'string=))) 573 | (when (and (not extends) 574 | (alexandria:ends-with-subseq "_EXTENSION_NAME" .name)) 575 | ;; todo: do something with the version/ext name enums 576 | (setf (gethash ext extension-names) 577 | (ppcre:regex-replace-all """ value ""))) 578 | (when extends 579 | (let ((extend (get-type extends))) 580 | (assert (or (and offset (not value) (not bitpos)) 581 | ;; see comment in vk.xml; should be a special case 582 | (and (string= .name "VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE") (not offset) value (not bitpos)) 583 | (and (not offset) (not value) bitpos))) 584 | (setf (getf extend :enum) 585 | (append (getf extend :enum) 586 | (list (list .name (* 587 | (if (equalp dir "-") 588 | -1 589 | 1) 590 | (or (and offset (+ *ext-base* 591 | (* *ext-block-size* (1- ext-number)) 592 | (parse-integer offset))) 593 | (and value (parse-integer value)) 594 | (and bitpos (ash 1 (parse-integer bitpos))))) 595 | :ext (format nil "~a" ext))))))) 596 | (format t "ext: ~s ~s ~s ~s ~s~%" value name extends (or offset value bitpos) dir))) 597 | ;; and also mark which functions are from extensions 598 | (xpath:do-node-set (node (xpath:evaluate "/registry/extensions/extension/require/command" vk.xml)) 599 | (let* ((ext (xps (xpath:evaluate "../../@name" node))) 600 | (name (xps (xpath:evaluate "@name" node))) 601 | (attribs (attrib-names node))) 602 | (assert (not (set-difference attribs 603 | '("name") 604 | :test 'string=))) 605 | (assert (gethash name funcs)) 606 | (setf (getf (cddr (gethash name funcs)) :ext) 607 | ext) 608 | (format t "extf: ~s ~s~%" name ext))) 609 | 610 | (setf types (nreverse types)) 611 | 612 | ;; write types file 613 | (with-open-file (out types-file :direction :output :if-exists :supersede) 614 | (format out ";;; this file is automatically generated, do not edit~%") 615 | (format out "#||~%~a~%||#~%~%" copyright) 616 | (format out "(in-package #:cl-vulkan-bindings)~%~%") 617 | ;; extension names 618 | (format out "(defparameter *extension-names*~% (alexandria:plist-hash-table~% '(~{~(:~a~) ~a~^~% ~})))~%~%" 619 | (loop for (k . v) in (alexandria:hash-table-alist extension-names) 620 | collect (ppcre:regex-replace-all 621 | "^VK-" (substitute #\- #\_ k) "") 622 | collect v)) 623 | 624 | ;; type aliases 625 | (loop for (name . attribs) in (remove-if-not 626 | (lambda (x) 627 | (and (consp (cdr x)) 628 | (eql (second x) :alias))) 629 | types) 630 | do (format out "~((defctype ~a ~s)~)~%~%" 631 | (fix-type-name name) (second attribs))) 632 | (format out "(defctype handle :pointer)~%") 633 | (format out "#.(if (= 8 (foreign-type-size :pointer))~% '(defctype non-dispatch-handle :pointer)~% '(defctype non-dispatch-handle :uint64))~%~%") 634 | ;; misc OS types that are just passed around as pointers 635 | (loop for name in *opaque-types* 636 | ;; fixme: is there a better type to use here? or use empty struct? 637 | do (format out "~((defctype ~a :void)~)~%~%" 638 | (fix-type-name name))) 639 | (loop for (name type) on *misc-os-types* by #'cddr 640 | do (format out "~((defctype ~a ~s)~)~%~%" 641 | (fix-type-name name) type)) 642 | (loop for name in *opaque-struct-types* 643 | do (format out "~((defcstruct ~a)~)~%~%" 644 | (fix-type-name name))) 645 | ;; handles 646 | (loop for (name . attribs) in (remove-if-not 647 | (lambda (x) 648 | (and (consp (cdr x)) 649 | (member (second x) 650 | '(:handle 651 | :non-dispatch-handle)))) 652 | types) 653 | ;; handles are pointers to foo_T struct 654 | ;; on 32bit platform, 'non-dispatch' handles are 64bit int, 655 | ;; otherwise pointer to foo_T struct 656 | do (format out "(~(defctype ~a ~a~))~%~%" 657 | (fix-type-name name) 658 | (car attribs))) 659 | ;; bitfields 660 | (loop for (name . attribs) in (sort (alexandria:hash-table-alist bitfields) 661 | 'string< :key 'car) 662 | for base-type = (second (get-type name)) 663 | for requires = (first attribs) 664 | for bits = (if (consp base-type) 665 | base-type 666 | (second (when requires 667 | (get-type requires)))) 668 | for prefix = "VK_" 669 | for fixed-name = (string (fix-type-name name)) 670 | do (format out "(defbitfield (~(~a~@[ ~a~]~))" fixed-name 671 | (when (stringp base-type) (fix-type-name base-type))) 672 | ;; possibly shouldn't strip prefix from things like 673 | ;; VK_QUERY_RESULT_64_BIT or VK_SAMPLE_COUNT_1_BIT where 674 | ;; only :64 or :1 is left? 675 | (let ((p (search "-FLAG" fixed-name))) 676 | (when p 677 | (setf prefix (format nil "VK_~a" 678 | (substitute #\_ #\- (subseq fixed-name 0 (1+ p))))) 679 | (format t "prefix -> ~s~%" prefix))) 680 | (loop for ((k . v) . more) on bits 681 | for comment = (getf (cdr v) :comment) 682 | do (format out "~% (:~(~a~) #x~x)" 683 | (fix-bit-name k :prefix prefix) 684 | (first v)) 685 | unless more 686 | do (format out ")") 687 | when comment 688 | do (format out " ;; ~a" comment)) 689 | (format out "~:[)~;~]~%~%" bits)) 690 | 691 | ;; enums 692 | (loop for (name . attribs) in (sort (remove-if-not 693 | (lambda (x) 694 | (and (consp (cdr x)) 695 | (eql (second x) :enum))) 696 | types) 697 | 'string< :key 'car) 698 | for type = (getf (cddr attribs) :type) 699 | for expand = (getf (cddr attribs) :expand) 700 | for requires = (getf (cddr attribs) :requires) 701 | for bits = (second attribs) 702 | for prefix = "VK_" 703 | for fixed-name = (string (fix-type-name name)) 704 | unless (or (eq type :bitmask) 705 | (and (not bits) 706 | (alexandria:ends-with-subseq "Bits" name))) 707 | do 708 | (if (string-equal fixed-name "RESULT") 709 | ;; work around cffi bug: cffi always uses unsigned 710 | ;; type for enums, and VkResult has negative values 711 | (format out "(defcenum (~(~a :int~))" fixed-name) 712 | (format out "(defcenum (~(~a~))" fixed-name)) 713 | (when bits 714 | ;; find longest prefix out of VK_, name - vendor, and expand 715 | (when expand 716 | (let ((l (loop for (k) in bits 717 | minimize (or (mismatch expand k) 0)))) 718 | (when (> l (length prefix)) 719 | (setf prefix (subseq expand 0 l))))) 720 | (let* ((p (loop for v in *vendor-ids* 721 | thereis (search v fixed-name))) 722 | (n (format nil "VK_~a" 723 | (substitute #\_ #\- 724 | (if p 725 | (subseq fixed-name 0 (- p 1)) 726 | fixed-name)))) 727 | (l (loop for (k) in bits 728 | minimize (or (mismatch n k) 0)))) 729 | (when (> l (length prefix)) 730 | (setf prefix (subseq n 0 l))))) 731 | (loop for ((k . v) . more) on bits 732 | for comment = (getf (cdr v) :comment) 733 | for ext = (getf (cdr v) :ext) 734 | do (format out "~% (:~(~a~) ~:[#x~x~;~d~])" 735 | (string-trim '(#\-) (fix-bit-name k :prefix prefix)) 736 | (minusp (first v)) (first v)) 737 | unless more 738 | do (format out ")") 739 | when (or ext comment) 740 | do (format out " ;;~@[ ~a~]~@[ ~a~]" ext comment)) 741 | (format out "~:[)~;~]~%~%" bits) 742 | (when (string-equal fixed-name "RESULT") 743 | ;; write out error->comment, since they seem useful 744 | ;; enough to print out to users in errors 745 | (format out "(defparameter *result-comments*~% (alexandria:plist-hash-table~% '(~{~(:~a~) ~s~^~% ~})))~%~%" 746 | (loop for (k nil . v) in bits 747 | collect (string-trim '(#\-) (fix-bit-name k :prefix prefix)) 748 | collect (getf v :comment))))) 749 | 750 | ;; function pointer types 751 | (loop for (name . attribs) in (sort (remove-if-not 752 | (lambda (x) 753 | (and (consp (cdr x)) 754 | (eql (second x) :func))) 755 | types) 756 | 'string< :key 'car) 757 | do (format out "~( ~<;; ~@;~a~;~:>~%(defctype ~a :pointer)~)~%~%" 758 | (list (cons "defcallback x" (getf (cdr attribs) :type))) 759 | (fix-type-name name))) 760 | 761 | ;; structs/unions 762 | (loop with dumped = (make-hash-table :test 'equal) 763 | for (name . attribs) in (sort (remove-if-not 764 | (lambda (x) 765 | (and (consp (cdr x)) 766 | (member (second x) 767 | '(:struct :union)))) 768 | types) 769 | 'string< :key 'car) 770 | do (labels 771 | ((dump (name) 772 | (if (and (consp name) 773 | (member (car name) '(:pointer :struct :union))) 774 | (dump (second name)) 775 | (when (and (gethash (fix-type-name name) structs) 776 | (not (gethash name dumped))) 777 | (let* ((attribs (get-type/f name)) 778 | (members (getf (cddr attribs) :members))) 779 | (loop for (nil mt) in members 780 | do (dump mt)) 781 | (format out "(defc~(~a~) ~(~a~)" (first attribs) 782 | (fix-type-name name)) 783 | (format out 784 | "~{~% ~1{(:~(~a ~s~@[ :count ~a~])~^#|~@{~a~^ ~}|#~)~}~}" 785 | members) 786 | (format out "~:[)~;~]~%~%" nil) 787 | (setf (gethash name dumped) t)))))) 788 | (dump name)))) 789 | 790 | ;; write functions file 791 | (with-open-file (out funcs-file :direction :output :if-exists :supersede) 792 | (format out ";;; this file is automatically generated, do not edit~%") 793 | (format out "#||~%~a~%||#~%~%" copyright) 794 | (format out "(in-package #:cl-vulkan-bindings)~%~%") 795 | (loop for (name . attribs) in (sort (alexandria:hash-table-alist funcs) 796 | 'string< :key 'car) 797 | for ret = (first attribs) 798 | for args = (second attribs) 799 | for success = (getf (cddr attribs) :success) 800 | for errors = (getf (cddr attribs) :errors) 801 | for queues = (getf (cddr attribs) :queues) 802 | for cbl = (getf (cddr attribs) :command-buffer-level) 803 | for ext = (getf (cddr attribs) :ext) 804 | do (format out "(~a (~s ~(~a) ~a~)" 805 | (if ext *ext-definer* *core-definer*) 806 | name 807 | (fix-function-name name) 808 | (cond 809 | ((string-equal ret "VkResult") 810 | "checked-result") 811 | ((keywordp ret) 812 | (format nil "~s" ret)) 813 | (t (fix-type-name ret)))) 814 | (loop with *print-right-margin* = 10000 815 | for (arg . opts) in args 816 | do (format out "~& ~1{~((~a ~s)~)~}" arg) 817 | when opts do (format out " ;; ~{~s~^ ~}~%" opts)) 818 | (format out ")~%~%"))) 819 | 820 | ;; write package file 821 | (with-open-file (out binding-package-file 822 | :direction :output :if-exists :supersede) 823 | (format out ";;; this file is automatically generated, do not edit~%") 824 | (format out "#||~%~a~%||#~%~%" copyright) 825 | (format out "(defpackage #:cl-vulkan-bindings~% (:use #:cl #:cffi)~%") 826 | (format out " (:nicknames #:%vk)~%") 827 | (format out " (:export~%") 828 | (loop for (type . (typetype)) in (sort (copy-list types) 829 | 'string< :key 'car) 830 | do (format out "~( #:~a ;; ~s~)~%" 831 | (fix-type-name type) typetype)) 832 | (format out "~%") 833 | (loop for (func) in (sort (alexandria:hash-table-alist funcs) 834 | 'string< :key 'car) 835 | do (format out "~( #:~a~)~%" (fix-function-name func))) 836 | (format out "))~%")) 837 | 838 | ;; write struct translators 839 | ;; possibly should do this while dumping struct types? 840 | (with-open-file (out translators-file 841 | :direction :output :if-exists :supersede) 842 | (format out ";;; this file is automatically generated, do not edit~%") 843 | (format out "#||~%~a~%||#~%~%" copyright) 844 | (format out "(in-package #:cl-vulkan-bindings)~%~%") 845 | (loop for (name . attribs) in (sort (remove-if-not 846 | (lambda (x) 847 | (and (consp (cdr x)) 848 | (member (second x) 849 | '(:struct :union)))) 850 | types) 851 | 'string< :key 'car) 852 | for members = (getf (cddr attribs) :members) 853 | do (format out "~((def-translator ~a (deref-~a ~:[:fill fill-~a~;~])~)~%" 854 | (fix-type-name name) 855 | (fix-type-name name) 856 | (getf (cddr attribs) :returned-only) 857 | (fix-type-name name)) 858 | (loop for m in members 859 | do (format out "~& ~((:~{~s~^ ~})~)" m)) 860 | (format out ")~%~%"))) 861 | 862 | ;; todo: print out changes 863 | (force-output) 864 | nil)) 865 | -------------------------------------------------------------------------------- /vk/bindings-package.lisp: -------------------------------------------------------------------------------- 1 | ;;; this file is automatically generated, do not edit 2 | #|| 3 | Copyright (c) 2015-2017 The Khronos Group Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and/or associated documentation files (the 7 | "Materials"), to deal in the Materials without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Materials, and to 10 | permit persons to whom the Materials are furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Materials. 15 | 16 | THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 23 | 24 | ------------------------------------------------------------------------ 25 | ||# 26 | 27 | (defpackage #:cl-vulkan-bindings 28 | (:use #:cl #:cffi) 29 | (:nicknames #:%vk) 30 | (:export 31 | #:pfn-allocation-function ;; :func 32 | #:pfn-debug-report-callback-ext ;; :func 33 | #:pfn-free-function ;; :func 34 | #:pfn-internal-allocation-notification ;; :func 35 | #:pfn-internal-free-notification ;; :func 36 | #:pfn-reallocation-function ;; :func 37 | #:pfn-void-function ;; :func 38 | #:access-flag-bits ;; :enum 39 | #:access-flags ;; :bitmask 40 | #:acquire-next-image-info-khx ;; :struct 41 | #:allocation-callbacks ;; :struct 42 | #:android-surface-create-flags-khr ;; :bitmask 43 | #:android-surface-create-info-khr ;; :struct 44 | #:application-info ;; :struct 45 | #:attachment-description ;; :struct 46 | #:attachment-description-flag-bits ;; :enum 47 | #:attachment-description-flags ;; :bitmask 48 | #:attachment-load-op ;; :enum 49 | #:attachment-reference ;; :struct 50 | #:attachment-store-op ;; :enum 51 | #:bind-buffer-memory-info-khx ;; :struct 52 | #:bind-image-memory-info-khx ;; :struct 53 | #:bind-image-memory-swapchain-info-khx ;; :struct 54 | #:bind-sparse-info ;; :struct 55 | #:blend-factor ;; :enum 56 | #:blend-op ;; :enum 57 | #:bool32 ;; :alias 58 | #:border-color ;; :enum 59 | #:buffer ;; :non-dispatch-handle 60 | #:buffer-copy ;; :struct 61 | #:buffer-create-flag-bits ;; :enum 62 | #:buffer-create-flags ;; :bitmask 63 | #:buffer-create-info ;; :struct 64 | #:buffer-image-copy ;; :struct 65 | #:buffer-memory-barrier ;; :struct 66 | #:buffer-usage-flag-bits ;; :enum 67 | #:buffer-usage-flags ;; :bitmask 68 | #:buffer-view ;; :non-dispatch-handle 69 | #:buffer-view-create-flag-bits ;; :enum 70 | #:buffer-view-create-flags ;; :bitmask 71 | #:buffer-view-create-info ;; :struct 72 | #:clear-attachment ;; :struct 73 | #:clear-color-value ;; :union 74 | #:clear-depth-stencil-value ;; :struct 75 | #:clear-rect ;; :struct 76 | #:clear-value ;; :union 77 | #:cmd-process-commands-info-nvx ;; :struct 78 | #:cmd-reserve-space-for-commands-info-nvx ;; :struct 79 | #:color-component-flag-bits ;; :enum 80 | #:color-component-flags ;; :bitmask 81 | #:color-space-khr ;; :enum 82 | #:command-buffer ;; :handle 83 | #:command-buffer-allocate-info ;; :struct 84 | #:command-buffer-begin-info ;; :struct 85 | #:command-buffer-inheritance-info ;; :struct 86 | #:command-buffer-level ;; :enum 87 | #:command-buffer-reset-flag-bits ;; :enum 88 | #:command-buffer-reset-flags ;; :bitmask 89 | #:command-buffer-usage-flag-bits ;; :enum 90 | #:command-buffer-usage-flags ;; :bitmask 91 | #:command-pool ;; :non-dispatch-handle 92 | #:command-pool-create-flag-bits ;; :enum 93 | #:command-pool-create-flags ;; :bitmask 94 | #:command-pool-create-info ;; :struct 95 | #:command-pool-reset-flag-bits ;; :enum 96 | #:command-pool-reset-flags ;; :bitmask 97 | #:command-pool-trim-flags-khr ;; :bitmask 98 | #:compare-op ;; :enum 99 | #:component-mapping ;; :struct 100 | #:component-swizzle ;; :enum 101 | #:composite-alpha-flag-bits-khr ;; :enum 102 | #:composite-alpha-flags-khr ;; :bitmask 103 | #:compute-pipeline-create-info ;; :struct 104 | #:copy-descriptor-set ;; :struct 105 | #:cull-mode-flag-bits ;; :enum 106 | #:cull-mode-flags ;; :bitmask 107 | #:d-3d-1-2-fence-submit-info-khx ;; :struct 108 | #:debug-marker-marker-info-ext ;; :struct 109 | #:debug-marker-object-name-info-ext ;; :struct 110 | #:debug-marker-object-tag-info-ext ;; :struct 111 | #:debug-report-callback-create-info-ext ;; :struct 112 | #:debug-report-callback-ext ;; :non-dispatch-handle 113 | #:debug-report-flag-bits-ext ;; :enum 114 | #:debug-report-flags-ext ;; :bitmask 115 | #:debug-report-object-type-ext ;; :enum 116 | #:dedicated-allocation-buffer-create-info-nv ;; :struct 117 | #:dedicated-allocation-image-create-info-nv ;; :struct 118 | #:dedicated-allocation-memory-allocate-info-nv ;; :struct 119 | #:dependency-flag-bits ;; :enum 120 | #:dependency-flags ;; :bitmask 121 | #:descriptor-buffer-info ;; :struct 122 | #:descriptor-image-info ;; :struct 123 | #:descriptor-pool ;; :non-dispatch-handle 124 | #:descriptor-pool-create-flag-bits ;; :enum 125 | #:descriptor-pool-create-flags ;; :bitmask 126 | #:descriptor-pool-create-info ;; :struct 127 | #:descriptor-pool-reset-flags ;; :bitmask 128 | #:descriptor-pool-size ;; :struct 129 | #:descriptor-set ;; :non-dispatch-handle 130 | #:descriptor-set-allocate-info ;; :struct 131 | #:descriptor-set-layout ;; :non-dispatch-handle 132 | #:descriptor-set-layout-binding ;; :struct 133 | #:descriptor-set-layout-create-flag-bits ;; :enum 134 | #:descriptor-set-layout-create-flags ;; :bitmask 135 | #:descriptor-set-layout-create-info ;; :struct 136 | #:descriptor-type ;; :enum 137 | #:descriptor-update-template-create-flags-khr ;; :bitmask 138 | #:descriptor-update-template-create-info-khr ;; :struct 139 | #:descriptor-update-template-entry-khr ;; :struct 140 | #:descriptor-update-template-khr ;; :non-dispatch-handle 141 | #:descriptor-update-template-type-khr ;; :enum 142 | #:device ;; :handle 143 | #:device-create-flag-bits ;; :enum 144 | #:device-create-flags ;; :bitmask 145 | #:device-create-info ;; :struct 146 | #:device-event-info-ext ;; :struct 147 | #:device-event-type-ext ;; :enum 148 | #:device-generated-commands-features-nvx ;; :struct 149 | #:device-generated-commands-limits-nvx ;; :struct 150 | #:device-group-bind-sparse-info-khx ;; :struct 151 | #:device-group-command-buffer-begin-info-khx ;; :struct 152 | #:device-group-device-create-info-khx ;; :struct 153 | #:device-group-present-capabilities-khx ;; :struct 154 | #:device-group-present-info-khx ;; :struct 155 | #:device-group-present-mode-flag-bits-khx ;; :enum 156 | #:device-group-present-mode-flags-khx ;; :bitmask 157 | #:device-group-render-pass-begin-info-khx ;; :struct 158 | #:device-group-submit-info-khx ;; :struct 159 | #:device-group-swapchain-create-info-khx ;; :struct 160 | #:device-memory ;; :non-dispatch-handle 161 | #:device-queue-create-flag-bits ;; :enum 162 | #:device-queue-create-flags ;; :bitmask 163 | #:device-queue-create-info ;; :struct 164 | #:device-size ;; :alias 165 | #:discard-rectangle-mode-ext ;; :enum 166 | #:dispatch-indirect-command ;; :struct 167 | #:display-event-info-ext ;; :struct 168 | #:display-event-type-ext ;; :enum 169 | #:display-khr ;; :non-dispatch-handle 170 | #:display-mode-create-flags-khr ;; :bitmask 171 | #:display-mode-create-info-khr ;; :struct 172 | #:display-mode-khr ;; :non-dispatch-handle 173 | #:display-mode-parameters-khr ;; :struct 174 | #:display-mode-properties-khr ;; :struct 175 | #:display-plane-alpha-flag-bits-khr ;; :enum 176 | #:display-plane-alpha-flags-khr ;; :bitmask 177 | #:display-plane-capabilities-khr ;; :struct 178 | #:display-plane-properties-khr ;; :struct 179 | #:display-power-info-ext ;; :struct 180 | #:display-power-state-ext ;; :enum 181 | #:display-present-info-khr ;; :struct 182 | #:display-properties-khr ;; :struct 183 | #:display-surface-create-flags-khr ;; :bitmask 184 | #:display-surface-create-info-khr ;; :struct 185 | #:draw-indexed-indirect-command ;; :struct 186 | #:draw-indirect-command ;; :struct 187 | #:dynamic-state ;; :enum 188 | #:event ;; :non-dispatch-handle 189 | #:event-create-flags ;; :bitmask 190 | #:event-create-info ;; :struct 191 | #:export-memory-allocate-info-khx ;; :struct 192 | #:export-memory-allocate-info-nv ;; :struct 193 | #:export-memory-win32-handle-info-khx ;; :struct 194 | #:export-memory-win32-handle-info-nv ;; :struct 195 | #:export-semaphore-create-info-khx ;; :struct 196 | #:export-semaphore-win32-handle-info-khx ;; :struct 197 | #:extension-properties ;; :struct 198 | #:extent-2d ;; :struct 199 | #:extent-3d ;; :struct 200 | #:external-buffer-properties-khx ;; :struct 201 | #:external-image-format-properties-khx ;; :struct 202 | #:external-image-format-properties-nv ;; :struct 203 | #:external-memory-buffer-create-info-khx ;; :struct 204 | #:external-memory-feature-flag-bits-khx ;; :enum 205 | #:external-memory-feature-flag-bits-nv ;; :enum 206 | #:external-memory-feature-flags-khx ;; :bitmask 207 | #:external-memory-feature-flags-nv ;; :bitmask 208 | #:external-memory-handle-type-flag-bits-khx ;; :enum 209 | #:external-memory-handle-type-flag-bits-nv ;; :enum 210 | #:external-memory-handle-type-flags-khx ;; :bitmask 211 | #:external-memory-handle-type-flags-nv ;; :bitmask 212 | #:external-memory-image-create-info-khx ;; :struct 213 | #:external-memory-image-create-info-nv ;; :struct 214 | #:external-memory-properties-khx ;; :struct 215 | #:external-semaphore-feature-flag-bits-khx ;; :enum 216 | #:external-semaphore-feature-flags-khx ;; :bitmask 217 | #:external-semaphore-handle-type-flag-bits-khx ;; :enum 218 | #:external-semaphore-handle-type-flags-khx ;; :bitmask 219 | #:external-semaphore-properties-khx ;; :struct 220 | #:fence ;; :non-dispatch-handle 221 | #:fence-create-flag-bits ;; :enum 222 | #:fence-create-flags ;; :bitmask 223 | #:fence-create-info ;; :struct 224 | #:filter ;; :enum 225 | #:flags ;; :alias 226 | #:format ;; :enum 227 | #:format-feature-flag-bits ;; :enum 228 | #:format-feature-flags ;; :bitmask 229 | #:format-properties ;; :struct 230 | #:format-properties-2-khr ;; :struct 231 | #:framebuffer ;; :non-dispatch-handle 232 | #:framebuffer-create-flag-bits ;; :enum 233 | #:framebuffer-create-flags ;; :bitmask 234 | #:framebuffer-create-info ;; :struct 235 | #:front-face ;; :enum 236 | #:graphics-pipeline-create-info ;; :struct 237 | #:hdr-metadata-ext ;; :struct 238 | #:i-o-s-surface-create-flags-mvk ;; :bitmask 239 | #:i-o-s-surface-create-info-mvk ;; :struct 240 | #:image ;; :non-dispatch-handle 241 | #:image-aspect-flag-bits ;; :enum 242 | #:image-aspect-flags ;; :bitmask 243 | #:image-blit ;; :struct 244 | #:image-copy ;; :struct 245 | #:image-create-flag-bits ;; :enum 246 | #:image-create-flags ;; :bitmask 247 | #:image-create-info ;; :struct 248 | #:image-format-properties ;; :struct 249 | #:image-format-properties-2-khr ;; :struct 250 | #:image-layout ;; :enum 251 | #:image-memory-barrier ;; :struct 252 | #:image-resolve ;; :struct 253 | #:image-subresource ;; :struct 254 | #:image-subresource-layers ;; :struct 255 | #:image-subresource-range ;; :struct 256 | #:image-swapchain-create-info-khx ;; :struct 257 | #:image-tiling ;; :enum 258 | #:image-type ;; :enum 259 | #:image-usage-flag-bits ;; :enum 260 | #:image-usage-flags ;; :bitmask 261 | #:image-view ;; :non-dispatch-handle 262 | #:image-view-create-flags ;; :bitmask 263 | #:image-view-create-info ;; :struct 264 | #:image-view-type ;; :enum 265 | #:import-memory-fd-info-khx ;; :struct 266 | #:import-memory-win32-handle-info-khx ;; :struct 267 | #:import-memory-win32-handle-info-nv ;; :struct 268 | #:import-semaphore-fd-info-khx ;; :struct 269 | #:import-semaphore-win32-handle-info-khx ;; :struct 270 | #:index-type ;; :enum 271 | #:indirect-commands-layout-create-info-nvx ;; :struct 272 | #:indirect-commands-layout-nvx ;; :non-dispatch-handle 273 | #:indirect-commands-layout-token-nvx ;; :struct 274 | #:indirect-commands-layout-usage-flag-bits-nvx ;; :enum 275 | #:indirect-commands-layout-usage-flags-nvx ;; :bitmask 276 | #:indirect-commands-token-nvx ;; :struct 277 | #:indirect-commands-token-type-nvx ;; :enum 278 | #:instance ;; :handle 279 | #:instance-create-flag-bits ;; :enum 280 | #:instance-create-flags ;; :bitmask 281 | #:instance-create-info ;; :struct 282 | #:internal-allocation-type ;; :enum 283 | #:layer-properties ;; :struct 284 | #:logic-op ;; :enum 285 | #:mac-o-s-surface-create-flags-mvk ;; :bitmask 286 | #:mac-o-s-surface-create-info-mvk ;; :struct 287 | #:mapped-memory-range ;; :struct 288 | #:memory-allocate-flag-bits-khx ;; :enum 289 | #:memory-allocate-flags-info-khx ;; :struct 290 | #:memory-allocate-flags-khx ;; :bitmask 291 | #:memory-allocate-info ;; :struct 292 | #:memory-barrier ;; :struct 293 | #:memory-fd-properties-khx ;; :struct 294 | #:memory-heap ;; :struct 295 | #:memory-heap-flag-bits ;; :enum 296 | #:memory-heap-flags ;; :bitmask 297 | #:memory-map-flags ;; :bitmask 298 | #:memory-property-flag-bits ;; :enum 299 | #:memory-property-flags ;; :bitmask 300 | #:memory-requirements ;; :struct 301 | #:memory-type ;; :struct 302 | #:memory-win32-handle-properties-khx ;; :struct 303 | #:mir-surface-create-flags-khr ;; :bitmask 304 | #:mir-surface-create-info-khr ;; :struct 305 | #:object-entry-type-nvx ;; :enum 306 | #:object-entry-usage-flag-bits-nvx ;; :enum 307 | #:object-entry-usage-flags-nvx ;; :bitmask 308 | #:object-table-create-info-nvx ;; :struct 309 | #:object-table-descriptor-set-entry-nvx ;; :struct 310 | #:object-table-entry-nvx ;; :struct 311 | #:object-table-index-buffer-entry-nvx ;; :struct 312 | #:object-table-nvx ;; :non-dispatch-handle 313 | #:object-table-pipeline-entry-nvx ;; :struct 314 | #:object-table-push-constant-entry-nvx ;; :struct 315 | #:object-table-vertex-buffer-entry-nvx ;; :struct 316 | #:object-type ;; :enum 317 | #:offset-2d ;; :struct 318 | #:offset-3d ;; :struct 319 | #:past-presentation-timing-google ;; :struct 320 | #:peer-memory-feature-flag-bits-khx ;; :enum 321 | #:peer-memory-feature-flags-khx ;; :bitmask 322 | #:physical-device ;; :handle 323 | #:physical-device-discard-rectangle-properties-ext ;; :struct 324 | #:physical-device-external-buffer-info-khx ;; :struct 325 | #:physical-device-external-image-format-info-khx ;; :struct 326 | #:physical-device-external-semaphore-info-khx ;; :struct 327 | #:physical-device-features ;; :struct 328 | #:physical-device-features-2-khr ;; :struct 329 | #:physical-device-group-properties-khx ;; :struct 330 | #:physical-device-id-properties-khx ;; :struct 331 | #:physical-device-image-format-info-2-khr ;; :struct 332 | #:physical-device-limits ;; :struct 333 | #:physical-device-memory-properties ;; :struct 334 | #:physical-device-memory-properties-2-khr ;; :struct 335 | #:physical-device-multiview-features-khx ;; :struct 336 | #:physical-device-multiview-per-view-attributes-properties-nvx ;; :struct 337 | #:physical-device-multiview-properties-khx ;; :struct 338 | #:physical-device-properties ;; :struct 339 | #:physical-device-properties-2-khr ;; :struct 340 | #:physical-device-push-descriptor-properties-khr ;; :struct 341 | #:physical-device-sparse-image-format-info-2-khr ;; :struct 342 | #:physical-device-sparse-properties ;; :struct 343 | #:physical-device-surface-info-2-khr ;; :struct 344 | #:physical-device-type ;; :enum 345 | #:pipeline ;; :non-dispatch-handle 346 | #:pipeline-bind-point ;; :enum 347 | #:pipeline-cache ;; :non-dispatch-handle 348 | #:pipeline-cache-create-flag-bits ;; :enum 349 | #:pipeline-cache-create-flags ;; :bitmask 350 | #:pipeline-cache-create-info ;; :struct 351 | #:pipeline-cache-header-version ;; :enum 352 | #:pipeline-color-blend-attachment-state ;; :struct 353 | #:pipeline-color-blend-state-create-flag-bits ;; :enum 354 | #:pipeline-color-blend-state-create-flags ;; :bitmask 355 | #:pipeline-color-blend-state-create-info ;; :struct 356 | #:pipeline-create-flag-bits ;; :enum 357 | #:pipeline-create-flags ;; :bitmask 358 | #:pipeline-depth-stencil-state-create-flag-bits ;; :enum 359 | #:pipeline-depth-stencil-state-create-flags ;; :bitmask 360 | #:pipeline-depth-stencil-state-create-info ;; :struct 361 | #:pipeline-discard-rectangle-state-create-flags-ext ;; :bitmask 362 | #:pipeline-discard-rectangle-state-create-info-ext ;; :struct 363 | #:pipeline-dynamic-state-create-flag-bits ;; :enum 364 | #:pipeline-dynamic-state-create-flags ;; :bitmask 365 | #:pipeline-dynamic-state-create-info ;; :struct 366 | #:pipeline-input-assembly-state-create-flag-bits ;; :enum 367 | #:pipeline-input-assembly-state-create-flags ;; :bitmask 368 | #:pipeline-input-assembly-state-create-info ;; :struct 369 | #:pipeline-layout ;; :non-dispatch-handle 370 | #:pipeline-layout-create-flag-bits ;; :enum 371 | #:pipeline-layout-create-flags ;; :bitmask 372 | #:pipeline-layout-create-info ;; :struct 373 | #:pipeline-multisample-state-create-flag-bits ;; :enum 374 | #:pipeline-multisample-state-create-flags ;; :bitmask 375 | #:pipeline-multisample-state-create-info ;; :struct 376 | #:pipeline-rasterization-state-create-flag-bits ;; :enum 377 | #:pipeline-rasterization-state-create-flags ;; :bitmask 378 | #:pipeline-rasterization-state-create-info ;; :struct 379 | #:pipeline-rasterization-state-rasterization-order-amd ;; :struct 380 | #:pipeline-shader-stage-create-flag-bits ;; :enum 381 | #:pipeline-shader-stage-create-flags ;; :bitmask 382 | #:pipeline-shader-stage-create-info ;; :struct 383 | #:pipeline-stage-flag-bits ;; :enum 384 | #:pipeline-stage-flags ;; :bitmask 385 | #:pipeline-tessellation-state-create-flag-bits ;; :enum 386 | #:pipeline-tessellation-state-create-flags ;; :bitmask 387 | #:pipeline-tessellation-state-create-info ;; :struct 388 | #:pipeline-vertex-input-state-create-flag-bits ;; :enum 389 | #:pipeline-vertex-input-state-create-flags ;; :bitmask 390 | #:pipeline-vertex-input-state-create-info ;; :struct 391 | #:pipeline-viewport-state-create-flag-bits ;; :enum 392 | #:pipeline-viewport-state-create-flags ;; :bitmask 393 | #:pipeline-viewport-state-create-info ;; :struct 394 | #:pipeline-viewport-swizzle-state-create-flags-nv ;; :bitmask 395 | #:pipeline-viewport-swizzle-state-create-info-nv ;; :struct 396 | #:pipeline-viewport-w-scaling-state-create-info-nv ;; :struct 397 | #:polygon-mode ;; :enum 398 | #:present-info-khr ;; :struct 399 | #:present-mode-khr ;; :enum 400 | #:present-region-khr ;; :struct 401 | #:present-regions-khr ;; :struct 402 | #:present-time-google ;; :struct 403 | #:present-times-info-google ;; :struct 404 | #:primitive-topology ;; :enum 405 | #:push-constant-range ;; :struct 406 | #:query-control-flag-bits ;; :enum 407 | #:query-control-flags ;; :bitmask 408 | #:query-pipeline-statistic-flag-bits ;; :enum 409 | #:query-pipeline-statistic-flags ;; :bitmask 410 | #:query-pool ;; :non-dispatch-handle 411 | #:query-pool-create-flag-bits ;; :enum 412 | #:query-pool-create-flags ;; :bitmask 413 | #:query-pool-create-info ;; :struct 414 | #:query-result-flag-bits ;; :enum 415 | #:query-result-flags ;; :bitmask 416 | #:query-type ;; :enum 417 | #:queue ;; :handle 418 | #:queue-family-properties ;; :struct 419 | #:queue-family-properties-2-khr ;; :struct 420 | #:queue-flag-bits ;; :enum 421 | #:queue-flags ;; :bitmask 422 | #:rasterization-order-amd ;; :enum 423 | #:rect-2d ;; :struct 424 | #:rect-3d ;; :struct 425 | #:rect-layer-khr ;; :struct 426 | #:refresh-cycle-duration-google ;; :struct 427 | #:render-pass ;; :non-dispatch-handle 428 | #:render-pass-begin-info ;; :struct 429 | #:render-pass-create-flag-bits ;; :enum 430 | #:render-pass-create-flags ;; :bitmask 431 | #:render-pass-create-info ;; :struct 432 | #:render-pass-multiview-create-info-khx ;; :struct 433 | #:result ;; :enum 434 | #:sample-count-flag-bits ;; :enum 435 | #:sample-count-flags ;; :bitmask 436 | #:sample-mask ;; :alias 437 | #:sampler ;; :non-dispatch-handle 438 | #:sampler-address-mode ;; :enum 439 | #:sampler-create-flag-bits ;; :enum 440 | #:sampler-create-flags ;; :bitmask 441 | #:sampler-create-info ;; :struct 442 | #:sampler-mipmap-mode ;; :enum 443 | #:semaphore ;; :non-dispatch-handle 444 | #:semaphore-create-flags ;; :bitmask 445 | #:semaphore-create-info ;; :struct 446 | #:shader-module ;; :non-dispatch-handle 447 | #:shader-module-create-flags ;; :bitmask 448 | #:shader-module-create-info ;; :struct 449 | #:shader-stage-flag-bits ;; :enum 450 | #:shader-stage-flags ;; :bitmask 451 | #:shared-present-surface-capabilities-khr ;; :struct 452 | #:sharing-mode ;; :enum 453 | #:sparse-buffer-memory-bind-info ;; :struct 454 | #:sparse-image-format-flag-bits ;; :enum 455 | #:sparse-image-format-flags ;; :bitmask 456 | #:sparse-image-format-properties ;; :struct 457 | #:sparse-image-format-properties-2-khr ;; :struct 458 | #:sparse-image-memory-bind ;; :struct 459 | #:sparse-image-memory-bind-info ;; :struct 460 | #:sparse-image-memory-requirements ;; :struct 461 | #:sparse-image-opaque-memory-bind-info ;; :struct 462 | #:sparse-memory-bind ;; :struct 463 | #:sparse-memory-bind-flag-bits ;; :enum 464 | #:sparse-memory-bind-flags ;; :bitmask 465 | #:specialization-info ;; :struct 466 | #:specialization-map-entry ;; :struct 467 | #:stencil-face-flag-bits ;; :enum 468 | #:stencil-face-flags ;; :bitmask 469 | #:stencil-op ;; :enum 470 | #:stencil-op-state ;; :struct 471 | #:structure-type ;; :enum 472 | #:submit-info ;; :struct 473 | #:subpass-contents ;; :enum 474 | #:subpass-dependency ;; :struct 475 | #:subpass-description ;; :struct 476 | #:subpass-description-flag-bits ;; :enum 477 | #:subpass-description-flags ;; :bitmask 478 | #:subresource-layout ;; :struct 479 | #:surface-capabilities-2-ext ;; :struct 480 | #:surface-capabilities-2-khr ;; :struct 481 | #:surface-capabilities-khr ;; :struct 482 | #:surface-counter-flag-bits-ext ;; :enum 483 | #:surface-counter-flags-ext ;; :bitmask 484 | #:surface-format-2-khr ;; :struct 485 | #:surface-format-khr ;; :struct 486 | #:surface-khr ;; :non-dispatch-handle 487 | #:surface-transform-flag-bits-khr ;; :enum 488 | #:surface-transform-flags-khr ;; :bitmask 489 | #:swapchain-counter-create-info-ext ;; :struct 490 | #:swapchain-create-flag-bits-khr ;; :enum 491 | #:swapchain-create-flags-khr ;; :bitmask 492 | #:swapchain-create-info-khr ;; :struct 493 | #:swapchain-khr ;; :non-dispatch-handle 494 | #:system-allocation-scope ;; :enum 495 | #:texture-l-o-d-gather-format-properties-amd ;; :struct 496 | #:validation-check-ext ;; :enum 497 | #:validation-flags-ext ;; :struct 498 | #:vertex-input-attribute-description ;; :struct 499 | #:vertex-input-binding-description ;; :struct 500 | #:vertex-input-rate ;; :enum 501 | #:vi-surface-create-flags-nn ;; :bitmask 502 | #:vi-surface-create-info-nn ;; :struct 503 | #:viewport ;; :struct 504 | #:viewport-coordinate-swizzle-nv ;; :enum 505 | #:viewport-swizzle-nv ;; :struct 506 | #:viewport-w-scaling-nv ;; :struct 507 | #:wayland-surface-create-flags-khr ;; :bitmask 508 | #:wayland-surface-create-info-khr ;; :struct 509 | #:win32-keyed-mutex-acquire-release-info-khx ;; :struct 510 | #:win32-keyed-mutex-acquire-release-info-nv ;; :struct 511 | #:win32-surface-create-flags-khr ;; :bitmask 512 | #:win32-surface-create-info-khr ;; :struct 513 | #:write-descriptor-set ;; :struct 514 | #:x-y-color-ext ;; :struct 515 | #:xcb-surface-create-flags-khr ;; :bitmask 516 | #:xcb-surface-create-info-khr ;; :struct 517 | #:xlib-surface-create-flags-khr ;; :bitmask 518 | #:xlib-surface-create-info-khr ;; :struct 519 | 520 | #:acquire-next-image-2-khx 521 | #:acquire-next-image-khr 522 | #:acquire-xlib-display-ext 523 | #:allocate-command-buffers 524 | #:allocate-descriptor-sets 525 | #:allocate-memory 526 | #:begin-command-buffer 527 | #:bind-buffer-memory 528 | #:bind-buffer-memory-2-khx 529 | #:bind-image-memory 530 | #:bind-image-memory-2-khx 531 | #:cmd-begin-query 532 | #:cmd-begin-render-pass 533 | #:cmd-bind-descriptor-sets 534 | #:cmd-bind-index-buffer 535 | #:cmd-bind-pipeline 536 | #:cmd-bind-vertex-buffers 537 | #:cmd-blit-image 538 | #:cmd-clear-attachments 539 | #:cmd-clear-color-image 540 | #:cmd-clear-depth-stencil-image 541 | #:cmd-copy-buffer 542 | #:cmd-copy-buffer-to-image 543 | #:cmd-copy-image 544 | #:cmd-copy-image-to-buffer 545 | #:cmd-copy-query-pool-results 546 | #:cmd-debug-marker-begin-ext 547 | #:cmd-debug-marker-end-ext 548 | #:cmd-debug-marker-insert-ext 549 | #:cmd-dispatch 550 | #:cmd-dispatch-base-khx 551 | #:cmd-dispatch-indirect 552 | #:cmd-draw 553 | #:cmd-draw-indexed 554 | #:cmd-draw-indexed-indirect 555 | #:cmd-draw-indexed-indirect-count-amd 556 | #:cmd-draw-indirect 557 | #:cmd-draw-indirect-count-amd 558 | #:cmd-end-query 559 | #:cmd-end-render-pass 560 | #:cmd-execute-commands 561 | #:cmd-fill-buffer 562 | #:cmd-next-subpass 563 | #:cmd-pipeline-barrier 564 | #:cmd-process-commands-nvx 565 | #:cmd-push-constants 566 | #:cmd-push-descriptor-set-khr 567 | #:cmd-push-descriptor-set-with-template-khr 568 | #:cmd-reserve-space-for-commands-nvx 569 | #:cmd-reset-event 570 | #:cmd-reset-query-pool 571 | #:cmd-resolve-image 572 | #:cmd-set-blend-constants 573 | #:cmd-set-depth-bias 574 | #:cmd-set-depth-bounds 575 | #:cmd-set-device-mask-khx 576 | #:cmd-set-discard-rectangle-ext 577 | #:cmd-set-event 578 | #:cmd-set-line-width 579 | #:cmd-set-scissor 580 | #:cmd-set-stencil-compare-mask 581 | #:cmd-set-stencil-reference 582 | #:cmd-set-stencil-write-mask 583 | #:cmd-set-viewport 584 | #:cmd-set-viewport-w-scaling-nv 585 | #:cmd-update-buffer 586 | #:cmd-wait-events 587 | #:cmd-write-timestamp 588 | #:create-android-surface-khr 589 | #:create-buffer 590 | #:create-buffer-view 591 | #:create-command-pool 592 | #:create-compute-pipelines 593 | #:create-debug-report-callback-ext 594 | #:create-descriptor-pool 595 | #:create-descriptor-set-layout 596 | #:create-descriptor-update-template-khr 597 | #:create-device 598 | #:create-display-mode-khr 599 | #:create-display-plane-surface-khr 600 | #:create-event 601 | #:create-fence 602 | #:create-framebuffer 603 | #:create-graphics-pipelines 604 | #:create-i-o-s-surface-mvk 605 | #:create-image 606 | #:create-image-view 607 | #:create-indirect-commands-layout-nvx 608 | #:create-instance 609 | #:create-mac-o-s-surface-mvk 610 | #:create-mir-surface-khr 611 | #:create-object-table-nvx 612 | #:create-pipeline-cache 613 | #:create-pipeline-layout 614 | #:create-query-pool 615 | #:create-render-pass 616 | #:create-sampler 617 | #:create-semaphore 618 | #:create-shader-module 619 | #:create-shared-swapchains-khr 620 | #:create-swapchain-khr 621 | #:create-vi-surface-nn 622 | #:create-wayland-surface-khr 623 | #:create-win32-surface-khr 624 | #:create-xcb-surface-khr 625 | #:create-xlib-surface-khr 626 | #:debug-marker-set-object-name-ext 627 | #:debug-marker-set-object-tag-ext 628 | #:debug-report-message-ext 629 | #:destroy-buffer 630 | #:destroy-buffer-view 631 | #:destroy-command-pool 632 | #:destroy-debug-report-callback-ext 633 | #:destroy-descriptor-pool 634 | #:destroy-descriptor-set-layout 635 | #:destroy-descriptor-update-template-khr 636 | #:destroy-device 637 | #:destroy-event 638 | #:destroy-fence 639 | #:destroy-framebuffer 640 | #:destroy-image 641 | #:destroy-image-view 642 | #:destroy-indirect-commands-layout-nvx 643 | #:destroy-instance 644 | #:destroy-object-table-nvx 645 | #:destroy-pipeline 646 | #:destroy-pipeline-cache 647 | #:destroy-pipeline-layout 648 | #:destroy-query-pool 649 | #:destroy-render-pass 650 | #:destroy-sampler 651 | #:destroy-semaphore 652 | #:destroy-shader-module 653 | #:destroy-surface-khr 654 | #:destroy-swapchain-khr 655 | #:device-wait-idle 656 | #:display-power-control-ext 657 | #:end-command-buffer 658 | #:enumerate-device-extension-properties 659 | #:enumerate-device-layer-properties 660 | #:enumerate-instance-extension-properties 661 | #:enumerate-instance-layer-properties 662 | #:enumerate-physical-device-groups-khx 663 | #:enumerate-physical-devices 664 | #:flush-mapped-memory-ranges 665 | #:free-command-buffers 666 | #:free-descriptor-sets 667 | #:free-memory 668 | #:get-buffer-memory-requirements 669 | #:get-device-group-peer-memory-features-khx 670 | #:get-device-group-present-capabilities-khx 671 | #:get-device-group-surface-present-modes-khx 672 | #:get-device-memory-commitment 673 | #:get-device-proc-addr 674 | #:get-device-queue 675 | #:get-display-mode-properties-khr 676 | #:get-display-plane-capabilities-khr 677 | #:get-display-plane-supported-displays-khr 678 | #:get-event-status 679 | #:get-fence-status 680 | #:get-image-memory-requirements 681 | #:get-image-sparse-memory-requirements 682 | #:get-image-subresource-layout 683 | #:get-instance-proc-addr 684 | #:get-memory-fd-khx 685 | #:get-memory-fd-properties-khx 686 | #:get-memory-win32-handle-khx 687 | #:get-memory-win32-handle-nv 688 | #:get-memory-win32-handle-properties-khx 689 | #:get-past-presentation-timing-google 690 | #:get-physical-device-display-plane-properties-khr 691 | #:get-physical-device-display-properties-khr 692 | #:get-physical-device-external-buffer-properties-khx 693 | #:get-physical-device-external-image-format-properties-nv 694 | #:get-physical-device-external-semaphore-properties-khx 695 | #:get-physical-device-features 696 | #:get-physical-device-features-2-khr 697 | #:get-physical-device-format-properties 698 | #:get-physical-device-format-properties-2-khr 699 | #:get-physical-device-generated-commands-properties-nvx 700 | #:get-physical-device-image-format-properties 701 | #:get-physical-device-image-format-properties-2-khr 702 | #:get-physical-device-memory-properties 703 | #:get-physical-device-memory-properties-2-khr 704 | #:get-physical-device-mir-presentation-support-khr 705 | #:get-physical-device-present-rectangles-khx 706 | #:get-physical-device-properties 707 | #:get-physical-device-properties-2-khr 708 | #:get-physical-device-queue-family-properties 709 | #:get-physical-device-queue-family-properties-2-khr 710 | #:get-physical-device-sparse-image-format-properties 711 | #:get-physical-device-sparse-image-format-properties-2-khr 712 | #:get-physical-device-surface-capabilities-2-ext 713 | #:get-physical-device-surface-capabilities-2-khr 714 | #:get-physical-device-surface-capabilities-khr 715 | #:get-physical-device-surface-formats-2-khr 716 | #:get-physical-device-surface-formats-khr 717 | #:get-physical-device-surface-present-modes-khr 718 | #:get-physical-device-surface-support-khr 719 | #:get-physical-device-wayland-presentation-support-khr 720 | #:get-physical-device-win32-presentation-support-khr 721 | #:get-physical-device-xcb-presentation-support-khr 722 | #:get-physical-device-xlib-presentation-support-khr 723 | #:get-pipeline-cache-data 724 | #:get-query-pool-results 725 | #:get-rand-r-output-display-ext 726 | #:get-refresh-cycle-duration-google 727 | #:get-render-area-granularity 728 | #:get-semaphore-fd-khx 729 | #:get-semaphore-win32-handle-khx 730 | #:get-swapchain-counter-ext 731 | #:get-swapchain-images-khr 732 | #:get-swapchain-status-khr 733 | #:import-semaphore-fd-khx 734 | #:import-semaphore-win32-handle-khx 735 | #:invalidate-mapped-memory-ranges 736 | #:map-memory 737 | #:merge-pipeline-caches 738 | #:queue-bind-sparse 739 | #:queue-present-khr 740 | #:queue-submit 741 | #:queue-wait-idle 742 | #:register-device-event-ext 743 | #:register-display-event-ext 744 | #:register-objects-nvx 745 | #:release-display-ext 746 | #:reset-command-buffer 747 | #:reset-command-pool 748 | #:reset-descriptor-pool 749 | #:reset-event 750 | #:reset-fences 751 | #:set-event 752 | #:set-hdr-metadata-ext 753 | #:trim-command-pool-khr 754 | #:unmap-memory 755 | #:unregister-objects-nvx 756 | #:update-descriptor-set-with-template-khr 757 | #:update-descriptor-sets 758 | #:wait-for-fences 759 | )) 760 | -------------------------------------------------------------------------------- /vk/bindings.lisp: -------------------------------------------------------------------------------- 1 | ;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- 2 | ;;; 3 | ;;; Copyright (c) 2016, Bart Botta <00003b@gmail.com> 4 | ;;; All rights reserved. 5 | ;;; 6 | ;;; Permission is hereby granted, free of charge, to any person 7 | ;;; obtaining a copy of this software and associated documentation 8 | ;;; files (the "Software"), to deal in the Software without 9 | ;;; restriction, including without limitation the rights to use, copy, 10 | ;;; modify, merge, publish, distribute, sublicense, and/or sell copies 11 | ;;; of the Software, and to permit persons to whom the Software is 12 | ;;; furnished to do so, subject to the following conditions: 13 | ;;; 14 | ;;; The above copyright notice and this permission notice shall be 15 | ;;; included in all copies or substantial portions of the Software. 16 | ;;; 17 | ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | ;;; DEALINGS IN THE SOFTWARE. 25 | ;;; 26 | 27 | (in-package #:cl-vulkan-bindings) 28 | 29 | (define-foreign-library vulkan 30 | #++(:darwin (:framework "?")) 31 | (:windows "vulkan-1.dll") 32 | (:unix (:or "libvulkan.so"))) 33 | 34 | (use-foreign-library vulkan) 35 | 36 | (defmacro defvkfun ((cname lname) result-type &body body) 37 | `(defcfun (,cname ,lname :library vulkan) ,result-type ,@body)) 38 | 39 | (defvar *instance*) ;; instance pointer 40 | (defvar *instance-params*) ;; plist of :layer, :exts, ? 41 | (defvar *instance-extensions*) ;; extension function pointers 42 | 43 | (defmacro defvkextfun ((cname lname) result-type &body args) 44 | `(defun ,lname (,@ (mapcar 'car args)) 45 | (assert *instance*) 46 | (foreign-funcall-pointer 47 | (or (gethash ',lname *instance-extensions*) 48 | (setf (gethash ',lname *instance-extensions*) 49 | (get-instance-proc-addr *instance* ,cname))) 50 | nil 51 | ,@(loop for arg in args 52 | collect (second arg) collect (first arg)) 53 | ,result-type))) 54 | 55 | (if (= 8 (foreign-type-size :pointer)) 56 | (defctype size-t :uint64) 57 | (defctype size-t :uint32)) 58 | 59 | (defun generate-reader (struct-type function-name members 60 | &aux (struct-name struct-type)) 61 | ;; todo: just use mem-ref for simple structs? 62 | (when (consp struct-name) 63 | (setf struct-name (second struct-name))) 64 | (labels ((get-reader-name (type-name) 65 | ;; hmm, hard-coding the prefix here is ugly possibly 66 | ;; should have some way to look it up? 67 | (intern (format nil "~a~a"'deref- type-name))) 68 | (len-reader (len) 69 | (when (symbolp (car len)) 70 | (assert 71 | (not 72 | (or 73 | (ignore-errors (cffi:foreign-enum-keyword-list (car len))) 74 | (ignore-errors (cffi:foreign-bitfield-symbol-list (car len))))))) 75 | (if (stringp (car len)) 76 | (cond 77 | ((string= (car len) "latexmath:[codesize \\over 4]") 78 | `(floor (foreign-slot-value p ',struct-type :code-size) 4)) 79 | ((string= (car len) "latexmath:[\\lceil{\\mathit{rasterizationsamples} \\over 32}\\rceil]") 80 | ;; slot is an enum (which happens to mean same 81 | ;; thing as its numeric value) so read as number 82 | ;; so we can use it to calculate length 83 | `(ceiling (mem-aref ,(slot-pointer :rasterization-samples) 84 | :int) 85 | 32)) 86 | (t (error "unhandled len='~s'" len))) 87 | `(foreign-slot-value p ',struct-type ,(first len)))) 88 | (slot-pointer (slot &key offset) 89 | (let ((fso (foreign-slot-offset struct-type slot))) 90 | `(cffi:inc-pointer 91 | p 92 | ,(if offset 93 | `(+ ,fso ,offset) 94 | fso)))) 95 | (make-reader (member) 96 | (destructuring-bind (name type count 97 | &key len optional opaque must-be) member 98 | ;; possibly should verify must-be on read too? 99 | (declare (ignore must-be)) 100 | (let ((cffi-type (foreign-slot-type struct-type 101 | name)) 102 | (aggregate (and (consp type) 103 | (or (eq (car type) :union) 104 | (eq (car type) :struct))))) 105 | (declare (ignore cffi-type)) 106 | (cond 107 | ;; simple type 108 | ((not (or count aggregate (consp type))) 109 | (list name `(foreign-slot-value p ',struct-type 110 | ,name))) 111 | ;; single aggregate 112 | ((and aggregate (not (or len count))) 113 | (list name 114 | `(,(get-reader-name (second type)) 115 | ,(slot-pointer name)))) 116 | ;; void* and pointers to OS structs/etc 117 | (opaque 118 | (list name `(let ((s (foreign-slot-value p ',struct-type 119 | ,name))) 120 | (if (null-pointer-p s) nil s)))) 121 | ;; c-string pointer 122 | ((and (equal type '(:pointer :char)) 123 | (equal len '(:null-terminated))) 124 | (list name `(foreign-string-to-lisp 125 | (foreign-slot-value p ',struct-type ,name)))) 126 | ;; fixed-length string member 127 | ((and (eq type :char) count) 128 | ;; fixme: is there a better way to read 129 | ;; 0-terminated string restricted to max N bytes? 130 | (list name `(let ((c (loop for i below ,count 131 | when (zerop (mem-aref ,(slot-pointer name) :char i)) 132 | return i 133 | finally (return ,count)))) 134 | (foreign-string-to-lisp 135 | ,(slot-pointer name) 136 | :max-chars c)))) 137 | ;; other fixed-length array members 138 | (count 139 | (list name 140 | (cond 141 | ((symbolp type) 142 | `(foreign-array-to-lisp ,(slot-pointer name) 143 | '(:array ,type ,count))) 144 | ((typep type '(cons (member :struct :union))) 145 | `(loop with s = ,(foreign-type-size type) 146 | for i below ,(if len 147 | `(min ,count 148 | ,(len-reader len)) 149 | count) 150 | collect (,(get-reader-name (second type)) 151 | ,(slot-pointer name 152 | :offset `(* i s))))) 153 | (t (error "~s[~s] not done yet" type count))))) 154 | ;; pointer to struct/union 155 | ((and (not count) 156 | (not len) 157 | (typep type '(cons (eql :pointer) 158 | (cons 159 | (cons (member :struct :union)))))) 160 | (list name 161 | `(,(get-reader-name (second (second type))) 162 | (foreign-slot-value p ',struct-type ,name)))) 163 | ;; pointer to counted array 164 | ((and len 165 | (consp type) 166 | (eql (first type) :pointer) 167 | ;; pointer to array of simple type 168 | (or (symbolp (second type)) 169 | ;; or array of struct/union 170 | (typep (second type) '(cons (member 171 | :struct :union))) 172 | ;; or array of (pointer to) c-string 173 | (and (equal (second type) '(:pointer :char)) 174 | (eql (second len) :null-terminated)))) 175 | (let ((atype (if (consp type) 176 | (second type) 177 | type))) 178 | (list name 179 | `(loop with c = ,(len-reader len) 180 | with a = (foreign-slot-value p ',struct-type 181 | ,name) 182 | for i below c 183 | collect 184 | ;; possibly should use foreign-array-to-lisp 185 | ;; for some of these? 186 | ;; (maybe only for static sizes?) 187 | ,(cond 188 | ((symbolp atype) 189 | ;; simple types 190 | `(mem-aref a ',atype i)) 191 | ;; strings 192 | ((equal atype '(:pointer :char)) 193 | `(mem-aref a :string i)) 194 | ;; structs 195 | (t 196 | `(progn 197 | (assert (not (null-pointer-p a))) 198 | (,(get-reader-name (second atype)) 199 | (inc-pointer a 200 | (* i ,(foreign-type-size 201 | atype))))))))))) 202 | ;; todo 203 | (t (error "not done yet? ~s ~s ~s ~s ~s" name type count len optional))))))) 204 | (let ((forms (mapcan #'make-reader members))) 205 | `(defun ,function-name (p) 206 | (unless (null-pointer-p p) 207 | (list :pointer p ,@forms)))))) 208 | 209 | 210 | (defvar *allocated-strings*) 211 | (defvar *allocated-objects*) 212 | 213 | (defun generate-member-filler (struct-type member p val 214 | &key is-count 215 | &aux (struct-name (second struct-type))) 216 | (destructuring-bind (name type count 217 | &key len optional opaque must-be 218 | &aux (struct (and (consp type) 219 | (eq (car type) :struct)))) 220 | member 221 | (labels ((get-value (name) 222 | `(getf ,val ,name)) 223 | (get-writer-name (type-name) 224 | ;; hmm, hard-coding the prefix here is ugly possibly 225 | ;; should have some way to look it up? 226 | ;; (can't use *translators* here unless we sort 227 | ;; translators.lisp) 228 | (intern (format nil "~a~a" 'fill- type-name))) 229 | (slot-pointer (slot &key offset) 230 | (let ((fso (foreign-slot-offset struct-type slot))) 231 | `(cffi:inc-pointer ,p ,(if offset 232 | `(+ ,fso ,offset) 233 | fso)))) 234 | (len-writer (len val) 235 | (if (stringp (car len)) 236 | (cond 237 | ((string= (car len) "codesize/4") 238 | `(setf (foreign-slot-value ,p ',struct-type :code-size) 239 | (* ,val 4))) 240 | ((string= (car len) "latexmath:[$\\lceil{\\mathit{rasterizationsamples} \\over 32}\\rceil$]") 241 | ;; can't invert the equation, so just require the 242 | ;; user to set it 243 | nil) 244 | (t (error "unhandled len='~s'" len))) 245 | `(setf (foreign-slot-value ,p ',struct-type ,(first len)) 246 | ,val)))) 247 | (cond 248 | ;; members with fixed value: set it and make sure caller 249 | ;; didn't pass something else 250 | (must-be 251 | (let ((must-be-val (foreign-enum-value type must-be 252 | ;; temporary hack until extension parsing is implemented in generator 253 | :errorp nil))) 254 | (list `(progn 255 | (assert ,must-be-val () 256 | "couldn't find enum ~s in type ~s?" 257 | ,must-be ',type) 258 | (setf (foreign-slot-value ,p ',struct-type ,name) 259 | ,must-be-val)) 260 | `(let ((v ,(get-value name))) 261 | (assert (or (not v) (not (= v ,must-be-val))) 262 | (v) 263 | "~s must be ~s for type ~s if specified, got ~s" 264 | ,name ,must-be-val ',struct-name v))))) 265 | ;; 'count' members are set by the member they count: just 266 | ;; return a check to make sure caller didn't send a value that 267 | ;; doesn't match 268 | (is-count 269 | (list 270 | ;; is-count is a list of names of members that use this 271 | ;; count either NAME or (:OPTIONAL NAME). generate code to 272 | ;; make sure they are same size (or empty if optional) 273 | ;; and store it 274 | (flet ((icn (a) 275 | (if (consp a) 276 | (second a) 277 | a))) 278 | ;; make sure optional fields are last... 279 | (setf is-count 280 | (append (remove-if 'consp is-count) 281 | (remove-if-not 'consp is-count))) 282 | `(let ((l (length ,(get-value (icn (car is-count)))))) 283 | ,@ (loop for .n in (cdr is-count) 284 | for n = (icn .n) 285 | for optional = (consp .n) 286 | when optional 287 | collect 288 | `(alexandria:when-let (l2 ,(get-value n)) 289 | (assert (= l (length l2)) 290 | () 291 | "lengths of members ~s with shared count ~s don't match: ~s" 292 | ',is-count ,name 293 | (list ,@(loop for i in is-count 294 | collect (get-value (icn i)))))) 295 | else collect `(assert (= l (length ,(get-value n))) 296 | () 297 | "lengths of members ~s with shared count ~s don't match: ~s" 298 | ',is-count ,name 299 | (list ,@(loop for i in is-count 300 | collect (get-value (icn i)))))) 301 | (alexandria:when-let (value ,(get-value name)) 302 | (assert 303 | (= value (foreign-slot-value ,p ',struct-type ,name)) 304 | () 305 | "supplied count ~s = ~s doesn't match calculated count ~s.~% (Specifying a count is optional, so it should probably be skipped unless a mismatch would indicate some error in the calling code.)" 306 | ,name value 307 | (foreign-slot-value ,p ',struct-type ,name))) 308 | ,(len-writer (list name) 'l))) 309 | nil ;; no post checks (todo: see if we still need those at all?) 310 | )) 311 | ;; void*, handles and pointers to OS structs/etc 312 | ((and opaque (or (not len) 313 | (equalp type '(:pointer :void)))) 314 | (list `(setf (foreign-slot-value ,p ',struct-type ,name) 315 | (or ,(get-value name) (null-pointer))))) 316 | ;; simple type 317 | ((and (or (symbolp type) 318 | (typep type '(cons (eql :union)))) 319 | (not (or count len))) 320 | (list `(setf (foreign-slot-value ,p ',struct-type ,name) 321 | ,(get-value name)))) 322 | ;; single struct 323 | ((and struct (not (or len count))) 324 | (list `(,(get-writer-name (second type)) 325 | ,(slot-pointer name) 326 | ,(get-value name)))) 327 | ;; c-string pointer 328 | ((and (equal type '(:pointer :char)) 329 | (equal len '(:null-terminated))) 330 | (list `(let ((s (foreign-string-alloc ,(get-value name)))) 331 | (push s *allocated-strings*) 332 | #++(format t "allocated string ~s->~s~%" ,(get-value name) s) 333 | (setf (foreign-slot-value ,p ',struct-type ,name) 334 | s)))) 335 | ;; fixed-length string member 336 | ((and (eq type :char) count) 337 | ;; assuming these are only in returnedonly 338 | ;; structs for now.. 339 | (error "writing fixed-length strings not implemented")) 340 | ;; other fixed-length array members 341 | (count 342 | (list 343 | `(progn 344 | ,(cond 345 | ((or (symbolp type) 346 | (typep type '(cons (eql :union)))) 347 | `(lisp-array-to-foreign (coerce ,val 'vector) 348 | ,(slot-pointer name) 349 | '(:array ,type ,count))) 350 | ;; not used? 351 | ((typep type '(cons (eql :struct))) 352 | `(loop with s = ,(foreign-type-size type) 353 | for i below ,count 354 | for v in val 355 | collect (,(get-writer-name (second type)) 356 | ,(slot-pointer name 357 | :offset `(* i s)) 358 | v))) 359 | (t (error "~s[~s] not done yet" type count)))))) 360 | ;; pointer to single struct 361 | ((and (not count) 362 | (not len) 363 | (typep type '(cons (eql :pointer) 364 | (cons 365 | (cons (member :struct)))))) 366 | (let* ((var (gensym (string name))) 367 | (val (gensym "VALUE")) 368 | (fill `(let ((,var (foreign-alloc ',(second type)))) 369 | (push ,var *allocated-objects*) 370 | (,(get-writer-name (second (second type))) 371 | ,var 372 | ,val) 373 | (setf (foreign-slot-value ,p ',struct-type ,name) 374 | ,var)))) 375 | (list `(let ((,val ,(get-value name))) 376 | ,(if optional 377 | `(if ,val 378 | ,fill 379 | (setf (foreign-slot-value ,p ',struct-type ,name) 380 | (null-pointer))) 381 | fill))))) 382 | ;; pointer to counted array 383 | ((and len 384 | (consp type) 385 | (eql (first type) :pointer) 386 | ;; pointer to array of simple type 387 | (or (symbolp (second type)) 388 | ;; or array of struct/union 389 | (typep (second type) '(cons (member 390 | :struct :union))) 391 | ;; or array of (pointer to) c-string 392 | (and (equal (second type) '(:pointer :char)) 393 | (eql (second len) :null-terminated)))) 394 | (let ((atype (if (consp type) 395 | (second type) 396 | type)) 397 | (var (gensym (string name)))) 398 | (list 399 | `(let* ((vval ,(get-value name)) 400 | (vlen (length vval)) 401 | (,var (if (plusp vlen) 402 | (foreign-alloc ',(second type) :count vlen) 403 | (null-pointer)))) 404 | (when (plusp vlen) 405 | (push ,var *allocated-objects*) 406 | #++(format t "allocated ~s * ~s-> ~s~%" ',type vlen ,var)) 407 | ;;,(len-writer len 'vlen) 408 | (setf (foreign-slot-value ,p ',struct-type ,name) 409 | ,var) 410 | (loop with c = vlen 411 | for v in vval 412 | for i below c 413 | do 414 | ,(cond 415 | ((or (symbolp atype) 416 | (eq (car atype) :union)) 417 | ;; simple types 418 | `(setf (mem-aref ,var ',atype i) v)) 419 | ;; strings 420 | ((equal atype '(:pointer :char)) 421 | `(progn ;;format t ".allocated ~s / ~s ->~s~%" 422 | ;; ,name v 423 | (car (push (setf (mem-aref ,var ',atype i) 424 | (foreign-string-alloc v)) 425 | *allocated-strings*)))) 426 | ;; structs 427 | ((eq (car atype) :struct) 428 | `(,(get-writer-name (second atype)) 429 | (inc-pointer ,var 430 | (* i ,(foreign-type-size atype))) 431 | v)) 432 | (t (error "unexpected type ~s?" type)))))))) 433 | (t (error "not done yet? ~s ~s ~s ~s ~s" name type count len optional)))))) 434 | 435 | (defun generate-filler (struct-name function-name members) 436 | (let ((size-members (make-hash-table))) 437 | 438 | ;; find any members used to store size of another member, so we know 439 | ;; not to set them from input (and possibly error if they are set 440 | ;; in input and don't match?) 441 | (loop for (name nil nil . attribs) in members 442 | for len = (getf attribs :len) 443 | for optional = (getf attribs :optional) 444 | when len 445 | do (assert (<= (length (remove :null-terminated len)) 446 | 1)) 447 | (loop for l in len 448 | when (string= l "codesize/4") 449 | do (setf (gethash :code-size size-members) 450 | (list name)) 451 | do (push (if optional 452 | (list :optional name) 453 | name) 454 | (gethash l size-members nil)))) 455 | 456 | `(defun ,function-name (.p .val) 457 | ,@(loop for member in members 458 | for (fill check) 459 | = (generate-member-filler `(:struct ,struct-name) member 460 | '.p '.val 461 | :is-count (gethash (first member) 462 | size-members)) 463 | collect fill into fills 464 | collect check into checks 465 | finally (return (remove 'nil (append fills checks)))) 466 | (format t "~&filled ~s @ ~s:~% @@ ~s~% -> ~s~%" 467 | ',struct-name .p 468 | .val 469 | (,(intern (format nil "~a~a" 'deref- struct-name) :%vk) .p)) 470 | ))) 471 | 472 | (defun generate-union-filler (struct-name function-name members) 473 | `(defun ,function-name (.p .val) 474 | (ecase (car .val) 475 | ,@ (loop for member in members 476 | collect (list* (car member) 477 | (generate-member-filler `(:union ,struct-name) 478 | member 479 | '.p '(second .val))))))) 480 | (defparameter *translators* (make-hash-table)) 481 | 482 | (defmacro with-vk-structs (((var type value &optional count) 483 | &rest more-bindings) &body body) 484 | (flet ((struct-type (type) 485 | (first (gethash type *translators*))) 486 | (filler (type) 487 | (second (gethash type *translators*))) 488 | (reader (type) 489 | (intern (format nil "~a~a" 'deref- type) :%vk))) 490 | (alexandria:with-gensyms (tmp i) 491 | `(let ((*allocated-strings* nil) 492 | (*allocated-objects* nil)) 493 | ;; todo: think more about the API for alloctating arrays 494 | ;; possibly should add a var for storing the count to avoid 495 | ;; recalculating it when using :auto? or maybe drop auto completely 496 | ;; and trust caller to get it right? 497 | (with-foreign-objects ((,var ',(struct-type type) 498 | ,@ (when count 499 | ;; not sure if we can safely 500 | ;; allocate 0 objects 501 | (if (member count '(:auto t)) 502 | `((min 1 (length ,value))) 503 | `((min 1 ,count))))) 504 | ,@(loop 505 | for (var type value count) in more-bindings 506 | collect 507 | (list* var `',(struct-type type) 508 | (when count 509 | (if (member count '(:auto t)) 510 | `((min 1 (length ,value))) 511 | `((min 1 ,count))))))) 512 | (unwind-protect 513 | (progn 514 | (,(filler type) ,var ,value) 515 | ,@(loop for (var type VALUE count) in more-bindings 516 | if count 517 | do (assert (symbolp value)) 518 | and collect 519 | `(loop with ,value = ,value ;;rebind so we can POP it 520 | for ,i below ,(if (member count '(:auto t)) 521 | `(length ,value) 522 | count) 523 | for ,tmp = (pop ,value)) 524 | else collect `(,(filler type) ,var ,value)) 525 | ,@ (loop for (var type nil count) 526 | in (list* (list var type value count) 527 | more-bindings) 528 | unless count ;; skipping for now... 529 | collect `(format t "with ~s:~% == ~s~%" 530 | ',type 531 | (,(reader type) ,var))) 532 | ,@body) 533 | (loop for i in *allocated-strings* 534 | do #++(format t "~&free string ~s~%" i) 535 | (foreign-string-free i)) 536 | (loop for i in *allocated-objects* 537 | do #++(format t "~&free object ~s~%" i) 538 | (foreign-free i)))))))) 539 | 540 | (defmacro def-translator (struct-name (reader &key fill) &body members) 541 | (let ((struct-type 542 | (cond 543 | ((ignore-errors (foreign-type-size `(:struct ,struct-name))) 544 | `(:struct ,struct-name)) 545 | ((ignore-errors (foreign-type-size `(:union ,struct-name))) 546 | `(:union ,struct-name)) 547 | (t (error "type ~s doesn't seem to be struct or union?" 548 | struct-name))))) 549 | `(progn 550 | ,(generate-reader struct-type reader members) 551 | ,@(when fill 552 | (list `(setf (gethash ',struct-name *translators*) 553 | (list ',struct-type ',fill)) 554 | (if (eq (car struct-type) :union) 555 | (generate-union-filler struct-name fill members) 556 | (generate-filler struct-name fill members))))))) 557 | -------------------------------------------------------------------------------- /vk/extra-types.lisp: -------------------------------------------------------------------------------- 1 | ;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- 2 | ;;; 3 | ;;; Copyright (c) 2016, Bart Botta <00003b@gmail.com> 4 | ;;; All rights reserved. 5 | ;;; 6 | ;;; Permission is hereby granted, free of charge, to any person 7 | ;;; obtaining a copy of this software and associated documentation 8 | ;;; files (the "Software"), to deal in the Software without 9 | ;;; restriction, including without limitation the rights to use, copy, 10 | ;;; modify, merge, publish, distribute, sublicense, and/or sell copies 11 | ;;; of the Software, and to permit persons to whom the Software is 12 | ;;; furnished to do so, subject to the following conditions: 13 | ;;; 14 | ;;; The above copyright notice and this permission notice shall be 15 | ;;; included in all copies or substantial portions of the Software. 16 | ;;; 17 | ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | ;;; DEALINGS IN THE SOFTWARE. 25 | ;;; 26 | 27 | (in-package #:cl-vulkan-bindings) 28 | 29 | ;;; used for positive non-zero returns 30 | (defun %print-vk-cond (condition stream type) 31 | (format stream "cl-vulkan ~a: ~a~% (~s = ~s)" 32 | type 33 | (message condition) 34 | (raw-value condition) 35 | (or (enum condition) "??"))) 36 | (defun print-vk-condition (c s) (%print-vk-cond c s "warning")) 37 | (defun print-vk-error (c s) (%print-vk-cond c s "error")) 38 | 39 | (define-condition vk-condition (condition) 40 | ((enum :reader enum :initarg :enum) 41 | (value :reader raw-value :initarg :value) 42 | (message :reader message :initarg :message)) 43 | (:report print-vk-condition)) 44 | 45 | ;;; used for negative non-zero returns 46 | (define-condition vk-error (vk-condition error) 47 | () 48 | (:report print-vk-error)) 49 | 50 | 51 | 52 | (defmacro %define-conditions (parent &body r) 53 | `(progn 54 | ,@ (loop for c in r 55 | for k = (find-symbol (symbol-name c) (find-package :keyword)) 56 | for v = (foreign-enum-value 'result k) 57 | for message = (gethash k *result-comments*) 58 | collect `(define-condition ,c (,parent) 59 | () 60 | (:default-initargs :enum ,k :value ,v :message ,message))))) 61 | 62 | (%define-conditions vk-condition 63 | not-ready 64 | timeout 65 | event-set 66 | event-reset 67 | incomplete 68 | suboptimal-khr) 69 | 70 | (%define-conditions vk-error 71 | error-out-of-host-memory 72 | error-out-of-device-memory 73 | error-initialization-failed 74 | error-device-lost 75 | error-memory-map-failed 76 | error-layer-not-present 77 | error-extension-not-present 78 | error-feature-not-present 79 | error-incompatible-driver 80 | error-too-many-objects 81 | error-format-not-supported 82 | error-fragmented-pool 83 | error-surface-lost-khr 84 | error-native-window-in-use-khr 85 | error-out-of-date-khr 86 | error-incompatible-display-khr 87 | error-validation-failed-ext 88 | error-invalid-shader-nv 89 | nv-extension-1-error 90 | error-out-of-pool-memory-khr 91 | error-invalid-external-handle-khx) 92 | 93 | ;;; make sure all of the error/condition types got defined, since we 94 | ;;; defined them manually. 95 | (loop for k in (foreign-enum-keyword-list 'result) 96 | for ctype = (or (find-symbol (symbol-name k)) t) 97 | for v = (foreign-enum-value 'result k) 98 | for type = (cond ((plusp v) 'vk-condition) 99 | ((minusp v) 'vk-error) 100 | (t)) 101 | do (assert (subtypep ctype type) 102 | () "no condition defined for result ~s?~% (~s isn't a subtype of ~s)" k ctype type)) 103 | 104 | 105 | (define-foreign-type checked-result () 106 | () 107 | (:actual-type result) 108 | (:simple-parser checked-result)) 109 | 110 | 111 | (defmacro %vk-error/warn (result) 112 | ;; only used once, so assuming V has no side effects 113 | `(case ,result 114 | (0 :success) 115 | ,@(loop for k in (foreign-enum-keyword-list 'result) 116 | for ctype = (or (find-symbol (symbol-name k)) t) 117 | for v = (foreign-enum-value 'result k) 118 | unless (zerop v) 119 | collect `(,v (,(if (plusp v) 'warn 'error) 120 | ',ctype) 121 | ,k)) 122 | (t (if (plusp ,result) 123 | (warn "unknown vk result ~s?" ,result) 124 | (error "unknown vk error ~s?" ,result))))) 125 | 126 | (defmethod translate-from-foreign (v (type checked-result)) 127 | ;; todo: expand-from-foreign/-dyn 128 | (%vk-error/warn v)) 129 | 130 | 131 | ;; override the default so we can convert to/from T/NIL 132 | (define-foreign-type bool32 () 133 | () 134 | (:actual-type :uint32) 135 | (:simple-parser bool32)) 136 | 137 | (defmethod translate-from-foreign (v (type bool32)) 138 | (not (zerop v))) 139 | (defmethod translate-to-foreign (v (type bool32)) 140 | (if v 1 0)) 141 | (defmethod expand-to-foreign (v (type bool32)) 142 | (if (constantp v) 143 | (if (eval v) 1 0) 144 | `(if ,v 1 0))) 145 | (defmethod expand-from-foreign (v (type bool32)) 146 | (if (constantp v) 147 | (not (zerop (eval v))) 148 | `(not (zerop ,v)))) 149 | -------------------------------------------------------------------------------- /vk/funcs.lisp: -------------------------------------------------------------------------------- 1 | ;;; this file is automatically generated, do not edit 2 | #|| 3 | Copyright (c) 2015-2017 The Khronos Group Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and/or associated documentation files (the 7 | "Materials"), to deal in the Materials without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Materials, and to 10 | permit persons to whom the Materials are furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Materials. 15 | 16 | THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 23 | 24 | ------------------------------------------------------------------------ 25 | ||# 26 | 27 | (in-package #:cl-vulkan-bindings) 28 | 29 | (defvkextfun ("vkAcquireNextImage2KHX" acquire-next-image-2-khx) checked-result 30 | (device device) 31 | (p-acquire-info (:pointer (:struct acquire-next-image-info-khx))) 32 | (p-image-index (:pointer :uint32))) 33 | 34 | (defvkextfun ("vkAcquireNextImageKHR" acquire-next-image-khr) checked-result 35 | (device device) 36 | (swapchain swapchain-khr) ;; :EXTERNSYNC "true" 37 | (timeout :uint64) 38 | (semaphore semaphore) ;; :OPTIONAL "true" :EXTERNSYNC "true" 39 | (fence fence) ;; :OPTIONAL "true" :EXTERNSYNC "true" 40 | (p-image-index (:pointer :uint32))) 41 | 42 | (defvkextfun ("vkAcquireXlibDisplayEXT" acquire-xlib-display-ext) checked-result 43 | (physical-device physical-device) 44 | (dpy (:pointer display)) 45 | (display display-khr)) 46 | 47 | (defvkfun ("vkAllocateCommandBuffers" allocate-command-buffers) checked-result 48 | (device device) 49 | (p-allocate-info (:pointer (:struct command-buffer-allocate-info))) ;; :EXTERNSYNC "pAllocateInfo::commandPool" 50 | (p-command-buffers (:pointer command-buffer)) ;; :LEN "pAllocateInfo::commandBufferCount" 51 | ) 52 | 53 | (defvkfun ("vkAllocateDescriptorSets" allocate-descriptor-sets) checked-result 54 | (device device) 55 | (p-allocate-info (:pointer (:struct descriptor-set-allocate-info))) ;; :EXTERNSYNC "pAllocateInfo::descriptorPool" 56 | (p-descriptor-sets (:pointer descriptor-set)) ;; :LEN "pAllocateInfo::descriptorSetCount" 57 | ) 58 | 59 | (defvkfun ("vkAllocateMemory" allocate-memory) checked-result 60 | (device device) 61 | (p-allocate-info (:pointer (:struct memory-allocate-info))) 62 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 63 | (p-memory (:pointer device-memory))) 64 | 65 | (defvkfun ("vkBeginCommandBuffer" begin-command-buffer) checked-result 66 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 67 | (p-begin-info (:pointer (:struct command-buffer-begin-info)))) 68 | 69 | (defvkfun ("vkBindBufferMemory" bind-buffer-memory) checked-result 70 | (device device) 71 | (buffer buffer) ;; :EXTERNSYNC "true" 72 | (memory device-memory) 73 | (memory-offset device-size)) 74 | 75 | (defvkextfun ("vkBindBufferMemory2KHX" bind-buffer-memory-2-khx) checked-result 76 | (device device) 77 | (bind-info-count :uint32) 78 | (p-bind-infos (:pointer (:struct bind-buffer-memory-info-khx))) ;; :LEN "bindInfoCount" 79 | ) 80 | 81 | (defvkfun ("vkBindImageMemory" bind-image-memory) checked-result 82 | (device device) 83 | (image image) ;; :EXTERNSYNC "true" 84 | (memory device-memory) 85 | (memory-offset device-size)) 86 | 87 | (defvkextfun ("vkBindImageMemory2KHX" bind-image-memory-2-khx) checked-result 88 | (device device) 89 | (bind-info-count :uint32) 90 | (p-bind-infos (:pointer (:struct bind-image-memory-info-khx))) ;; :LEN "bindInfoCount" 91 | ) 92 | 93 | (defvkfun ("vkCmdBeginQuery" cmd-begin-query) :void 94 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 95 | (query-pool query-pool) 96 | (query :uint32) 97 | (flags query-control-flags) ;; :OPTIONAL "true" 98 | ) 99 | 100 | (defvkfun ("vkCmdBeginRenderPass" cmd-begin-render-pass) :void 101 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 102 | (p-render-pass-begin (:pointer (:struct render-pass-begin-info))) 103 | (contents subpass-contents)) 104 | 105 | (defvkfun ("vkCmdBindDescriptorSets" cmd-bind-descriptor-sets) :void 106 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 107 | (pipeline-bind-point pipeline-bind-point) 108 | (layout pipeline-layout) 109 | (first-set :uint32) 110 | (descriptor-set-count :uint32) 111 | (p-descriptor-sets (:pointer descriptor-set)) ;; :LEN "descriptorSetCount" 112 | (dynamic-offset-count :uint32) ;; :OPTIONAL "true" 113 | (p-dynamic-offsets (:pointer :uint32)) ;; :LEN "dynamicOffsetCount" 114 | ) 115 | 116 | (defvkfun ("vkCmdBindIndexBuffer" cmd-bind-index-buffer) :void 117 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 118 | (buffer buffer) 119 | (offset device-size) 120 | (index-type index-type)) 121 | 122 | (defvkfun ("vkCmdBindPipeline" cmd-bind-pipeline) :void 123 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 124 | (pipeline-bind-point pipeline-bind-point) 125 | (pipeline pipeline)) 126 | 127 | (defvkfun ("vkCmdBindVertexBuffers" cmd-bind-vertex-buffers) :void 128 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 129 | (first-binding :uint32) 130 | (binding-count :uint32) 131 | (p-buffers (:pointer buffer)) ;; :LEN "bindingCount" 132 | (p-offsets (:pointer device-size)) ;; :LEN "bindingCount" 133 | ) 134 | 135 | (defvkfun ("vkCmdBlitImage" cmd-blit-image) :void 136 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 137 | (src-image image) 138 | (src-image-layout image-layout) 139 | (dst-image image) 140 | (dst-image-layout image-layout) 141 | (region-count :uint32) 142 | (p-regions (:pointer (:struct image-blit))) ;; :LEN "regionCount" 143 | (filter filter)) 144 | 145 | (defvkfun ("vkCmdClearAttachments" cmd-clear-attachments) :void 146 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 147 | (attachment-count :uint32) 148 | (p-attachments (:pointer (:struct clear-attachment))) ;; :LEN "attachmentCount" 149 | (rect-count :uint32) 150 | (p-rects (:pointer (:struct clear-rect))) ;; :LEN "rectCount" 151 | ) 152 | 153 | (defvkfun ("vkCmdClearColorImage" cmd-clear-color-image) :void 154 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 155 | (image image) 156 | (image-layout image-layout) 157 | (p-color (:pointer (:union clear-color-value))) 158 | (range-count :uint32) 159 | (p-ranges (:pointer (:struct image-subresource-range))) ;; :LEN "rangeCount" 160 | ) 161 | 162 | (defvkfun ("vkCmdClearDepthStencilImage" cmd-clear-depth-stencil-image) :void 163 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 164 | (image image) 165 | (image-layout image-layout) 166 | (p-depth-stencil (:pointer (:struct clear-depth-stencil-value))) 167 | (range-count :uint32) 168 | (p-ranges (:pointer (:struct image-subresource-range))) ;; :LEN "rangeCount" 169 | ) 170 | 171 | (defvkfun ("vkCmdCopyBuffer" cmd-copy-buffer) :void 172 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 173 | (src-buffer buffer) 174 | (dst-buffer buffer) 175 | (region-count :uint32) 176 | (p-regions (:pointer (:struct buffer-copy))) ;; :LEN "regionCount" 177 | ) 178 | 179 | (defvkfun ("vkCmdCopyBufferToImage" cmd-copy-buffer-to-image) :void 180 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 181 | (src-buffer buffer) 182 | (dst-image image) 183 | (dst-image-layout image-layout) 184 | (region-count :uint32) 185 | (p-regions (:pointer (:struct buffer-image-copy))) ;; :LEN "regionCount" 186 | ) 187 | 188 | (defvkfun ("vkCmdCopyImage" cmd-copy-image) :void 189 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 190 | (src-image image) 191 | (src-image-layout image-layout) 192 | (dst-image image) 193 | (dst-image-layout image-layout) 194 | (region-count :uint32) 195 | (p-regions (:pointer (:struct image-copy))) ;; :LEN "regionCount" 196 | ) 197 | 198 | (defvkfun ("vkCmdCopyImageToBuffer" cmd-copy-image-to-buffer) :void 199 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 200 | (src-image image) 201 | (src-image-layout image-layout) 202 | (dst-buffer buffer) 203 | (region-count :uint32) 204 | (p-regions (:pointer (:struct buffer-image-copy))) ;; :LEN "regionCount" 205 | ) 206 | 207 | (defvkfun ("vkCmdCopyQueryPoolResults" cmd-copy-query-pool-results) :void 208 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 209 | (query-pool query-pool) 210 | (first-query :uint32) 211 | (query-count :uint32) 212 | (dst-buffer buffer) 213 | (dst-offset device-size) 214 | (stride device-size) 215 | (flags query-result-flags) ;; :OPTIONAL "true" 216 | ) 217 | 218 | (defvkextfun ("vkCmdDebugMarkerBeginEXT" cmd-debug-marker-begin-ext) :void 219 | (command-buffer command-buffer) 220 | (p-marker-info (:pointer (:struct debug-marker-marker-info-ext)))) 221 | 222 | (defvkextfun ("vkCmdDebugMarkerEndEXT" cmd-debug-marker-end-ext) :void 223 | (command-buffer command-buffer)) 224 | 225 | (defvkextfun ("vkCmdDebugMarkerInsertEXT" cmd-debug-marker-insert-ext) :void 226 | (command-buffer command-buffer) 227 | (p-marker-info (:pointer (:struct debug-marker-marker-info-ext)))) 228 | 229 | (defvkfun ("vkCmdDispatch" cmd-dispatch) :void 230 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 231 | (group-count-x :uint32) 232 | (group-count-y :uint32) 233 | (group-count-z :uint32)) 234 | 235 | (defvkextfun ("vkCmdDispatchBaseKHX" cmd-dispatch-base-khx) :void 236 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 237 | (base-group-x :uint32) 238 | (base-group-y :uint32) 239 | (base-group-z :uint32) 240 | (group-count-x :uint32) 241 | (group-count-y :uint32) 242 | (group-count-z :uint32)) 243 | 244 | (defvkfun ("vkCmdDispatchIndirect" cmd-dispatch-indirect) :void 245 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 246 | (buffer buffer) 247 | (offset device-size)) 248 | 249 | (defvkfun ("vkCmdDraw" cmd-draw) :void 250 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 251 | (vertex-count :uint32) 252 | (instance-count :uint32) 253 | (first-vertex :uint32) 254 | (first-instance :uint32)) 255 | 256 | (defvkfun ("vkCmdDrawIndexed" cmd-draw-indexed) :void 257 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 258 | (index-count :uint32) 259 | (instance-count :uint32) 260 | (first-index :uint32) 261 | (vertex-offset :int32) 262 | (first-instance :uint32)) 263 | 264 | (defvkfun ("vkCmdDrawIndexedIndirect" cmd-draw-indexed-indirect) :void 265 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 266 | (buffer buffer) 267 | (offset device-size) 268 | (draw-count :uint32) 269 | (stride :uint32)) 270 | 271 | (defvkextfun ("vkCmdDrawIndexedIndirectCountAMD" cmd-draw-indexed-indirect-count-amd) :void 272 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 273 | (buffer buffer) 274 | (offset device-size) 275 | (count-buffer buffer) 276 | (count-buffer-offset device-size) 277 | (max-draw-count :uint32) 278 | (stride :uint32)) 279 | 280 | (defvkfun ("vkCmdDrawIndirect" cmd-draw-indirect) :void 281 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 282 | (buffer buffer) 283 | (offset device-size) 284 | (draw-count :uint32) 285 | (stride :uint32)) 286 | 287 | (defvkextfun ("vkCmdDrawIndirectCountAMD" cmd-draw-indirect-count-amd) :void 288 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 289 | (buffer buffer) 290 | (offset device-size) 291 | (count-buffer buffer) 292 | (count-buffer-offset device-size) 293 | (max-draw-count :uint32) 294 | (stride :uint32)) 295 | 296 | (defvkfun ("vkCmdEndQuery" cmd-end-query) :void 297 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 298 | (query-pool query-pool) 299 | (query :uint32)) 300 | 301 | (defvkfun ("vkCmdEndRenderPass" cmd-end-render-pass) :void 302 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 303 | ) 304 | 305 | (defvkfun ("vkCmdExecuteCommands" cmd-execute-commands) :void 306 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 307 | (command-buffer-count :uint32) 308 | (p-command-buffers (:pointer command-buffer)) ;; :LEN "commandBufferCount" 309 | ) 310 | 311 | (defvkfun ("vkCmdFillBuffer" cmd-fill-buffer) :void 312 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 313 | (dst-buffer buffer) 314 | (dst-offset device-size) 315 | (size device-size) 316 | (data :uint32)) 317 | 318 | (defvkfun ("vkCmdNextSubpass" cmd-next-subpass) :void 319 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 320 | (contents subpass-contents)) 321 | 322 | (defvkfun ("vkCmdPipelineBarrier" cmd-pipeline-barrier) :void 323 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 324 | (src-stage-mask pipeline-stage-flags) 325 | (dst-stage-mask pipeline-stage-flags) 326 | (dependency-flags dependency-flags) ;; :OPTIONAL "true" 327 | (memory-barrier-count :uint32) ;; :OPTIONAL "true" 328 | (p-memory-barriers (:pointer (:struct memory-barrier))) ;; :LEN "memoryBarrierCount" 329 | (buffer-memory-barrier-count :uint32) ;; :OPTIONAL "true" 330 | (p-buffer-memory-barriers (:pointer (:struct buffer-memory-barrier))) ;; :LEN "bufferMemoryBarrierCount" 331 | (image-memory-barrier-count :uint32) ;; :OPTIONAL "true" 332 | (p-image-memory-barriers (:pointer (:struct image-memory-barrier))) ;; :LEN "imageMemoryBarrierCount" 333 | ) 334 | 335 | (defvkextfun ("vkCmdProcessCommandsNVX" cmd-process-commands-nvx) :void 336 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 337 | (p-process-commands-info (:pointer (:struct cmd-process-commands-info-nvx)))) 338 | 339 | (defvkfun ("vkCmdPushConstants" cmd-push-constants) :void 340 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 341 | (layout pipeline-layout) 342 | (stage-flags shader-stage-flags) 343 | (offset :uint32) 344 | (size :uint32) 345 | (p-values (:pointer :void)) ;; :LEN "size" 346 | ) 347 | 348 | (defvkextfun ("vkCmdPushDescriptorSetKHR" cmd-push-descriptor-set-khr) :void 349 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 350 | (pipeline-bind-point pipeline-bind-point) 351 | (layout pipeline-layout) 352 | (set :uint32) 353 | (descriptor-write-count :uint32) 354 | (p-descriptor-writes (:pointer (:struct write-descriptor-set))) ;; :LEN "descriptorWriteCount" 355 | ) 356 | 357 | (defvkextfun ("vkCmdPushDescriptorSetWithTemplateKHR" cmd-push-descriptor-set-with-template-khr) :void 358 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 359 | (descriptor-update-template descriptor-update-template-khr) 360 | (layout pipeline-layout) 361 | (set :uint32) 362 | (p-data (:pointer :void))) 363 | 364 | (defvkextfun ("vkCmdReserveSpaceForCommandsNVX" cmd-reserve-space-for-commands-nvx) :void 365 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 366 | (p-reserve-space-info (:pointer (:struct cmd-reserve-space-for-commands-info-nvx)))) 367 | 368 | (defvkfun ("vkCmdResetEvent" cmd-reset-event) :void 369 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 370 | (event event) 371 | (stage-mask pipeline-stage-flags)) 372 | 373 | (defvkfun ("vkCmdResetQueryPool" cmd-reset-query-pool) :void 374 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 375 | (query-pool query-pool) 376 | (first-query :uint32) 377 | (query-count :uint32)) 378 | 379 | (defvkfun ("vkCmdResolveImage" cmd-resolve-image) :void 380 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 381 | (src-image image) 382 | (src-image-layout image-layout) 383 | (dst-image image) 384 | (dst-image-layout image-layout) 385 | (region-count :uint32) 386 | (p-regions (:pointer (:struct image-resolve))) ;; :LEN "regionCount" 387 | ) 388 | 389 | (defvkfun ("vkCmdSetBlendConstants" cmd-set-blend-constants) :void 390 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 391 | (blend-constants :float)) 392 | 393 | (defvkfun ("vkCmdSetDepthBias" cmd-set-depth-bias) :void 394 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 395 | (depth-bias-constant-factor :float) 396 | (depth-bias-clamp :float) 397 | (depth-bias-slope-factor :float)) 398 | 399 | (defvkfun ("vkCmdSetDepthBounds" cmd-set-depth-bounds) :void 400 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 401 | (min-depth-bounds :float) 402 | (max-depth-bounds :float)) 403 | 404 | (defvkextfun ("vkCmdSetDeviceMaskKHX" cmd-set-device-mask-khx) :void 405 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 406 | (device-mask :uint32)) 407 | 408 | (defvkextfun ("vkCmdSetDiscardRectangleEXT" cmd-set-discard-rectangle-ext) :void 409 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 410 | (first-discard-rectangle :uint32) 411 | (discard-rectangle-count :uint32) 412 | (p-discard-rectangles (:pointer (:struct rect-2d))) ;; :LEN "discardRectangleCount" 413 | ) 414 | 415 | (defvkfun ("vkCmdSetEvent" cmd-set-event) :void 416 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 417 | (event event) 418 | (stage-mask pipeline-stage-flags)) 419 | 420 | (defvkfun ("vkCmdSetLineWidth" cmd-set-line-width) :void 421 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 422 | (line-width :float)) 423 | 424 | (defvkfun ("vkCmdSetScissor" cmd-set-scissor) :void 425 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 426 | (first-scissor :uint32) 427 | (scissor-count :uint32) 428 | (p-scissors (:pointer (:struct rect-2d))) ;; :LEN "scissorCount" 429 | ) 430 | 431 | (defvkfun ("vkCmdSetStencilCompareMask" cmd-set-stencil-compare-mask) :void 432 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 433 | (face-mask stencil-face-flags) 434 | (compare-mask :uint32)) 435 | 436 | (defvkfun ("vkCmdSetStencilReference" cmd-set-stencil-reference) :void 437 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 438 | (face-mask stencil-face-flags) 439 | (reference :uint32)) 440 | 441 | (defvkfun ("vkCmdSetStencilWriteMask" cmd-set-stencil-write-mask) :void 442 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 443 | (face-mask stencil-face-flags) 444 | (write-mask :uint32)) 445 | 446 | (defvkfun ("vkCmdSetViewport" cmd-set-viewport) :void 447 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 448 | (first-viewport :uint32) 449 | (viewport-count :uint32) 450 | (p-viewports (:pointer (:struct viewport))) ;; :LEN "viewportCount" :NOAUTOVALIDITY "true" 451 | ) 452 | 453 | (defvkextfun ("vkCmdSetViewportWScalingNV" cmd-set-viewport-w-scaling-nv) :void 454 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 455 | (first-viewport :uint32) 456 | (viewport-count :uint32) 457 | (p-viewport-w-scalings (:pointer (:struct viewport-w-scaling-nv))) ;; :LEN "viewportCount" :NOAUTOVALIDITY "true" 458 | ) 459 | 460 | (defvkfun ("vkCmdUpdateBuffer" cmd-update-buffer) :void 461 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 462 | (dst-buffer buffer) 463 | (dst-offset device-size) 464 | (data-size device-size) 465 | (p-data (:pointer :void)) ;; :LEN "dataSize" 466 | ) 467 | 468 | (defvkfun ("vkCmdWaitEvents" cmd-wait-events) :void 469 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 470 | (event-count :uint32) 471 | (p-events (:pointer event)) ;; :LEN "eventCount" 472 | (src-stage-mask pipeline-stage-flags) 473 | (dst-stage-mask pipeline-stage-flags) 474 | (memory-barrier-count :uint32) ;; :OPTIONAL "true" 475 | (p-memory-barriers (:pointer (:struct memory-barrier))) ;; :LEN "memoryBarrierCount" 476 | (buffer-memory-barrier-count :uint32) ;; :OPTIONAL "true" 477 | (p-buffer-memory-barriers (:pointer (:struct buffer-memory-barrier))) ;; :LEN "bufferMemoryBarrierCount" 478 | (image-memory-barrier-count :uint32) ;; :OPTIONAL "true" 479 | (p-image-memory-barriers (:pointer (:struct image-memory-barrier))) ;; :LEN "imageMemoryBarrierCount" 480 | ) 481 | 482 | (defvkfun ("vkCmdWriteTimestamp" cmd-write-timestamp) :void 483 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 484 | (pipeline-stage pipeline-stage-flag-bits) 485 | (query-pool query-pool) 486 | (query :uint32)) 487 | 488 | (defvkextfun ("vkCreateAndroidSurfaceKHR" create-android-surface-khr) checked-result 489 | (instance instance) 490 | (p-create-info (:pointer (:struct android-surface-create-info-khr))) 491 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 492 | (p-surface (:pointer surface-khr))) 493 | 494 | (defvkfun ("vkCreateBuffer" create-buffer) checked-result 495 | (device device) 496 | (p-create-info (:pointer (:struct buffer-create-info))) 497 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 498 | (p-buffer (:pointer buffer))) 499 | 500 | (defvkfun ("vkCreateBufferView" create-buffer-view) checked-result 501 | (device device) 502 | (p-create-info (:pointer (:struct buffer-view-create-info))) 503 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 504 | (p-view (:pointer buffer-view))) 505 | 506 | (defvkfun ("vkCreateCommandPool" create-command-pool) checked-result 507 | (device device) 508 | (p-create-info (:pointer (:struct command-pool-create-info))) 509 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 510 | (p-command-pool (:pointer command-pool))) 511 | 512 | (defvkfun ("vkCreateComputePipelines" create-compute-pipelines) checked-result 513 | (device device) 514 | (pipeline-cache pipeline-cache) ;; :OPTIONAL "true" 515 | (create-info-count :uint32) 516 | (p-create-infos (:pointer (:struct compute-pipeline-create-info))) ;; :LEN "createInfoCount" 517 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 518 | (p-pipelines (:pointer pipeline)) ;; :LEN "createInfoCount" 519 | ) 520 | 521 | (defvkextfun ("vkCreateDebugReportCallbackEXT" create-debug-report-callback-ext) checked-result 522 | (instance instance) 523 | (p-create-info (:pointer (:struct debug-report-callback-create-info-ext))) 524 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 525 | (p-callback (:pointer debug-report-callback-ext))) 526 | 527 | (defvkfun ("vkCreateDescriptorPool" create-descriptor-pool) checked-result 528 | (device device) 529 | (p-create-info (:pointer (:struct descriptor-pool-create-info))) 530 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 531 | (p-descriptor-pool (:pointer descriptor-pool))) 532 | 533 | (defvkfun ("vkCreateDescriptorSetLayout" create-descriptor-set-layout) checked-result 534 | (device device) 535 | (p-create-info (:pointer (:struct descriptor-set-layout-create-info))) 536 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 537 | (p-set-layout (:pointer descriptor-set-layout))) 538 | 539 | (defvkextfun ("vkCreateDescriptorUpdateTemplateKHR" create-descriptor-update-template-khr) checked-result 540 | (device device) 541 | (p-create-info (:pointer (:struct descriptor-update-template-create-info-khr))) 542 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 543 | (p-descriptor-update-template (:pointer descriptor-update-template-khr))) 544 | 545 | (defvkfun ("vkCreateDevice" create-device) checked-result 546 | (physical-device physical-device) 547 | (p-create-info (:pointer (:struct device-create-info))) 548 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 549 | (p-device (:pointer device))) 550 | 551 | (defvkextfun ("vkCreateDisplayModeKHR" create-display-mode-khr) checked-result 552 | (physical-device physical-device) 553 | (display display-khr) ;; :EXTERNSYNC "true" 554 | (p-create-info (:pointer (:struct display-mode-create-info-khr))) 555 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 556 | (p-mode (:pointer display-mode-khr))) 557 | 558 | (defvkextfun ("vkCreateDisplayPlaneSurfaceKHR" create-display-plane-surface-khr) checked-result 559 | (instance instance) 560 | (p-create-info (:pointer (:struct display-surface-create-info-khr))) 561 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 562 | (p-surface (:pointer surface-khr))) 563 | 564 | (defvkfun ("vkCreateEvent" create-event) checked-result 565 | (device device) 566 | (p-create-info (:pointer (:struct event-create-info))) 567 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 568 | (p-event (:pointer event))) 569 | 570 | (defvkfun ("vkCreateFence" create-fence) checked-result 571 | (device device) 572 | (p-create-info (:pointer (:struct fence-create-info))) 573 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 574 | (p-fence (:pointer fence))) 575 | 576 | (defvkfun ("vkCreateFramebuffer" create-framebuffer) checked-result 577 | (device device) 578 | (p-create-info (:pointer (:struct framebuffer-create-info))) 579 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 580 | (p-framebuffer (:pointer framebuffer))) 581 | 582 | (defvkfun ("vkCreateGraphicsPipelines" create-graphics-pipelines) checked-result 583 | (device device) 584 | (pipeline-cache pipeline-cache) ;; :OPTIONAL "true" 585 | (create-info-count :uint32) 586 | (p-create-infos (:pointer (:struct graphics-pipeline-create-info))) ;; :LEN "createInfoCount" 587 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 588 | (p-pipelines (:pointer pipeline)) ;; :LEN "createInfoCount" 589 | ) 590 | 591 | (defvkextfun ("vkCreateIOSSurfaceMVK" create-i-o-s-surface-mvk) checked-result 592 | (instance instance) 593 | (p-create-info (:pointer (:struct i-o-s-surface-create-info-mvk))) 594 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 595 | (p-surface (:pointer surface-khr))) 596 | 597 | (defvkfun ("vkCreateImage" create-image) checked-result 598 | (device device) 599 | (p-create-info (:pointer (:struct image-create-info))) 600 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 601 | (p-image (:pointer image))) 602 | 603 | (defvkfun ("vkCreateImageView" create-image-view) checked-result 604 | (device device) 605 | (p-create-info (:pointer (:struct image-view-create-info))) 606 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 607 | (p-view (:pointer image-view))) 608 | 609 | (defvkextfun ("vkCreateIndirectCommandsLayoutNVX" create-indirect-commands-layout-nvx) checked-result 610 | (device device) 611 | (p-create-info (:pointer (:struct indirect-commands-layout-create-info-nvx))) 612 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 613 | (p-indirect-commands-layout (:pointer indirect-commands-layout-nvx))) 614 | 615 | (defvkfun ("vkCreateInstance" create-instance) checked-result 616 | (p-create-info (:pointer (:struct instance-create-info))) 617 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 618 | (p-instance (:pointer instance))) 619 | 620 | (defvkextfun ("vkCreateMacOSSurfaceMVK" create-mac-o-s-surface-mvk) checked-result 621 | (instance instance) 622 | (p-create-info (:pointer (:struct mac-o-s-surface-create-info-mvk))) 623 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 624 | (p-surface (:pointer surface-khr))) 625 | 626 | (defvkextfun ("vkCreateMirSurfaceKHR" create-mir-surface-khr) checked-result 627 | (instance instance) 628 | (p-create-info (:pointer (:struct mir-surface-create-info-khr))) 629 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 630 | (p-surface (:pointer surface-khr))) 631 | 632 | (defvkextfun ("vkCreateObjectTableNVX" create-object-table-nvx) checked-result 633 | (device device) 634 | (p-create-info (:pointer (:struct object-table-create-info-nvx))) 635 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 636 | (p-object-table (:pointer object-table-nvx))) 637 | 638 | (defvkfun ("vkCreatePipelineCache" create-pipeline-cache) checked-result 639 | (device device) 640 | (p-create-info (:pointer (:struct pipeline-cache-create-info))) 641 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 642 | (p-pipeline-cache (:pointer pipeline-cache))) 643 | 644 | (defvkfun ("vkCreatePipelineLayout" create-pipeline-layout) checked-result 645 | (device device) 646 | (p-create-info (:pointer (:struct pipeline-layout-create-info))) 647 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 648 | (p-pipeline-layout (:pointer pipeline-layout))) 649 | 650 | (defvkfun ("vkCreateQueryPool" create-query-pool) checked-result 651 | (device device) 652 | (p-create-info (:pointer (:struct query-pool-create-info))) 653 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 654 | (p-query-pool (:pointer query-pool))) 655 | 656 | (defvkfun ("vkCreateRenderPass" create-render-pass) checked-result 657 | (device device) 658 | (p-create-info (:pointer (:struct render-pass-create-info))) 659 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 660 | (p-render-pass (:pointer render-pass))) 661 | 662 | (defvkfun ("vkCreateSampler" create-sampler) checked-result 663 | (device device) 664 | (p-create-info (:pointer (:struct sampler-create-info))) 665 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 666 | (p-sampler (:pointer sampler))) 667 | 668 | (defvkfun ("vkCreateSemaphore" create-semaphore) checked-result 669 | (device device) 670 | (p-create-info (:pointer (:struct semaphore-create-info))) 671 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 672 | (p-semaphore (:pointer semaphore))) 673 | 674 | (defvkfun ("vkCreateShaderModule" create-shader-module) checked-result 675 | (device device) 676 | (p-create-info (:pointer (:struct shader-module-create-info))) 677 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 678 | (p-shader-module (:pointer shader-module))) 679 | 680 | (defvkextfun ("vkCreateSharedSwapchainsKHR" create-shared-swapchains-khr) checked-result 681 | (device device) 682 | (swapchain-count :uint32) 683 | (p-create-infos (:pointer (:struct swapchain-create-info-khr))) ;; :LEN "swapchainCount" :EXTERNSYNC "pCreateInfos[].surface,pCreateInfos[].oldSwapchain" 684 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 685 | (p-swapchains (:pointer swapchain-khr)) ;; :LEN "swapchainCount" 686 | ) 687 | 688 | (defvkextfun ("vkCreateSwapchainKHR" create-swapchain-khr) checked-result 689 | (device device) 690 | (p-create-info (:pointer (:struct swapchain-create-info-khr))) ;; :EXTERNSYNC "pCreateInfo.surface,pCreateInfo.oldSwapchain" 691 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 692 | (p-swapchain (:pointer swapchain-khr))) 693 | 694 | (defvkextfun ("vkCreateViSurfaceNN" create-vi-surface-nn) checked-result 695 | (instance instance) 696 | (p-create-info (:pointer (:struct vi-surface-create-info-nn))) 697 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 698 | (p-surface (:pointer surface-khr))) 699 | 700 | (defvkextfun ("vkCreateWaylandSurfaceKHR" create-wayland-surface-khr) checked-result 701 | (instance instance) 702 | (p-create-info (:pointer (:struct wayland-surface-create-info-khr))) 703 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 704 | (p-surface (:pointer surface-khr))) 705 | 706 | (defvkextfun ("vkCreateWin32SurfaceKHR" create-win32-surface-khr) checked-result 707 | (instance instance) 708 | (p-create-info (:pointer (:struct win32-surface-create-info-khr))) 709 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 710 | (p-surface (:pointer surface-khr))) 711 | 712 | (defvkextfun ("vkCreateXcbSurfaceKHR" create-xcb-surface-khr) checked-result 713 | (instance instance) 714 | (p-create-info (:pointer (:struct xcb-surface-create-info-khr))) 715 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 716 | (p-surface (:pointer surface-khr))) 717 | 718 | (defvkextfun ("vkCreateXlibSurfaceKHR" create-xlib-surface-khr) checked-result 719 | (instance instance) 720 | (p-create-info (:pointer (:struct xlib-surface-create-info-khr))) 721 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 722 | (p-surface (:pointer surface-khr))) 723 | 724 | (defvkextfun ("vkDebugMarkerSetObjectNameEXT" debug-marker-set-object-name-ext) checked-result 725 | (device device) 726 | (p-name-info (:pointer (:struct debug-marker-object-name-info-ext))) ;; :EXTERNSYNC "pNameInfo.object" 727 | ) 728 | 729 | (defvkextfun ("vkDebugMarkerSetObjectTagEXT" debug-marker-set-object-tag-ext) checked-result 730 | (device device) 731 | (p-tag-info (:pointer (:struct debug-marker-object-tag-info-ext))) ;; :EXTERNSYNC "pTagInfo.object" 732 | ) 733 | 734 | (defvkextfun ("vkDebugReportMessageEXT" debug-report-message-ext) :void 735 | (instance instance) 736 | (flags debug-report-flags-ext) 737 | (object-type debug-report-object-type-ext) 738 | (object :uint64) 739 | (location size-t) 740 | (message-code :int32) 741 | (p-layer-prefix :string) ;; :LEN "null-terminated" 742 | (p-message :string) ;; :LEN "null-terminated" 743 | ) 744 | 745 | (defvkfun ("vkDestroyBuffer" destroy-buffer) :void 746 | (device device) 747 | (buffer buffer) ;; :OPTIONAL "true" :EXTERNSYNC "true" 748 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 749 | ) 750 | 751 | (defvkfun ("vkDestroyBufferView" destroy-buffer-view) :void 752 | (device device) 753 | (buffer-view buffer-view) ;; :OPTIONAL "true" :EXTERNSYNC "true" 754 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 755 | ) 756 | 757 | (defvkfun ("vkDestroyCommandPool" destroy-command-pool) :void 758 | (device device) 759 | (command-pool command-pool) ;; :OPTIONAL "true" :EXTERNSYNC "true" 760 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 761 | ) 762 | 763 | (defvkextfun ("vkDestroyDebugReportCallbackEXT" destroy-debug-report-callback-ext) :void 764 | (instance instance) 765 | (callback debug-report-callback-ext) ;; :EXTERNSYNC "true" 766 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 767 | ) 768 | 769 | (defvkfun ("vkDestroyDescriptorPool" destroy-descriptor-pool) :void 770 | (device device) 771 | (descriptor-pool descriptor-pool) ;; :OPTIONAL "true" :EXTERNSYNC "true" 772 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 773 | ) 774 | 775 | (defvkfun ("vkDestroyDescriptorSetLayout" destroy-descriptor-set-layout) :void 776 | (device device) 777 | (descriptor-set-layout descriptor-set-layout) ;; :OPTIONAL "true" :EXTERNSYNC "true" 778 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 779 | ) 780 | 781 | (defvkextfun ("vkDestroyDescriptorUpdateTemplateKHR" destroy-descriptor-update-template-khr) :void 782 | (device device) 783 | (descriptor-update-template descriptor-update-template-khr) ;; :OPTIONAL "true" :EXTERNSYNC "true" 784 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 785 | ) 786 | 787 | (defvkfun ("vkDestroyDevice" destroy-device) :void 788 | (device device) ;; :OPTIONAL "true" :EXTERNSYNC "true" 789 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 790 | ) 791 | 792 | (defvkfun ("vkDestroyEvent" destroy-event) :void 793 | (device device) 794 | (event event) ;; :OPTIONAL "true" :EXTERNSYNC "true" 795 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 796 | ) 797 | 798 | (defvkfun ("vkDestroyFence" destroy-fence) :void 799 | (device device) 800 | (fence fence) ;; :OPTIONAL "true" :EXTERNSYNC "true" 801 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 802 | ) 803 | 804 | (defvkfun ("vkDestroyFramebuffer" destroy-framebuffer) :void 805 | (device device) 806 | (framebuffer framebuffer) ;; :OPTIONAL "true" :EXTERNSYNC "true" 807 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 808 | ) 809 | 810 | (defvkfun ("vkDestroyImage" destroy-image) :void 811 | (device device) 812 | (image image) ;; :OPTIONAL "true" :EXTERNSYNC "true" 813 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 814 | ) 815 | 816 | (defvkfun ("vkDestroyImageView" destroy-image-view) :void 817 | (device device) 818 | (image-view image-view) ;; :OPTIONAL "true" :EXTERNSYNC "true" 819 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 820 | ) 821 | 822 | (defvkextfun ("vkDestroyIndirectCommandsLayoutNVX" destroy-indirect-commands-layout-nvx) :void 823 | (device device) 824 | (indirect-commands-layout indirect-commands-layout-nvx) 825 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 826 | ) 827 | 828 | (defvkfun ("vkDestroyInstance" destroy-instance) :void 829 | (instance instance) ;; :OPTIONAL "true" :EXTERNSYNC "true" 830 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 831 | ) 832 | 833 | (defvkextfun ("vkDestroyObjectTableNVX" destroy-object-table-nvx) :void 834 | (device device) 835 | (object-table object-table-nvx) ;; :EXTERNSYNC "true" 836 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 837 | ) 838 | 839 | (defvkfun ("vkDestroyPipeline" destroy-pipeline) :void 840 | (device device) 841 | (pipeline pipeline) ;; :OPTIONAL "true" :EXTERNSYNC "true" 842 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 843 | ) 844 | 845 | (defvkfun ("vkDestroyPipelineCache" destroy-pipeline-cache) :void 846 | (device device) 847 | (pipeline-cache pipeline-cache) ;; :OPTIONAL "true" :EXTERNSYNC "true" 848 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 849 | ) 850 | 851 | (defvkfun ("vkDestroyPipelineLayout" destroy-pipeline-layout) :void 852 | (device device) 853 | (pipeline-layout pipeline-layout) ;; :OPTIONAL "true" :EXTERNSYNC "true" 854 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 855 | ) 856 | 857 | (defvkfun ("vkDestroyQueryPool" destroy-query-pool) :void 858 | (device device) 859 | (query-pool query-pool) ;; :OPTIONAL "true" :EXTERNSYNC "true" 860 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 861 | ) 862 | 863 | (defvkfun ("vkDestroyRenderPass" destroy-render-pass) :void 864 | (device device) 865 | (render-pass render-pass) ;; :OPTIONAL "true" :EXTERNSYNC "true" 866 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 867 | ) 868 | 869 | (defvkfun ("vkDestroySampler" destroy-sampler) :void 870 | (device device) 871 | (sampler sampler) ;; :OPTIONAL "true" :EXTERNSYNC "true" 872 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 873 | ) 874 | 875 | (defvkfun ("vkDestroySemaphore" destroy-semaphore) :void 876 | (device device) 877 | (semaphore semaphore) ;; :OPTIONAL "true" :EXTERNSYNC "true" 878 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 879 | ) 880 | 881 | (defvkfun ("vkDestroyShaderModule" destroy-shader-module) :void 882 | (device device) 883 | (shader-module shader-module) ;; :OPTIONAL "true" :EXTERNSYNC "true" 884 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 885 | ) 886 | 887 | (defvkextfun ("vkDestroySurfaceKHR" destroy-surface-khr) :void 888 | (instance instance) 889 | (surface surface-khr) ;; :OPTIONAL "true" :EXTERNSYNC "true" 890 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 891 | ) 892 | 893 | (defvkextfun ("vkDestroySwapchainKHR" destroy-swapchain-khr) :void 894 | (device device) 895 | (swapchain swapchain-khr) ;; :OPTIONAL "true" :EXTERNSYNC "true" 896 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 897 | ) 898 | 899 | (defvkfun ("vkDeviceWaitIdle" device-wait-idle) checked-result 900 | (device device)) 901 | 902 | (defvkextfun ("vkDisplayPowerControlEXT" display-power-control-ext) checked-result 903 | (device device) 904 | (display display-khr) 905 | (p-display-power-info (:pointer (:struct display-power-info-ext)))) 906 | 907 | (defvkfun ("vkEndCommandBuffer" end-command-buffer) checked-result 908 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 909 | ) 910 | 911 | (defvkfun ("vkEnumerateDeviceExtensionProperties" enumerate-device-extension-properties) checked-result 912 | (physical-device physical-device) 913 | (p-layer-name :string) ;; :OPTIONAL "true" :LEN "null-terminated" 914 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 915 | (p-properties (:pointer (:struct extension-properties))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 916 | ) 917 | 918 | (defvkfun ("vkEnumerateDeviceLayerProperties" enumerate-device-layer-properties) checked-result 919 | (physical-device physical-device) 920 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 921 | (p-properties (:pointer (:struct layer-properties))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 922 | ) 923 | 924 | (defvkfun ("vkEnumerateInstanceExtensionProperties" enumerate-instance-extension-properties) checked-result 925 | (p-layer-name :string) ;; :OPTIONAL "true" :LEN "null-terminated" 926 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 927 | (p-properties (:pointer (:struct extension-properties))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 928 | ) 929 | 930 | (defvkfun ("vkEnumerateInstanceLayerProperties" enumerate-instance-layer-properties) checked-result 931 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 932 | (p-properties (:pointer (:struct layer-properties))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 933 | ) 934 | 935 | (defvkextfun ("vkEnumeratePhysicalDeviceGroupsKHX" enumerate-physical-device-groups-khx) checked-result 936 | (instance instance) 937 | (p-physical-device-group-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 938 | (p-physical-device-group-properties (:pointer (:struct physical-device-group-properties-khx))) ;; :OPTIONAL "true" :LEN "pPhysicalDeviceGroupCount" 939 | ) 940 | 941 | (defvkfun ("vkEnumeratePhysicalDevices" enumerate-physical-devices) checked-result 942 | (instance instance) 943 | (p-physical-device-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 944 | (p-physical-devices (:pointer physical-device)) ;; :OPTIONAL "true" :LEN "pPhysicalDeviceCount" 945 | ) 946 | 947 | (defvkfun ("vkFlushMappedMemoryRanges" flush-mapped-memory-ranges) checked-result 948 | (device device) 949 | (memory-range-count :uint32) 950 | (p-memory-ranges (:pointer (:struct mapped-memory-range))) ;; :LEN "memoryRangeCount" 951 | ) 952 | 953 | (defvkfun ("vkFreeCommandBuffers" free-command-buffers) :void 954 | (device device) 955 | (command-pool command-pool) ;; :EXTERNSYNC "true" 956 | (command-buffer-count :uint32) 957 | (p-command-buffers (:pointer command-buffer)) ;; :LEN "commandBufferCount" :NOAUTOVALIDITY "true" :EXTERNSYNC "true" 958 | ) 959 | 960 | (defvkfun ("vkFreeDescriptorSets" free-descriptor-sets) checked-result 961 | (device device) 962 | (descriptor-pool descriptor-pool) ;; :EXTERNSYNC "true" 963 | (descriptor-set-count :uint32) 964 | (p-descriptor-sets (:pointer descriptor-set)) ;; :LEN "descriptorSetCount" :NOAUTOVALIDITY "true" :EXTERNSYNC "true" 965 | ) 966 | 967 | (defvkfun ("vkFreeMemory" free-memory) :void 968 | (device device) 969 | (memory device-memory) ;; :OPTIONAL "true" :EXTERNSYNC "true" 970 | (p-allocator (:pointer (:struct allocation-callbacks))) ;; :OPTIONAL "true" 971 | ) 972 | 973 | (defvkfun ("vkGetBufferMemoryRequirements" get-buffer-memory-requirements) :void 974 | (device device) 975 | (buffer buffer) 976 | (p-memory-requirements (:pointer (:struct memory-requirements)))) 977 | 978 | (defvkextfun ("vkGetDeviceGroupPeerMemoryFeaturesKHX" get-device-group-peer-memory-features-khx) :void 979 | (device device) 980 | (heap-index :uint32) 981 | (local-device-index :uint32) 982 | (remote-device-index :uint32) 983 | (p-peer-memory-features (:pointer peer-memory-feature-flags-khx))) 984 | 985 | (defvkextfun ("vkGetDeviceGroupPresentCapabilitiesKHX" get-device-group-present-capabilities-khx) checked-result 986 | (device device) 987 | (p-device-group-present-capabilities (:pointer (:struct device-group-present-capabilities-khx)))) 988 | 989 | (defvkextfun ("vkGetDeviceGroupSurfacePresentModesKHX" get-device-group-surface-present-modes-khx) checked-result 990 | (device device) 991 | (surface surface-khr) ;; :EXTERNSYNC "true" 992 | (p-modes (:pointer device-group-present-mode-flags-khx))) 993 | 994 | (defvkfun ("vkGetDeviceMemoryCommitment" get-device-memory-commitment) :void 995 | (device device) 996 | (memory device-memory) 997 | (p-committed-memory-in-bytes (:pointer device-size))) 998 | 999 | (defvkfun ("vkGetDeviceProcAddr" get-device-proc-addr) pfn-void-function 1000 | (device device) 1001 | (p-name :string) ;; :LEN "null-terminated" 1002 | ) 1003 | 1004 | (defvkfun ("vkGetDeviceQueue" get-device-queue) :void 1005 | (device device) 1006 | (queue-family-index :uint32) 1007 | (queue-index :uint32) 1008 | (p-queue (:pointer queue))) 1009 | 1010 | (defvkextfun ("vkGetDisplayModePropertiesKHR" get-display-mode-properties-khr) checked-result 1011 | (physical-device physical-device) 1012 | (display display-khr) 1013 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1014 | (p-properties (:pointer (:struct display-mode-properties-khr))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 1015 | ) 1016 | 1017 | (defvkextfun ("vkGetDisplayPlaneCapabilitiesKHR" get-display-plane-capabilities-khr) checked-result 1018 | (physical-device physical-device) 1019 | (mode display-mode-khr) ;; :EXTERNSYNC "true" 1020 | (plane-index :uint32) 1021 | (p-capabilities (:pointer (:struct display-plane-capabilities-khr)))) 1022 | 1023 | (defvkextfun ("vkGetDisplayPlaneSupportedDisplaysKHR" get-display-plane-supported-displays-khr) checked-result 1024 | (physical-device physical-device) 1025 | (plane-index :uint32) 1026 | (p-display-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1027 | (p-displays (:pointer display-khr)) ;; :OPTIONAL "true" :LEN "pDisplayCount" 1028 | ) 1029 | 1030 | (defvkfun ("vkGetEventStatus" get-event-status) checked-result 1031 | (device device) 1032 | (event event)) 1033 | 1034 | (defvkfun ("vkGetFenceStatus" get-fence-status) checked-result 1035 | (device device) 1036 | (fence fence)) 1037 | 1038 | (defvkfun ("vkGetImageMemoryRequirements" get-image-memory-requirements) :void 1039 | (device device) 1040 | (image image) 1041 | (p-memory-requirements (:pointer (:struct memory-requirements)))) 1042 | 1043 | (defvkfun ("vkGetImageSparseMemoryRequirements" get-image-sparse-memory-requirements) :void 1044 | (device device) 1045 | (image image) 1046 | (p-sparse-memory-requirement-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1047 | (p-sparse-memory-requirements (:pointer (:struct sparse-image-memory-requirements))) ;; :OPTIONAL "true" :LEN "pSparseMemoryRequirementCount" 1048 | ) 1049 | 1050 | (defvkfun ("vkGetImageSubresourceLayout" get-image-subresource-layout) :void 1051 | (device device) 1052 | (image image) 1053 | (p-subresource (:pointer (:struct image-subresource))) 1054 | (p-layout (:pointer (:struct subresource-layout)))) 1055 | 1056 | (defvkfun ("vkGetInstanceProcAddr" get-instance-proc-addr) pfn-void-function 1057 | (instance instance) ;; :OPTIONAL "true" 1058 | (p-name :string) ;; :LEN "null-terminated" 1059 | ) 1060 | 1061 | (defvkextfun ("vkGetMemoryFdKHX" get-memory-fd-khx) checked-result 1062 | (device device) 1063 | (memory device-memory) 1064 | (handle-type external-memory-handle-type-flag-bits-khx) 1065 | (p-fd (:pointer :int))) 1066 | 1067 | (defvkextfun ("vkGetMemoryFdPropertiesKHX" get-memory-fd-properties-khx) checked-result 1068 | (device device) 1069 | (handle-type external-memory-handle-type-flag-bits-khx) 1070 | (fd :int) 1071 | (p-memory-fd-properties (:pointer (:struct memory-fd-properties-khx)))) 1072 | 1073 | (defvkextfun ("vkGetMemoryWin32HandleKHX" get-memory-win32-handle-khx) checked-result 1074 | (device device) 1075 | (memory device-memory) 1076 | (handle-type external-memory-handle-type-flag-bits-khx) 1077 | (p-handle (:pointer handle))) 1078 | 1079 | (defvkextfun ("vkGetMemoryWin32HandleNV" get-memory-win32-handle-nv) checked-result 1080 | (device device) 1081 | (memory device-memory) 1082 | (handle-type external-memory-handle-type-flags-nv) 1083 | (p-handle (:pointer handle))) 1084 | 1085 | (defvkextfun ("vkGetMemoryWin32HandlePropertiesKHX" get-memory-win32-handle-properties-khx) checked-result 1086 | (device device) 1087 | (handle-type external-memory-handle-type-flag-bits-khx) 1088 | (handle handle) 1089 | (p-memory-win32-handle-properties (:pointer (:struct memory-win32-handle-properties-khx)))) 1090 | 1091 | (defvkextfun ("vkGetPastPresentationTimingGOOGLE" get-past-presentation-timing-google) checked-result 1092 | (device device) 1093 | (swapchain swapchain-khr) ;; :EXTERNSYNC "true" 1094 | (p-presentation-timing-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1095 | (p-presentation-timings (:pointer (:struct past-presentation-timing-google))) ;; :OPTIONAL "true" :LEN "pPresentationTimingCount" 1096 | ) 1097 | 1098 | (defvkextfun ("vkGetPhysicalDeviceDisplayPlanePropertiesKHR" get-physical-device-display-plane-properties-khr) checked-result 1099 | (physical-device physical-device) 1100 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1101 | (p-properties (:pointer (:struct display-plane-properties-khr))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 1102 | ) 1103 | 1104 | (defvkextfun ("vkGetPhysicalDeviceDisplayPropertiesKHR" get-physical-device-display-properties-khr) checked-result 1105 | (physical-device physical-device) 1106 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1107 | (p-properties (:pointer (:struct display-properties-khr))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 1108 | ) 1109 | 1110 | (defvkextfun ("vkGetPhysicalDeviceExternalBufferPropertiesKHX" get-physical-device-external-buffer-properties-khx) :void 1111 | (physical-device physical-device) 1112 | (p-external-buffer-info (:pointer (:struct physical-device-external-buffer-info-khx))) 1113 | (p-external-buffer-properties (:pointer (:struct external-buffer-properties-khx)))) 1114 | 1115 | (defvkextfun ("vkGetPhysicalDeviceExternalImageFormatPropertiesNV" get-physical-device-external-image-format-properties-nv) checked-result 1116 | (physical-device physical-device) 1117 | (format format) 1118 | (type image-type) 1119 | (tiling image-tiling) 1120 | (usage image-usage-flags) 1121 | (flags image-create-flags) ;; :OPTIONAL "true" 1122 | (external-handle-type external-memory-handle-type-flags-nv) ;; :OPTIONAL "true" 1123 | (p-external-image-format-properties (:pointer (:struct external-image-format-properties-nv)))) 1124 | 1125 | (defvkextfun ("vkGetPhysicalDeviceExternalSemaphorePropertiesKHX" get-physical-device-external-semaphore-properties-khx) :void 1126 | (physical-device physical-device) 1127 | (p-external-semaphore-info (:pointer (:struct physical-device-external-semaphore-info-khx))) 1128 | (p-external-semaphore-properties (:pointer (:struct external-semaphore-properties-khx)))) 1129 | 1130 | (defvkfun ("vkGetPhysicalDeviceFeatures" get-physical-device-features) :void 1131 | (physical-device physical-device) 1132 | (p-features (:pointer (:struct physical-device-features)))) 1133 | 1134 | (defvkextfun ("vkGetPhysicalDeviceFeatures2KHR" get-physical-device-features-2-khr) :void 1135 | (physical-device physical-device) 1136 | (p-features (:pointer (:struct physical-device-features-2-khr)))) 1137 | 1138 | (defvkfun ("vkGetPhysicalDeviceFormatProperties" get-physical-device-format-properties) :void 1139 | (physical-device physical-device) 1140 | (format format) 1141 | (p-format-properties (:pointer (:struct format-properties)))) 1142 | 1143 | (defvkextfun ("vkGetPhysicalDeviceFormatProperties2KHR" get-physical-device-format-properties-2-khr) :void 1144 | (physical-device physical-device) 1145 | (format format) 1146 | (p-format-properties (:pointer (:struct format-properties-2-khr)))) 1147 | 1148 | (defvkextfun ("vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX" get-physical-device-generated-commands-properties-nvx) :void 1149 | (physical-device physical-device) 1150 | (p-features (:pointer (:struct device-generated-commands-features-nvx))) 1151 | (p-limits (:pointer (:struct device-generated-commands-limits-nvx)))) 1152 | 1153 | (defvkfun ("vkGetPhysicalDeviceImageFormatProperties" get-physical-device-image-format-properties) checked-result 1154 | (physical-device physical-device) 1155 | (format format) 1156 | (type image-type) 1157 | (tiling image-tiling) 1158 | (usage image-usage-flags) 1159 | (flags image-create-flags) ;; :OPTIONAL "true" 1160 | (p-image-format-properties (:pointer (:struct image-format-properties)))) 1161 | 1162 | (defvkextfun ("vkGetPhysicalDeviceImageFormatProperties2KHR" get-physical-device-image-format-properties-2-khr) checked-result 1163 | (physical-device physical-device) 1164 | (p-image-format-info (:pointer (:struct physical-device-image-format-info-2-khr))) 1165 | (p-image-format-properties (:pointer (:struct image-format-properties-2-khr)))) 1166 | 1167 | (defvkfun ("vkGetPhysicalDeviceMemoryProperties" get-physical-device-memory-properties) :void 1168 | (physical-device physical-device) 1169 | (p-memory-properties (:pointer (:struct physical-device-memory-properties)))) 1170 | 1171 | (defvkextfun ("vkGetPhysicalDeviceMemoryProperties2KHR" get-physical-device-memory-properties-2-khr) :void 1172 | (physical-device physical-device) 1173 | (p-memory-properties (:pointer (:struct physical-device-memory-properties-2-khr)))) 1174 | 1175 | (defvkextfun ("vkGetPhysicalDeviceMirPresentationSupportKHR" get-physical-device-mir-presentation-support-khr) bool32 1176 | (physical-device physical-device) 1177 | (queue-family-index :uint32) 1178 | (connection (:pointer mir-connection))) 1179 | 1180 | (defvkextfun ("vkGetPhysicalDevicePresentRectanglesKHX" get-physical-device-present-rectangles-khx) checked-result 1181 | (physical-device physical-device) 1182 | (surface surface-khr) ;; :EXTERNSYNC "true" 1183 | (p-rect-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1184 | (p-rects (:pointer (:struct rect-2d))) ;; :OPTIONAL "true" :LEN "pRectCount" 1185 | ) 1186 | 1187 | (defvkfun ("vkGetPhysicalDeviceProperties" get-physical-device-properties) :void 1188 | (physical-device physical-device) 1189 | (p-properties (:pointer (:struct physical-device-properties)))) 1190 | 1191 | (defvkextfun ("vkGetPhysicalDeviceProperties2KHR" get-physical-device-properties-2-khr) :void 1192 | (physical-device physical-device) 1193 | (p-properties (:pointer (:struct physical-device-properties-2-khr)))) 1194 | 1195 | (defvkfun ("vkGetPhysicalDeviceQueueFamilyProperties" get-physical-device-queue-family-properties) :void 1196 | (physical-device physical-device) 1197 | (p-queue-family-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1198 | (p-queue-family-properties (:pointer (:struct queue-family-properties))) ;; :OPTIONAL "true" :LEN "pQueueFamilyPropertyCount" 1199 | ) 1200 | 1201 | (defvkextfun ("vkGetPhysicalDeviceQueueFamilyProperties2KHR" get-physical-device-queue-family-properties-2-khr) :void 1202 | (physical-device physical-device) 1203 | (p-queue-family-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1204 | (p-queue-family-properties (:pointer (:struct queue-family-properties-2-khr))) ;; :OPTIONAL "true" :LEN "pQueueFamilyPropertyCount" 1205 | ) 1206 | 1207 | (defvkfun ("vkGetPhysicalDeviceSparseImageFormatProperties" get-physical-device-sparse-image-format-properties) :void 1208 | (physical-device physical-device) 1209 | (format format) 1210 | (type image-type) 1211 | (samples sample-count-flag-bits) 1212 | (usage image-usage-flags) 1213 | (tiling image-tiling) 1214 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1215 | (p-properties (:pointer (:struct sparse-image-format-properties))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 1216 | ) 1217 | 1218 | (defvkextfun ("vkGetPhysicalDeviceSparseImageFormatProperties2KHR" get-physical-device-sparse-image-format-properties-2-khr) :void 1219 | (physical-device physical-device) 1220 | (p-format-info (:pointer (:struct physical-device-sparse-image-format-info-2-khr))) 1221 | (p-property-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1222 | (p-properties (:pointer (:struct sparse-image-format-properties-2-khr))) ;; :OPTIONAL "true" :LEN "pPropertyCount" 1223 | ) 1224 | 1225 | (defvkextfun ("vkGetPhysicalDeviceSurfaceCapabilities2EXT" get-physical-device-surface-capabilities-2-ext) checked-result 1226 | (physical-device physical-device) 1227 | (surface surface-khr) 1228 | (p-surface-capabilities (:pointer (:struct surface-capabilities-2-ext)))) 1229 | 1230 | (defvkextfun ("vkGetPhysicalDeviceSurfaceCapabilities2KHR" get-physical-device-surface-capabilities-2-khr) checked-result 1231 | (physical-device physical-device) 1232 | (p-surface-info (:pointer (:struct physical-device-surface-info-2-khr))) 1233 | (p-surface-capabilities (:pointer (:struct surface-capabilities-2-khr)))) 1234 | 1235 | (defvkextfun ("vkGetPhysicalDeviceSurfaceCapabilitiesKHR" get-physical-device-surface-capabilities-khr) checked-result 1236 | (physical-device physical-device) 1237 | (surface surface-khr) 1238 | (p-surface-capabilities (:pointer (:struct surface-capabilities-khr)))) 1239 | 1240 | (defvkextfun ("vkGetPhysicalDeviceSurfaceFormats2KHR" get-physical-device-surface-formats-2-khr) checked-result 1241 | (physical-device physical-device) 1242 | (p-surface-info (:pointer (:struct physical-device-surface-info-2-khr))) 1243 | (p-surface-format-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1244 | (p-surface-formats (:pointer (:struct surface-format-2-khr))) ;; :OPTIONAL "true" :LEN "pSurfaceFormatCount" 1245 | ) 1246 | 1247 | (defvkextfun ("vkGetPhysicalDeviceSurfaceFormatsKHR" get-physical-device-surface-formats-khr) checked-result 1248 | (physical-device physical-device) 1249 | (surface surface-khr) 1250 | (p-surface-format-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1251 | (p-surface-formats (:pointer (:struct surface-format-khr))) ;; :OPTIONAL "true" :LEN "pSurfaceFormatCount" 1252 | ) 1253 | 1254 | (defvkextfun ("vkGetPhysicalDeviceSurfacePresentModesKHR" get-physical-device-surface-present-modes-khr) checked-result 1255 | (physical-device physical-device) 1256 | (surface surface-khr) 1257 | (p-present-mode-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1258 | (p-present-modes (:pointer present-mode-khr)) ;; :OPTIONAL "true" :LEN "pPresentModeCount" 1259 | ) 1260 | 1261 | (defvkextfun ("vkGetPhysicalDeviceSurfaceSupportKHR" get-physical-device-surface-support-khr) checked-result 1262 | (physical-device physical-device) 1263 | (queue-family-index :uint32) 1264 | (surface surface-khr) 1265 | (p-supported (:pointer bool32))) 1266 | 1267 | (defvkextfun ("vkGetPhysicalDeviceWaylandPresentationSupportKHR" get-physical-device-wayland-presentation-support-khr) bool32 1268 | (physical-device physical-device) 1269 | (queue-family-index :uint32) 1270 | (display (:pointer (:struct wl_display)))) 1271 | 1272 | (defvkextfun ("vkGetPhysicalDeviceWin32PresentationSupportKHR" get-physical-device-win32-presentation-support-khr) bool32 1273 | (physical-device physical-device) 1274 | (queue-family-index :uint32)) 1275 | 1276 | (defvkextfun ("vkGetPhysicalDeviceXcbPresentationSupportKHR" get-physical-device-xcb-presentation-support-khr) bool32 1277 | (physical-device physical-device) 1278 | (queue-family-index :uint32) 1279 | (connection (:pointer xcb_connection_t)) 1280 | (visual_id xcb_visualid_t)) 1281 | 1282 | (defvkextfun ("vkGetPhysicalDeviceXlibPresentationSupportKHR" get-physical-device-xlib-presentation-support-khr) bool32 1283 | (physical-device physical-device) 1284 | (queue-family-index :uint32) 1285 | (dpy (:pointer display)) 1286 | (visual-id visual-id)) 1287 | 1288 | (defvkfun ("vkGetPipelineCacheData" get-pipeline-cache-data) checked-result 1289 | (device device) 1290 | (pipeline-cache pipeline-cache) 1291 | (p-data-size (:pointer size-t)) ;; :OPTIONAL "false,true" 1292 | (p-data (:pointer :void)) ;; :OPTIONAL "true" :LEN "pDataSize" 1293 | ) 1294 | 1295 | (defvkfun ("vkGetQueryPoolResults" get-query-pool-results) checked-result 1296 | (device device) 1297 | (query-pool query-pool) 1298 | (first-query :uint32) 1299 | (query-count :uint32) 1300 | (data-size size-t) 1301 | (p-data (:pointer :void)) ;; :LEN "dataSize" 1302 | (stride device-size) 1303 | (flags query-result-flags) ;; :OPTIONAL "true" 1304 | ) 1305 | 1306 | (defvkextfun ("vkGetRandROutputDisplayEXT" get-rand-r-output-display-ext) checked-result 1307 | (physical-device physical-device) 1308 | (dpy (:pointer display)) 1309 | (rr-output rr-output) 1310 | (p-display (:pointer display-khr))) 1311 | 1312 | (defvkextfun ("vkGetRefreshCycleDurationGOOGLE" get-refresh-cycle-duration-google) checked-result 1313 | (device device) 1314 | (swapchain swapchain-khr) ;; :EXTERNSYNC "true" 1315 | (p-display-timing-properties (:pointer (:struct refresh-cycle-duration-google)))) 1316 | 1317 | (defvkfun ("vkGetRenderAreaGranularity" get-render-area-granularity) :void 1318 | (device device) 1319 | (render-pass render-pass) 1320 | (p-granularity (:pointer (:struct extent-2d)))) 1321 | 1322 | (defvkextfun ("vkGetSemaphoreFdKHX" get-semaphore-fd-khx) checked-result 1323 | (device device) 1324 | (semaphore semaphore) 1325 | (handle-type external-semaphore-handle-type-flag-bits-khx) 1326 | (p-fd (:pointer :int))) 1327 | 1328 | (defvkextfun ("vkGetSemaphoreWin32HandleKHX" get-semaphore-win32-handle-khx) checked-result 1329 | (device device) 1330 | (semaphore semaphore) 1331 | (handle-type external-semaphore-handle-type-flag-bits-khx) 1332 | (p-handle (:pointer handle))) 1333 | 1334 | (defvkextfun ("vkGetSwapchainCounterEXT" get-swapchain-counter-ext) checked-result 1335 | (device device) 1336 | (swapchain swapchain-khr) 1337 | (counter surface-counter-flag-bits-ext) 1338 | (p-counter-value (:pointer :uint64))) 1339 | 1340 | (defvkextfun ("vkGetSwapchainImagesKHR" get-swapchain-images-khr) checked-result 1341 | (device device) 1342 | (swapchain swapchain-khr) 1343 | (p-swapchain-image-count (:pointer :uint32)) ;; :OPTIONAL "false,true" 1344 | (p-swapchain-images (:pointer image)) ;; :OPTIONAL "true" :LEN "pSwapchainImageCount" 1345 | ) 1346 | 1347 | (defvkextfun ("vkGetSwapchainStatusKHR" get-swapchain-status-khr) checked-result 1348 | (device device) 1349 | (swapchain swapchain-khr) ;; :EXTERNSYNC "true" 1350 | ) 1351 | 1352 | (defvkextfun ("vkImportSemaphoreFdKHX" import-semaphore-fd-khx) checked-result 1353 | (device device) 1354 | (p-import-semaphore-fd-info (:pointer (:struct import-semaphore-fd-info-khx)))) 1355 | 1356 | (defvkextfun ("vkImportSemaphoreWin32HandleKHX" import-semaphore-win32-handle-khx) checked-result 1357 | (device device) 1358 | (p-import-semaphore-win32-handle-info (:pointer (:struct import-semaphore-win32-handle-info-khx)))) 1359 | 1360 | (defvkfun ("vkInvalidateMappedMemoryRanges" invalidate-mapped-memory-ranges) checked-result 1361 | (device device) 1362 | (memory-range-count :uint32) 1363 | (p-memory-ranges (:pointer (:struct mapped-memory-range))) ;; :LEN "memoryRangeCount" 1364 | ) 1365 | 1366 | (defvkfun ("vkMapMemory" map-memory) checked-result 1367 | (device device) 1368 | (memory device-memory) ;; :EXTERNSYNC "true" 1369 | (offset device-size) 1370 | (size device-size) 1371 | (flags memory-map-flags) ;; :OPTIONAL "true" 1372 | (pp-data (:pointer (:pointer :void)))) 1373 | 1374 | (defvkfun ("vkMergePipelineCaches" merge-pipeline-caches) checked-result 1375 | (device device) 1376 | (dst-cache pipeline-cache) ;; :EXTERNSYNC "true" 1377 | (src-cache-count :uint32) 1378 | (p-src-caches (:pointer pipeline-cache)) ;; :LEN "srcCacheCount" 1379 | ) 1380 | 1381 | (defvkfun ("vkQueueBindSparse" queue-bind-sparse) checked-result 1382 | (queue queue) ;; :EXTERNSYNC "true" 1383 | (bind-info-count :uint32) ;; :OPTIONAL "true" 1384 | (p-bind-info (:pointer (:struct bind-sparse-info))) ;; :LEN "bindInfoCount" :EXTERNSYNC "pBindInfo[].pWaitSemaphores[],pBindInfo[].pSignalSemaphores[],pBindInfo[].pBufferBinds[].buffer,pBindInfo[].pImageOpaqueBinds[].image,pBindInfo[].pImageBinds[].image" 1385 | (fence fence) ;; :OPTIONAL "true" :EXTERNSYNC "true" 1386 | ) 1387 | 1388 | (defvkextfun ("vkQueuePresentKHR" queue-present-khr) checked-result 1389 | (queue queue) ;; :EXTERNSYNC "true" 1390 | (p-present-info (:pointer (:struct present-info-khr))) ;; :EXTERNSYNC "pPresentInfo.pWaitSemaphores[],pPresentInfo.pSwapchains[]" 1391 | ) 1392 | 1393 | (defvkfun ("vkQueueSubmit" queue-submit) checked-result 1394 | (queue queue) ;; :EXTERNSYNC "true" 1395 | (submit-count :uint32) ;; :OPTIONAL "true" 1396 | (p-submits (:pointer (:struct submit-info))) ;; :LEN "submitCount" :EXTERNSYNC "pSubmits[].pWaitSemaphores[],pSubmits[].pSignalSemaphores[]" 1397 | (fence fence) ;; :OPTIONAL "true" :EXTERNSYNC "true" 1398 | ) 1399 | 1400 | (defvkfun ("vkQueueWaitIdle" queue-wait-idle) checked-result 1401 | (queue queue)) 1402 | 1403 | (defvkextfun ("vkRegisterDeviceEventEXT" register-device-event-ext) checked-result 1404 | (device device) 1405 | (p-device-event-info (:pointer (:struct device-event-info-ext))) 1406 | (p-allocator (:pointer (:struct allocation-callbacks))) 1407 | (p-fence (:pointer fence))) 1408 | 1409 | (defvkextfun ("vkRegisterDisplayEventEXT" register-display-event-ext) checked-result 1410 | (device device) 1411 | (display display-khr) 1412 | (p-display-event-info (:pointer (:struct display-event-info-ext))) 1413 | (p-allocator (:pointer (:struct allocation-callbacks))) 1414 | (p-fence (:pointer fence))) 1415 | 1416 | (defvkextfun ("vkRegisterObjectsNVX" register-objects-nvx) checked-result 1417 | (device device) 1418 | (object-table object-table-nvx) ;; :EXTERNSYNC "true" 1419 | (object-count :uint32) 1420 | (pp-object-table-entries (:pointer (:pointer (:struct object-table-entry-nvx)))) ;; :LEN "objectCount" 1421 | (p-object-indices (:pointer :uint32)) ;; :LEN "objectCount" 1422 | ) 1423 | 1424 | (defvkextfun ("vkReleaseDisplayEXT" release-display-ext) checked-result 1425 | (physical-device physical-device) 1426 | (display display-khr)) 1427 | 1428 | (defvkfun ("vkResetCommandBuffer" reset-command-buffer) checked-result 1429 | (command-buffer command-buffer) ;; :EXTERNSYNC "true" 1430 | (flags command-buffer-reset-flags) ;; :OPTIONAL "true" 1431 | ) 1432 | 1433 | (defvkfun ("vkResetCommandPool" reset-command-pool) checked-result 1434 | (device device) 1435 | (command-pool command-pool) ;; :EXTERNSYNC "true" 1436 | (flags command-pool-reset-flags) ;; :OPTIONAL "true" 1437 | ) 1438 | 1439 | (defvkfun ("vkResetDescriptorPool" reset-descriptor-pool) checked-result 1440 | (device device) 1441 | (descriptor-pool descriptor-pool) ;; :EXTERNSYNC "true" 1442 | (flags descriptor-pool-reset-flags) ;; :OPTIONAL "true" 1443 | ) 1444 | 1445 | (defvkfun ("vkResetEvent" reset-event) checked-result 1446 | (device device) 1447 | (event event) ;; :EXTERNSYNC "true" 1448 | ) 1449 | 1450 | (defvkfun ("vkResetFences" reset-fences) checked-result 1451 | (device device) 1452 | (fence-count :uint32) 1453 | (p-fences (:pointer fence)) ;; :LEN "fenceCount" :EXTERNSYNC "true" 1454 | ) 1455 | 1456 | (defvkfun ("vkSetEvent" set-event) checked-result 1457 | (device device) 1458 | (event event) ;; :EXTERNSYNC "true" 1459 | ) 1460 | 1461 | (defvkextfun ("vkSetHdrMetadataEXT" set-hdr-metadata-ext) :void 1462 | (device device) 1463 | (swapchain-count :uint32) 1464 | (p-swapchains (:pointer swapchain-khr)) ;; :LEN "swapchainCount" 1465 | (p-metadata (:pointer (:struct hdr-metadata-ext))) ;; :LEN "swapchainCount" 1466 | ) 1467 | 1468 | (defvkextfun ("vkTrimCommandPoolKHR" trim-command-pool-khr) :void 1469 | (device device) 1470 | (command-pool command-pool) ;; :EXTERNSYNC "true" 1471 | (flags command-pool-trim-flags-khr) ;; :OPTIONAL "true" 1472 | ) 1473 | 1474 | (defvkfun ("vkUnmapMemory" unmap-memory) :void 1475 | (device device) 1476 | (memory device-memory) ;; :EXTERNSYNC "true" 1477 | ) 1478 | 1479 | (defvkextfun ("vkUnregisterObjectsNVX" unregister-objects-nvx) checked-result 1480 | (device device) 1481 | (object-table object-table-nvx) ;; :EXTERNSYNC "true" 1482 | (object-count :uint32) 1483 | (p-object-entry-types (:pointer object-entry-type-nvx)) ;; :LEN "objectCount" 1484 | (p-object-indices (:pointer :uint32)) ;; :LEN "objectCount" 1485 | ) 1486 | 1487 | (defvkextfun ("vkUpdateDescriptorSetWithTemplateKHR" update-descriptor-set-with-template-khr) :void 1488 | (device device) 1489 | (descriptor-set descriptor-set) ;; :EXTERNSYNC "true" 1490 | (descriptor-update-template descriptor-update-template-khr) 1491 | (p-data (:pointer :void))) 1492 | 1493 | (defvkfun ("vkUpdateDescriptorSets" update-descriptor-sets) :void 1494 | (device device) 1495 | (descriptor-write-count :uint32) ;; :OPTIONAL "true" 1496 | (p-descriptor-writes (:pointer (:struct write-descriptor-set))) ;; :LEN "descriptorWriteCount" :EXTERNSYNC "pDescriptorWrites[].dstSet" 1497 | (descriptor-copy-count :uint32) ;; :OPTIONAL "true" 1498 | (p-descriptor-copies (:pointer (:struct copy-descriptor-set))) ;; :LEN "descriptorCopyCount" :EXTERNSYNC "pDescriptorCopies[].dstSet" 1499 | ) 1500 | 1501 | (defvkfun ("vkWaitForFences" wait-for-fences) checked-result 1502 | (device device) 1503 | (fence-count :uint32) 1504 | (p-fences (:pointer fence)) ;; :LEN "fenceCount" 1505 | (wait-all bool32) 1506 | (timeout :uint64)) 1507 | 1508 | -------------------------------------------------------------------------------- /vk/package.lisp: -------------------------------------------------------------------------------- 1 | (defpackage #:cl-vulkan 2 | (:use :cl :cffi) 3 | (:nicknames :vk) 4 | (:import-from 5 | #:%vk 6 | #:not-ready 7 | #:timeout 8 | #:event-set 9 | #:event-reset 10 | #:incomplete 11 | #:suboptimal-khr 12 | #:error-out-of-host-memory 13 | #:error-out-of-device-memory 14 | #:error-initialization-failed 15 | #:error-device-lost 16 | #:error-memory-map-failed 17 | #:error-layer-not-present 18 | #:error-extension-not-present 19 | #:error-feature-not-present 20 | #:error-incompatible-driver 21 | #:error-too-many-objects 22 | #:error-format-not-supported 23 | #:error-fragmented-pool 24 | #:error-surface-lost-khr 25 | #:error-native-window-in-use-khr 26 | #:error-out-of-date-khr 27 | #:error-incompatible-display-khr 28 | #:error-validation-failed-ext 29 | #:error-invalid-shader-nv 30 | #:nv-extension-1-error 31 | #:error-out-of-pool-memory-khr 32 | #:error-invalid-external-handle-khx 33 | 34 | #:device-wait-idle 35 | #:get-device-proc-addr 36 | #:get-event-status 37 | #:get-fence-status 38 | #:get-instance-proc-addr 39 | #:get-physical-device-mir-presentation-support-khr 40 | #:get-physical-device-wayland-presentation-support-khr 41 | #:get-physical-device-win32-presentation-support-khr 42 | #:get-physical-device-xlib-presentation-support-khr 43 | #:get-physical-device-xcb-presentation-support-khr 44 | #:queue-wait-idle) 45 | (:export 46 | #:not-ready 47 | #:timeout 48 | #:event-set 49 | #:event-reset 50 | #:incomplete 51 | #:suboptimal-khr 52 | 53 | #:error-out-of-host-memory 54 | #:error-out-of-device-memory 55 | #:error-initialization-failed 56 | #:error-device-lost 57 | #:error-memory-map-failed 58 | #:error-layer-not-present 59 | #:error-extension-not-present 60 | #:error-feature-not-present 61 | #:error-incompatible-driver 62 | #:error-too-many-objects 63 | #:error-format-not-supported 64 | #:error-fragmented-pool 65 | #:error-surface-lost-khr 66 | #:error-native-window-in-use-khr 67 | #:error-out-of-date-khr 68 | #:error-incompatible-display-khr 69 | #:error-validation-failed-ext 70 | #:error-invalid-shader-nv 71 | #:nv-extension-1-error 72 | #:error-out-of-pool-memory-khr 73 | #:error-invalid-external-handle-khx 74 | 75 | #:with-instance 76 | #:enumerate-physical-devices 77 | #:get-physical-device-properties 78 | #:get-physical-device-queue-family-properties 79 | #:get-physical-device-memory-properties 80 | #:with-device 81 | #:get-physical-device-features 82 | #:decode-version 83 | #:enumerate-instance-layer-properties 84 | #:enumerate-instance-extension-properties 85 | #:with-debug-report 86 | #:get-physical-device-surface-support-khr 87 | #:get-physical-device-mir-presentation-support-khr 88 | #:get-physical-device-wayland-presentation-support-khr 89 | #:get-physical-device-win32-presentation-support-khr 90 | #:get-physical-device-xlib-presentation-support-khr 91 | #:get-physical-device-xcb-presentation-support-khr 92 | #:with-win32-surface-khr 93 | #:get-physical-device-surface-formats-khr 94 | #:with-swapchain 95 | #:get-physical-device-surface-present-modes-khr 96 | #:create-command-pool 97 | #:create-swapchain-khr 98 | #:destroy-swapchain-khr 99 | #:get-swapchain-images-khr 100 | #:acquire-next-image-khr 101 | #:allocate-command-buffers 102 | #:device-wait-idle 103 | #:destroy-command-pool 104 | #:destroy-image-view 105 | #:with-command-buffers 106 | #:with-commands 107 | #:create-image-view 108 | #:queue-submit1 109 | #:queue-wait-idle 110 | #:cmd-pipeline-barrier)) 111 | -------------------------------------------------------------------------------- /vk/wrappers.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:cl-vulkan) 2 | 3 | (defun api-version (major minor patch) 4 | (logior (ash major 22) 5 | (ash minor 12) 6 | patch)) 7 | 8 | (defun decode-version (v) 9 | (list (ldb (byte 12 22) v) 10 | (ldb (byte 10 12) v) 11 | (ldb (byte 12 0) v))) 12 | (defparameter *api-version* (api-version 1 0 3)) 13 | 14 | (defparameter *debug-report-callback* nil) 15 | (defparameter *debug-report-callback-handle* nil) 16 | 17 | #++ 18 | (defmacro with-foreign-string-arrays (((pointer-var lisp-var) 19 | &rest more-var-defs) 20 | &body body) 21 | (let ((string-pointers (gensym (string lisp-var)))) 22 | `(let* ((,string-pointers (map 'vector 'foreign-string-alloc ,lisp-var))) 23 | (unwind-protect 24 | (with-foreign-array (,pointer-var ,string-pointers 25 | `(:array :pointer ,(length ,lisp-var))) 26 | ,(if more-var-defs 27 | `(with-foreign-string-arrays (,@more-var-defs) 28 | ,@body) 29 | `(progn ,@body))) 30 | (map nil 'foreign-string-free ,string-pointers))))) 31 | 32 | (macrolet ((define-creator (fun &body args) 33 | (let ((structs 34 | (loop for a in args 35 | when (consp a) 36 | collect (list (first a) 37 | (find-symbol (string (second a)) 38 | (find-package :%vk)) 39 | (second a)))) 40 | (p (gensym "POINTER"))) 41 | (print 42 | `(defun ,fun (,@(loop for a in args 43 | collect (if (consp a) (second a) a))) 44 | (%vk::with-vk-structs (,@structs) 45 | (with-foreign-object (,p :pointer) 46 | (setf (mem-ref ,p :pointer) (null-pointer)) 47 | (,(intern (string-trim "%"(string fun)) 48 | (find-package :%vk)) 49 | ,@(loop for a in args 50 | collect (if (consp a) (car a) a)) 51 | (null-pointer) ;; no allocator support for now... 52 | ,p) 53 | (let ((v (mem-ref ,p :pointer))) 54 | (unless (null-pointer-p v) v))))))))) 55 | (define-creator %create-instance (ici instance-create-info)) 56 | (define-creator %create-device physical-device (dci device-create-info)) 57 | (define-creator %create-android-surface-khr instance (asci android-surface-create-info-khr)) 58 | (define-creator %create-buffer device (bci buffer-create-info)) 59 | (define-creator %create-buffer-view device (bvci buffer-view-create-info)) 60 | (define-creator %create-command-pool device (cpci command-pool-create-info)) 61 | #++ 62 | (define-creator %create-compute-pipelines device pipeline-cache 63 | (cpci compute-pipeline-create-info :counted t)) 64 | (define-creator %create-debug-report-callback-ext instance 65 | (drcci debug-report-callback-create-info-ext)) 66 | (define-creator %create-descriptor-pool device (dpci descriptor-pool-create-info)) 67 | (define-creator %create-descriptor-set-layout device (dslci descriptor-set-layout-create-info)) 68 | (define-creator %create-display-mode-khr physical-device display 69 | (dmci display-mode-create-info-khr)) 70 | (define-creator %create-display-plane-surface-khr instance (dsci display-surface-create-info-khr)) 71 | (define-creator %create-event device (eci event-create-info)) 72 | (define-creator %create-fence device (fci fence-create-info)) 73 | (define-creator %create-framebuffer device (fci framebuffer-create-info)) 74 | #++ 75 | (define-creator %create-graphics-pipelines device pipeline-cache 76 | (gpci graphics-pipeline-create-info :counted t)) 77 | (define-creator %create-image device (ici image-create-info)) 78 | (define-creator %create-image-view device (ivci image-view-create-info)) 79 | (define-creator %create-mir-surface-khr instance (msci mir-surface-create-info-khr)) 80 | (define-creator %create-pipeline-cache device (pcci pipeline-cache-create-info)) 81 | (define-creator %create-pipeline-layout device (plci pipeline-layout-create-info)) 82 | (define-creator %create-query-pool device (qpci query-pool-create-info)) 83 | (define-creator %create-render-pass device (rpci render-pass-create-info)) 84 | (define-creator %create-sampler device (sci sampler-create-info)) 85 | (define-creator %create-semaphore device (sci semaphore-create-info)) 86 | (define-creator %create-shader-module device (smci shader-module-create-info)) 87 | #++ 88 | (define-creator %create-shared-swapchains-khr device (sci swapchain-create-info-khr :counted t)) 89 | (define-creator %create-swapchain-khr device (sci swapchain-create-info-khr)) 90 | (define-creator %create-wayland-surface-khr instance (wsci wayland-surface-create-info-khr)) 91 | (define-creator %create-win32-surface-khr instance (wsci win32-surface-create-info-khr)) 92 | (define-creator %create-xcb-surface-khr instance (xsci xcb-surface-create-info-khr)) 93 | (define-creator %create-xlib-surface-khr instance (xsci xlib-surface-create-info-khr))) 94 | 95 | (macrolet ((define-destroy (fun &body args) 96 | `(defun ,fun (,@args) 97 | (,(intern (string-trim "%"(string fun)) 98 | (find-package :%vk)) 99 | ,@args 100 | ;; no allocator support for now... 101 | (null-pointer))))) 102 | (define-destroy destroy-swapchain-khr device swapchain) 103 | (define-destroy destroy-command-pool device pool) 104 | (define-destroy destroy-image-view device image-view)) 105 | 106 | 107 | 108 | (defun %allocate-command-buffers (device comand-buffer-allocate-info) 109 | (%vk::with-vk-structs ((ai %vk:command-buffer-allocate-info 110 | comand-buffer-allocate-info)) 111 | (with-foreign-object (p '%vk:command-buffer 112 | (getf comand-buffer-allocate-info 113 | :command-buffer-count)) 114 | (%vk:allocate-command-buffers device ai p) 115 | (loop for i below (getf comand-buffer-allocate-info 116 | :command-buffer-count) 117 | collect (mem-aref p '%vk:command-buffer i))))) 118 | 119 | #++ 120 | (macrolet 121 | ((wrap-creator (name with-name destroy (&rest args) (&rest call) 122 | &key filter) 123 | (print 124 | `(progn 125 | (defun ,name (,@args) 126 | ,filter 127 | (,@call)) 128 | (defmacro with-name ((var ,@args) &body body) 129 | `(let ((,var (,',name ,,@(loop with key = nil 130 | for a in args 131 | for an = (if (consp a) 132 | (car a) 133 | a) 134 | when (eq a '&key) 135 | do (setf key t) 136 | else 137 | append (if key 138 | (list (alexandria:make-keyword an) an) 139 | (list an)))))) 140 | (unwind-protect 141 | (progn ,@body) 142 | (when ,var (,',destroy ,var (null-pointer)))))))))) 143 | (wrap-creator create-instance with-instance %vk:destroy-instance 144 | (&key exts layers (app "cl-vulkan test") 145 | (engine "cl-vulkan")) 146 | (%create-instance 147 | `(:p-next nil 148 | :flags 0 149 | :p-application-info (:p-next nil 150 | :p-application-name ,app 151 | :application-version 0 152 | :p-engine-name ,engine 153 | :engine-version 0 154 | :api-version ,*api-version*) 155 | :pp-enabled-layer-names ,layers 156 | :pp-enabled-extension-names ,exts)) 157 | :filter (setf exts (loop for x in exts 158 | when (keywordp x) 159 | collect (gethash x %vk::*extension-names* x) 160 | else collect x)))) 161 | 162 | (defmacro with-with ((with-name destroy 163 | &key (allocator t) 164 | pre-bindings 165 | post-bindings) 166 | &body defun) 167 | (let* ((name (second (first defun))) 168 | (fn-args (third (first defun))) 169 | (macro-args (loop for a in fn-args 170 | if (consp a) 171 | collect (list* (car a) 172 | `',(cadr a) 173 | (cddr a)) 174 | else collect a)) 175 | (call-args (loop with key = nil 176 | for a in fn-args 177 | for an = (if (consp a) 178 | (car a) 179 | a) 180 | when (eq a '&key) 181 | do (setf key t) 182 | else 183 | append (if key 184 | (list (alexandria:make-keyword an) an) 185 | (list an))))) 186 | (print 187 | `(progn 188 | ,@defun 189 | (defmacro ,with-name ((var ,@macro-args) &body body) 190 | (flet ((pre-bindings () 191 | ,pre-bindings) 192 | (post-bindings () 193 | ,post-bindings)) 194 | `(let* (,@(pre-bindings) 195 | (,var (,',name ,,@call-args)) 196 | ,@(post-bindings)) 197 | (unwind-protect 198 | (progn 199 | ,@body) 200 | (when ,var (,@(list ',(car destroy) ,@ (cdr destroy)) ,var ,@',(when allocator `((null-pointer))))))))))))) 201 | 202 | (defmacro without-fp-traps (&body body) 203 | #+(and sbcl (or x86 x86-64)) 204 | `(sb-int:with-float-traps-masked (:invalid :divide-by-zero) 205 | ,@body) 206 | #-(and sbcl (or x86 x86-64)) 207 | `(progn ,@body)) 208 | 209 | ;; todo: add option to warn when optional layer/ext aren't found? 210 | (defun check-layers (layers) 211 | (let ((available (mapcar (lambda (a) 212 | (getf a :layer-name)) 213 | (vk:enumerate-instance-layer-properties)))) 214 | (loop for .layer in layers 215 | for layer = (if (consp .layer) (car .layer) .layer) 216 | for optional = (when (consp .layer) (getf (cdr .layer) :optional)) 217 | for found = (position layer available :test 'string=) 218 | when (and (not found) (not optional)) 219 | do (error "required layer ~s not found.~%available: ~s" layer 220 | available) 221 | when found 222 | collect layer))) 223 | 224 | (defun check-extensions (extensions layers) 225 | ;; we need to check all the layers we will activate, since the 226 | ;; extension might be from one of them... 227 | (let ((available 228 | (loop for l in (cons (null-pointer) layers) 229 | append (mapcar (lambda (a) 230 | (getf a :extension-name)) 231 | (enumerate-instance-extension-properties l))))) 232 | (loop for .ext in extensions 233 | for ext = (if (consp .ext) (car .ext) .ext) 234 | for optional = (when (consp .ext) (getf (cdr .ext) :optional)) 235 | for found = (position ext available :test 'string=) 236 | when (and (not found) (not optional)) 237 | ;; todo: enumerate extensions from layers we don't activate so 238 | ;; we can give a more specific message if the desired extension 239 | ;; if from one of those. 240 | do (error "required extension ~s not found. Available: ~s" ext 241 | available) 242 | when found 243 | collect ext 244 | else do (format t "missing extension ~s? / ~s~%" ext available)))) 245 | 246 | 247 | (with-with (with-instance (%vk:destroy-instance) 248 | :pre-bindings 249 | `((%vk::*instance-extensions* (make-hash-table)) 250 | (%vk::*instance-params* (print (list :layers nil :exts nil)))) 251 | :post-bindings 252 | `((%vk::*instance* ,var))) 253 | ;; EXTS and LAYERS are lists of names or (name &key optional) 254 | ;; extension names can be string or keyword for known extensions, 255 | ;; layer names are strings 256 | (defun create-instance (&key exts layers 257 | (app "cl-vulkan test") 258 | (app-version 0) 259 | (engine "cl-vulkan") 260 | (engine-version 1)) 261 | (setf layers (check-layers layers)) 262 | (setf exts (check-extensions 263 | (loop for x in exts 264 | when (keywordp x) 265 | collect (gethash x %vk::*extension-names* x) 266 | else when (typep x '(cons keyword)) 267 | collect (list* (gethash (car x) 268 | %vk::*extension-names* 269 | (car x)) 270 | (cdr x)) 271 | else collect x) 272 | layers)) 273 | (when (boundp '%vk::*instance-params*) 274 | (setf (getf %vk::*instance-params* :exts) exts) 275 | (setf (getf %vk::*instance-params* :layers) layers) 276 | (print %vk::*instance-params*)) 277 | (format t "creating instance with~% layers ~s~% exts ~s~%" layers exts) 278 | (without-fp-traps 279 | (%create-instance `( ;:s-type :instance-create-info 280 | :p-next nil 281 | :flags 0 282 | :p-application-info ( ;:s-type :application-info 283 | :p-next nil 284 | :p-application-name ,app 285 | :application-version ,app-version 286 | :p-engine-name ,engine 287 | :engine-version ,engine-version 288 | :api-version ,*api-version*) 289 | ;:enabled-layer-count ,(length layers) 290 | :pp-enabled-layer-names ,layers 291 | ;:enabled-extension-count ,(length exts) 292 | :pp-enabled-extension-names ,exts))))) 293 | 294 | #++ 295 | (defmacro with-instance ((var &key exts layers (app "cl-vulkan test") 296 | (engine "cl-vulkan")) 297 | &body body) 298 | `(let ((,var (create-instance :exts ,exts :layers ,layers 299 | :app ,app :engine ,engine))) 300 | (unwind-protect 301 | (progn ,@body) 302 | (when ,var 303 | (%vk:destroy-instance ,var (null-pointer)))))) 304 | 305 | (defcallback %debug-report-callback %vk:bool32 306 | ((flags %vk:debug-report-flags-ext) 307 | (objecttype %vk:debug-report-object-type-ext) 308 | (object :uint64) 309 | (location %vk::size-t) 310 | (messagecode :int32) 311 | (playerprefix :string) 312 | (pmessage/const :string) 313 | (puserdata/const (:pointer :void))) 314 | (declare (ignore puserdata/const)) 315 | (when *debug-report-callback* 316 | (funcall *debug-report-callback* 317 | flags objecttype object location messagecode 318 | playerprefix pmessage/const)) 319 | ;; if callback returns T, the calling API function will fail with 320 | ;; :error-validation-failed-ext. Better to just error here if we 321 | ;; want that though, so return NIL 322 | nil) 323 | 324 | (defun default-debug-report-callback (flags object-type object location 325 | message-code player-prefix message) 326 | (declare (ignorable flags object-type object location 327 | message-code player-prefix message)) 328 | (progn ;unless (member :information flags) ;;todo: make this configurable 329 | (format t "~&~a:~s ~s~%" 330 | player-prefix flags message) 331 | #++(format t "code=~s, object=~s/~x, location=~s" 332 | message-code object object-type location)) 333 | (when (member :error flags) 334 | (cerror "continue" 335 | "vulkan validation error ~s:~% ~s.~% code=~s, object=~s/~x, location=~s" 336 | player-prefix message message-code object-type object location))) 337 | 338 | (defmacro with-debug-report ((instance &key (callback ''default-debug-report-callback)) 339 | &body body) 340 | (let ((cb (gensym "CALLBACK-HANDLE"))) 341 | `(let ((*debug-report-callback* ,callback) 342 | (,cb (when (position "VK_EXT_debug_report" 343 | (getf (print %vk::*instance-params*) :exts) 344 | :test 'string=) 345 | (%create-debug-report-callback-ext 346 | ,instance `(:flags (:information 347 | :warning :performance-warning 348 | :error :debug) 349 | :pfn-callback ,(cffi:callback %debug-report-callback)))))) 350 | (unwind-protect 351 | (progn ,@body) 352 | (when ,cb 353 | (%vk:destroy-debug-report-callback-ext ,instance ,cb (null-pointer))))))) 354 | 355 | 356 | ;; todo: add option to warn when optional layer/ext aren't found? 357 | (defun check-device-layers (physical-device layers) 358 | (let ((available (mapcar (lambda (a) 359 | (getf a :layer-name)) 360 | (enumerate-device-layer-properties physical-device)))) 361 | (loop for .layer in layers 362 | for layer = (if (consp .layer) (car .layer) .layer) 363 | for optional = (when (consp .layer) (getf (cdr .layer) :optional)) 364 | for found = (position layer available :test 'string=) 365 | when (and (not found) (not optional)) 366 | do (error "required device layer ~s not found.~%available: ~s" layer 367 | available) 368 | when found 369 | collect layer))) 370 | 371 | (defun check-device-extensions (physical-device extensions layers) 372 | ;; we need to check all the layers we will activate, since the 373 | ;; extension might be from one of them... 374 | (let ((available 375 | (loop for l in (cons (null-pointer) layers) 376 | append (mapcar (lambda (a) 377 | (getf a :extension-name)) 378 | (enumerate-device-extension-properties 379 | physical-device l))))) 380 | (loop for .ext in extensions 381 | for ext = (if (consp .ext) (car .ext) .ext) 382 | for optional = (when (consp .ext) (getf (cdr .ext) :optional)) 383 | for found = (position ext available :test 'string=) 384 | when (and (not found) (not optional)) 385 | ;; todo: enumerate extensions from layers we don't activate so 386 | ;; we can give a more specific message if the desired extension 387 | ;; if from one of those. 388 | do (error "required device extension ~s not found. Available: ~s" ext 389 | available) 390 | when found 391 | collect ext))) 392 | 393 | 394 | 395 | (with-with (with-device (%vk:destroy-device)) 396 | (defun create-device (physical-device &key (queue-family-index 0) 397 | (priorities '(0.0)) 398 | layers exts 399 | features) 400 | (setf layers (check-device-layers physical-device layers)) 401 | (setf exts (check-device-extensions 402 | physical-device (loop for x in exts 403 | when (keywordp x) 404 | collect (gethash x %vk::*extension-names* x) 405 | else collect x) 406 | layers)) 407 | ;; todo: verify numbers are between 0.0 and 1.0 inclusive 408 | (if (consp queue-family-index) 409 | ;; if using multiple queue families, priorities must be an 410 | ;; equal length list of lists of numbers 411 | (assert (and (= (length queue-family-index) 412 | (length priorities)) 413 | (every (lambda (a) (every 'realp a)) priorities))) 414 | ;; if we have 1 index, priorities must be a list of numbers from 0-1 415 | (assert (and (plusp (length priorities)) 416 | (every 'realp priorities)))) 417 | (without-fp-traps 418 | (%create-device physical-device 419 | (print `(:flags 0 420 | :p-queue-create-infos 421 | ,(loop for i in (alexandria:ensure-list 422 | queue-family-index) 423 | for p in (if (consp queue-family-index) 424 | priorities 425 | (list priorities)) 426 | collect `(:flags 0 427 | :queue-family-index ,i 428 | :p-queue-priorities ,p)) 429 | :pp-enabled-layer-names ,layers 430 | :pp-enabled-extension-names ,exts 431 | :p-enabled-features ,features)))))) 432 | 433 | #++ 434 | (defmacro with-device ((var physical-device 435 | &key (queue-family-index 0) 436 | (priorities ''(1.0)) 437 | layers exts 438 | (features '(get-physical-device-features physical-device))) 439 | &body body) 440 | `(let ((,var (create-device ,physical-device 441 | :queue-family-index ,queue-family-index 442 | :priorities ,priorities 443 | :layers ,layers 444 | :exts ,exts 445 | :features ,features))) 446 | (unwind-protect 447 | ,@body 448 | (when ,var 449 | (%vk:destroy-device ,var (null-pointer)))))) 450 | 451 | (with-with (with-win32-surface-khr (%vk:destroy-surface-khr instance)) 452 | (defun create-win32-surface-khr (instance hinstance hwnd) 453 | (%create-win32-surface-khr instance `(:flags 0 454 | :hinstance ,hinstance 455 | :hwnd ,hwnd)))) 456 | 457 | (with-with (with-swapchain (%vk:destroy-swapchain-khr device)) 458 | (defun create-swapchain-khr (device surface 459 | width height 460 | &key (min-image-count 1) ;; single buffer 461 | (image-format :r8g8b8a8-uint) 462 | (image-color-space :srgb-nonlinear-khr) 463 | (image-array-layers 1) 464 | ;; image-usage-flags 465 | (image-usage '(:color-attachment 466 | :depth-stencil-attachment)) 467 | ;; sharing-mode 468 | (image-sharing-mode :exclusive) 469 | (queue-family-indices '()) 470 | ;; surface-transform-flag-bits-khr 471 | (pre-transform :identity) 472 | (composite-alpha :opaque) 473 | (present-mode :fifo-khr) ;; vsync 474 | (clipped t) 475 | (old-swapchain nil)) 476 | (%create-swapchain-khr device 477 | `(:p-next ,(null-pointer) 478 | :flags 0 479 | :surface ,surface 480 | :min-image-count ,min-image-count 481 | :image-format ,image-format 482 | :image-color-space ,image-color-space 483 | :image-extent (:width ,width :height ,height) 484 | 485 | :image-array-layers ,image-array-layers 486 | :image-usage ,image-usage 487 | :image-sharing-mode ,image-sharing-mode 488 | :p-queue-family-indices ,queue-family-indices 489 | :pre-transform ,pre-transform 490 | :composite-alpha ,composite-alpha 491 | :present-mode ,present-mode 492 | :clipped ,clipped 493 | :old-swapchain ,(or old-swapchain 494 | (null-pointer)))))) 495 | 496 | (with-with (with-fence (%vk:destroy-fence device)) 497 | (defun create-fence (device &key signaled) 498 | (%create-fence device `(:flags ,(if signaled '(:signaled) 0))))) 499 | 500 | (with-with (with-semaphore (%vk:destroy-semaphore device)) 501 | (defun create-semaphore (device) 502 | (%create-semaphore device `(:flags 0)))) 503 | 504 | 505 | (with-with (with-command-pool (%vk:destroy-command-pool device)) 506 | (defun create-command-pool (device &key (queue-family 0) 507 | flags) 508 | (%create-command-pool device `(:flags ,(or flags 0) 509 | :queue-family-index ,queue-family)))) 510 | 511 | (with-with (with-command-buffers (free-command-buffers device command-pool) 512 | :allocator nil) 513 | (defun allocate-command-buffers (device command-pool count 514 | &key (level :primary)) 515 | (%allocate-command-buffers device 516 | `(:command-pool ,command-pool 517 | :level ,level 518 | :command-buffer-count ,count)))) 519 | 520 | (defmacro with-commands ((command-buffer &key begin-flags) &body body) 521 | `(progn 522 | (%vk::with-vk-structs ((bi %vk:command-buffer-begin-info 523 | '(:flags ,(or (alexandria:ensure-list begin-flags) 524 | 0) 525 | :p-inheritance-info 526 | ( ;:render-pass nil;; render-pass 527 | :subpass 0 528 | ;:framebuffer nil;; framebuffer 529 | :occlusion-query-enable nil 530 | ;; query-control-flags 531 | :query-flags 0 532 | ;; query-pipeline-statistic-flags 533 | :pipeline-statistics 0)))) 534 | (%vk:begin-command-buffer ,command-buffer bi) 535 | ,@body 536 | (%vk:end-command-buffer ,command-buffer)))) 537 | 538 | 539 | 540 | (defun create-image-view (device image 541 | &key flags 542 | (view-type :2d) 543 | (format) 544 | (components '(:r :r :g :g :b :b :a :a)) 545 | (subresource-range '(:aspect-mask :color 546 | :base-mip-level 0 547 | :level-count 1 548 | :base-array-layer 0 549 | :layer-count 1))) 550 | (%create-image-view device `(:image ,image 551 | :format ,format 552 | :flags ,flags 553 | :view-type ,view-type 554 | :components ,components 555 | :subresource-range ,subresource-range))) 556 | 557 | 558 | 559 | ;; fixme: handle case where amount of objects changes between when we 560 | ;; query count and when we query actual values. 561 | ;; (possibly for example in enumerate-instance-layer/extension-properties 562 | ;; if someone installs more at that exact instant) 563 | (defun enumerate-physical-devices (instance) 564 | (with-foreign-object (p-count :uint32) 565 | (setf (mem-ref p-count :uint32) 0) 566 | (%vk:enumerate-physical-devices instance p-count (null-pointer)) 567 | (let ((count (mem-ref p-count :uint32))) 568 | (with-foreign-object (phys '%vk:physical-device count) 569 | (let ((ret (%vk:enumerate-physical-devices instance p-count phys))) 570 | (values (loop for i below count 571 | collect (mem-aref phys '%vk:physical-device i)) 572 | ret)))))) 573 | 574 | (macrolet 575 | ((getter (.object fun .type &rest args) 576 | (let* ((%vk (find-package '%vk)) 577 | (counted (typep .type '(cons (eql :count)))) 578 | (type-name (if (consp .type) (second .type) .type)) 579 | (vkfun (find-symbol (string fun) %vk)) 580 | (deref (find-symbol (format nil "DEREF-~a" type-name) %vk)) 581 | (type (if deref `(:struct ,type-name) type-name)) 582 | (object (when .object (list .object)))) 583 | (flet ((ref (p) 584 | (if deref 585 | `(,deref ,p) 586 | `(mem-ref ,p ',type)))) 587 | (assert vkfun () "~s not found?" fun) 588 | (if counted 589 | (print `(defun ,fun (,@object ,@args) 590 | (let ((count 0)) 591 | (with-foreign-object (c :uint32) 592 | (setf (mem-ref c :uint32) 0) 593 | (,vkfun ,@object ,@args c (null-pointer)) 594 | (setf count (mem-ref c :uint32)) 595 | (with-foreign-object (p ',type count) 596 | (,vkfun ,@object ,@args c p) 597 | (loop for i below count 598 | collect ,(ref 599 | `(inc-pointer p 600 | (* i ,(foreign-type-size 601 | type)))))))))) 602 | (print `(defun ,fun (,@object ,@args) 603 | (with-foreign-object (p ',type) 604 | (,vkfun ,@object ,@args p) 605 | ,(ref 'p)))))))) 606 | (getters (object &body defs) 607 | (cons 'progn 608 | (loop for def in defs 609 | collect `(getter ,object ,@def))))) 610 | 611 | (getters nil 612 | (enumerate-instance-extension-properties (:count %vk:extension-properties) layer-name) 613 | (enumerate-instance-layer-properties (:count %vk:layer-properties)) 614 | ) 615 | 616 | (getters device 617 | (get-buffer-memory-requirements %vk:memory-requirements buffer) 618 | (get-image-memory-requirements %vk:memory-requirements image) 619 | (get-image-sparse-memory-requirements (:count %vk:sparse-image-memory-requirements) image) 620 | (get-render-area-granularity %vk:extent-2d render-pass) 621 | (get-swapchain-images-khr (:count %vk:image) swapchain) 622 | (get-device-memory-commitment %vk:device-size memory) 623 | (acquire-next-image-khr :uint32 swapchain timeout semaphore fence) 624 | ) 625 | 626 | (getters physical-device 627 | (enumerate-device-extension-properties (:count %vk:extension-properties) layer-name) 628 | (enumerate-device-layer-properties (:count %vk:layer-properties)) 629 | (get-display-mode-properties-khr (:count %vk:display-mode-properties-khr) display) 630 | (get-display-plane-capabilities-khr %vk:display-plane-capabilities-khr mode plane-index) 631 | #++(get-display-plane-supported-displays-khr (:count %vk:display-khr) plane-index) 632 | (get-physical-device-display-plane-properties-khr (:count %vk:display-plane-properties-khr)) 633 | (get-physical-device-display-properties-khr (:count %vk:display-properties-khr)) 634 | (get-physical-device-features %vk:physical-device-features) 635 | (get-physical-device-format-properties %vk:format-properties format) 636 | (get-physical-device-image-format-properties %vk:image-format-properties format type tiling usage flags) 637 | (get-physical-device-memory-properties %vk:physical-device-memory-properties) 638 | (get-physical-device-properties %vk:physical-device-properties) 639 | (get-physical-device-queue-family-properties (:count %vk:queue-family-properties)) 640 | (get-physical-device-sparse-image-format-properties (:count %vk:sparse-image-format-properties) format type samples usage tiiling) 641 | (get-physical-device-surface-capabilities-khr %vk:surface-capabilities-khr surface) 642 | (get-physical-device-surface-formats-khr (:count %vk:surface-format-khr) surface) 643 | (get-physical-device-surface-present-modes-khr (:count %vk:present-mode-khr) surface))) 644 | 645 | #++ 646 | (defun get-device-memory-commitment (device memory) 647 | (with-foreign-object (p '%vk:device-size) 648 | (%vk:get-device-memory-commitment device memory p) 649 | (mem-ref p '%vk:device-size))) 650 | 651 | (defun get-device-queue (device queue-family-index queue-index) 652 | (with-foreign-object (p '%vk:queue) 653 | (%vk:get-device-queue device queue-family-index queue-index p) 654 | (mem-ref p '%vk:queue))) 655 | 656 | (defun get-physical-device-surface-support-khr (physical-device queue-family-index surface) 657 | (with-foreign-object (p '%vk:bool32) 658 | (%vk:get-physical-device-surface-support-khr physical-device queue-family-index surface p) 659 | (mem-ref p '%vk:bool32))) 660 | 661 | 662 | (defun get-image-subresource-layout (device image subresource) 663 | (%vk::with-vk-structs ((sr %vk:image-subresource subresource)) 664 | (with-foreign-object (p '(:struct %vk:subresource-layout)) 665 | (%vk:get-image-subresource-layout device image sr p) 666 | (%vk::deref-physical-device-memory-properties p)))) 667 | 668 | 669 | (macrolet 670 | ((wrap-counted-args (name &body args) 671 | (let ((pointers (loop for a in args 672 | if (consp a) 673 | collect (gensym "P") 674 | else collect nil)) 675 | (i (gensym "I")) 676 | (o (gensym "O"))) 677 | (print 678 | `(defun ,name ,(loop for a in args 679 | if (consp a) 680 | collect (car a) 681 | else collect a) 682 | (with-foreign-objects 683 | (,@(loop for a in args 684 | for p in pointers 685 | when (consp a) 686 | collect (list p `',(second a) 687 | (if (eq (third a) :pointer) 688 | 1 689 | `(length ,(first a)))))) 690 | ,@(loop for a in args 691 | for p in pointers 692 | for at = (when (consp a) (second a)) 693 | for setter = `(setf (mem-aref ,p ',at ,i) ,o) 694 | when (consp a) 695 | do (when (consp at) 696 | (setf setter 697 | `(,(find-symbol (format nil "FILL-~a" 698 | (second at)) 699 | (find-package :%vk)) 700 | ,p ,o))) 701 | and collect (if (eq (third a) :pointer) 702 | `(let ((,i 0) 703 | (,o ,(first a))) 704 | (declare (ignorable ,i)) 705 | ,setter) 706 | `(loop for ,o in ,(first a) 707 | for ,i from 0 708 | do ,setter))) 709 | (,(find-symbol (string name) (find-package :%vk)) 710 | ,@(loop for a in args 711 | for p in pointers 712 | if (and (consp a) (not (eq (third a) :pointer))) 713 | collect `(length ,(first a)) 714 | if (consp a) collect p 715 | else collect a)))))))) 716 | (wrap-counted-args reset-fences device (fences %vk:fence)) 717 | (wrap-counted-args wait-for-fences device (fences %vk:fence) wait-all timeout) 718 | (wrap-counted-args free-command-buffers device command-pool (command-buffers %vk:command-buffer)) 719 | (wrap-counted-args cmd-clear-color-image command-buffer image image-layout 720 | (color (:union %vk:clear-color-value) :pointer) 721 | (ranges (:struct %vk:image-subresource-range)))) 722 | 723 | 724 | ;; not sure about full version of this, API would be messier, and probably 725 | ;; if submitting a bunch at once mattered, we'd also want to pre-allocate 726 | ;; and reuse the foreign struct anyway 727 | (defun queue-submit1 (queue buffer &key wait-semaphores wait-dst-stage-mask 728 | signal-semaphores 729 | fence) 730 | "simplified queue submit that only accepts a single command 731 | buffer (or single batch of command buffers with same waits/signals)" 732 | (%vk::with-vk-structs ((vsi %vk:submit-info 733 | `(:wait-semaphores ,wait-semaphores 734 | :wait-dst-stage-mask ,wait-dst-stage-mask 735 | :signal-semaphores ,signal-semaphores 736 | :buffers ,(alexandria:ensure-list buffer)))) 737 | (%vk:queue-submit queue 1 vsi 738 | (or fence (cffi:null-pointer))))) 739 | 740 | (defun cmd-pipeline-barrier (command-buffer 741 | src-stage-mask dst-stage-mask 742 | &key dependency-flags 743 | memory-barriers 744 | buffer-memory-barriers 745 | image-memory-barriers) 746 | (let ((lmb (length memory-barriers)) 747 | (lbmb (length buffer-memory-barriers)) 748 | (limb (length image-memory-barriers))) 749 | (%vk::with-vk-structs ((mb %vk:memory-barrier memory-barriers lmb) 750 | (bmb %vk:buffer-memory-barrier buffer-memory-barriers lbmb) 751 | (imb %vk:image-memory-barrier image-memory-barriers limb)) 752 | (%vk:cmd-pipeline-barrier command-buffer src-stage-mask dst-stage-mask 753 | dependency-flags 754 | lmb mb 755 | lbmb bmb 756 | limb imb)))) 757 | --------------------------------------------------------------------------------