Skip to content

Add METALLIB output support for the CLI#40

Draft
TheSpydog wants to merge 4 commits into
libsdl-org:mainfrom
TheSpydog:metallib
Draft

Add METALLIB output support for the CLI#40
TheSpydog wants to merge 4 commits into
libsdl-org:mainfrom
TheSpydog:metallib

Conversation

@TheSpydog

@TheSpydog TheSpydog commented Oct 31, 2024

Copy link
Copy Markdown
Collaborator

Resolves #39

In addition to the new METALLIB output format, this also adds an optional --platform argument to specify whether you're targeting macOS or iOS. I'm not including Simulator support because the iOS simulator is actually below our min specs at this point. tvOS and iOS appear to share the same Metal bytecode format so I don't think we need a separate platform for tvOS.

Note again that this is exclusively for CLI -- runtime compilation of MSL can be handled by the Metal API with no special handling.

Remaining to-do:

  • Windows support
  • Linux support (somehow?)
  • Test generated binaries

@flibitijibibo

Copy link
Copy Markdown
Collaborator

This needs a rebase, I can test Linux builds this week with the right example input/output to compare with.

thatcosmonaut pushed a commit to thatcosmonaut/SDL_shadercross that referenced this pull request Jan 18, 2025
@flibitijibibo

Copy link
Copy Markdown
Collaborator

If it helps wrap this up, let's skip Linux support for now. SDL_Process will let us do this eventually but it's not terribly important when you'll need a Mac to test Metal support anyway.

@flibitijibibo flibitijibibo removed their assignment Jan 27, 2025

@madebr madebr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase.

Let's just fail on non-supported platforms?
SDL3 also does not support gpu on all platforms.

Comment thread src/cli.c
Comment on lines +604 to +605
SDL_Process *process = SDL_CreateProcess(compileToIRCommand, true);
SDL_WaitProcess(process, true, &exitcode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a chance to deadlock when metallib/xcrun echoes lots of data (when the pipe buffer is full, further writes will sleep).
Perhaps it's better to use SDL_CreateProcessWithProperties and set a null stdin/stdout/stderr?

Or, if that does not work, close stdin and read all stdout using SDL_ReadProcess

(Same applies to the next SDL_CreateProcess)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support metallib from CLI?

3 participants