-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metal Translation #165
Comments
Hey I was able to gt Lygia linked and working in a live code Metal App im working on, which now makes it SO MUCH easier for me to validate porting and test things. Most of this will be driven completely by my own self interest and be in no particular order. YMMV etc etc. Progress on the Metal Port (as well as issues) is tracked in the |
Awesome @vade! Self interest it's 100% the name of the project. I'm really happy that you have something that is useful and work. Without that is hard to muster any energy/interest. Yay for proving that just works and is possible. Fully excited! |
Hey @vade did you end up setting up lydia manually, without using SPM? |
Yea, basically in my setup right now, im using include paths in my metal shaders I load / compile at runtime (thanks to Satin from @rezaali ) I think doing SPM is going to be next to impossible without a breaking set of changes because SPM sort of enforces some directory structure stuff as far as I can tell? |
Did some work in #197 which gets some very basic sampling set up. ill be sort of ad hoc going through shit slowly as I need it. If anyone else wants to do a more systematic port it's pretty straightforward. Check the |
hey @patriciogonzalezvivo - is there any reason all the languages are in the same folders? It might be helpful to understand what is/ isnt ported by being able to compare top level file trees like "glsl/filters/*.glsl" vs etc |
oh... interesting. didn't thought it that way, I founded easier to see files side by side. If you want to see all the files from one single language you could use the server: https://lygia.xyz/glsl.json fun fact about the server it can return you can get language specific meta data by adding or the metadata Also related. I have mean to add some sort of script that remove all languages and keep only one. So people interested on bundling lygia can do that. And have release versions that way. Just GLSL, just HLSL, metal, WGSL, CUDA, etc. Is that the question? |
Oh no, was more of an organizing / adhd principle. I just find all the files in a single directory a bit cumbersome for my brain is all haha. all good, it would be a large change, I just like being able to a / b two folders side by side to see whats what. |
oh got it! Yeah it gets hard to follow. Sorry. ONE-MORE-NOTE on the server: the long term idea for this kind of API https://lygia.xyz/color/blend/screen.json?lang=msl is to be able to populate the catalog of a node graph editor ; ) the server is doing some very poor parsing. But if you are interested we could put more love in this |
Interesting points @patriciogonzalezvivo and @vade. As a Lygia DEV, I can see arguments for both approaches (single folder vs. per-language folder), however as a Lygia USER, I really want to have only the language I'm interested in. For example, it's very cumbersome to have |
Yes, I think that script + per release with per language zip files + independent CI testing. We have lot to entertain our selfs : ). Would be nice to have per language leads. @shadielhajj have been championing HLSL, @vade it's the soul contributor to METAL and @sdedovic started working on bringing WGSL to parity (WGSL is really different, it's challenging lot of the design decisions). Let me know if you are interested on being the official lead for each language. |
Yes, happy to take the lead for HLSL @patriciogonzalezvivo :-D Speaking of which. One thing that has been bugging me for a while is the sync between languages. I've been updating HLSL in a very ad-hoc manner and have no idea of what needs to be done to bring it to parity with GLSL. Some automatic tools would be ideal, not sure if that exists. Obviously, the tool would need to keep track of every change to the reference version (GLSL) Again, nothing urgent. But I feel sync between languages is going to become an issue at some point. |
Did a pretty large PR of math / draw / SDF metal shaders. I have not vetted most, but spot checks seem to work? 🤷♀️ |
Need to proxy some GLSL 'compat' functions in some sort of include / compat header.
|
|
Need to handle |
Need to figure out |
"So [[position]] coming out of the vertex shader contains the float4 position of the vertex, but going into the fragment shader, the xy of the [[position]] contains the screen coordinates of the current fragment." Ref: https://forums.kodeco.com/t/screenspace-uv-coordinates-in-fragment-shader/112236 |
Yea @rezaali but I meant more of a clean way to shim in all of the assumed calls to gl_fragCoord.xy in fragment programs in a nice clean way so that metal shaders can have the same functionality. I think the [[position]] style variables have to be declared in the main fragment shader code function declaration? |
@vade and @apsalin started working on this PR for a translation for Metal #140 (comment)
I'm opening this Issue so we can merge that initial effort and use this place to have conversations about the strategy and specs for Metal.
My suggestion for handling samplers is:
sampler.mls
followingsampler.glsl
pattern * define overloaded function declarations which allow users to override the border, mip map and wrapping calls while providing sane defaults. Look into:https://github.com/patriciogonzalezvivo/lygia/blob/main/sample/repeat.glsl
https://github.com/patriciogonzalezvivo/lygia/blob/main/sample/zero.glsl
https://github.com/patriciogonzalezvivo/lygia/blob/main/sample/clamp2edge.glsl
Which allows in GLSL that samplers can be "over-writen" per function using #defines. Ex. : https://github.com/patriciogonzalezvivo/lygia/blob/main/filter/bilateral.glsl#L18
The text was updated successfully, but these errors were encountered: