Post

Replies

Boosts

Views

Activity

Buffer declaration: why not uint64_t possible?
This is my function: kernel void shaderFunction(device uint64_t* result, uint index [[thread_position_in_grid]]) { ... } This is the error: Invalid type 'device uint64_t *' (aka 'device unsigned long *') for buffer declaration When I looked in the Metal Specification, section scalar data types, uint64_t should be possible? Unless those can't be used to declare a buffer, but what types can then be used? And how can I use 64 bit data? (see: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf)
2
0
593
Mar ’23
In iOS, what is the possible minimum amount of threads in a threadGroup
Question I can check for the maximum via the code below, but how can I check for the minimum? let maxThreads = mFunctionPSO.maxTotalThreadsPerThreadgroup I saw that the minimum amount of threads depends on the chip architecture, but I could not find it in the metal documentation. Of course it makes no sense to make for example one thread in a threadGroup, but I keep running into the error below when the data inside the buffer is not long enough. Setup I test on an iPhone 8 running iOS 13.5. var message: [UInt8] = [UInt8]("ABC".utf8) threadAmount = message.count mBufferResult = self.device.makeBuffer( bytes: &message, length: MemoryLayout<UInt8>.stride * threadAmount, options: MTLResourceOptions.storageModeShared) mCommandBuffer = mCommandQueue.makeCommandBuffer() mEncoder = mCommandBuffer?.makeComputeCommandEncoder() mEncoder?.setBuffer(mBufferResult, offset: 0, index: 0) let grid = MTLSize(width: threadAmount, height: 1, depth: 1) let maxThreads = mFunctionPSO.maxTotalThreadsPerThreadgroup let threadGroupSize = MTLSize(width: maxThreads, height: 1, depth: 1) mEncoder?.setComputePipelineState(mFunctionPSO) mEncoder?.dispatchThreads(grid, threadsPerThreadgroup: threadGroupSize) Problem threadAmount will be 3, then this is the error I get on dispatchThreads... what does this error even mean? If i change the message to ABCD then the error disappears. Compute Function(example): argument result[0] from buffer(0) with offset(0) and length(3) has space for 3 bytes, but argument has a length(4). This is the metal shader code, just a basic test setup: kernel void example(device uint* result, uint index [[thread_position_in_grid]]) { //some code }
1
0
402
Mar ’23
using xcrun to compile .metal shader
XCRUN Two questions What version does xcrun use when not specified with 'std=ios-metal2.4'? How can I find out, if I want to use 'std=ios-metal...', what version to use? Also is there somewhere documentation about all the xcrun command flags and what ios-metal version(s) run on what chipset (eg. A11 can run ios-metal...)? Can't seem to find them. Test setup I am building for a iPhone 8 running iOS version 13.5.1. The terminal commands I run (see below): $ xcrun -sdk iphoneos metal -c -mios-version-min=13.5 MyLibrary.metal -o MyLibrary.air $ xcrun -sdk iphoneos metallib MyLibrary.air -o MyLibrary.metallib This builds and run on the device. But when I run it with the 'std=ios-metal2.4' flag (see below): $ xcrun -sdk iphoneos metal -c -std=ios-metal2.4 -mios-version-min=13.5 MyLibrary.metal -o MyLibrary.air $ xcrun -sdk iphoneos metallib MyLibrary.air -o MyLibrary.metallib It does not build and run on the device. The error I get is this: Error Domain=AGXMetalA11 Code=3 "Function myFunction is using language version 2.4 which is incompatible with this OS."
4
0
1.1k
Mar ’23