This project compiles GLSL 4.5/4.6 compute shaders to a C library with low dependencies that can be called from any language allowing C bindings. Additionally such a Go package is generated, providing a clean interface while using cgo and the C library underneath.
Not all built-in functions in GLSL are yet implemented, this is a wip and bugs are to be expected. Bug reports are appreciated, but please note that the project main use case is for use in gioui and features not needed may not be prioritized.
For linux through docker:
-
Cd into the directory with your shader file(s) (*.comp)
-
Run:
docker run -v $(pwd):/data vron/compute your_shader.comp
Unless you get errors (try with a simple shader first) you should have both the C and the go library wrapper generated in the current directory.
For an example of using compute to generate a package, including how to call it please see github.com/vron/computeexample
Currently supported on Linux, windows, osX amd64. Intended to support arm32 and arm64 as well.
In order to run the project locally (not through docker) you will need a set of dependences, in particular: recent clang, go, rust, lua, glslangValidator. For details please refer to the Dockerfile to ensure you have all that is needed.
-
Cd into the top level directory of this project
-
Run (to run all tests and ensure everything works):
go run test/main.go
-
Run (to build your shader):
go run script/build.go path_to_your_shader.comp
-
Find your generated lib in ./build/go/*