commit | 9b0ec3c692578858c1d2f3f1d7bc2fa3ddfe4451 | [log] [tgz] |
---|---|---|
author | alan-baker <alanbaker@google.com> | Mon Apr 06 18:45:34 2020 |
committer | GitHub <noreply@github.com> | Mon Apr 06 18:45:34 2020 |
tree | 9e761ade18284a72e44b5ff3697b32f414d4483e | |
parent | 0c9cd04ea9a3c9b669d3a7278ce212df33f6a287 [diff] |
POD arguments in push constants (#542) * Add options to pass POD args as push constants * validate option: * no -pod-ubo * no option that generates module scope push constants * Add option to specify max push constant interface size * Frontend checks for push constant pod args * disallow arrays in push constants * Check the size against MaxPushConstantsSize() * Validate the layout as std430 * New ArgKind for POD push constants * Updated descriptor allocation to generate push constants resource vars * update pod clustering to record the correct arg kind * change descriptor map output for push constant kernel args * update spirv producer to generate push constant interface variable * docs * Simplify pod arg kind logic * Change GetArgKindForType to be able to return specific pod types * update uses to not assume basic ArgKind::Pod is ambiguous * simplifies several bits of code * Tests
Clspv is a prototype compiler for a subset of OpenCL C to Vulkan compute shaders.
It consists of:
Clspv depends on external projects:
Clspv is licensed under the terms of the Apache 2.0 license. The AUTHORS file lists the copyright owners, while individual credit is given in the CONTRIBUTORS file. To contribute, see CONTRIBUTING.md.
Materials in projects Clspv depends on are licensed under their own terms.
Clspv is not an official Google product.
The compiler is an incomplete prototype, with many rough edges.
The input language is a subset of OpenCL C version 1.2. The OpenCL C on Vulkan Specification describes the specific subset, and also the mapping into Vulkan compute shaders.
Compile a set of kernels into a SPIR-V binary module:
clspv foo.cl -o foo.spv
Emit the binary as a C initializer list, for easy embedding of a shader in in a C or C++ program source:
clspv -mfmt=c foo.cl -o -
Predefine some preprocessor symbols:
clspv -DWIDTH=32 -DHEIGHT=64 foo.cl -o foo.spv
Use OpenCL compiler options:
clspv -cl-fast-relaxed-math -cl-single-precision-constant foo.cl -o foo.spv
Show help:
clspv -help
You will need:
Clspv depends on the sources for other projects, at specific commits. Run the following command to download those dependencies, and place them in the third_party
directory:
python utils/fetch_sources.py
Then, create a build directory:
cd <clspv-dir> mkdir build cd build
Then configure and build the code:
cmake <clspv-dir> cmake --build .
This will build the clspv
command line compiler and place it in location bin/clspv
under the build directory.
We recommend you use the Ninja build tool if it's available. To do so, replace the last two commands with:
cmake -G Ninja <clspv-dir> ninja
Other useful configuration options (the first cmake
command):
-DCMAKE_BUILD_TYPE=RelWithDebInfo
: Build in release mode, with debugging information. Default is a debug build.See the CMake documentation for more generic options.
To run the test suite from within the build directory:
cmake --build . --target check-spirv
Or if you are using Ninja:
ninja check-spirv