Skip to content
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 Shaders support #1586

Open
yaroslavyaroslav opened this issue Jul 25, 2024 · 4 comments
Open

Metal Shaders support #1586

yaroslavyaroslav opened this issue Jul 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@yaroslavyaroslav
Copy link
Contributor

yaroslavyaroslav commented Jul 25, 2024

Description

Currently when I'm opening metal and defining it as a c++ scope I got AST error from sourcekit-lsp. This way there's actually a lack of metal shaders development support out of Xcode in both completion and diagnostic. It would be great to bring such support to sourcekit-lsp even though metal is Apple's proprietary technology.

@yaroslavyaroslav yaroslavyaroslav added the enhancement New feature or request label Jul 25, 2024
@ahoppen
Copy link
Member

ahoppen commented Jul 25, 2024

Synced to Apple’s issue tracker as rdar://132478984

@yaroslavyaroslav
Copy link
Contributor Author

yaroslavyaroslav commented Nov 5, 2024

Haven't tried it with sourcekit-lsp directly, but this config works well with clangd.

Put .clangd in the root folder of the project with the following content:

If:
  PathMatch: .*\.metal?

CompileFlags:
  Add:
    - '--std'
    - 'c++17'
    - '-x'
    - 'c++'
    - '-I'
    - '/System/Library/Frameworks'
    - '-I'
    - '/Library/Frameworks'
    - '-I'
    - '/usr/local/include'
    - '-I'
    - '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/metal/32023/lib/clang/32023.335/include'
    - '-I'
    - '/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.401/include/metal'

After clangd server restarted completion works well with in metal files in Sublime Text.

@ahoppen I wonder if it's worth it to mention this configuration somewhere in the sourcekit-lsp docs to ease other folks of cracking that down?

UPD: All the other missing headers can be found following the steps below:

  1. mdfind -name [missing_header]
  2. Add such in a separate line with -I flag to the config.

@ahoppen
Copy link
Member

ahoppen commented Nov 5, 2024

IIRC, Metal is a proper extension of C++ and has syntax constructs that won’t be supported by clangd. While your solution might cover many or most cases, I think the fact that it works is more a coincidence than proper support and thus I am very hesitant to offer it as any kind of officially supported solution in SourceKit-LSP’s docs.

@yaroslavyaroslav
Copy link
Contributor Author

Yeah, fair enough. So looking forward to metal compiler will be supported by clangd as cuda did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants