commit | c3fd07f93783dfa2b5c03e7ab03dce34f383f0d9 | [log] [tgz] |
---|---|---|
author | alan-baker <alanbaker@google.com> | Thu Oct 22 09:48:49 2020 -0400 |
committer | GitHub <noreply@github.com> | Thu Oct 22 09:48:49 2020 -0400 |
tree | 0bf7d4bf70fc34c4ce29324f5bb0a53dfd52d876 | |
parent | 77838ff92e0bab0f6bc61d0d9bddcfa21695b7ca [diff] |
Prevent duplicate types and decorations (#654) Fixes #651 * Prevent duplicate types and decorations from being generated for equivalent pointer types * Due to the shared mapping of __global and __constant to StorageBuffer, type-based containers need extra uniquing to ensure equivalent types don't result in invalid SPIR-V * getSPIRVType now uses a helper function to determine (and utilize) a canonical type * unless __constant is generated as a UBO, the canonical type for __constant pointers is __global * ArrayStride decorations now check based on the resulting SPIR-V result id instead of the LLVM type * Type mapping maps the canonical type (and base type if it differs) * Updated how some layouts are generated to account for canonical types * difficult to test because we cannot support pointers in structs properly
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:
python3 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