Path: blob/21.2-virgl/src/gallium/frontends/clover/spirv/invocation.hpp
4573 views
//1// Copyright 2018 Pierre Moreau2//3// Permission is hereby granted, free of charge, to any person obtaining a4// copy of this software and associated documentation files (the "Software"),5// to deal in the Software without restriction, including without limitation6// the rights to use, copy, modify, merge, publish, distribute, sublicense,7// and/or sell copies of the Software, and to permit persons to whom the8// Software is furnished to do so, subject to the following conditions:9//10// The above copyright notice and this permission notice shall be included in11// all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR17// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19// OTHER DEALINGS IN THE SOFTWARE.20//2122#ifndef CLOVER_SPIRV_INVOCATION_HPP23#define CLOVER_SPIRV_INVOCATION_HPP2425#include <unordered_set>2627#include "core/context.hpp"28#include "core/module.hpp"29#include "core/program.hpp"3031namespace clover {32namespace spirv {33// Returns whether the binary starts with the SPIR-V magic word.34//35// The first word is interpreted as little endian and big endian, but36// only one of them has to match.37bool is_binary_spirv(const std::string &binary);3839// Returns whether the given binary is considered valid for the given40// OpenCL version.41//42// It uses SPIRV-Tools validator to do the validation, and potential43// warnings and errors are appended to |r_log|.44bool is_valid_spirv(const std::string &binary,45const cl_version opencl_version,46std::string &r_log);4748// Converts an integer SPIR-V version into its textual representation.49std::string version_to_string(uint32_t version);5051// Creates a clover module out of the given SPIR-V binary.52module compile_program(const std::string &binary,53const device &dev, std::string &r_log,54bool validate = true);5556// Combines multiple clover modules into a single one, resolving57// link dependencies between them.58module link_program(const std::vector<module> &modules, const device &dev,59const std::string &opts, std::string &r_log);6061// Returns a textual representation of the given binary.62std::string print_module(const std::string &binary,63const cl_version opencl_version);6465// Returns a set of supported SPIR-V extensions.66std::unordered_set<std::string> supported_extensions();6768// Returns a vector (sorted in increasing order) of supported SPIR-V69// versions.70std::vector<cl_name_version> supported_versions();7172// Converts a version number from SPIR-V's encoding to OpenCL's one.73cl_version to_opencl_version_encoding(uint32_t version);7475// Converts a version number from OpenCL's encoding to SPIR-V's one.76uint32_t to_spirv_version_encoding(cl_version version);77}78}7980#endif818283