clover/spirv: rework handling of spirv extensions
[mesa.git] / src / gallium / frontends / clover / spirv / invocation.hpp
1 //
2 // Copyright 2018 Pierre Moreau
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
21 //
22
23 #ifndef CLOVER_SPIRV_INVOCATION_HPP
24 #define CLOVER_SPIRV_INVOCATION_HPP
25
26 #include <unordered_set>
27
28 #include "core/context.hpp"
29 #include "core/module.hpp"
30 #include "core/program.hpp"
31
32 namespace clover {
33 namespace spirv {
34 // Returns whether the given binary is considered valid for the given
35 // OpenCL version.
36 //
37 // It uses SPIRV-Tools validator to do the validation, and potential
38 // warnings and errors are appended to |r_log|.
39 bool is_valid_spirv(const std::vector<char> &binary,
40 const std::string &opencl_version,
41 std::string &r_log);
42
43 // Creates a clover module out of the given SPIR-V binary.
44 module compile_program(const std::vector<char> &binary,
45 const device &dev, std::string &r_log);
46
47 // Combines multiple clover modules into a single one, resolving
48 // link dependencies between them.
49 module link_program(const std::vector<module> &modules, const device &dev,
50 const std::string &opts, std::string &r_log);
51
52 // Returns a textual representation of the given binary.
53 std::string print_module(const std::vector<char> &binary,
54 const std::string &opencl_version);
55
56 // Returns a set of supported SPIR-V extensions.
57 std::unordered_set<std::string> supported_extensions();
58 }
59 }
60
61 #endif