Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- HLSLRuntime.h - HLSL Runtime -----------------------------*- C++ -*-===// |
| 2 | // |
||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
| 6 | // |
||
| 7 | //===----------------------------------------------------------------------===// |
||
| 8 | // |
||
| 9 | /// \file |
||
| 10 | /// Defines helper utilities for supporting the HLSL runtime environment. |
||
| 11 | // |
||
| 12 | //===----------------------------------------------------------------------===// |
||
| 13 | |||
| 14 | #ifndef CLANG_BASIC_HLSLRUNTIME_H |
||
| 15 | #define CLANG_BASIC_HLSLRUNTIME_H |
||
| 16 | |||
| 17 | #include "clang/Basic/LangOptions.h" |
||
| 18 | #include <cstdint> |
||
| 19 | |||
| 20 | namespace clang { |
||
| 21 | namespace hlsl { |
||
| 22 | |||
| 23 | constexpr ShaderStage |
||
| 24 | getStageFromEnvironment(const llvm::Triple::EnvironmentType &E) { |
||
| 25 | uint32_t Pipeline = |
||
| 26 | static_cast<uint32_t>(E) - static_cast<uint32_t>(llvm::Triple::Pixel); |
||
| 27 | |||
| 28 | if (Pipeline > (uint32_t)ShaderStage::Invalid) |
||
| 29 | return ShaderStage::Invalid; |
||
| 30 | return static_cast<ShaderStage>(Pipeline); |
||
| 31 | } |
||
| 32 | |||
| 33 | #define ENUM_COMPARE_ASSERT(Value) \ |
||
| 34 | static_assert( \ |
||
| 35 | getStageFromEnvironment(llvm::Triple::Value) == ShaderStage::Value, \ |
||
| 36 | "Mismatch between llvm::Triple and clang::ShaderStage for " #Value); |
||
| 37 | |||
| 38 | ENUM_COMPARE_ASSERT(Pixel) |
||
| 39 | ENUM_COMPARE_ASSERT(Vertex) |
||
| 40 | ENUM_COMPARE_ASSERT(Geometry) |
||
| 41 | ENUM_COMPARE_ASSERT(Hull) |
||
| 42 | ENUM_COMPARE_ASSERT(Domain) |
||
| 43 | ENUM_COMPARE_ASSERT(Compute) |
||
| 44 | ENUM_COMPARE_ASSERT(Library) |
||
| 45 | ENUM_COMPARE_ASSERT(RayGeneration) |
||
| 46 | ENUM_COMPARE_ASSERT(Intersection) |
||
| 47 | ENUM_COMPARE_ASSERT(AnyHit) |
||
| 48 | ENUM_COMPARE_ASSERT(ClosestHit) |
||
| 49 | ENUM_COMPARE_ASSERT(Miss) |
||
| 50 | ENUM_COMPARE_ASSERT(Callable) |
||
| 51 | ENUM_COMPARE_ASSERT(Mesh) |
||
| 52 | ENUM_COMPARE_ASSERT(Amplification) |
||
| 53 | |||
| 54 | static_assert(getStageFromEnvironment(llvm::Triple::UnknownEnvironment) == |
||
| 55 | ShaderStage::Invalid, |
||
| 56 | "Mismatch between llvm::Triple and " |
||
| 57 | "clang::ShaderStage for Invalid"); |
||
| 58 | static_assert(getStageFromEnvironment(llvm::Triple::MSVC) == |
||
| 59 | ShaderStage::Invalid, |
||
| 60 | "Mismatch between llvm::Triple and " |
||
| 61 | "clang::ShaderStage for Invalid"); |
||
| 62 | |||
| 63 | } // namespace hlsl |
||
| 64 | } // namespace clang |
||
| 65 | |||
| 66 | #endif // CLANG_BASIC_HLSLRUNTIME_H |