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 SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum}, 34 35 static const EnumEntry<PSV::SemanticKind> SemanticKindNames[] = { 36 #include "llvm/BinaryFormat/DXContainerConstants.def" 37 }; 38 39 ArrayRef<EnumEntry<PSV::SemanticKind>> PSV::getSemanticKinds() { 40 return ArrayRef(SemanticKindNames); 41 } 42 43 #define COMPONENT_TYPE(Val, Enum) {#Enum, PSV::ComponentType::Enum}, 44 45 static const EnumEntry<PSV::ComponentType> ComponentTypeNames[] = { 46 #include "llvm/BinaryFormat/DXContainerConstants.def" 47 }; 48 49 ArrayRef<EnumEntry<PSV::ComponentType>> PSV::getComponentTypes() { 50 return ArrayRef(ComponentTypeNames); 51 } 52 53 #define INTERPOLATION_MODE(Val, Enum) {#Enum, PSV::InterpolationMode::Enum}, 54 55 static const EnumEntry<PSV::InterpolationMode> InterpolationModeNames[] = { 56 #include "llvm/BinaryFormat/DXContainerConstants.def" 57 }; 58 59 ArrayRef<EnumEntry<PSV::InterpolationMode>> PSV::getInterpolationModes() { 60 return ArrayRef(InterpolationModeNames); 61 } 62