1 module metal.commandbuffer; 2 3 version(D_ObjectiveC): 4 extern(Objective-C): 5 6 import metal.metal; 7 import metal.rendercommandencoder; 8 import metal.blitcommandencoder; 9 10 ///Options for reporting errors from a command buffer. 11 enum MTLCommandBufferErrorOption : NSUInteger 12 { 13 ///An option that clears a command buffer’s error options. 14 None = 0, 15 ///An option that instructs a command buffer to save additional details about a GPU runtime error. 16 EncoderExecutionStatus = 1 << 0 17 } 18 19 ///A configuration that customizes the behavior for a new command buffer. 20 extern class MTLCommandBufferDescriptor : NSObject 21 { 22 ///A Boolean value that indicates whether the command buffer the descriptor creates maintains strong references to the resources it uses. 23 @selector("retainedResources") 24 BOOL retainedResources(); 25 @selector("setRetainedResources:") 26 BOOL retainedResources(BOOL); 27 28 ///The reporting configuration that indicates which information the GPU driver stores in a command buffer’s error property. 29 @selector("errorOptions") 30 MTLCommandBufferErrorOption errorOptions(); 31 32 @selector("setErrorOptions:") 33 MTLCommandBufferErrorOption errorOptions(MTLCommandBufferErrorOption); 34 } 35 36 ///The discrete states for a command buffer that represent its life cycle stages. 37 enum MTLCommandBufferStatus : NSUInteger 38 { 39 ///A command buffer’s initial state, which indicates its command queue isn’t reserving a place for it. 40 NotEnqueued = 0, 41 ///A command buffer’s second state, which indicates its command queue is reserving a place for it. 42 Enqueued = 1, 43 ///A command buffer’s third state, which indicates the command queue is preparing to schedule the command buffer by resolving its dependencies. 44 Committed = 2, 45 ///A command buffer’s fourth state, which indicates the command buffer has its resources ready and is waiting for the GPU to run its commands. 46 Scheduled = 3, 47 ///A command buffer’s successful, final state, which indicates the GPU finished running the command buffer’s commands without any problems. 48 Completed = 4, 49 ///A command buffer’s unsuccessful, final state, which indicates the GPU stopped running the buffer’s commands because of a runtime issue. 50 Error = 5 51 } 52 53 ///A configuration you create to customize a blit command encoder, which affects the runtime behavior of the blit pass you encode with it. 54 extern class MTLBlitPassDescriptor : NSObject 55 { 56 ///Creates a new blit pass descriptor with a default configuration. 57 @selector("blitPassDescriptor") 58 static MTLBlitPassDescriptor blitPassDescriptor(); 59 60 ///An array of counter sample buffer attachments that you configure for a blit pass. 61 62 } 63 64 ///A completion handler signature a GPU device calls when it finishes scheduling a command buffer, or when the GPU finishes running it. 65 alias MTLCommandBufferHandler = extern(C) void function(MTLCommandBuffer); 66 67 ///A container that stores a sequence of GPU commands that you encode into it. 68 extern interface MTLCommandBuffer 69 { 70 ///Encodes a command into the command buffer that pauses the GPU from running subsequent passes until the event equals or exceeds a value. 71 @selector("encodeWaitForEvent:value:") 72 void encodeWaitForEvent(MTLEvent event, ulong value); 73 74 ///Encodes a command into the command buffer that pauses the GPU from running subsequent passes until the event equals or exceeds a value. 75 @selector("encodeSignalEvent:value:") 76 void encodeSignalEvent(MTLEvent event, ulong value); 77 78 ///Presents a drawable as early as possible. 79 @selector("presentDrawable:") 80 void presentDrawable(MTLDrawable drawable); 81 82 ///Presents a drawable at a specific time. 83 @selector("presentDrawable:atTime:") 84 void presentDrawable(MTLDrawable drawable, CFTimeInterval presentationTime); 85 86 ///Presents a drawable after the system presents the previous drawable for an amount of time. 87 @selector("presentDrawable:afterMinimumDuration:") 88 void presentDrawableAfterMinimumDuration(MTLDrawable drawable, CFTimeInterval duration); 89 90 ///Registers a completion handler the GPU device calls immediately after it schedules the command buffer to run on the GPU. 91 @selector("addScheduleHandler:") 92 void addScheduleHandler(MTLCommandBufferHandler); 93 94 ///Registers a completion handler the GPU device calls immediately after the GPU finishes running the commands in the command buffer. 95 @selector("addCompletedHandler:") 96 void addCompletedHandler(MTLCommandBufferHandler); 97 98 ///Reserves the next available place for the command buffer in its command queue. 99 @selector("enqueue") 100 void enqueue(); 101 102 ///Submits the command buffer to run on the GPU. 103 @selector("commit") 104 void commit(); 105 106 ///Synchronously waits for the command queue to schedule the buffer, which can block the current thread’s execution. 107 @selector("waitUntilScheduled") 108 void waitUntilScheduled(); 109 110 ///Synchronously waits for the GPU to finish running the command buffer, which can block the current thread’s execution. 111 @selector("waitUntilCompleted") 112 void waitUntilCompleted(); 113 114 ///The command buffer’s current state. 115 @selector("status") 116 MTLCommandBufferStatus status(); 117 118 @selector("renderCommandEncoderWithDescriptor:") 119 MTLRenderCommandEncoder renderCommandEncoderWithDescriptor(MTLRenderPassDescriptor renderPassDescriptor); 120 121 ///Creates a block information transfer (blit) encoder. 122 @selector("blitCommandEncoder") 123 MTLBlitCommandEncoder blitCommandEncoder(); 124 125 ///Creates a block information transfer (blit) encoder from a descriptor. 126 @selector("blitCommandEncoderWithDescriptor:") 127 MTLBlitCommandEncoder blitCommandEncoderWithDescriptor(MTLBlitPassDescriptor); 128 129 130 ///A string to help identify this object 131 @selector("label") 132 NSString label(); 133 @selector("setLabel:") 134 NSString label(NSString); 135 }