Skip to content

document the required printf string operand - #1629

Open
bashbaug wants to merge 1 commit into
KhronosGroup:mainfrom
bashbaug:printf-s-specifier
Open

bashbaug wants to merge 1 commit into
KhronosGroup:mainfrom
bashbaug:printf-s-specifier

Conversation

@bashbaug

@bashbaug bashbaug commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Since we accept %s as a printf format specifier, we should describe the required operand for it in the SPIR-V environment spec, similar to the other printf format specifiers.

I did some experiments looking at the SPIR-V modules coming out of the SPIR-V LLVM translator and the SPIR-V LLVM backend and I believe this is correct, but it is possible that I am missing some additional cases that should also be accepted.

We should probably document what the printf format string should look like also, though I would prefer to do this in a separate PR.

@bashbaug

bashbaug commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

CC @TApplencourt

@TApplencourt

Copy link
Copy Markdown

\o/ I guess then the next step is to relax UniformConstant ? Or the UniformConstant is just what the format point to (and not the string who need to be inlined in the%s)?

@bashbaug

Copy link
Copy Markdown
Contributor Author

I guess then the next step is to relax UniformConstant ?

The SPIR-V "UniformConstant" storage class is effectively the same as the OpenCL "constant" address space, so this is essentially saying that "the string you are printing cannot change or be generated dynamically". In other words, this is intended to be the SPIR-V equivalent of the OpenCL C restriction that "The argument shall be a literal string" (see link).

An extension could certainly relax this, if desired. See, for example, here, although this extension is currently relaxing both the address space (AKA storage class) for both the format string and other string operands.

@TApplencourt

Copy link
Copy Markdown

Thanks a lot! Everything make sensen ow

#807

If that help adoption, we can potentially have a "weaker" version of the PR where just the string operands is relaxed.

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.

2 participants