2 //===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // This file contains utility functions for working with DXContainers.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/BinaryFormat/DXContainer.h"
15 #include "llvm/ADT/StringSwitch.h"
16 #include "llvm/Support/ScopedPrinter.h"
19 using namespace llvm::dxbc
;
21 dxbc::PartType
dxbc::parsePartType(StringRef S
) {
22 #define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
23 return StringSwitch
<dxbc::PartType
>(S
)
24 #include "llvm/BinaryFormat/DXContainerConstants.def"
25 .Default(dxbc::PartType::Unknown
);
28 bool ShaderHash::isPopulated() {
29 static uint8_t Zeros
[16] = {0};
30 return Flags
> 0 || 0 != memcmp(&Digest
, &Zeros
, 16);
33 #define COMPONENT_PRECISION(Val, Enum) {#Enum, SigMinPrecision::Enum},
35 static const EnumEntry
<SigMinPrecision
> SigMinPrecisionNames
[] = {
36 #include "llvm/BinaryFormat/DXContainerConstants.def"
39 ArrayRef
<EnumEntry
<SigMinPrecision
>> dxbc::getSigMinPrecisions() {
40 return ArrayRef(SigMinPrecisionNames
);
43 #define D3D_SYSTEM_VALUE(Val, Enum) {#Enum, D3DSystemValue::Enum},
45 static const EnumEntry
<D3DSystemValue
> D3DSystemValueNames
[] = {
46 #include "llvm/BinaryFormat/DXContainerConstants.def"
49 ArrayRef
<EnumEntry
<D3DSystemValue
>> dxbc::getD3DSystemValues() {
50 return ArrayRef(D3DSystemValueNames
);
53 #define COMPONENT_TYPE(Val, Enum) {#Enum, SigComponentType::Enum},
55 static const EnumEntry
<SigComponentType
> SigComponentTypes
[] = {
56 #include "llvm/BinaryFormat/DXContainerConstants.def"
59 ArrayRef
<EnumEntry
<SigComponentType
>> dxbc::getSigComponentTypes() {
60 return ArrayRef(SigComponentTypes
);
63 #define SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum},
65 static const EnumEntry
<PSV::SemanticKind
> SemanticKindNames
[] = {
66 #include "llvm/BinaryFormat/DXContainerConstants.def"
69 ArrayRef
<EnumEntry
<PSV::SemanticKind
>> PSV::getSemanticKinds() {
70 return ArrayRef(SemanticKindNames
);
73 #define COMPONENT_TYPE(Val, Enum) {#Enum, PSV::ComponentType::Enum},
75 static const EnumEntry
<PSV::ComponentType
> ComponentTypeNames
[] = {
76 #include "llvm/BinaryFormat/DXContainerConstants.def"
79 ArrayRef
<EnumEntry
<PSV::ComponentType
>> PSV::getComponentTypes() {
80 return ArrayRef(ComponentTypeNames
);
83 #define INTERPOLATION_MODE(Val, Enum) {#Enum, PSV::InterpolationMode::Enum},
85 static const EnumEntry
<PSV::InterpolationMode
> InterpolationModeNames
[] = {
86 #include "llvm/BinaryFormat/DXContainerConstants.def"
89 ArrayRef
<EnumEntry
<PSV::InterpolationMode
>> PSV::getInterpolationModes() {
90 return ArrayRef(InterpolationModeNames
);