Posts

Post not yet marked as solved
2 Replies
913 Views
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?
Posted
by demitri.
Last updated
.
Post marked as solved
6 Replies
971 Views
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!
Posted
by demitri.
Last updated
.
Post marked as solved
1 Replies
588 Views
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!
Posted
by demitri.
Last updated
.
Post not yet marked as solved
0 Replies
643 Views
Hi,I recently posted this question to the cocoa-dev list but didn't get an answer; maybe someone here can help!I have a 10.11+ NSCollectionView and a custom layout, and I’d like to animate the items in the collection when the bounds change. This does not involve inserting or deleting items or changing the layout, just repositioning them when the view changes size. It’s exactly this question:https://stackoverflow.com/questions/52091074/how-to-animate-a-relayout-of-nscollectionviewlayout-on-bounds-changeI see the code belongs in- (void)prepareForAnimatedBoundsChange:(NSRect)oldBounds; - (void)finalizeAnimatedBoundsChange;but it’s not clear to me what to put in these methods.Thanks,Demitri
Posted
by demitri.
Last updated
.
Post not yet marked as solved
0 Replies
400 Views
Hi,I have a program that reads float image data from files that are recorded in a big-endian format. (The data are literally an array of float values, not RGB or similar.) I use a library that reads the values into memory and converts them from big endian to little, then I create a CGImage from this data. Some of the data files can grow to be quite large, e.g. hundreds of MB, which when converted to an image can consume a lot of memory.I've considered exploring memory mapping to avoid having a full copy of the data in RAM that I pass to various CIFilters, but the data is the wrong endian-ness. I am wondering if it's possible to create a CIFilter that will convert the values to little-endian so I can use memory mapping. I am hoping that the performance will still be ok on at least SSD drives.Thanks,Demitri
Posted
by demitri.
Last updated
.