0

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

user1822451
  • 101
  • 1
  • 5

2 Answers2

1

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)
rickster
  • 124,678
  • 26
  • 272
  • 326
  • thanks for the Answer Rick, I've tried your suggestion but I get this error: Cannot convert value of type 'CountableRange' to expected argument type 'NSRange' (aka '_NSRange'). – user1822451 Nov 20 '17 at 20:19
0

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

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94