1 module metal.blitcommandencoder; 2 import objc.meta : selector; 3 import metal.metal; 4 import metal.texture; 5 6 @ObjectiveC final extern(C++): 7 @nogc nothrow: 8 9 ///The options that enable behavior for some blit operations. 10 enum MTLBlitOption : NSUInteger 11 { 12 ///A blit option that copies the depth portion of a combined depth and stencil texture to or from a buffer. 13 DepthFromDepthStencil = 1 << 0, 14 ///A blit option that copies the stencil portion of a combined depth and stencil texture to or from a buffer. 15 StencilFromDepthStencil = 1 << 1, 16 ///A blit option that copies PVRTC data between a texture and a buffer. 17 RowLinearPVRTC = 1 << 2, 18 ///A blit option that clears other blit options, which removes any optional behavior for a blit operation. 19 None = 0 20 } 21 22 ///An interface you can use to encode GPU commands that copy and modify the underlying memory of various Metal resources. 23 interface MTLBlitCommandEncoder : MTLCommandEncoder 24 { 25 @nogc nothrow: 26 27 ///Encodes a command that fills a buffer with a constant value for each byte. 28 @selector("fillBuffer:range:value:") 29 void fillBuffer(MTLBuffer buffer, NSRange range, ubyte value); 30 31 ///Encodes a command that generates mipmaps for a texture from the base mipmap level up to the highest mipmap level. 32 @selector("generateMipmapsForTexture:") 33 void generateMipmapsForTexture(MTLTexture); 34 35 ///Encodes a command that copies data from one buffer into another. 36 @selector("copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:") 37 void copyFromBuffer( 38 MTLBuffer sourceBuffer, 39 NSUInteger sourceOffset, 40 MTLBuffer destinationBuffer, 41 NSUInteger destinationOffset, 42 NSUInteger size 43 ); 44 45 ///Encodes a command that copies data from one texture to another. 46 @selector("copyFromTexture:toTexture:") 47 void copyFromTexture(MTLTexture source, MTLTexture ddestination); 48 49 ///Encodes a command that copies slices of a texture to another texture’s slices. 50 @selector("copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:") 51 void copyFromTexture( 52 MTLTexture sourceTexture, 53 NSUInteger sourceSlice, 54 NSUInteger sourceLevel, 55 MTLTexture destinationTexture, 56 NSUInteger destinationSlice, 57 NSUInteger destinationLevel, 58 NSUInteger sliceCount, 59 NSUInteger levelCount, 60 ); 61 62 ///Encodes a command that copies image data from a texture’s slice into another slice. 63 @selector("copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:") 64 void copyFromTexture( 65 MTLTexture sourceTexture, 66 NSUInteger sourceSlice, 67 NSUInteger sourceLevel, 68 MTLOrigin sourceOrigin, 69 MTLSize sourceSize, 70 MTLTexture destinationTexture, 71 NSUInteger destinationSlice, 72 NSUInteger destinationLevel, 73 MTLOrigin destinationOrigin, 74 ); 75 76 ///Encodes a command to copy image data from a source buffer into a destination texture. 77 @selector("copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:") 78 void copyFromBuffer(MTLBuffer sourceBuffer, 79 NSUInteger sourceOffset, 80 NSUInteger sourceBytesPerRow, 81 NSUInteger sourceBytesPerImage, 82 MTLSize sourceSize, 83 MTLTexture destinationTexture, 84 NSUInteger destinationSlice, 85 NSUInteger destinationLevel, 86 MTLOrigin destinationOrigin, 87 ); 88 89 ///Encodes a command to copy image data from a source buffer into a destination texture. 90 @selector("copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:") 91 void copyFromBuffer(MTLBuffer sourceBuffer, 92 NSUInteger sourceOffset, 93 NSUInteger sourceBytesPerRow, 94 NSUInteger sourceBytesPerImage, 95 MTLSize sourceSize, 96 MTLTexture destinationTexture, 97 NSUInteger destinationSlice, 98 NSUInteger destinationLevel, 99 MTLOrigin destinationOrigin, 100 MTLBlitOption options, 101 ); 102 103 ///Encodes a command that copies image data from a texture slice to a buffer. 104 @selector("copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:") 105 void copyFromTexture(MTLTexture sourceTexture, 106 NSUInteger sourceSlice, 107 NSUInteger sourceLevel, 108 MTLOrigin sourceOrigin, 109 MTLSize sourceSize, 110 MTLBuffer destinationBuffer, 111 NSUInteger destinationOffset, 112 NSUInteger destinationBytesPerRow, 113 NSUInteger destinationBytesPerImage, 114 ); 115 116 ///Encodes a command that copies image data from a texture slice to a buffer, and provides options for special texture formats. 117 @selector("copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:") 118 void copyFromTexture(MTLTexture sourceTexture, 119 NSUInteger sourceSlice, 120 NSUInteger sourceLevel, 121 MTLOrigin sourceOrigin, 122 MTLSize sourceSize, 123 MTLBuffer destinationBuffer, 124 NSUInteger destinationOffset, 125 NSUInteger destinationBytesPerRow, 126 NSUInteger destinationBytesPerImage, 127 MTLBlitOption options, 128 ); 129 130 ///Encodes a command that improves the performance of the GPU’s accesses to a texture. 131 @selector("optimizeContentsForGPUAccess:") 132 void optimizeContentsForGPUAccess(MTLTexture texture); 133 134 ///Encodes a command that improves the performance of the GPU’s accesses to a specific portion of a texture. 135 @selector("optimizeContentsForGPUAccess:slice:level:") 136 void optimizeContentsForGPUAccess(MTLTexture texture, 137 NSUInteger slice, 138 NSUInteger level 139 ); 140 141 ///Encodes a command that improves the performance of the CPU’s accesses to a texture. 142 @selector("optimizeContentsForCPUAccess:") 143 void optimizeContentsForCPUAccess(MTLTexture texture); 144 145 ///Encodes a command that improves the performance of the CPU’s accesses to a specific portion of a texture. 146 @selector("optimizeContentsForCPUAccess:slice:level:") 147 void optimizeContentsForCPUAccess(MTLTexture texture, 148 NSUInteger slice, 149 NSUInteger level 150 ); 151 152 ///Encodes a command that synchronizes the CPU’s copy of a managed resource, such as a buffer or texture, so that it matches the GPU’s copy. 153 @selector("synchronizeResource:") 154 void synchronizeResource(MTLResource resource); 155 156 ///Encodes a command that synchronizes a part of the CPU’s copy of a texture so that it matches the GPU’s copy. 157 @selector("synchronizeTexture:slice:level:") 158 void synchronizeTexture(MTLTexture texture, 159 NSUInteger slice, 160 NSUInteger level, 161 ); 162 163 ///Encodes a command that instructs the GPU to update a fence, which can signal a pass that’s waiting for it. 164 @selector("updateFence:") 165 void updateFence(MTLFence); 166 167 ///Encodes a command that instructs the GPU to wait until a pass updates a fence. 168 @selector("waitForFence:") 169 void waitForFence(MTLFence); 170 171 // ///Encodes a command that copies commands from one indirect command buffer into another. 172 // @selector("copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:") 173 // void copyIndirectCommandBuffer(MTLIndirectCommandBuffer source, 174 // NSRange sourceRange, 175 // MTLIndirectCommandBuffer destination, 176 // NSUInteger destinationIndex, 177 // ); 178 179 // ///Encodes a command that resets a range of commands in an indirect command buffer. 180 // @selector("resetCommandsInBuffer:withRange:") 181 // void resetCommandsInBuffer(MTLIndirectCommandBuffer buffer, NSRange range); 182 183 // ///Encodes a command that can improve the performance of a range of commands within an indirect command buffer. 184 // @selector("optimizeIndirectCommandBuffer:withRange:") 185 // void optimizeIndirectCommandBuffer( 186 // MTLIndirectCommandBuffer indirectCommandBuffer, 187 // NSRange range 188 // ); 189 190 // ///Encodes a command that samples the GPU’s hardware counters during a blit pass and stores the data in a counter sample buffer. 191 // @selector("sampleCountersInBuffer:atSampleIndex:withBarrier:") 192 // void sampleCountersInBuffer(MTLCounterSampleBuffer sampleBuffer, 193 // NSUInteger sampleIndex, 194 // BOOL barrier, 195 // ); 196 197 // ///Encodes a command that resolves the data from the samples in a sample counter buffer and stores the results into a buffer. 198 // @selector("resolveCounters:inRange:destinationBuffer:destinationOffset:") 199 // void resolveCounters(MTLCounterSampleBuffer sampleBuffer, 200 // NSRange range, 201 // MTLBuffer destinationBuffer, 202 // NSUInteger destinationOffset, 203 // ); 204 205 ///Encodes a command that retrieves a sparse texture’s access data for a specific region, mipmap level, and slice. 206 @selector("getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:") 207 void getTextureAccessCounters(MTLTexture texture, 208 MTLRegion region, 209 NSUInteger mipLevel, 210 NSUInteger slice, 211 BOOL resetCounters, 212 MTLBuffer countersBuffer, 213 NSUInteger countersBufferOffset, 214 ); 215 216 ///Encodes a command that resets a sparse texture’s access data for a specific region, mipmap level, and slice. 217 @selector("resetTextureAccessCounters:region:mipLevel:slice:") 218 void resetTextureAccessCounters(MTLTexture texture, 219 MTLRegion region, 220 NSUInteger mipLevel, 221 NSUInteger slice, 222 ); 223 } 224