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

Generate the SPIR-V shaders automatically at build time #2200

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

ahesham-arm
Copy link
Contributor

Add custom commands and targets to automatically assemble and validate the SPIR-V shaders used by the test.

Automatic assembly depends on finding python3, spirv-as and spirv-val. SPIRV_TOOLS_DIR can be defined by the user during configuration to provide an override path. Default behaviour assumes that the binaries exist in PATH.

`FindPython3` and `FindPython2` were added in version 3.12. Used by
the spirv_new suite.

Signed-off-by: Ahmed Hesham <[email protected]>
Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

I gave this a try today and it seems to be working, but there appears to be an issue with the dependencies and it's re-generating the SPIR-V modules even when nothing is changing. Is this a problem on my side?

Example:

$ make spirv_new_shaders
Generating assume.spv32 [... and lots more output]
Built target spirv_new_shaders
$ make spirv_new_shaders
Generating assume.spv32 [... and lots more output]
Built target spirv_new_shaders

The same is happening if I build a project dependent on spirv_new_shaders, e.g. spirv_new.

@ahesham-arm
Copy link
Contributor Author

I gave this a try today and it seems to be working, but there appears to be an issue with the dependencies and it's re-generating the SPIR-V modules even when nothing is changing. Is this a problem on my side?

Example:

$ make spirv_new_shaders
Generating assume.spv32 [... and lots more output]
Built target spirv_new_shaders
$ make spirv_new_shaders
Generating assume.spv32 [... and lots more output]
Built target spirv_new_shaders

The same is happening if I build a project dependent on spirv_new_shaders, e.g. spirv_new.

I can confirm that I can reproduce this on my setup as well. I will fix this. Files should only be regenerated if the sources are modified.

Move the SPIR-V assembly helper Python script to the `spirv_asm`
subdirectory.

Add custom commands and targets to automatically assemble and validate
the SPIR-V shaders used by the test.

Automatic assembly depends on finding `python3`, `spirv-as` and
`spirv-val`. `SPIRV_TOOLS_DIR` can be defined by the user during
configuration to provide an override path. Default behaviour assumes
that the binaries exist in PATH.

Signed-off-by: Ahmed Hesham <[email protected]>
@ahesham-arm
Copy link
Contributor Author

Addressed the outstanding review comments and updated the patch such that the SPIR-V files are only re-generated when the source files are modified. Note that because the Python script works on all files in a given source directory, if one SPIR-V source changes, all SPIR-V files are regenerated.

This can be improved later to have better correspondance, i.e. changing a SPIR-V source file only regenerates the relevant binaries.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Thanks, this is working for me now, and this is a nice improvement!

@bashbaug
Copy link
Contributor

Merging as discussed in the February 11th teleconference.

@bashbaug bashbaug merged commit ecd0127 into KhronosGroup:main Feb 11, 2025
9 checks passed
@ahesham-arm ahesham-arm deleted the spirv_new branch February 11, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants