1 2 //===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===// 3 // 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 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file contains utility functions for working with DXContainers. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "llvm/BinaryFormat/DXContainer.h" 15 #include "llvm/ADT/StringSwitch.h" 16 #include "llvm/Support/ScopedPrinter.h" 17 18 using namespace llvm; 19 using namespace llvm::dxbc; 20 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); 26 } 27 28 bool ShaderHash::isPopulated() { 29 static uint8_t Zeros[16] = {0}; 30 return Flags > 0 || 0 != memcmp(&Digest, &Zeros, 16); 31 } 32 33 #define COMPONENT_PRECISION(Val, Enum) {#Enum, SigMinPrecision::Enum}, 34 35 static const EnumEntry<SigMinPrecision> SigMinPrecisionNames[] = { 36 #include "llvm/BinaryFormat/DXContainerConstants.def" 37 }; 38 39 ArrayRef<EnumEntry<SigMinPrecision>> dxbc::getSigMinPrecisions() { 40 return ArrayRef(SigMinPrecisionNames); 41 } 42 43 #define D3D_SYSTEM_VALUE(Val, Enum) {#Enum, D3DSystemValue::Enum}, 44 45 static const EnumEntry<D3DSystemValue> D3DSystemValueNames[] = { 46 #include "llvm/BinaryFormat/DXContainerConstants.def" 47 }; 48 49 ArrayRef<EnumEntry<D3DSystemValue>> dxbc::getD3DSystemValues() { 50 return ArrayRef(D3DSystemValueNames); 51 } 52 53 #define COMPONENT_TYPE(Val, Enum) {#Enum, SigComponentType::Enum}, 54 55 static const EnumEntry<SigComponentType> SigComponentTypes[] = { 56 #include "llvm/BinaryFormat/DXContainerConstants.def" 57 }; 58 59 ArrayRef<EnumEntry<SigComponentType>> dxbc::getSigComponentTypes() { 60 return ArrayRef(SigComponentTypes); 61 } 62 63 #define SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum}, 64 65 static const EnumEntry<PSV::SemanticKind> SemanticKindNames[] = { 66 #include "llvm/BinaryFormat/DXContainerConstants.def" 67 }; 68 69 ArrayRef<EnumEntry<PSV::SemanticKind>> PSV::getSemanticKinds() { 70 return ArrayRef(SemanticKindNames); 71 } 72 73 #define COMPONENT_TYPE(Val, Enum) {#Enum, PSV::ComponentType::Enum}, 74 75 static const EnumEntry<PSV::ComponentType> ComponentTypeNames[] = { 76 #include "llvm/BinaryFormat/DXContainerConstants.def" 77 }; 78 79 ArrayRef<EnumEntry<PSV::ComponentType>> PSV::getComponentTypes() { 80 return ArrayRef(ComponentTypeNames); 81 } 82 83 #define INTERPOLATION_MODE(Val, Enum) {#Enum, PSV::InterpolationMode::Enum}, 84 85 static const EnumEntry<PSV::InterpolationMode> InterpolationModeNames[] = { 86 #include "llvm/BinaryFormat/DXContainerConstants.def" 87 }; 88 89 ArrayRef<EnumEntry<PSV::InterpolationMode>> PSV::getInterpolationModes() { 90 return ArrayRef(InterpolationModeNames); 91 } 92