Hi,
I have a shader that needs one line of code inserted at runtime, based on a choice made by the user.
I can do this using the .newLibraryWithSource( ... method on my MTLDevice.
In order to do this, I load the contents of my .metal file into a String, and then pass that String as an argument to newLibrary WithSource, after making the appropriate modification.
The problem is that this requires runtime compilation of an entire Metal library. It doesn't seem to have much of a negative impact on performance because it does not need to be done repeatedly; however, it seems very cumbersome from the perspective of code management.
Is there any way to merge Metal Libraries? If there is, then I could convert the line that needs to be changed to a function, and minimize the amount of code that needs to be compiled at runtime.
Thank you.
I have a shader that needs one line of code inserted at runtime, based on a choice made by the user.
I can do this using the .newLibraryWithSource( ... method on my MTLDevice.
In order to do this, I load the contents of my .metal file into a String, and then pass that String as an argument to newLibrary WithSource, after making the appropriate modification.
The problem is that this requires runtime compilation of an entire Metal library. It doesn't seem to have much of a negative impact on performance because it does not need to be done repeatedly; however, it seems very cumbersome from the perspective of code management.
Is there any way to merge Metal Libraries? If there is, then I could convert the line that needs to be changed to a function, and minimize the amount of code that needs to be compiled at runtime.
Thank you.