luv

Workshop wiki

native.lisp

hal/vulkan/native.lisp

system luv · 157 definitions · on GitHub

Lisp-shaped Vulkan operations built on the owned ABI.

The raw `vk:` entry points and structs stay in defs.lisp; this file gives the GPU and canvas backends the small, direct `lvk:` vocabulary they use.

in-package#:luv.vulkan

The three ordinary Vulkan call shapes used so far.

defmacrodefine-enumerator
namelambda-listcall&keyelementextractor
operation
intern
symbol-namename
:keyword
let
count
gensym"COUNT"
capacity
gensym"CAPACITY"
items
gensym"ITEMS"
result
gensym"RESULT"
index
gensym"INDEX"
`
defun,name,lambda-list
cffi:with-foreign-object
,count:uint32
setf
cffi:mem-ref,count:uint32
0
with-vulkan-results
,operation:success:incomplete
,
firstcall
,@
restcall
,count
cffi:null-pointer
loopfor,capacity=
cffi:mem-ref,count:uint32
when
zerop,capacity
returnnildo
cffi:with-foreign-object
,items',element,capacity
let
,result
with-vulkan-results
,operation:success:incomplete
,
firstcall
,@
restcall
,count,items
unless
eq,result:incomplete
return-from,name
loopfor,indexbelow
cffi:mem-ref,count:uint32
collect,
ifextractor`
,extractor,items,index
`
cffi:mem-aref,items',element,index
defmacrodefine-creator
namelambda-listcall&key
element:pointer
checked
operation
intern
symbol-namename
:keyword
let
output
gensym"OUTPUT"
`
defun,name,lambda-list
cffi:with-foreign-object
,output',element
,
ifchecked`
with-vulkan-results
,operation
,
firstcall
,@
restcall
,output
`
,
firstcall
,@
restcall
,output
cffi:mem-ref,output',element
defunextension-property-name
propertiesindex
let
property
cffi:mem-aptrproperties'index
cffi:foreign-string-to-lisp
cffi:foreign-slot-pointerproperty''extension-name
define-enumeratorenumerate-instance-extension-names
vk:enumerate-instance-extension-properties
cffi:null-pointer
:element:extractorextension-property-name:operation:enumerate-instance-extension-properties
define-enumeratorenumerate-device-extension-names
physical-device
vk:enumerate-device-extension-propertiesphysical-device
cffi:null-pointer
:element:extractorextension-property-name:operation:enumerate-device-extension-properties
define-creatorcreate-instance-handle
create-info
vk:create-instancecreate-info
cffi:null-pointer
:checkedt:operation:create-instance
define-creatorcreate-device-handle
physical-devicecreate-info
vk:create-devicephysical-devicecreate-info
cffi:null-pointer
:checkedt:operation:create-device
define-creatorget-device-queue-handle
devicequeue-family-indexqueue-index
vk:get-device-queuedevicequeue-family-indexqueue-index
define-creatorcreate-image-handle
devicecreate-info
vk:create-imagedevicecreate-info
cffi:null-pointer
:checkedt:operation:create-image
define-creatorcreate-buffer-handle
devicecreate-info
vk:create-bufferdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-buffer
define-creatorallocate-memory-handle
deviceallocate-info
vk:allocate-memorydeviceallocate-info
cffi:null-pointer
:checkedt:operation:allocate-memory
define-creatorcreate-image-view-handle
devicecreate-info
vk:create-image-viewdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-image-view
define-creatorcreate-shader-module-handle
devicecreate-info
vk:create-shader-moduledevicecreate-info
cffi:null-pointer
:checkedt:operation:create-shader-module
define-creatorcreate-descriptor-set-layout-handle
devicecreate-info
vk:create-descriptor-set-layoutdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-descriptor-set-layout
define-creatorcreate-pipeline-layout-handle
devicecreate-info
vk:create-pipeline-layoutdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-pipeline-layout
define-creatorcreate-compute-pipeline-handle
devicecreate-info
vk:create-compute-pipelinesdevice
cffi:null-pointer
1create-info
cffi:null-pointer
:checkedt:operation:create-compute-pipeline
define-creatorcreate-graphics-pipeline-handle
devicecreate-info
vk:create-graphics-pipelinesdevice
cffi:null-pointer
1create-info
cffi:null-pointer
:checkedt:operation:create-graphics-pipeline
define-creatorcreate-sampler-handle
devicecreate-info
vk:create-samplerdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-sampler
define-creatorcreate-render-pass-handle
devicecreate-info
vk:create-render-passdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-render-pass
define-creatorcreate-framebuffer-handle
devicecreate-info
vk:create-framebufferdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-framebuffer
define-creatorcreate-descriptor-pool-handle
devicecreate-info
vk:create-descriptor-pooldevicecreate-info
cffi:null-pointer
:checkedt:operation:create-descriptor-pool
define-creatorallocate-descriptor-set-handle
deviceallocate-info
vk:allocate-descriptor-setsdeviceallocate-info
:checkedt:operation:allocate-descriptor-set
define-creatorcreate-command-pool-handle
devicecreate-info
vk:create-command-pooldevicecreate-info
cffi:null-pointer
:checkedt:operation:create-command-pool
define-creatorallocate-command-buffer-handle
deviceallocate-info
vk:allocate-command-buffersdeviceallocate-info
:checkedt:operation:allocate-command-buffer
define-creatorcreate-swapchain-handle
devicecreate-info
vk:create-swapchain-khrdevicecreate-info
cffi:null-pointer
:checkedt:operation:create-swapchain
define-creatorcreate-semaphore-handle
devicecreate-info
vk:create-semaphoredevicecreate-info
cffi:null-pointer
:checkedt:operation:create-semaphore

Public, Lisp-shaped operations.

defstructqueue-family
flagsnil:typelist
count0:type
unsigned-byte32
defstructphysical-memory-type
flagsnil:typelist
heap-index0:type
unsigned-byte32
defstructimage-memory-requirements
size0:type
unsigned-byte64
alignment0:type
unsigned-byte64
memory-type-bits0:type
unsigned-byte32
defstructbuffer-memory-requirements
size0:type
unsigned-byte64
alignment0:type
unsigned-byte64
memory-type-bits0:type
unsigned-byte32
defstructpresentation-capabilities
min-image-count0:type
unsigned-byte32
max-image-count0:type
unsigned-byte32
current-extentmin-image-extentmax-image-extentcurrent-transform
composite-alphanil:typelist
usagenil:typelist
defstructpresentation-timing-capabilities
supported-pnil:typeboolean
absolute-time-pnil:typeboolean
relative-time-pnil:typeboolean
stagesnil:typelist
present-id-2-pnil:typeboolean
defstructswapchain-timing-properties
refresh-duration0:type
unsigned-byte64
refresh-interval0:type
unsigned-byte64
defstructpresentation-formatformatcolor-space
defunmake-version
majorminorpatch
logior
ashmajor22
ashminor12
patch
defuncreate-instance
&key
application-name"luv"
:application-versionapplication-version-value
engine-name"luv"
:engine-versionengine-version-value

Luv assumes modern Vulkan. Timeline semaphores and synchronization2 are mandatory core features at this version.

:api-versionapi-version-value
flagsenabled-extension-names
with-translated-values
application-name-pointerapplication-name:string
engine-name-pointerengine-name:string
extension-namesenabled-extension-namesstring-list
with-vk
application-infoapplication-info:p-application-nameapplication-name-pointer:application-versionapplication-version-value:p-engine-nameengine-name-pointer:engine-versionengine-version-value:api-versionapi-version-value
with-vk
create-infoinstance-create-info:flagsflags:p-application-infoapplication-info:enabled-layer-count0:pp-enabled-layer-names
cffi:null-pointer
:enabled-extension-count
lengthenabled-extension-names
:pp-enabled-extension-namesextension-names
defundestroy-instance
instance
vk:destroy-instanceinstance
cffi:null-pointer
values
defstruct
debug-message
:constructor%make-debug-message
severitytypesid-nameid-numbertext
defstruct
debug-messenger
:constructor%make-debug-messenger
instancehandleuser-data
destroyed-pnil
defvar*debug-messenger-callbacks*
make-hash-table:test#'eql
"Callbacks keyed by the address passed through VkDebugUtils user data."
defunnullable-foreign-string
pointer
unless
cffi:null-pointer-ppointer
cffi:foreign-string-to-lisppointer
cffi:defcallbackdispatch-debug-utils-message:uint32
severitydebug-utils-message-severity-flags
typesdebug-utils-message-type-flags
callback-data:pointer
user-data:pointer

Never unwind through a Vulkan driver. Callback failures are reported and Vulkan is always told not to abort the call which produced the message.

handler-case
let
callback
gethash
cffi:pointer-addressuser-data
*debug-messenger-callbacks*
whencallback
cffi:with-foreign-slots
p-message-id-namemessage-id-numberp-message
callback-data
funcallcallback
%make-debug-message:severityseverity:typestypes:id-name
nullable-foreign-stringp-message-id-name
:id-numbermessage-id-number:text
serious-condition
condition
ignore-errors
format*error-output*"~&Vulkan debug callback failed: ~A~%"condition
0
defuninstance-procedure
instancename
let
procedure
vk:get-instance-proc-addrinstancename
when
cffi:null-pointer-pprocedure
error"Vulkan instance procedure ~A is unavailable."name
procedure
defuninstall-debug-messenger
instancecallback&key
severities'
:warning:error
types'
:general:validation:performance

Install callback for instance and return an owned DEBUG-MESSENGER.

callback receives one DEBUG-MESSAGE. VK_EXT_debug_utils must have been enabled when instance was created. Keep the returned messenger alive and destroy it before destroying instance.

check-typecallback
let
user-data
cffi:foreign-alloc:uint8
handlenil
completed-pnil
setf
gethash
cffi:pointer-addressuser-data
*debug-messenger-callbacks*
callback
unwind-protect
with-vk
create-infodebug-utils-messenger-create-info-ext:flags0:message-severityseverities:message-typetypes:pfn-user-callback:p-user-datauser-data
cffi:with-foreign-object
output:pointer
setf
cffi:mem-refoutput:pointer
cffi:null-pointer
with-vulkan-results
:create-debug-utils-messenger-ext
vk:create-debug-utils-messenger-extinstancecreate-info
cffi:null-pointer
output
setfhandle
cffi:mem-refoutput:pointer
completed-pt
%make-debug-messenger:instanceinstance:handlehandle:user-datauser-data
unlesscompleted-p
remhash
cffi:pointer-addressuser-data
*debug-messenger-callbacks*
cffi:foreign-freeuser-data
defundestroy-debug-messenger
messenger

Destroy messenger and release its Lisp callback. Safe to call twice.

unless
debug-messenger-destroyed-pmessenger
unwind-protect
vk:destroy-debug-utils-messenger-ext
debug-messenger-instancemessenger
debug-messenger-handlemessenger
cffi:null-pointer
remhash
cffi:pointer-address
debug-messenger-user-datamessenger
*debug-messenger-callbacks*
cffi:foreign-free
debug-messenger-user-datamessenger
setf
debug-messenger-destroyed-pmessenger
t
values
defunphysical-device-queue-families
physical-device
cffi:with-foreign-object
count:uint32
setf
cffi:mem-refcount:uint32
0
vk:get-physical-device-queue-family-propertiesphysical-devicecount
cffi:null-pointer
let
capacity
cffi:mem-refcount:uint32
if
zeropcapacity
nil
cffi:with-foreign-object
properties'capacity
vk:get-physical-device-queue-family-propertiesphysical-devicecountproperties
loopforindexbelow
mincapacity
cffi:mem-refcount:uint32
forproperty=
cffi:mem-aptrproperties'index
collect
cffi:with-foreign-slots
queue-flagsqueue-count
property
make-queue-family:flagsqueue-flags:countqueue-count
defunphysical-device-shader-int64-p
physical-device

Whether physical-device exposes Vulkan's core shaderInt64 feature.

cffi:with-foreign-object
features'
vk:get-physical-device-featuresphysical-devicefeatures
not
zerop
cffi:foreign-slot-valuefeatures''shader-int64
defunphysical-device-mesh-shader-p
physical-device

Whether physical-device offers VK_EXT_mesh_shader's task and mesh stages.

defunphysical-device-presentation-features
physical-device&keypresent-timing-ppresent-id-2-p

Return the optional presentation feature bits exposed by physical-device.

The values are PRESENT-TIMING, PRESENT-AT-ABSOLUTE-TIME, PRESENT-AT-RELATIVE-TIME, and present-id-2. A feature whose extension was not advertised is never placed in the query chain and is returned as NIL.

if
orpresent-timing-ppresent-id-2-p
with-vk
with-vk
timing-featuresphysical-device-present-timing-features-ext:p-next
ifpresent-id-2-pid-features
cffi:null-pointer
:present-timing0:present-at-absolute-time0:present-at-relative-time0
with-vk
featuresphysical-device-features-2:p-next
cond
present-timing-ptiming-features
present-id-2-pid-features
t
cffi:null-pointer
vk:get-physical-device-features2physical-devicefeatures
values
andpresent-timing-p
not
zerop
cffi:foreign-slot-valuetiming-features''present-timing
andpresent-timing-p
not
zerop
cffi:foreign-slot-valuetiming-features''present-at-absolute-time
andpresent-timing-p
not
zerop
cffi:foreign-slot-valuetiming-features''present-at-relative-time
andpresent-id-2-p
not
zerop
cffi:foreign-slot-valueid-features''present-id-2
valuesnilnilnilnil
defuncreate-device
physical-devicefamily-index&keyenabled-extension-namesadditional-family-indices
unless
error"The Vulkan physical device lacks luv's required shaderInt64 feature."
let
present-timing-p
member+present-timing-extension-name+enabled-extension-names:test#'string=
present-id-2-p
member+present-id-2-extension-name+enabled-extension-names:test#'string=
multiple-value-bind
present-timing-feature-ppresent-at-absolute-time-ppresent-at-relative-time-ppresent-id-2-feature-p
physical-device-presentation-featuresphysical-device:present-timing-ppresent-timing-p:present-id-2-ppresent-id-2-p
with-translated-values
extension-namesenabled-extension-namesstring-list
let*
families
remove-duplicates
consfamily-indexadditional-family-indices
queue-count
lengthfamilies
cffi:with-foreign-object
queue-priority:float
setf
cffi:mem-refqueue-priority:float
1.0
cffi:with-foreign-object
queue-infos'queue-count
loopforfamilyinfamiliesforindexfrom0do
fill-vk
cffi:mem-aptrqueue-infos'index
'device-queue-create-info:flags0:queue-family-indexfamily:queue-count1:p-queue-prioritiesqueue-priority
with-vk
featuresphysical-device-features:shader-int641
with-vk
timeline-featuresphysical-device-timeline-semaphore-features:timeline-semaphore1
with-vk
synchronization-featuresphysical-device-synchronization-2-features:p-nexttimeline-features:synchronization-21

Asking for VK_EXT_mesh_shader admits its commands; the two stages themselves are features, and a pipeline whose module declares MeshShadingEXT is invalid without them.

with-vk
mesh-featuresphysical-device-mesh-shader-features-ext:p-nextsynchronization-features:task-shader1:mesh-shader1:multiview-mesh-shader0:primitive-fragment-shading-rate-mesh-shader0:mesh-shader-queries0
let
base-features
if
member+mesh-shader-extension-name+enabled-extension-names:test#'string=
mesh-featuressynchronization-features
with-vk
id-featuresphysical-device-present-id-2-features-khr:p-nextbase-features:present-id-2
ifpresent-id-2-feature-p10
with-vk
timing-featuresphysical-device-present-timing-features-ext:p-next
ifpresent-id-2-pid-featuresbase-features
:present-timing
ifpresent-timing-feature-p10
:present-at-absolute-time
ifpresent-at-absolute-time-p10
:present-at-relative-time
ifpresent-at-relative-time-p10
with-vk
create-infodevice-create-info:p-next
cond
present-timing-ptiming-features
present-id-2-pid-features
tbase-features
:flags0:queue-create-info-countqueue-count:p-queue-create-infosqueue-infos:enabled-layer-count0:pp-enabled-layer-names
cffi:null-pointer
:enabled-extension-count
lengthenabled-extension-names
:pp-enabled-extension-namesextension-names:p-enabled-featuresfeatures
create-device-handlephysical-devicecreate-info
defundestroy-device
device
vk:destroy-devicedevice
cffi:null-pointer
values
defunget-device-queue
devicequeue-family-index&optional
queue-index0
get-device-queue-handledevicequeue-family-indexqueue-index
defundevice-wait-idle
device
values
defunphysical-device-memory-types
physical-device
cffi:with-foreign-object
vk:get-physical-device-memory-propertiesphysical-deviceproperties
let
count
cffi:foreign-slot-valueproperties''memory-type-count
types
cffi:foreign-slot-pointerproperties''memory-types
loopforindexbelowcountformemory-type=
cffi:mem-aptrtypes'index
collect
cffi:with-foreign-slots
property-flagsheap-index
memory-type
make-physical-memory-type:flagsproperty-flags:heap-indexheap-index
defuncreate-image
device&keytypeformatwidthheight
depth1
usage
mip-levels1
array-layers1
samples:1
tiling:optimal
sharing-mode:exclusive
initial-layout:undefined
with-vk
create-infoimage-create-info:flags0:image-typetype:formatformat:mip-levelsmip-levels:array-layersarray-layers:samplessamples:tilingtiling:usageusage:sharing-modesharing-mode:queue-family-index-count0:p-queue-family-indices
cffi:null-pointer
:initial-layoutinitial-layout
fill-vk
cffi:foreign-slot-pointercreate-info''extent
'extent-3d:widthwidth:heightheight:depthdepth
create-image-handledevicecreate-info
defundestroy-image
deviceimage
vk:destroy-imagedeviceimage
cffi:null-pointer
values
defunget-image-memory-requirements
deviceimage
cffi:with-foreign-object
requirements'
vk:get-image-memory-requirementsdeviceimagerequirements
cffi:with-foreign-slots
sizealignmentmemory-type-bits
requirements
make-image-memory-requirements:sizesize:alignmentalignment:memory-type-bitsmemory-type-bits
defuncreate-buffer
devicesizeusage
with-vk
create-infobuffer-create-info:flags0:sizesize:usageusage:sharing-mode:exclusive:queue-family-index-count0:p-queue-family-indices
cffi:null-pointer
create-buffer-handledevicecreate-info
defundestroy-buffer
devicebuffer
vk:destroy-bufferdevicebuffer
cffi:null-pointer
values
defunget-buffer-memory-requirements
devicebuffer
cffi:with-foreign-object
requirements'
vk:get-buffer-memory-requirementsdevicebufferrequirements
cffi:with-foreign-slots
sizealignmentmemory-type-bits
requirements
make-buffer-memory-requirements:sizesize:alignmentalignment:memory-type-bitsmemory-type-bits
defunallocate-memory
devicesizememory-type-index
with-vk
allocate-infomemory-allocate-info:allocation-sizesize:memory-type-indexmemory-type-index
allocate-memory-handledeviceallocate-info
defunfree-memory
devicememory
vk:free-memorydevicememory
cffi:null-pointer
values
defunbind-image-memory
deviceimagememory&optional
offset0
with-vulkan-results
:bind-image-memory
vk:bind-image-memorydeviceimagememoryoffset
values
defunbind-buffer-memory
devicebuffermemory&optional
offset0
with-vulkan-results
:bind-buffer-memory
vk:bind-buffer-memorydevicebuffermemoryoffset
values
defunmap-memory
devicememorysize&optional
offset0
cffi:with-foreign-object
data:pointer
with-vulkan-results
:map-memory
vk:map-memorydevicememoryoffsetsize0data
cffi:mem-refdata:pointer
defununmap-memory
devicememory
vk:unmap-memorydevicememory
values
defuncreate-image-view
deviceimageformat&key
view-type:2d
aspect:color
with-vk
create-infoimage-view-create-info:flags0:imageimage:view-typeview-type:formatformat
fill-vk
cffi:foreign-slot-pointercreate-info''components
'component-mapping:r:identity:g:identity:b:identity:a:identity
fill-image-subresource-range
cffi:foreign-slot-pointercreate-info''subresource-range
aspect
create-image-view-handledevicecreate-info
defundestroy-image-view
deviceview
vk:destroy-image-viewdeviceview
cffi:null-pointer
values
defuncreate-shader-module
devicewords
with-foreign-array
code:uint32words
with-vk
create-infoshader-module-create-info:flags0:code-size
*4
lengthwords
:p-codecode
defuncreate-storage-image-descriptor-set-layout
device&key
binding0
with-vk
layout-bindingdescriptor-set-layout-binding:bindingbinding:descriptor-type:storage-image:descriptor-count1:stage-flags'
:compute
:p-immutable-samplers
cffi:null-pointer
with-vk
create-infodescriptor-set-layout-create-info:flags0:binding-count1:p-bindingslayout-binding
defuncreate-uniform-buffer-descriptor-set-layout
device&key
binding0
stages'
:vertex
with-vk
layout-bindingdescriptor-set-layout-binding:bindingbinding:descriptor-type:uniform-buffer:descriptor-count1:stage-flagsstages:p-immutable-samplers
cffi:null-pointer
with-vk
create-infodescriptor-set-layout-create-info:flags0:binding-count1:p-bindingslayout-binding
defuntexture-sampler-uniform-descriptor-type
ecasetype
:texture:sampled-image
:sampler:sampler
:uniform-buffer:uniform-buffer
:storage-buffer:storage-buffer
defuntexture-sampler-uniform-descriptor-stages
entry

A mesh pipeline has no vertex stage, and a resource it reads from the task or mesh stage must say so: a descriptor visible only to :VERTEX is not visible to the stages that replaced it.

or
getfentry:stages
ecase
getfentry:type
:texture:sampler:uniform-buffer:storage-buffer
'
:vertex:fragment
defuncreate-texture-sampler-uniform-descriptor-set-layout
deviceentries
let
count
lengthentries
cffi:with-foreign-object
bindings'count
loopforentryinentriesforindexfrom0do
fill-vk
cffi:mem-aptrbindings'index
'descriptor-set-layout-binding:binding
getfentry:binding
:descriptor-type:descriptor-count1:stage-flags:p-immutable-samplers
cffi:null-pointer
with-vk
create-infodescriptor-set-layout-create-info:flags0:binding-countcount:p-bindingsbindings
defuncreate-pipeline-layout
deviceset-layouts
with-foreign-array
layouts:pointerset-layouts
with-vk
create-infopipeline-layout-create-info:flags0:set-layout-count
lengthset-layouts
:p-set-layoutslayouts:push-constant-range-count0:p-push-constant-ranges
cffi:null-pointer
defuncreate-compute-pipeline
cffi:with-foreign-string
entry-point-pointerentry-point
with-vk
create-infocompute-pipeline-create-info:flags0:layoutlayout:base-pipeline-handle
cffi:null-pointer
:base-pipeline-index-1
fill-vk
cffi:foreign-slot-pointercreate-info''stage
'pipeline-shader-stage-create-info:flags0:stage'
:compute
:moduleshader-module:p-nameentry-point-pointer:p-specialization-info
cffi:null-pointer
defuncreate-sampler
device&key
mag-filter:linear
min-filter:linear
mipmap-mode:nearest
address-mode-u:clamp-to-edge
address-mode-v:clamp-to-edge
address-mode-w:clamp-to-edge
compare
with-vk
create-infosampler-create-info:flags0:mag-filtermag-filter:min-filtermin-filter:mipmap-modemipmap-mode:address-mode-uaddress-mode-u:address-mode-vaddress-mode-v:address-mode-waddress-mode-w:mip-lod-bias0.0:anisotropy-enable0:max-anisotropy1.0:compare-enable
ifcompare10
:compare-op
orcompare:always
:min-lod0.0:max-lod0.0:border-color:float-transparent-black:unnormalized-coordinates0
create-sampler-handledevicecreate-info
defundestroy-sampler
devicesampler
vk:destroy-samplerdevicesampler
cffi:null-pointer
values
defunvulkan-attachment-store-op
store-op
ecasestore-op
:store:store
:discard:dont-care
defuncreate-color-render-pass
deviceformats&keydepth-format
depth-store-op:discard

Create a pass whose color attachments have formats in location order.

let*
formats
cond
vectorpformats
formats
listpformats
coerceformats'vector
t
vectorformats
color-count
lengthformats
attachment-count
+color-count
ifdepth-format10
cffi:with-foreign-object
attachments'attachment-count
loopforformatacrossformatsforindexfrom0do
fill-vk
cffi:mem-aptrattachments'index
'attachment-description:flags0:formatformat:samples:1:load-op:clear:store-op:store:stencil-load-op:dont-care:stencil-store-op:dont-care:initial-layout:color-attachment-optimal:final-layout:color-attachment-optimal
whendepth-format
fill-vk
cffi:mem-aptrattachments'color-count
'attachment-description:flags0:formatdepth-format:samples:1:load-op:clear:store-op:stencil-load-op:dont-care:stencil-store-op:dont-care:initial-layout:depth-stencil-attachment-optimal:final-layout:depth-stencil-attachment-optimal
cffi:with-foreign-object
color-references'color-count
dotimes
indexcolor-count
fill-vk
cffi:mem-aptrcolor-references'index
'attachment-reference:attachmentindex:layout:color-attachment-optimal
labels
create-with-depth-reference
depth-reference
with-vk
subpasssubpass-description:flags0:pipeline-bind-point:graphics:input-attachment-count0:p-input-attachments
cffi:null-pointer
:color-attachment-countcolor-count:p-color-attachmentscolor-references:p-resolve-attachments
cffi:null-pointer
:p-depth-stencil-attachmentdepth-reference:preserve-attachment-count0:p-preserve-attachments
cffi:null-pointer
with-vk
create-inforender-pass-create-info:flags0:attachment-countattachment-count:p-attachmentsattachments:subpass-count1:p-subpassessubpass:dependency-count0:p-dependencies
cffi:null-pointer
create-render-pass-handledevicecreate-info
ifdepth-format
with-vk
depth-referenceattachment-reference:attachmentcolor-count:layout:depth-stencil-attachment-optimal
create-with-depth-referencedepth-reference
create-with-depth-reference
cffi:null-pointer
defuncreate-depth-render-pass
devicedepth-format&key
depth-store-op:store
cffi:with-foreign-object
attachments'1
fill-vkattachments'attachment-description:flags0:formatdepth-format:samples:1:load-op:clear:store-op:stencil-load-op:dont-care:stencil-store-op:dont-care:initial-layout:depth-stencil-attachment-optimal:final-layout:depth-stencil-attachment-optimal
with-vk
depth-referenceattachment-reference:attachment0:layout:depth-stencil-attachment-optimal
with-vk
subpasssubpass-description:flags0:pipeline-bind-point:graphics:input-attachment-count0:p-input-attachments
cffi:null-pointer
:color-attachment-count0:p-color-attachments
cffi:null-pointer
:p-resolve-attachments
cffi:null-pointer
:p-depth-stencil-attachmentdepth-reference:preserve-attachment-count0:p-preserve-attachments
cffi:null-pointer
with-vk
create-inforender-pass-create-info:flags0:attachment-count1:p-attachmentsattachments:subpass-count1:p-subpassessubpass:dependency-count0:p-dependencies
cffi:null-pointer
create-render-pass-handledevicecreate-info
defundestroy-render-pass
devicerender-pass
vk:destroy-render-passdevicerender-pass
cffi:null-pointer
values
defuncreate-framebuffer
devicerender-passimage-viewswidthheight&keydepth-view
let*
image-views
cond
nullimage-views
nil
listpimage-views
image-views
vectorpimage-views
coerceimage-views'list
t
listimage-views
attachment-vector
coerce
appendimage-views
anddepth-view
listdepth-view
'vector
when
zerop
lengthattachment-vector
error"A framebuffer needs at least one attachment."
with-foreign-array
attachments:pointerattachment-vector
with-vk
create-infoframebuffer-create-info:flags0:render-passrender-pass:attachment-count
lengthattachment-vector
:p-attachmentsattachments:widthwidth:heightheight:layers1
create-framebuffer-handledevicecreate-info
defundestroy-framebuffer
deviceframebuffer
vk:destroy-framebufferdeviceframebuffer
cffi:null-pointer
values
defuncall-with-vertex-input-descriptions
vertex-buffersfunction
if
nullvertex-buffers
funcallfunction0
cffi:null-pointer
0
cffi:null-pointer
let
attribute-count
loopforbufferinvertex-bufferssum
length
getfbuffer:attributes
cffi:with-foreign-object
bindings'
lengthvertex-buffers
cffi:with-foreign-object
attributes'attribute-count
loopwithattribute-index=0forbufferinvertex-buffersfordefault-bindingfrom0forbinding=
or
getfbuffer:binding
default-binding
do
fill-vk
cffi:mem-aptrbindings'default-binding
'vertex-input-binding-description:bindingbinding:stride
getfbuffer:array-stride
:input-rate
or
getfbuffer:step-mode
:vertex
dolist
attribute
getfbuffer:attributes
fill-vk
cffi:mem-aptrattributes'attribute-index
'vertex-input-attribute-description:location
getfattribute:shader-location
:bindingbinding:format
getfattribute:format
:offset
getfattribute:offset
incfattribute-index
funcallfunction
lengthvertex-buffers
bindingsattribute-countattributes
defuncall-with-depth-stencil-state
depth-comparedepth-write-enabledfunction
ifdepth-compare
with-vk
statepipeline-depth-stencil-state-create-info:flags0:depth-test-enable1:depth-write-enable
ifdepth-write-enabled10
:depth-compare-opdepth-compare:depth-bounds-test-enable0:stencil-test-enable0:min-depth-bounds0.0:max-depth-bounds1.0
funcallfunctionstate
funcallfunction
cffi:null-pointer
defuncall-with-color-blend-attachments
blendsfunction

Call function with one Vulkan blend attachment per fragment target.

if
nullblends
funcallfunction0
cffi:null-pointer
cffi:with-foreign-object
loopforblendinblendsforindexfrom0do
fill-vk
cffi:mem-aptrattachments'index
'pipeline-color-blend-attachment-state:blend-enable
ifblend10
:src-color-blend-factor:one:dst-color-blend-factor
ifblend:one-minus-src-alpha:zero
:color-blend-op:add:src-alpha-blend-factor:one:dst-alpha-blend-factor
ifblend:one-minus-src-alpha:zero
:alpha-blend-op:add:color-write-mask'
:r:g:b:a
funcallfunction
lengthblends
attachments
defuncreate-graphics-pipeline
devicevertex-modulefragment-modulelayoutrender-pass&key
vertex-entry-point"main"
fragment-entry-point"main"
topology:triangle-strip
vertex-buffersdepth-comparedepth-write-enabledblendsblend
labels
create-with-shader-names
vertex-namefragment-name
let
stage-count
iffragment-module21
cffi:with-foreign-object
stages'stage-count
fill-vk
cffi:mem-aptrstages'0
'pipeline-shader-stage-create-info:flags0:stage'
:vertex
:modulevertex-module:p-namevertex-name:p-specialization-info
cffi:null-pointer
whenfragment-module
fill-vk
cffi:mem-aptrstages'1
'pipeline-shader-stage-create-info:flags0:stage'
:fragment
:modulefragment-module:p-namefragment-name:p-specialization-info
cffi:null-pointer
call-with-vertex-input-descriptionsvertex-buffers
lambda
binding-countbindingsattribute-countattributes
with-vk
vertex-inputpipeline-vertex-input-state-create-info:flags0:vertex-binding-description-countbinding-count:p-vertex-binding-descriptionsbindings:vertex-attribute-description-countattribute-count:p-vertex-attribute-descriptionsattributes
with-vk
input-assemblypipeline-input-assembly-state-create-info:flags0:topologytopology:primitive-restart-enable0
with-vk
viewport-statepipeline-viewport-state-create-info:flags0:viewport-count1:p-viewports
cffi:null-pointer
:scissor-count1:p-scissors
cffi:null-pointer
with-vk
rasterizationpipeline-rasterization-state-create-info:flags0:depth-clamp-enable0:rasterizer-discard-enable0:polygon-mode:fill:cull-modenil:front-face:counter-clockwise:depth-bias-enable0:depth-bias-constant-factor0.0:depth-bias-clamp0.0:depth-bias-slope-factor0.0:line-width1.0
with-vk
multisamplepipeline-multisample-state-create-info:flags0:rasterization-samples:1:sample-shading-enable0:min-sample-shading0.0:p-sample-mask
cffi:null-pointer
:alpha-to-coverage-enable0:alpha-to-one-enable0
labels
create-with-blend
attachment-countattachments
with-vk
blendpipeline-color-blend-state-create-info:flags0:logic-op-enable0:logic-op:copy:attachment-countattachment-count:p-attachmentsattachments
with-foreign-array
dynamic-statesdynamic-state
:viewport:scissor
with-vk
dynamicpipeline-dynamic-state-create-info:flags0:dynamic-state-count2:p-dynamic-statesdynamic-states
call-with-depth-stencil-statedepth-comparedepth-write-enabled
lambda
depth-state
with-vk
create-infographics-pipeline-create-info:flags0:stage-countstage-count:p-stagesstages:p-vertex-input-statevertex-input:p-input-assembly-stateinput-assembly:p-tessellation-state
cffi:null-pointer
:p-viewport-stateviewport-state:p-rasterization-staterasterization:p-multisample-statemultisample:p-depth-stencil-statedepth-state:p-color-blend-stateblend:p-dynamic-statedynamic:layoutlayout:render-passrender-pass:subpass0:base-pipeline-handle
cffi:null-pointer
:base-pipeline-index-1
call-with-color-blend-attachments
andfragment-module
orblends
listblend
#'create-with-blend
cffi:with-foreign-string
vertex-namevertex-entry-point
iffragment-module
cffi:with-foreign-string
fragment-namefragment-entry-point
create-with-shader-namesvertex-namefragment-name
create-with-shader-namesvertex-name
cffi:null-pointer
defundevice-procedure
devicename
let
procedure
vk:get-device-proc-addrdevicename
when
cffi:null-pointer-pprocedure
error"Vulkan device procedure ~A is unavailable."name
procedure
defuncreate-mesh-graphics-pipeline
devicemesh-modulefragment-modulelayoutrender-pass&keytask-module
task-entry-point"main"
mesh-entry-point"main"
fragment-entry-point"main"
depth-comparedepth-write-enabledblendsblend

Link a task, mesh, and fragment stage into one VK_EXT_mesh_shader pipeline.

A mesh pipeline draws no vertices, so it carries neither a vertex input nor an input assembly state; the mesh stage's own OpExecutionMode names its output topology.

labels
create-with-shader-names
task-namemesh-namefragment-name
let*
stage-count
+
iftask-module10
1
iffragment-module10
cffi:with-foreign-object
stages'stage-count
let
index-1
flet
stage
bitmodulename
fill-vk
cffi:mem-aptrstages'
incfindex
'pipeline-shader-stage-create-info:flags0:stage
listbit
:modulemodule:p-namename:p-specialization-info
cffi:null-pointer
whentask-module
stage:task-exttask-moduletask-name
stage:mesh-extmesh-modulemesh-name
whenfragment-module
stage:fragmentfragment-modulefragment-name
with-vk
viewport-statepipeline-viewport-state-create-info:flags0:viewport-count1:p-viewports
cffi:null-pointer
:scissor-count1:p-scissors
cffi:null-pointer
with-vk
rasterizationpipeline-rasterization-state-create-info:flags0:depth-clamp-enable0:rasterizer-discard-enable0:polygon-mode:fill:cull-modenil:front-face:counter-clockwise:depth-bias-enable0:depth-bias-constant-factor0.0:depth-bias-clamp0.0:depth-bias-slope-factor0.0:line-width1.0
with-vk
multisamplepipeline-multisample-state-create-info:flags0:rasterization-samples:1:sample-shading-enable0:min-sample-shading0.0:p-sample-mask
cffi:null-pointer
:alpha-to-coverage-enable0:alpha-to-one-enable0
labels
create-with-blend
attachment-countattachments
with-vk
blend-statepipeline-color-blend-state-create-info:flags0:logic-op-enable0:logic-op:copy:attachment-countattachment-count:p-attachmentsattachments
with-foreign-array
dynamic-statesdynamic-state
:viewport:scissor
with-vk
dynamicpipeline-dynamic-state-create-info:flags0:dynamic-state-count2:p-dynamic-statesdynamic-states
call-with-depth-stencil-statedepth-comparedepth-write-enabled
lambda
depth-state
with-vk
create-infographics-pipeline-create-info:flags0:stage-countstage-count:p-stagesstages:p-vertex-input-state
cffi:null-pointer
:p-input-assembly-state
cffi:null-pointer
:p-tessellation-state
cffi:null-pointer
:p-viewport-stateviewport-state:p-rasterization-staterasterization:p-multisample-statemultisample:p-depth-stencil-statedepth-state:p-color-blend-stateblend-state:p-dynamic-statedynamic:layoutlayout:render-passrender-pass:subpass0:base-pipeline-handle
cffi:null-pointer
:base-pipeline-index-1
call-with-color-blend-attachments
andfragment-module
orblends
listblend
#'create-with-blend
with-optional-string
ifvalue
cffi:with-foreign-string
pointervalue
funcallfunctionpointer
funcallfunction
cffi:null-pointer
with-optional-string
andtask-moduletask-entry-point
lambda
task-name
cffi:with-foreign-string
mesh-namemesh-entry-point
with-optional-string
andfragment-modulefragment-entry-point
lambda
fragment-name
create-with-shader-namestask-namemesh-namefragment-name
defuncmd-draw-mesh-tasks
devicecommand-bufferxyz

Dispatch X by Y by Z task (or mesh) workgroups into command-buffer.

cffi:foreign-funcall-pointer
device-proceduredevice"vkCmdDrawMeshTasksEXT"
:pointercommand-buffer:uint32x:uint32y:uint32z:void
values
defundestroy-pipeline
devicepipeline
vk:destroy-pipelinedevicepipeline
cffi:null-pointer
values
defuncreate-storage-image-descriptor-pool
device&key
max-sets1
with-vk
pool-sizedescriptor-pool-size:type:storage-image:descriptor-countmax-sets
with-vk
create-infodescriptor-pool-create-info:flags0:max-setsmax-sets:pool-size-count1:p-pool-sizespool-size
defuncreate-uniform-buffer-descriptor-pool
device&key
max-sets1
with-vk
pool-sizedescriptor-pool-size:type:uniform-buffer:descriptor-countmax-sets
with-vk
create-infodescriptor-pool-create-info:flags0:max-setsmax-sets:pool-size-count1:p-pool-sizespool-size
defuntexture-sampler-uniform-pool-counts
entries
values
count:textureentries:key
lambda
entry
getfentry:type
count:samplerentries:key
lambda
entry
getfentry:type
count:uniform-bufferentries:key
lambda
entry
getfentry:type
count:storage-bufferentries:key
lambda
entry
getfentry:type
defuncreate-texture-sampler-uniform-descriptor-pool
deviceentries&key
max-sets1
multiple-value-bind
texture-countsampler-countuniform-countstorage-count
let
sizes
append
when
plusptexture-count
list
list:sampled-imagetexture-count
when
pluspsampler-count
list
list:samplersampler-count
when
pluspuniform-count
list
list:uniform-bufferuniform-count
when
pluspstorage-count
list
list:storage-bufferstorage-count
cffi:with-foreign-object
pool-sizes'
lengthsizes
loopfor
typecount
insizesforindexfrom0do
fill-vk
cffi:mem-aptrpool-sizes'index
'descriptor-pool-size:typetype:descriptor-count
*countmax-sets
with-vk
create-infodescriptor-pool-create-info:flags0:max-setsmax-sets:pool-size-count
lengthsizes
:p-pool-sizespool-sizes
defundestroy-descriptor-pool
devicepool
vk:destroy-descriptor-pooldevicepool
cffi:null-pointer
values
defunallocate-descriptor-set
devicepoollayout
with-foreign-array
layouts:pointer
vectorlayout
with-vk
allocate-infodescriptor-set-allocate-info:descriptor-poolpool:descriptor-set-count1:p-set-layoutslayouts
defunupdate-storage-image-descriptor
devicedescriptor-setimage-view&key
binding0
with-vk
image-infodescriptor-image-info:sampler
cffi:null-pointer
:image-viewimage-view:image-layout:general
with-vk
writewrite-descriptor-set:dst-setdescriptor-set:dst-bindingbinding:dst-array-element0:descriptor-count1:descriptor-type:storage-image:p-image-infoimage-info:p-buffer-info
cffi:null-pointer
:p-texel-buffer-view
cffi:null-pointer
vk:update-descriptor-setsdevice1write0
cffi:null-pointer
values
defunupdate-uniform-buffer-descriptor
devicedescriptor-setbufferbuffer-size&key
binding0
with-vk
buffer-infodescriptor-buffer-info:bufferbuffer:offset0:rangebuffer-size
with-vk
writewrite-descriptor-set:dst-setdescriptor-set:dst-bindingbinding:dst-array-element0:descriptor-count1:descriptor-type:uniform-buffer:p-image-info
cffi:null-pointer
:p-buffer-infobuffer-info:p-texel-buffer-view
cffi:null-pointer
vk:update-descriptor-setsdevice1write0
cffi:null-pointer
values
defunupdate-texture-sampler-uniform-descriptors
devicedescriptor-setentries
let
image-count
count-if
lambda
entry
member
getfentry:type
'
:texture:sampler
entries
buffer-count
count-if
lambda
entry
member
getfentry:type
'
:uniform-buffer:storage-buffer
entries
write-count
lengthentries
cffi:with-foreign-object
image-infos'
max1image-count
cffi:with-foreign-object
buffer-infos'
max1buffer-count
cffi:with-foreign-object
writes'write-count
loopwithimage-index=0withbuffer-index=0forentryinentriesforwrite-indexfrom0fortype=
getfentry:type
forwrite=
cffi:mem-aptrwrites'write-index
do
ecasetype
:texture
let
image-info
cffi:mem-aptrimage-infos'image-index
fill-vkimage-info'descriptor-image-info:sampler
cffi:null-pointer
:image-view
getfentry:image-view
:image-layout:shader-read-only-optimal
fill-vkwrite'write-descriptor-set:dst-setdescriptor-set:dst-binding
getfentry:binding
:dst-array-element0:descriptor-count1:descriptor-type:sampled-image:p-image-infoimage-info:p-buffer-info
cffi:null-pointer
:p-texel-buffer-view
cffi:null-pointer
incfimage-index
:sampler
let
image-info
cffi:mem-aptrimage-infos'image-index
fill-vkimage-info'descriptor-image-info:sampler
getfentry:sampler
:image-view
cffi:null-pointer
:image-layout:undefined
fill-vkwrite'write-descriptor-set:dst-setdescriptor-set:dst-binding
getfentry:binding
:dst-array-element0:descriptor-count1:descriptor-type:sampler:p-image-infoimage-info:p-buffer-info
cffi:null-pointer
:p-texel-buffer-view
cffi:null-pointer
incfimage-index
:uniform-buffer:storage-buffer
let
buffer-info
cffi:mem-aptrbuffer-infos'buffer-index
fill-vkbuffer-info'descriptor-buffer-info:buffer
getfentry:buffer
:offset0:range
getfentry:buffer-size
fill-vkwrite'write-descriptor-set:dst-setdescriptor-set:dst-binding
getfentry:binding
:dst-array-element0:descriptor-count1:descriptor-typetype:p-image-info
cffi:null-pointer
:p-buffer-infobuffer-info:p-texel-buffer-view
cffi:null-pointer
incfbuffer-index
vk:update-descriptor-setsdevicewrite-countwrites0
cffi:null-pointer
values
defuncreate-command-pool
devicequeue-family-index&keyflags
with-vk
create-infocommand-pool-create-info:flagsflags:queue-family-indexqueue-family-index
defundestroy-command-pool
devicecommand-pool
vk:destroy-command-pooldevicecommand-pool
cffi:null-pointer
values
defunallocate-command-buffer
devicecommand-pool&key
level:primary
with-vk
allocate-infocommand-buffer-allocate-info:command-poolcommand-pool:levellevel:command-buffer-count1
defunbegin-command-buffer
command-buffer&keyflags
with-vk
begin-infocommand-buffer-begin-info:flagsflags:p-inheritance-info
cffi:null-pointer
with-vulkan-results
:begin-command-buffer
vk:begin-command-buffercommand-bufferbegin-info
command-buffer
defunend-command-buffer
command-buffer
with-vulkan-results
:end-command-buffer
vk:end-command-buffercommand-buffer
command-buffer
defunfill-image-subresource-range
rangeaspect
fill-vkrange'image-subresource-range:aspect-mask
listaspect
:base-mip-level0:level-count1:base-array-layer0:layer-count1
defuncmd-transition-image
command-bufferimageold-layoutnew-layoutsrc-accessdst-accesssrc-stagedst-stage&key
aspect:color
with-vk
barrierimage-memory-barrier:src-access-masksrc-access:dst-access-maskdst-access:old-layoutold-layout:new-layoutnew-layout:src-queue-family-index+queue-family-ignored+:dst-queue-family-index+queue-family-ignored+:imageimage
fill-image-subresource-range
cffi:foreign-slot-pointerbarrier''subresource-range
aspect
vk:cmd-pipeline-barriercommand-buffersrc-stagedst-stagenil0
cffi:null-pointer
0
cffi:null-pointer
1barrier
values
defuncmd-clear-color-image
command-bufferimagelayoutcolor
with-vk
cffi:with-foreign-object
foreign-color'
let
components
cffi:foreign-slot-pointerforeign-color''float-32
loopforcomponentacrosscolorforindexfrom0below4do
setf
cffi:mem-arefcomponents:floatindex
component
vk:cmd-clear-color-imagecommand-bufferimagelayoutforeign-color1range
values
defunfill-color-subresource-layers
layers
fill-vklayers'image-subresource-layers:aspect-mask'
:color
:mip-level0:base-array-layer0:layer-count1
defuncmd-copy-image
command-buffersourcesource-layoutdestinationdestination-layoutwidthheight&optional
depth1
with-vk
dolist
slot'
src-subresourcedst-subresource
fill-color-subresource-layers
cffi:foreign-slot-pointerregion'
:structimage-copy
slot
dolist
slot'
src-offsetdst-offset
fill-vk
cffi:foreign-slot-pointerregion'
:structimage-copy
slot
'offset-3d:x0:y0:z0
fill-vk
cffi:foreign-slot-pointerregion'
:structimage-copy
'extent
'extent-3d:widthwidth:heightheight:depthdepth
vk:cmd-copy-imagecommand-buffersourcesource-layoutdestinationdestination-layout1region
values
defuncmd-copy-buffer-to-image
command-bufferbufferimagelayoutwidthheight&key
buffer-offset0
buffer-row-length0
buffer-image-height0
x0
y0
depth1
with-vk
regionbuffer-image-copy:buffer-offsetbuffer-offset:buffer-row-lengthbuffer-row-length:buffer-image-heightbuffer-image-height
fill-color-subresource-layers
cffi:foreign-slot-pointerregion''image-subresource
fill-vk
cffi:foreign-slot-pointerregion''image-offset
'offset-3d:xx:yy:z0
fill-vk
cffi:foreign-slot-pointerregion''image-extent
'extent-3d:widthwidth:heightheight:depthdepth
vk:cmd-copy-buffer-to-imagecommand-bufferbufferimagelayout1region
values
defuncmd-copy-image-to-buffer
command-bufferimagelayoutbufferwidthheight&optional
depth1
with-vk
regionbuffer-image-copy:buffer-offset0:buffer-row-length0:buffer-image-height0
fill-color-subresource-layers
cffi:foreign-slot-pointerregion''image-subresource
fill-vk
cffi:foreign-slot-pointerregion''image-offset
'offset-3d:x0:y0:z0
fill-vk
cffi:foreign-slot-pointerregion''image-extent
'extent-3d:widthwidth:heightheight:depthdepth
vk:cmd-copy-image-to-buffercommand-bufferimagelayoutbuffer1region
values
defuncmd-bind-compute-pipeline
command-bufferpipeline
vk:cmd-bind-pipelinecommand-buffer:computepipeline
values
defuncmd-bind-graphics-pipeline
command-bufferpipeline
vk:cmd-bind-pipelinecommand-buffer:graphicspipeline
values
defuncmd-bind-compute-descriptor-set
command-bufferpipeline-layoutdescriptor-set
with-foreign-array
sets:pointer
vectordescriptor-set
vk:cmd-bind-descriptor-setscommand-buffer:computepipeline-layout01sets0
cffi:null-pointer
values
defuncmd-bind-graphics-descriptor-set
command-bufferpipeline-layoutdescriptor-set
with-foreign-array
sets:pointer
vectordescriptor-set
vk:cmd-bind-descriptor-setscommand-buffer:graphicspipeline-layout01sets0
cffi:null-pointer
values
defuncmd-bind-vertex-buffer
command-bufferbindingbuffer&optional
offset0
with-foreign-array
buffers:pointer
vectorbuffer
with-foreign-array
offsets:uint64
vectoroffset
vk:cmd-bind-vertex-bufferscommand-bufferbinding1buffersoffsets
values
defuncmd-dispatch
command-bufferxy&optional
z1
vk:cmd-dispatchcommand-bufferxyz
values
defuncmd-begin-color-render-pass
command-bufferrender-passframebufferwidthheightclear-colors&keydepth-clear-value
let*
clear-colors
if
and
vectorpclear-colors
every#'realpclear-colors
listclear-colors
coerceclear-colors'list
color-count
lengthclear-colors
clear-count
+color-count
ifdepth-clear-value10
cffi:with-foreign-object
clears'clear-count
clear-foreign-objectclears'clear-count
loopforclear-colorinclear-colorsforattachment-indexfrom0forcolor=
cffi:foreign-slot-pointer
cffi:mem-aptrclears'attachment-index
''color
forcomponents=
cffi:foreign-slot-pointercolor''float-32
do
loopforcomponentacrossclear-colorforcomponent-indexbelow4do
setf
cffi:mem-arefcomponents:floatcomponent-index
component
whendepth-clear-value
fill-vk
cffi:foreign-slot-pointer
cffi:mem-aptrclears'color-count
''depth-stencil
'clear-depth-stencil-value:depth
coercedepth-clear-value'single-float
:stencil0
with-vk
begin-inforender-pass-begin-info:render-passrender-pass:framebufferframebuffer:clear-value-countclear-count:p-clear-valuesclears
let
area
cffi:foreign-slot-pointerbegin-info''render-area
fill-vk
cffi:foreign-slot-pointerarea'
:structrect-2d
'offset
'offset-2d:x0:y0
fill-vk
cffi:foreign-slot-pointerarea'
:structrect-2d
'extent
'extent-2d:widthwidth:heightheight
vk:cmd-begin-render-passcommand-bufferbegin-info:inline
values
defuncmd-begin-depth-render-pass
command-bufferrender-passframebufferwidthheightdepth-clear-value
cffi:with-foreign-object
clears'1
fill-vk
cffi:foreign-slot-pointerclears''depth-stencil
'clear-depth-stencil-value:depth
coercedepth-clear-value'single-float
:stencil0
with-vk
begin-inforender-pass-begin-info:render-passrender-pass:framebufferframebuffer:clear-value-count1:p-clear-valuesclears
let
area
cffi:foreign-slot-pointerbegin-info''render-area
fill-vk
cffi:foreign-slot-pointerarea'
:structrect-2d
'offset
'offset-2d:x0:y0
fill-vk
cffi:foreign-slot-pointerarea'
:structrect-2d
'extent
'extent-2d:widthwidth:heightheight
vk:cmd-begin-render-passcommand-bufferbegin-info:inline
values
defuncmd-set-viewport-and-scissor
command-bufferwidthheight
with-vk
viewportviewport:x0.0:y0.0:width
coercewidth'single-float
:height
coerceheight'single-float
:min-depth0.0:max-depth1.0
vk:cmd-set-viewportcommand-buffer01viewport
with-vk
scissorrect-2d
fill-vk
cffi:foreign-slot-pointerscissor'
:structrect-2d
'offset
'offset-2d:x0:y0
fill-vk
cffi:foreign-slot-pointerscissor'
:structrect-2d
'extent
'extent-2d:widthwidth:heightheight
vk:cmd-set-scissorcommand-buffer01scissor
values
defuncmd-set-scissor
command-bufferxywidthheight
with-vk
scissorrect-2d
fill-vk
cffi:foreign-slot-pointerscissor'
:structrect-2d
'offset
'offset-2d:xx:yy
fill-vk
cffi:foreign-slot-pointerscissor'
:structrect-2d
'extent
'extent-2d:widthwidth:heightheight
vk:cmd-set-scissorcommand-buffer01scissor
values
defuncmd-end-render-pass
command-buffer
values
defuncmd-draw
command-buffervertex-count&optional
instance-count1
first-vertex0
first-instance0
vk:cmd-drawcommand-buffervertex-countinstance-countfirst-vertexfirst-instance
values
defuncmd-bind-index-buffer
command-bufferbufferoffsetindex-type
vk:cmd-bind-index-buffercommand-bufferbufferoffsetindex-type
values
defuncmd-draw-indexed
command-bufferindex-count&optional
instance-count1
first-index0
vertex-offset0
first-instance0
vk:cmd-draw-indexedcommand-bufferindex-countinstance-countfirst-indexvertex-offsetfirst-instance
values
defunfill-semaphore-submit-infos
pointerentries

Fill pointer, an array of VkSemaphoreSubmitInfo, from entries.

Each entry is a list (SEMAPHORE STAGES &optional VALUE). STAGES is a PIPELINE-STAGE-FLAGS-2 keyword list. VALUE is meaningful only when SEMAPHORE is a timeline semaphore.

loopforindexbelow
lengthentries
forentry=
eltentriesindex
do
destructuring-bind
semaphorestages&optional
value0
entry
fill-vk
cffi:mem-aptrpointer'index
'semaphore-submit-info:semaphoresemaphore:valuevalue:stage-maskstages:device-index0
pointer
defunsubmit-command-buffers
queuebuffers&key
wait-semaphores
signal-semaphores

Submit buffers through vkQueueSubmit2.

wait-semaphores and signal-semaphores are sequences of semaphore submit entries as understood by fill-semaphore-submit-infos.

let
buffer-count
lengthbuffers
wait-count
lengthwait-semaphores
signal-count
lengthsignal-semaphores
cffi:with-foreign-objects
buffer-infos'
maxbuffer-count1
wait-infos'
maxwait-count1
signal-infos'
maxsignal-count1
loopforindexbelowbuffer-countdo
fill-vk
cffi:mem-aptrbuffer-infos'index
'command-buffer-submit-info:command-buffer
eltbuffersindex
:device-mask0
fill-semaphore-submit-infoswait-infoswait-semaphores
fill-semaphore-submit-infossignal-infossignal-semaphores
with-vk
submitsubmit-info-2:flags0:wait-semaphore-info-countwait-count:p-wait-semaphore-infoswait-infos:command-buffer-info-countbuffer-count:p-command-buffer-infosbuffer-infos:signal-semaphore-info-countsignal-count:p-signal-semaphore-infossignal-infos
with-vulkan-results
:queue-submit-2
vk:queue-submit2queue1submit
cffi:null-pointer
values
defunsubmit-command-buffer
queuecommand-buffer
submit-command-buffersqueue
vectorcommand-buffer
defunqueue-wait-idle
queue
values
defunsurface-supported-p
physical-devicequeue-family-indexsurface
cffi:with-foreign-object
supported:uint32
setf
cffi:mem-refsupported:uint32
0
with-vulkan-results
:get-physical-device-surface-support
vk:get-physical-device-surface-support-khrphysical-devicequeue-family-indexsurfacesupported
not
zerop
cffi:mem-refsupported:uint32
defunread-extent-2d
pointer
cffi:with-foreign-slots
pointer
:structextent-2d
defunget-surface-capabilities
physical-devicesurface
cffi:with-foreign-object
capabilities'
with-vulkan-results
:get-physical-device-surface-capabilities
vk:get-physical-device-surface-capabilities-khrphysical-devicesurfacecapabilities
cffi:with-foreign-slots
min-image-countmax-image-countcurrent-transformsupported-composite-alphasupported-usage-flags
capabilities
make-presentation-capabilities:min-image-countmin-image-count:max-image-countmax-image-count:current-extent
read-extent-2d
cffi:foreign-slot-pointercapabilities''current-extent
:min-image-extent
read-extent-2d
cffi:foreign-slot-pointercapabilities''min-image-extent
:max-image-extent
read-extent-2d
cffi:foreign-slot-pointercapabilities''max-image-extent
:current-transformcurrent-transform:composite-alphasupported-composite-alpha:usagesupported-usage-flags
defunget-presentation-timing-surface-capabilities
physical-devicesurface

Return timing and present-id capabilities for this particular surface.

with-vk
present-idsurface-capabilities-present-id-2:present-id-2-supported0
with-vk
timingpresent-timing-surface-capabilities:p-nextpresent-id:present-timing-supported0:present-at-absolute-time-supported0:present-at-relative-time-supported0:present-stage-queriesnil
with-vk
capabilitiessurface-capabilities-2:p-nexttiming
with-vk
surface-infophysical-device-surface-info-2:surfacesurface
with-vulkan-results
:get-physical-device-surface-capabilities-2
vk:get-physical-device-surface-capabilities2khrphysical-devicesurface-infocapabilities
cffi:with-foreign-slots
present-timing-supportedpresent-at-absolute-time-supportedpresent-at-relative-time-supportedpresent-stage-queries
timing
make-presentation-timing-capabilities:supported-p
not
zeroppresent-timing-supported
:absolute-time-p
not
zeroppresent-at-absolute-time-supported
:relative-time-p
not
zeroppresent-at-relative-time-supported
:stagespresent-stage-queries:present-id-2-p
not
zerop
cffi:foreign-slot-valuepresent-id''present-id-2-supported
defunextract-surface-format
formatsindex
let
format
cffi:mem-aptrformats'index
cffi:with-foreign-slots
formatcolor-space
format
make-presentation-format:formatformat:color-spacecolor-space
define-enumeratorget-surface-formats
physical-devicesurface
vk:get-physical-device-surface-formats-khrphysical-devicesurface
:element:extractorextract-surface-format
define-enumeratorget-surface-present-modes
physical-devicesurface
vk:get-physical-device-surface-present-modes-khrphysical-devicesurface
:elementpresent-mode
define-enumeratorget-swapchain-images
deviceswapchain
vk:get-swapchain-images-khrdeviceswapchain
:element:pointer
defuncreate-swapchain
devicesurfaceformatcolor-spaceextent&keymin-image-count
usage'
:transfer-dst
pre-transform:identity
composite-alpha:opaque
present-mode:fifo-khr
old-swapchainpresent-timing-p
with-vk
create-infoswapchain-create-info:flags
ifpresent-timing-p'
:present-id-2-khr:present-timing-ext
nil
:surfacesurface:min-image-countmin-image-count:image-formatformat:image-color-spacecolor-space:image-array-layers1:image-usageusage:image-sharing-mode:exclusive:queue-family-index-count0:p-queue-family-indices
cffi:null-pointer
:pre-transformpre-transform:composite-alphacomposite-alpha:present-modepresent-mode:clipped1:old-swapchain
orold-swapchain
cffi:null-pointer
fill-vk
cffi:foreign-slot-pointercreate-info''image-extent
'extent-2d:width
firstextent
:height
secondextent
create-swapchain-handledevicecreate-info
defunset-swapchain-present-timing-queue-size
deviceswapchainsize
with-vulkan-results
:set-swapchain-present-timing-queue-size
vk:set-swapchain-present-timing-queue-size-extdeviceswapchainsize
size
defunget-swapchain-timing-properties
deviceswapchain

Return current swapchain timing properties, or NIL while they are warming.

with-vk
propertiesswapchain-timing-properties:refresh-duration0:refresh-interval0
cffi:with-foreign-object
counter:uint64
setf
cffi:mem-refcounter:uint64
0
let
result
with-vulkan-results
:get-swapchain-timing-properties:success:not-ready
vk:get-swapchain-timing-properties-extdeviceswapchainpropertiescounter
when
eqresult:success
cffi:with-foreign-slots
refresh-durationrefresh-interval
properties
values
make-swapchain-timing-properties:refresh-durationrefresh-duration:refresh-intervalrefresh-interval
cffi:mem-refcounter:uint64
defunget-swapchain-time-domains
deviceswapchain

Return (TIME-DOMAIN . ID) pairs, or NIL while they are warming.

labels
query
propertiescounter
with-vulkan-results
:get-swapchain-time-domain-properties:success:incomplete:not-ready
vk:get-swapchain-time-domain-properties-extdeviceswapchainpropertiescounter
with-vk
propertiesswapchain-time-domain-properties:time-domain-count0:p-time-domains
cffi:null-pointer
:p-time-domain-ids
cffi:null-pointer
cffi:with-foreign-object
counter:uint64
setf
cffi:mem-refcounter:uint64
0
unless
eq:not-ready
querypropertiescounter
let
count
cffi:foreign-slot-valueproperties''time-domain-count
when
pluspcount
cffi:with-foreign-object
domains'time-domaincount
cffi:with-foreign-object
ids:uint64count
setf
cffi:foreign-slot-valueproperties''p-time-domains
domains
cffi:foreign-slot-valueproperties''p-time-domain-ids
ids
let
result
querypropertiescounter
unless
eqresult:not-ready
loopforindexbelow
cffi:foreign-slot-valueproperties''time-domain-count
collect
cons
cffi:mem-arefdomains'time-domainindex
cffi:mem-arefids:uint64index
defunmap-past-presentation-timings
deviceswapchainfunction

Call function for each complete timing as ID, STAGE, TIME, DOMAIN, DOMAIN-ID.

with-vk
infopast-presentation-timing-info:flagsnil:swapchainswapchain
with-vk
propertiespast-presentation-timing-properties:timing-properties-counter0:time-domains-counter0:presentation-timing-count0:p-presentation-timings
cffi:null-pointer
with-vulkan-results
:get-past-presentation-timing
vk:get-past-presentation-timing-extdeviceinfoproperties
let
count
cffi:foreign-slot-valueproperties''presentation-timing-count
when
pluspcount
cffi:with-foreign-object
timings'count
cffi:with-foreign-object
stages'count
dotimes
indexcount
fill-vk
cffi:mem-aptrtimings'index
'past-presentation-timing:present-id0:target-time0:present-stage-count1:p-present-stages
cffi:mem-aptrstages'index
:time-domain:device:time-domain-id0:report-complete0
setf
cffi:foreign-slot-valueproperties''presentation-timing-count
count
cffi:foreign-slot-valueproperties''p-presentation-timings
timings
with-vulkan-results
:get-past-presentation-timing:success:incomplete
vk:get-past-presentation-timing-extdeviceinfoproperties
dotimes
index
cffi:foreign-slot-valueproperties''presentation-timing-count
let
timing
cffi:mem-aptrtimings'index
cffi:with-foreign-slots
present-idpresent-stage-countp-present-stagestime-domaintime-domain-idreport-complete
timing
when
and
not
zeropreport-complete
plusppresent-stage-count
cffi:with-foreign-slots
stagetime
p-present-stages
funcallfunctionpresent-id
if
and
conspstage
null
reststage
firststage
stage
timetime-domaintime-domain-id
values
defundestroy-swapchain
deviceswapchain
vk:destroy-swapchain-khrdeviceswapchain
cffi:null-pointer
values
defuncreate-semaphore
device
with-vk
create-infosemaphore-create-info:flags0
create-semaphore-handledevicecreate-info
defuncreate-timeline-semaphore
device&key
initial-value0

Create a timeline semaphore whose 64-bit counter starts at initial-value.

with-vk
type-infosemaphore-type-create-info:semaphore-type:timeline:initial-valueinitial-value
with-vk
create-infosemaphore-create-info:p-nexttype-info:flags0
create-semaphore-handledevicecreate-info
defundestroy-semaphore
devicesemaphore
vk:destroy-semaphoredevicesemaphore
cffi:null-pointer
values
defunsemaphore-counter-value
devicesemaphore

Return the current 64-bit counter of a timeline semaphore.

cffi:with-foreign-object
value:uint64
with-vulkan-results
:get-semaphore-counter-value
vk:get-semaphore-counter-valuedevicesemaphorevalue
cffi:mem-refvalue:uint64
defunwait-semaphore-value
devicesemaphorevalue&key
timeout#xffffffffffffffff

Block until timeline semaphore's counter reaches at least value.

with-foreign-array
semaphores:pointer
vectorsemaphore
cffi:with-foreign-object
values:uint64
setf
cffi:mem-refvalues:uint64
value
with-vk
wait-infosemaphore-wait-info:flags0:semaphore-count1:p-semaphoressemaphores:p-valuesvalues
with-vulkan-results
:wait-semaphores
vk:wait-semaphoresdevicewait-infotimeout
values
defunacquire-next-image
deviceswapchainsemaphore&key
timeout#xffffffffffffffff
cffi:with-foreign-object
index:uint32
let
result

An out-of-date swapchain is an ordinary answer rather than a failure: the window changed size and the caller is expected to rebuild. Report it as the second value instead of signalling.

with-vulkan-results
:acquire-next-image:success:suboptimal-khr:error-out-of-date-khr
vk:acquire-next-image-khrdeviceswapchaintimeoutsemaphore
cffi:null-pointer
index
values
cffi:mem-refindex:uint32
result
defunpresent
queueswapchainimage-index&key
wait-semaphores
present-idpresent-stagetime-domain-idtarget-timetarget-time-domain-present-stage
with-foreign-array
waits:pointerwait-semaphores
with-foreign-array
swapchains:pointer
vectorswapchain
with-foreign-array
indices:uint32
vectorimage-index
cffi:with-foreign-object
present-ids:uint64
setf
cffi:mem-refpresent-ids:uint64
orpresent-id0
with-vk
timingpresent-timing-info:flags
iftarget-time'
:present-at-nearest-refresh-cycle
nil
:target-time
ortarget-time0
:time-domain-id
ortime-domain-id0
:present-stage-queries
ifpresent-stage
listpresent-stage
nil
:target-time-domain-present-stage
iftarget-time-domain-present-stage
listtarget-time-domain-present-stage
nil
with-vk
timingspresent-timings-info:swapchain-count1:p-timing-infostiming
with-vk
idpresent-id-2:p-next
ifpresent-stagetimings
cffi:null-pointer
:swapchain-count1:p-present-idspresent-ids
with-vk
present-infopresent-info:p-next
ifpresent-idid
cffi:null-pointer
:wait-semaphore-count
lengthwait-semaphores
:p-wait-semaphoreswaits:swapchain-count1:p-swapchainsswapchains:p-image-indicesindices:p-results
cffi:null-pointer
with-vulkan-results
:present:success:suboptimal-khr:error-out-of-date-khr:error-present-timing-queue-full-ext
vk:queue-present-khrqueuepresent-info