This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This is the simplest way I've found to create a dynamic library in swift, then call a function from it in another swift program. | |
It doesn't use any package manager nonsense, just a compiled library and executable. | |
**/ | |
///// Step 1: Create your dylib/dll | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// This is a 'single' function way to get a UIImage from a Metal shader | |
/// You still need to set up an MTLibrary in your app, but you should be | |
/// able to fairly readily drop this into a standard XCode app and as long | |
/// as you have the vertex and fragment shaders compiled into the library | |
/// you should be good to go. | |
/// | |
/** | |
In your shader file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// This is a very simple command line application to work out how | |
/// to just run a compute program on the Metal GPU. It's not safe, | |
/// and will crash without warning if anything goes wrong, but I | |
/// was just trying to get the bare minimum thing working. | |
/// | |
/// It's based off of Apple's sample code here: | |
/// https://developer.apple.com/documentation/metal/basic_tasks_and_concepts/performing_calculations_on_a_gpu | |
/// but I converted it from Objective-C to Swift and stripped out all the OO stuff. | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return "some string"; |