clang  19.0.0git
HLSLRuntime.h
Go to the documentation of this file.
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 
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 
39 ENUM_COMPARE_ASSERT(Vertex)
40 ENUM_COMPARE_ASSERT(Geometry)
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)
50 ENUM_COMPARE_ASSERT(Callable)
52 ENUM_COMPARE_ASSERT(Amplification)
53 
54 static_assert(getStageFromEnvironment(llvm::Triple::UnknownEnvironment) ==
56  "Mismatch between llvm::Triple and "
57  "clang::ShaderStage for Invalid");
58 static_assert(getStageFromEnvironment(llvm::Triple::MSVC) ==
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
#define ENUM_COMPARE_ASSERT(Value)
Definition: HLSLRuntime.h:33
Defines the clang::LangOptions interface.
constexpr ShaderStage getStageFromEnvironment(const llvm::Triple::EnvironmentType &E)
Definition: HLSLRuntime.h:24
The JSON file list parser is used to communicate input to InstallAPI.
ShaderStage
Shader programs run in specific pipeline stages.
Definition: LangOptions.h:41