Post

Replies

Boosts

Views

Activity

MTLTexture streaming to app directory
For better memory usage when working with MTLTextures (editing + displaying in render passes, compute shaders, etc.) is it possible to save the texture to the app's Documents folder, and then use an UnsafeMutablePointer to access/modify the contents of the texture before displaying in a render pass? And would this be performant (i.e 60fps)? That way the texture won't be directly in memory all the time, but the contents can still be edited and displayed when needed.
1
0
977
Nov ’23
Hover state on UIMenu item?
I have a UIMenu that is being triggered as a primary action for a UIButton. Each menu item has a UIAction associated with it that gets called when I click on the item. What I'm wondering is if there is a way to add a hover action to these menu items so that they can run a different action only when being hovered?
0
0
887
Jul ’22
How to parse ascii characters in Swift?
I have a string encoded as ascii characters that contains letters and numbers. When I print out the string it looks like the numbers are not showing up properly. The string is being read from a data object where I convert everything to an Int8 type and construct a Character from that: for i in 0..<dataLength { let byte: Int8 = readByte() let char = Character(unicodeScalarLiteral: .init(.init(byte))) print("Character: ", char, char.asciiValue) } Example.) "40" appears as "@D". I was able to print out the ascii codes of these and found it to be [64, 68], but I'm not sure how to now convert it to the number 40.
4
0
2.2k
Feb ’22
MTLDebugCommandBuffer lockPurgeableObjects
I'm using Xcode 13 after recently updating to MacOS Monterey, and only after updating am I getting this error: [MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x14a8a8cc0 (label: null), referenced in cmd buffer 0x149091400 (label: null) is in volatile or empty purgeable state at commit' I haven't changed my code at all between updating to the latest OS, and it worked perfectly before. How can I fix this? I don't think there should be any reason that I can't use a command buffer on a texture resource with a volatile/empty purgeable state.
4
0
3.5k
Jan ’22
How to use SF Symbols 3
If I want to use SF Symbols 3 in my swift project, do I have to export the symbols from the SF Symbols app and add them to my app's Asset Catalog, or is there a way for Xcode to automatically use those symbols without me having to add them to the Asset Catalog?
Topic: Design SubTopic: General Tags:
2
0
3.5k
Dec ’21
Custom File Type
I created a custom file type for my app as a package. However when I run the app and try to open a file it does not recognize it as the custom file type, but instead as a regular folder. I haven't changed my settings since I first setup the custom type, and only some of these files in Finder are showing properly. Do I need to do something in Xcode to change the rest of the files in Finder?
1
0
1.4k
Oct ’21
Draw Call vs Tile Shader
While developing my Metal application I noticed that making a draw call is a lot slower than using a tile shader. In particular, when operating on a 4k resolution texture it takes about 3ms to complete a draw call while the tile shader takes about 150ns. I was wondering, is a tile shader the preferred approach for drawing with Metal now? Or is there any particular reason why a typical draw call should be used.
1
0
1.5k
Sep ’21
Access Parent Render Pass
I have two render passes, one that is nested within another, and I'd like for the inner pass to have access to the color attachments of the outer pass. Is it possible for render pass 2 to have knowledge of render pass 1's color at any given moment? Here is the logic: 1.) Start render pass 1 with texture 1 2.) Draw objects 3.) Start render pass 2 with texture 2 4.) Draw objects using color from render pass 1 5.) End render pass 2 6.) Draw output of render pass 2 into render pass 1 7.) End render pass 1
1
0
1.5k
Sep ’21
Draw Smooth Lines in Metal
I'm developing a drawing application using Metal and was wondering what the best way to draw smooth lines is? I current use the touchesMoved function to track where the user draws, and then attempt to create triangulated lines from that. The problem I am facing is that the line segments start to fold at the edges while drawing. How can I implement round line caps to avoid this? As you can see from the circled parts of the image, the ends of the brush stroke are very jagged. I'd like to avoid these and instead make them round.
1
0
1.7k
Sep ’21
Core Video help
Where can I find documentation, example projects, or video tutorials on how to work with Core Video and Metal?
Replies
0
Boosts
0
Views
922
Activity
Dec ’23
MTLTexture streaming to app directory
For better memory usage when working with MTLTextures (editing + displaying in render passes, compute shaders, etc.) is it possible to save the texture to the app's Documents folder, and then use an UnsafeMutablePointer to access/modify the contents of the texture before displaying in a render pass? And would this be performant (i.e 60fps)? That way the texture won't be directly in memory all the time, but the contents can still be edited and displayed when needed.
Replies
1
Boosts
0
Views
977
Activity
Nov ’23
Render a CAShapeLayer into MTLTexture
How can I take the contents (i.e. the stroke and fill) of a CAShapeLayer and draw it into an MTLTexture, which can then be displayed with a normal vertex/fragment shader?
Replies
0
Boosts
0
Views
872
Activity
Oct ’23
How to create a perspective transform using Metal
I have a quad made up of two triangles rendered using indexed primitives. How can I create a transform where only one corner of the quad is stretched, like the perspective tool in most drawing apps? For example:
Replies
2
Boosts
0
Views
1.2k
Activity
Mar ’23
Dashed Line in Metal
How can I create a dashed line using a Metal shader? I'm thinking something similar to the CoreGraphics "lineDash" property.
Replies
3
Boosts
0
Views
2.4k
Activity
Nov ’22
Hover state on UIMenu item?
I have a UIMenu that is being triggered as a primary action for a UIButton. Each menu item has a UIAction associated with it that gets called when I click on the item. What I'm wondering is if there is a way to add a hover action to these menu items so that they can run a different action only when being hovered?
Replies
0
Boosts
0
Views
887
Activity
Jul ’22
Maintain text selection with multiple input fields
I have a UITextView and a UITextField. I would like to select a range of text in the text view and then edit the text in the text field, which will perform some action on the selected text from the text view. Is there a way to edit the text field without losing the selected text in the text view?
Replies
1
Boosts
0
Views
1.3k
Activity
Jul ’22
Render MTKView with different Colorspace
Is it possible to render an MTKView in different color spaces? For example, if I want to render it in CMYK, is there a way to adjust the colors on every frame to that colorspace before presenting it on the screen, or is that something that needs to be handled in a shader?
Replies
3
Boosts
0
Views
2.1k
Activity
Mar ’22
How to parse ascii characters in Swift?
I have a string encoded as ascii characters that contains letters and numbers. When I print out the string it looks like the numbers are not showing up properly. The string is being read from a data object where I convert everything to an Int8 type and construct a Character from that: for i in 0..<dataLength { let byte: Int8 = readByte() let char = Character(unicodeScalarLiteral: .init(.init(byte))) print("Character: ", char, char.asciiValue) } Example.) "40" appears as "@D". I was able to print out the ascii codes of these and found it to be [64, 68], but I'm not sure how to now convert it to the number 40.
Replies
4
Boosts
0
Views
2.2k
Activity
Feb ’22
MTLDebugCommandBuffer lockPurgeableObjects
I'm using Xcode 13 after recently updating to MacOS Monterey, and only after updating am I getting this error: [MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x14a8a8cc0 (label: null), referenced in cmd buffer 0x149091400 (label: null) is in volatile or empty purgeable state at commit' I haven't changed my code at all between updating to the latest OS, and it worked perfectly before. How can I fix this? I don't think there should be any reason that I can't use a command buffer on a texture resource with a volatile/empty purgeable state.
Replies
4
Boosts
0
Views
3.5k
Activity
Jan ’22
How to use SF Symbols 3
If I want to use SF Symbols 3 in my swift project, do I have to export the symbols from the SF Symbols app and add them to my app's Asset Catalog, or is there a way for Xcode to automatically use those symbols without me having to add them to the Asset Catalog?
Topic: Design SubTopic: General Tags:
Replies
2
Boosts
0
Views
3.5k
Activity
Dec ’21
Custom File Type
I created a custom file type for my app as a package. However when I run the app and try to open a file it does not recognize it as the custom file type, but instead as a regular folder. I haven't changed my settings since I first setup the custom type, and only some of these files in Finder are showing properly. Do I need to do something in Xcode to change the rest of the files in Finder?
Replies
1
Boosts
0
Views
1.4k
Activity
Oct ’21
Draw Call vs Tile Shader
While developing my Metal application I noticed that making a draw call is a lot slower than using a tile shader. In particular, when operating on a 4k resolution texture it takes about 3ms to complete a draw call while the tile shader takes about 150ns. I was wondering, is a tile shader the preferred approach for drawing with Metal now? Or is there any particular reason why a typical draw call should be used.
Replies
1
Boosts
0
Views
1.5k
Activity
Sep ’21
Access Parent Render Pass
I have two render passes, one that is nested within another, and I'd like for the inner pass to have access to the color attachments of the outer pass. Is it possible for render pass 2 to have knowledge of render pass 1's color at any given moment? Here is the logic: 1.) Start render pass 1 with texture 1 2.) Draw objects 3.) Start render pass 2 with texture 2 4.) Draw objects using color from render pass 1 5.) End render pass 2 6.) Draw output of render pass 2 into render pass 1 7.) End render pass 1
Replies
1
Boosts
0
Views
1.5k
Activity
Sep ’21
Draw Smooth Lines in Metal
I'm developing a drawing application using Metal and was wondering what the best way to draw smooth lines is? I current use the touchesMoved function to track where the user draws, and then attempt to create triangulated lines from that. The problem I am facing is that the line segments start to fold at the edges while drawing. How can I implement round line caps to avoid this? As you can see from the circled parts of the image, the ends of the brush stroke are very jagged. I'd like to avoid these and instead make them round.
Replies
1
Boosts
0
Views
1.7k
Activity
Sep ’21