luv

Workshop wiki

ffi.lisp

hal/metal/ffi.lisp

system luv · 267 definitions · on GitHub

The Metal 4 and CAMetalLayer vocabulary needed by the first frame.

The two small structures cross as typed foreign storage through either the default NSInvocation bridge or direct libffi calls in an explicitly unchecked scope. They stay declarations in the same message system as scalar and object calls; no per-selector shim is needed.

in-package#:luv.metal
cffi:defcstructcg-size
width:double
height:double
cffi:defcstructmtl-clear-color
red:double
green:double
blue:double
alpha:double
cffi:defcstructmtl-resource-id
value:uint64
cffi:defcstructmtl-origin
x:uint64
y:uint64
z:uint64
cffi:defcstructmtl-size
width:uint64
height:uint64
depth:uint64
cffi:defcstructmtl-scissor-rect
x:uint64
y:uint64
width:uint64
height:uint64

MTLStages and MTL4VisibilityOptions used by explicit Metal 4 barriers.

defconstant+stage-fragment+
ash11
defconstant+stage-blit+
ash128
defconstant+visibility-device+
ash10
cffi:defcstructmtl-region

MTLRegion is two adjacent three-NSUInteger structures. Flat fields keep the identical ABI while remaining directly assignable through CFFI.

x:uint64
y:uint64
z:uint64
width:uint64
height:uint64
depth:uint64
defconstant+texture-type-2d+2
defconstant+load-action-load+1
defconstant+language-version-4-0+
ash416
defconstant+blend-factor-one+1
defconstant+render-stage-vertex+
ash10
defconstant+render-stage-fragment+
ash11
defconstant+render-stage-object+
ash13
defconstant+render-stage-mesh+
ash14

Device and Metal 4 submission.

objc:define-objective-c-messagenew-metal-4-command-queue
"newMTL4CommandQueue":object:ownership:owned:class"MTL4CommandQueue"
objc:define-objective-c-messagenew-metal-shared-event
"newSharedEvent":object:ownership:owned:class"MTLSharedEvent"
objc:define-objective-c-messagewait-for-metal-shared-event
"waitUntilSignaledValue:timeoutMS:":uint8
value:uint64
timeout-milliseconds:uint64
objc:define-objective-c-messagesignal-metal-event
"signalEvent:value:":void
event:object
value:uint64

Device resources and Metal 4 binding infrastructure.

objc:define-objective-c-messagenew-metal-buffer
"newBufferWithLength:options:":object:ownership:owned:class"MTLBuffer"
length:uint64
options:uint64
objc:define-objective-c-message%new-metal-texture-descriptor
"new":object:ownership:owned:class"MTLTextureDescriptor"
objc:define-objective-c-message%new-metal-texture
"newTextureWithDescriptor:":object:ownership:owned:class"MTLTexture"
descriptor:object
objc:define-objective-c-message%replace-metal-texture-region
"replaceRegion:mipmapLevel:withBytes:bytesPerRow:":void
region
:structmtl-region
mipmap-level:uint64
bytes:pointer
bytes-per-row:uint64
defunreplace-metal-texture-region
texturewidthheightbytesbytes-per-row

Replace the complete base level of a two-dimensional Metal texture.

%replace-metal-texture-regiontexture
list'x0'y0'z0'widthwidth'heightheight'depth1
0bytesbytes-per-row
objc:define-objective-c-message%new-metal-sampler-descriptor
"new":object:ownership:owned:class"MTLSamplerDescriptor"
objc:define-objective-c-message%new-metal-sampler
"newSamplerStateWithDescriptor:":object:ownership:owned:class"MTLSamplerState"
descriptor:object
defunnew-metal-sampler
devicemin-filtermag-filtermip-filteraddress-mode-saddress-mode-taddress-mode-rcompare-function&keylabel

Create one owned Metal sampler state.

objc:define-objective-c-message%new-metal-residency-set-descriptor
"new":object:ownership:owned:class"MTLResidencySetDescriptor"
objc:define-objective-c-message%new-metal-residency-set
"newResidencySetWithDescriptor:error:":object:ownership:owned:class"MTLResidencySet"
descriptor:object
error:pointer
objc:define-objective-c-messageadd-metal-queue-residency-set
"addResidencySet:":void
residency-set:object
objc:define-objective-c-messageremove-metal-queue-residency-set
"removeResidencySet:":void
residency-set:object
objc:define-objective-c-message%new-metal-4-argument-table-descriptor
"new":object:ownership:owned:class"MTL4ArgumentTableDescriptor"
objc:define-objective-c-message%set-argument-table-max-sampler-count
"setMaxSamplerStateBindCount:":void
count:uint64
objc:define-objective-c-message%new-metal-4-argument-table
"newArgumentTableWithDescriptor:error:":object:ownership:owned:class"MTL4ArgumentTable"
descriptor:object
error:pointer
objc:define-objective-c-messageset-metal-argument-table-buffer
"setAddress:attributeStride:atIndex:":void
address:uint64
attribute-stride:uint64
index:uint64
objc:define-objective-c-messageset-metal-argument-table-address
"setAddress:atIndex:":void
address:uint64
index:uint64
objc:define-objective-c-messageset-metal-argument-table-texture
"setTexture:atIndex:":void
resource-id
index:uint64
objc:define-objective-c-messageset-metal-argument-table-sampler
"setSamplerState:atIndex:":void
resource-id
index:uint64
objc:define-objective-c-message%new-metal-4-compiler-descriptor
"new":object:ownership:owned:class"MTL4CompilerDescriptor"
objc:define-objective-c-message%new-metal-4-library-descriptor
"new":object:ownership:owned:class"MTL4LibraryDescriptor"
objc:define-objective-c-message%new-metal-compile-options
"new":object:ownership:owned:class"MTLCompileOptions"
objc:define-objective-c-message%set-language-version
"setLanguageVersion:":void
version:uint64
objc:define-objective-c-message%new-metal-4-compiler
"newCompilerWithDescriptor:error:":object:ownership:owned:class"MTL4Compiler"
descriptor:object
error:pointer
objc:define-objective-c-message%new-metal-4-library
"newLibraryWithDescriptor:error:":object:ownership:owned:class"MTLLibrary"
descriptor:object
error:pointer
objc:define-objective-c-messagenew-metal-library-function
"newFunctionWithName:":object:ownership:owned:class"MTLFunction"
name:object
defunobjective-c-error-pointer-description
storage
let
pointer
cffi:mem-refstorage:pointer
unless
cffi:null-pointer-ppointer
objc:objective-c-error-description
objc:wrap-objective-c-objectpointer:ownership:borrowed:protocol-name"NSError"
defunnew-metal-residency-set
device&keylabel
initial-capacity64

Create an owned residency set for long-lived Metal allocations.

objc:with-autorelease-pool
objc:with-owned-objective-c-object
%set-residency-set-initial-capacitydescriptorinitial-capacity
cffi:with-foreign-object
error:pointer
setf
cffi:mem-referror:pointer
cffi:null-pointer
let
residency-set
%new-metal-residency-setdevicedescriptorerror
defunnew-metal-4-argument-table
devicemax-buffer-count&key
max-texture-count0
max-sampler-count0
label
attribute-strides-pnil

Create an owned Metal 4 argument table with a buffer binding range.

defunnew-metal-4-compiler
device&keylabel

Create one synchronous Metal 4 compiler owned by device.

Return the owned compiler and NIL on success, or NIL and a copied NSError description on native rejection.

objc:with-autorelease-pool
objc:with-owned-objective-c-object
cffi:with-foreign-object
error:pointer
setf
cffi:mem-referror:pointer
cffi:null-pointer
let
compiler
%new-metal-4-compilerdevicedescriptorerror

MetalFX temporal reconstruction on a Metal 4 command buffer.

objc:define-objective-c-message%new-temporal-scaler-descriptor
"new":object:ownership:owned:class"MTLFXTemporalScalerDescriptor"
objc:define-objective-c-message%set-temporal-color-format
"setColorTextureFormat:":void
format:uint64
objc:define-objective-c-message%set-temporal-depth-format
"setDepthTextureFormat:":void
format:uint64
objc:define-objective-c-message%set-temporal-motion-format
"setMotionTextureFormat:":void
format:uint64
objc:define-objective-c-message%set-temporal-output-format
"setOutputTextureFormat:":void
format:uint64
objc:define-objective-c-message%set-temporal-synchronous-initialization
"setRequiresSynchronousInitialization:":void
enabled:uint8
objc:define-objective-c-message%new-temporal-scaler-with-compiler
"newTemporalScalerWithDevice:compiler:":object:ownership:owned:class"MTL4FXTemporalScaler"
device:object
compiler:object
objc:define-objective-c-messagenew-metal-fence
"newFence":object:ownership:owned:class"MTLFence"
objc:define-objective-c-message%set-temporal-jitter-x
"setJitterOffsetX:":void
offset:float
objc:define-objective-c-message%set-temporal-jitter-y
"setJitterOffsetY:":void
offset:float
objc:define-objective-c-messageencode-metal-temporal-scaler
"encodeToCommandBuffer:":void
command-buffer:object
objc:define-objective-c-messageupdate-metal-fence
"updateFence:afterEncoderStages:":void
fence:object
stages:uint64
objc:define-objective-c-messagewait-for-metal-fence
"waitForFence:beforeEncoderStages:":void
fence:object
stages:uint64
defunnew-metal-4-temporal-scaler
devicecompilercolor-formatdepth-formatmotion-formatoutput-formatinput-widthinput-heightoutput-widthoutput-height

Create an owned Metal4FX temporal scaler and its owned synchronization fence.

objc:with-autorelease-pool
let
class
objc:find-objective-c-class"MTLFXTemporalScalerDescriptor"
when
objc:with-owned-objective-c-object
%set-temporal-color-formatdescriptorcolor-format
%set-temporal-depth-formatdescriptordepth-format
%set-temporal-motion-formatdescriptormotion-format
%set-temporal-output-formatdescriptoroutput-format
%set-temporal-input-widthdescriptorinput-width
%set-temporal-input-heightdescriptorinput-height
%set-temporal-output-widthdescriptoroutput-width
%set-temporal-output-heightdescriptoroutput-height
let
scaler
%new-temporal-scaler-with-compilerdescriptordevicecompiler
whenscaler
let
fence
iffence
progn
valuesscalerfence
progn
valuesnilnil
defunmetal-temporal-scaler-texture-usages
scaler

Return scaler's required color, depth, motion, and output usage masks.

defunconfigure-metal-temporal-scaler
scalercolordepthmotionexposureoutputwidthheightjitter-xjitter-yreset-p

Bind one native frame to scaler before encoding it.

%set-temporal-jitter-xscaler
coercejitter-x'single-float
%set-temporal-jitter-yscaler
coercejitter-y'single-float

Luft writes normalized current-to-previous motion. MetalFX consumes pixels after applying these once-per-frame extent scales.

%set-temporal-motion-scale-xscaler
coercewidth'single-float
%set-temporal-motion-scale-yscaler
coerceheight'single-float
%set-temporal-resetscaler
ifreset-p10
scaler
defuncompile-metal-4-library
compilersource&keyname

Synchronously compile source as Metal 4 and return an owned MTLLibrary.

The second value is NIL on success or a copied NSError description on native rejection. Source and names cross only as in-memory NSString objects.

check-typesourcestring

Metal 4 render pipeline compilation.

objc:define-objective-c-message%new-metal-4-render-pipeline-descriptor
"new":object:ownership:owned:class"MTL4RenderPipelineDescriptor"
objc:define-objective-c-message%new-metal-4-mesh-render-pipeline-descriptor
"new":object:ownership:owned:class"MTL4MeshRenderPipelineDescriptor"
objc:define-objective-c-message%new-metal-4-library-function-descriptor
"new":object:ownership:owned:class"MTL4LibraryFunctionDescriptor"
objc:define-objective-c-message%new-metal-vertex-descriptor
"new":object:ownership:owned:class"MTLVertexDescriptor"
objc:define-objective-c-message%set-vertex-function-descriptor
"setVertexFunctionDescriptor:":void
descriptor:object
objc:define-objective-c-message%set-fragment-function-descriptor
"setFragmentFunctionDescriptor:":void
descriptor:object
objc:define-objective-c-message%set-object-function-descriptor
"setObjectFunctionDescriptor:":void
descriptor:object
objc:define-objective-c-message%set-mesh-function-descriptor
"setMeshFunctionDescriptor:":void
descriptor:object
objc:define-objective-c-message%set-max-object-threads
"setMaxTotalThreadsPerObjectThreadgroup:":void
count:uint64
objc:define-objective-c-message%set-max-mesh-threads
"setMaxTotalThreadsPerMeshThreadgroup:":void
count:uint64
objc:define-objective-c-message%set-max-mesh-workgroups
"setMaxTotalThreadgroupsPerMeshGrid:":void
count:uint64
objc:define-objective-c-message%set-pipeline-vertex-descriptor
"setVertexDescriptor:":void
descriptor:object
objc:define-objective-c-message%set-input-primitive-topology
"setInputPrimitiveTopology:":void
topology:uint64
objc:define-objective-c-message%render-pipeline-color-attachments
"colorAttachments":object:ownership:borrowed:class"MTL4RenderPipelineColorAttachmentDescriptorArray"
objc:define-objective-c-message%render-pipeline-color-attachment-at
"objectAtIndexedSubscript:":object:ownership:borrowed:class"MTL4RenderPipelineColorAttachmentDescriptor"
index:uint64
objc:define-objective-c-message%set-source-rgb-blend-factor
"setSourceRGBBlendFactor:":void
factor:uint64
objc:define-objective-c-message%set-destination-rgb-blend-factor
"setDestinationRGBBlendFactor:":void
factor:uint64
objc:define-objective-c-message%set-rgb-blend-operation
"setRgbBlendOperation:":void
operation:uint64
objc:define-objective-c-message%set-source-alpha-blend-factor
"setSourceAlphaBlendFactor:":void
factor:uint64
objc:define-objective-c-message%set-destination-alpha-blend-factor
"setDestinationAlphaBlendFactor:":void
factor:uint64
objc:define-objective-c-message%set-alpha-blend-operation
"setAlphaBlendOperation:":void
operation:uint64
objc:define-objective-c-message%vertex-descriptor-layouts
"layouts":object:ownership:borrowed:class"MTLVertexBufferLayoutDescriptorArray"
objc:define-objective-c-message%vertex-layout-at
"objectAtIndexedSubscript:":object:ownership:borrowed:class"MTLVertexBufferLayoutDescriptor"
index:uint64
objc:define-objective-c-message%set-vertex-layout-step-function
"setStepFunction:":void
step-function:uint64
objc:define-objective-c-message%vertex-descriptor-attributes
"attributes":object:ownership:borrowed:class"MTLVertexAttributeDescriptorArray"
objc:define-objective-c-message%vertex-attribute-at
"objectAtIndexedSubscript:":object:ownership:borrowed:class"MTLVertexAttributeDescriptor"
index:uint64
objc:define-objective-c-message%new-metal-4-render-pipeline-state
"newRenderPipelineStateWithDescriptor:compilerTaskOptions:error:":object:ownership:owned:class"MTLRenderPipelineState"
descriptor:object
compiler-task-options:object
error:pointer
objc:define-objective-c-message%new-metal-depth-stencil-descriptor
"new":object:ownership:owned:class"MTLDepthStencilDescriptor"
objc:define-objective-c-message%set-depth-write-enabled
"setDepthWriteEnabled:":void
enabled:uint8
objc:define-objective-c-message%new-depth-stencil-state
"newDepthStencilStateWithDescriptor:":object:ownership:owned:class"MTLDepthStencilState"
descriptor:object
defunconfigure-metal-vertex-descriptor
descriptorvertex-buffers
let
dolist
buffervertex-buffers
let*
binding
getfbuffer:binding
%set-vertex-layout-stridelayout
getfbuffer:array-stride
dolist
attribute
getfbuffer:attributes
let
native-attribute
%vertex-attribute-atattributes
getfattribute:shader-location
%set-vertex-attribute-formatnative-attribute
ecase
getfattribute:format
%set-vertex-attribute-offsetnative-attribute
getfattribute:offset
%set-vertex-attribute-buffer-indexnative-attributebinding
descriptor
defuncompile-metal-4-render-pipeline
compilervertex-libraryvertex-namefragment-libraryfragment-namevertex-bufferscolor-formatstopology&keydepth-formatblendslabel

Synchronously link Metal libraries into an owned Metal 4 pipeline state.

declare
ignoredepth-format
objc:with-autorelease-pool
objc:with-owned-objective-c-object
vertex-function
%set-function-libraryvertex-functionvertex-library
let
fragment-functionnil
unwind-protect
progn
whenfragment-library
setffragment-function
%set-function-libraryfragment-functionfragment-library
objc:with-owned-objective-c-object
vertex-descriptor
configure-metal-vertex-descriptorvertex-descriptorvertex-buffers
whenfragment-function
defuncompile-metal-4-mesh-render-pipeline
compilerobject-libraryobject-nameobject-workgroup-sizemesh-librarymesh-namemesh-workgroup-sizefragment-libraryfragment-namecolor-formatmax-mesh-workgroups&keyblendlabel

Synchronously link object, mesh, and fragment libraries into Metal 4.

objc:with-autorelease-pool
let
object-functionnil
mesh-functionnil
fragment-functionnil
unwind-protect
progn
whenobject-library
setfobject-function
%set-function-libraryobject-functionobject-library
setfmesh-function
%set-function-librarymesh-functionmesh-library
whenfragment-library
setffragment-function
%set-function-libraryfragment-functionfragment-library
whenfragment-function
whenmesh-function
whenobject-function
defunnew-metal-depth-stencil-state
devicecompare-functiondepth-write-enabled&keylabel

Create an owned MTLDepthStencilState for a Metal render pipeline.

objc:define-objective-c-messagenew-command-allocator
"newCommandAllocator":object:ownership:owned:class"MTL4CommandAllocator"
objc:define-objective-c-messagenew-command-buffer
"newCommandBuffer":object:ownership:owned:class"MTL4CommandBuffer"
objc:define-objective-c-messagebegin-command-buffer
"beginCommandBufferWithAllocator:":void
allocator:object
objc:define-objective-c-messagerender-command-encoder
"renderCommandEncoderWithDescriptor:":object:ownership:borrowed:class"MTL4RenderCommandEncoder"
descriptor:object
objc:define-objective-c-messagecompute-command-encoder
"computeCommandEncoder":object:ownership:borrowed:class"MTL4ComputeCommandEncoder"
objc:define-objective-c-messageset-metal-render-pipeline
"setRenderPipelineState:":void
pipeline:object
objc:define-objective-c-messageset-metal-depth-stencil-state
"setDepthStencilState:":void
depth-stencil-state:object
objc:define-objective-c-messageset-metal-render-argument-table
"setArgumentTable:atStages:":void
argument-table:object
stages:uint64
objc:define-objective-c-messagedraw-metal-primitives
"drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:":void
primitive-type:uint64
vertex-start:uint64
vertex-count:uint64
instance-count:uint64
base-instance:uint64
objc:define-objective-c-messagedraw-metal-indexed-primitives
"drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferLength:instanceCount:baseVertex:baseInstance:":void
primitive-type:uint64
index-count:uint64
index-type:uint64
index-buffer:uint64
index-buffer-length:uint64
instance-count:uint64
base-vertex:int64
base-instance:uint64
objc:define-objective-c-messagedraw-metal-mesh-threadgroups
"drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:":void
threadgroups-per-grid
:structmtl-size
threads-per-object-threadgroup
:structmtl-size
threads-per-mesh-threadgroup
:structmtl-size
objc:define-objective-c-messagecopy-metal-texture
"copyFromTexture:toTexture:":void
source:object
destination:object
objc:define-objective-c-message%copy-metal-texture-to-buffer
"copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:":void
source:object
source-level:uint64
source-origin
:structmtl-origin
source-size
:structmtl-size
destination:object
destination-offset:uint64
destination-bytes-per-row:uint64
destination-bytes-per-image:uint64
defuncopy-metal-texture-to-buffer
encodersourcewidthheightdestinationbytes-per-row

Copy a complete two-dimensional Metal texture into a buffer.

%copy-metal-texture-to-bufferencodersource00
list'x0'y0'z0
destination0bytes-per-row0
objc:define-objective-c-messagebarrier-after-queue-stages
"barrierAfterQueueStages:beforeStages:visibilityOptions:":void
after-queue-stages:uint64
before-stages:uint64
visibility-options:uint64
objc:define-objective-c-messagewait-for-drawable
"waitForDrawable:":void
drawable:object
objc:define-objective-c-message%commit-command-buffers
"commit:count:":void
command-buffers:pointer
count:uint64
objc:define-objective-c-messagesignal-drawable
"signalDrawable:":void
drawable:object
defuncommit-command-buffers
queuecommand-buffers

Commit a non-empty vector of ended Metal 4 command buffers to queue.

unless
and
vectorpcommand-buffers
plusp
lengthcommand-buffers
error"Expected a non-empty vector of Metal command buffers, got ~S."command-buffers
cffi:with-foreign-object
native-command-buffers:pointer
lengthcommand-buffers
loopforcommand-bufferacrosscommand-buffersforindexfrom0do
setf
cffi:mem-arefnative-command-buffers:pointerindex
%commit-command-buffersqueuenative-command-buffers
lengthcommand-buffers
values
defuncommit-command-buffer
queuecommand-buffer

Commit one ended Metal 4 command buffer to queue.

commit-command-buffersqueue
vectorcommand-buffer
values

SDL's borrowed CAMetalLayer and its current drawable.

objc:define-objective-c-messageset-layer-pixel-format
"setPixelFormat:":void
pixel-format:uint64
objc:define-objective-c-messageset-layer-framebuffer-only
"setFramebufferOnly:":void
enabled:uint8
objc:define-objective-c-messagenext-drawable
"nextDrawable":object:ownership:borrowed:class"CAMetalDrawable"
objc:define-objective-c-messagedrawable-texture
"texture":object:ownership:borrowed:class"MTLTexture"
defunset-layer-drawable-size

Set layer's drawable extent in physical pixels.

%set-layer-drawable-sizelayer
list'width
coercewidth'double-float
'height
coerceheight'double-float
values
defunlayer-drawable-size
layer

Return layer's physical drawable width and height as two values.

let
values
getfsize'width
getfsize'height

Empty render pass used as a deterministic clear.

objc:define-objective-c-message%new-render-pass-descriptor
"new":object:ownership:owned:class"MTL4RenderPassDescriptor"
objc:define-objective-c-message%render-pass-color-attachments
"colorAttachments":object:ownership:borrowed:class"MTLRenderPassColorAttachmentDescriptorArray"
objc:define-objective-c-message%color-attachment-at
"objectAtIndexedSubscript:":object:ownership:borrowed:class"MTLRenderPassColorAttachmentDescriptor"
index:uint64
objc:define-objective-c-message%render-pass-depth-attachment
"depthAttachment":object:ownership:borrowed:class"MTLRenderPassDepthAttachmentDescriptor"
defunconfigure-metal-pass-color-attachment
descriptorindextexturecolorclear-pstore-p
whentexture
let*
attachments
attachment
%color-attachment-atattachmentsindex
whenclear-p
destructuring-bind
redgreenbluealpha
coercecolor'list
%set-color-attachment-clear-colorattachment
list'red
coercered'double-float
'green
coercegreen'double-float
'blue
coerceblue'double-float
'alpha
coercealpha'double-float
defunconfigure-metal-pass-depth-attachment
descriptortextureclear-depthclear-pstore-p
defunnew-render-command-encoder
command-buffer&keycolor-attachmentscolor-texture
color
0.00.00.01.0
color-clear-pt
color-store-pt
depth-texture
clear-depth1.0
depth-clear-pt
depth-store-pnil

Begin one Metal 4 render pass with optional color and depth attachments.

objc:with-owned-objective-c-object
descriptor
ifcolor-attachments
loopfor
textureattachment-colorclear-pstore-p
incolor-attachmentsforindexfrom0do
configure-metal-pass-color-attachmentdescriptorindextextureattachment-colorclear-pstore-p
configure-metal-pass-color-attachmentdescriptor0color-texturecolorcolor-clear-pcolor-store-p
configure-metal-pass-depth-attachmentdescriptordepth-textureclear-depthdepth-clear-pdepth-store-p
render-command-encodercommand-bufferdescriptor
defunnew-color-render-command-encoder
command-buffertexturecolor&key
clear-pt

Begin one Metal 4 color pass and return its borrowed render encoder.

new-render-command-encodercommand-buffer:color-texturetexture:colorcolor:color-clear-pclear-p:color-store-pt
defunencode-clear-pass
command-buffertexturecolor

Encode one empty Metal 4 render pass which clears texture to color.

let
encoder
new-color-render-command-encodercommand-buffertexturecolor:clear-pt
unlessencoder
error"Metal did not create a render command encoder."
encoder