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

PoC: MVKShaderLibrary: Handle specializtion with macros #2434

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dboyan
Copy link
Contributor

@dboyan dboyan commented Feb 2, 2025

The converted MSL may use macro instead of function constants to realize spirv specialization constant for various reasons (e.g. when the constant is used as array size).

In this case, we should define the macros at shader compilation stage and generate different variants of the metal shader library depending on macro-value mapping to make specializtion work properly when we cannot rely on metal's specialization.

The current version is hacky as it scans the shader for macro each time we create the function, and guesses the macro based on spirv-cross's habit. Ideally, we should obtain the information from spirv-cross instead.

Although the current form is not ready to merge but I would like to throw it in to see how people think about the approach. I would appreciate insights and suggestions on API design and coding as I'm not an objc guru or equipped with a good knowledge of how the internal API should be.

Fixes: #2423

The converted MSL may use macro instead of function constants to realize
spirv specialization constant for various reasons (e.g. when the constant
is used as array size).

In this case, we should define the macros at shader compilation stage and
generate different variants of the metal shader library depending on
macro-value mapping to make specializtion work properly when we cannot rely
on metal's specialization.

The current version is hacky as it scans the shader for macro each time we
create the function, and guesses the macro based on spirv-cross's habit.
Ideally, we should obtain the information from spirv-cross instead.
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.

MoltenVK bug people are discussing re: ollama, llama.cpp
1 participant