| 1 | // Copyright (c) 2016 Google Inc. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef SOURCE_SPIRV_TARGET_ENV_H_ |
| 16 | #define SOURCE_SPIRV_TARGET_ENV_H_ |
| 17 | |
| 18 | #include <string> |
| 19 | |
| 20 | #include "spirv-tools/libspirv.h" |
| 21 | |
| 22 | // Returns true if |env| is a VULKAN environment, false otherwise. |
| 23 | bool spvIsVulkanEnv(spv_target_env env); |
| 24 | |
| 25 | // Returns true if |env| is an OPENCL environment, false otherwise. |
| 26 | bool spvIsOpenCLEnv(spv_target_env env); |
| 27 | |
| 28 | // Returns true if |env| is an WEBGPU environment, false otherwise. |
| 29 | bool spvIsWebGPUEnv(spv_target_env env); |
| 30 | |
| 31 | // Returns true if |env| is an OPENGL environment, false otherwise. |
| 32 | bool spvIsOpenGLEnv(spv_target_env env); |
| 33 | |
| 34 | // Returns true if |env| is a VULKAN or WEBGPU environment, false otherwise. |
| 35 | bool spvIsVulkanOrWebGPUEnv(spv_target_env env); |
| 36 | |
| 37 | // Returns the version number for the given SPIR-V target environment. |
| 38 | uint32_t spvVersionForTargetEnv(spv_target_env env); |
| 39 | |
| 40 | // Returns a string to use in logging messages that indicates the class of |
| 41 | // environment, i.e. "Vulkan", "WebGPU", "OpenCL", etc. |
| 42 | std::string spvLogStringForEnv(spv_target_env env); |
| 43 | |
| 44 | // Returns a formatted list of all SPIR-V target environment names that |
| 45 | // can be parsed by spvParseTargetEnv. |
| 46 | // |pad| is the number of space characters that the begining of each line |
| 47 | // except the first one will be padded with. |
| 48 | // |wrap| is the max length of lines the user desires. Word-wrapping will |
| 49 | // occur to satisfy this limit. |
| 50 | std::string spvTargetEnvList(const int pad, const int wrap); |
| 51 | |
| 52 | #endif // SOURCE_SPIRV_TARGET_ENV_H_ |
| 53 | |