Reputation: 111
I'm trying to tell a MTLBuffer that the range has changed but the compiler won't let me do that:
vertexBuffer?.didModifyRange(NSMakeRange(0,MemoryLayout<MetalVertex>.stride*nbVerts))
it just says: 'didModifyRange' is unavailable why is that?
thanks
Upvotes: 0
Views: 181
Reputation: 23138
Are you targeting iOS? Per the Apple Documentation, didModifyRange
is only supported on macOS and Catalyst. It also only applies to buffers created with MTLStorageModeManaged
, which has the same constraints.
If you're targeting multiple platforms, you will need to make both conditional, see:
Swift availability check for macCatalyst
Upvotes: 0
Reputation: 126127
In Swift, didModifyRange
takes a Range<Int>
, not an NSRange
. So instead of using NSMakeRange
, you can construct one using the ..<
operator.
vertexBuffer?.didModifyRange(0 ..< MemoryLayout<MetalVertex>.stride * nbVerts)
Upvotes: 1