Post

Replies

Boosts

Views

Activity

Indexing bringing Xcode to a crawl.
I am running Xcode 11.3.1 on macOS 10.14. (I know, I'm a little behind, but the Mail bug in Catalina still makes me wary.) Lately editing in Xcode has slowed to a crawl. Activity Monitor shows the process com.apple.dt.SKAgent running consistently at over 170%. Keystrokes are often delayed by up to several seconds, and I had to turn off "suggest completions while typing" altogether, which further slows me down. I've tried: rebooting closing any other open projects quitting Xcode and deleting the "DerivedData" directory The problem remains. Is there anything else I can try short of upgrading the OS? If the index parser is getting hung up on something, is there a way I can try to see what it might be?
4
0
1.5k
Jun ’20
How to use NSScrollView with a very large MTKView document view?
Hi, My macOS app has an NSScrollView to display an image. The document view is an MTKView. I have a Metal pipeline that renders the image and draws it into the view. The view supports "pinch and zoom" scaling. I set the view's drawableSize to be the size of the scaled data, and that works. The problem I have is that when the image is zoomed in to a large size, I get: validateTextureDimensions, line 1081: error 'MTLTextureDescriptor has width (18798) greater than the maximum allowed size of 16384.' MTKView's underlying texture is now exceeding the GPU RAM. This happens even if I don't draw anything into the drawable. Is there a way I can get the functionality of the scroll view (i.e. scroll bars, response to mouse/touch) while still using a MTKView? A few thoughts: Can I fix the size of the actual MTKView while "tricking" NSScrollView into thinking it was larger? Can I make the document view large but draw into the visible (clipped) portion? Is CATiledLayer an option? I could manage the Metal textures, but how would I draw them into the tiles? Or another recommended option? I had two WWDC20 labs this weeks and got some great help and suggestions, but am still trying to effectively bridge AppKit and Metal in this case. Thanks!
6
0
2.4k
Jun ’20
Creating a Metal texture with float data
Hi,I'm trying to transition my macOS application to use Metal. It uses CIFilter's extensively. I'm trying to create a Metal texture for use in a MTKView subclass. The source data is an array of float values, not an RGB image. I add color later with a CIFilter colormap. The existing code (that works) creates a CIImage like this:NSData *convertedData = <float data> CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)convertedData); CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrder32Host | kCGBitmapFloatComponents; CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); CGImageRef cgImage = CGImageCreate(width, // size_t width height, // size_t height 32, // size_t bitsPerComponent (float=32) 32, // size_t bitsPerPixel == bitsPerComponent for float bytesPerRow, // size_t bytesPerRow -> width in pixels * sizeof(float) colorSpace, // CGColorSpaceRef bitmapInfo, // CGBitmapInfo dataProvider, // CGDataProviderRef NULL, // const CGFloat decode[] - NULL = do not want to allow // remapping of the image’s color values NO, // shouldInterpolate? kCGRenderingIntentDefault); // CGColorRenderingIntent CIImage *ciImage = [CIImage imageWithCGImage:cgImage options:@{kCIImageColorSpace: [NSNull null]}];I tried to convert this into a Metal texture:MTKTextureLoader *textureLoader = [[MTKTextureLoader alloc] initWithDevice:self.device]; NSError *error = nil; NSNumber *textureUsageOptions = @(MTLTextureUsageUnknown); // TODO: revisit this when things work texture = [textureLoader newTextureWithCGImage:ciImage.CGImage // CGImageRef options:@{ MTKTextureLoaderOptionTextureUsage:textureUsageOptions, MTKTextureLoaderOptionSRGB:@(0) // image data is linear } error:&error];I get this error:Error Domain=MTKTextureLoaderErrorDomain Code=0 "Image decoding failed" UserInfo={NSLocalizedDescription=Image decoding failed, MTKTextureLoaderErrorKey=Image decoding failed}Is this the right approach? I don't tend to see many examples using float components to create images.Thanks!
1
0
1.4k
May ’20