@@ -12055,73 +12055,25 @@ SpirvConstant *SpirvEmitter::tryToEvaluateAsConst(const Expr *expr) {
12055
12055
}
12056
12056
12057
12057
hlsl::ShaderModel::Kind SpirvEmitter::getShaderModelKind(StringRef stageName) {
12058
- hlsl::ShaderModel::Kind smk;
12059
- switch (stageName[0]) {
12060
- case 'c':
12061
- switch (stageName[1]) {
12062
- case 'o':
12063
- smk = hlsl::ShaderModel::Kind::Compute;
12064
- break;
12065
- case 'l':
12066
- smk = hlsl::ShaderModel::Kind::ClosestHit;
12067
- break;
12068
- case 'a':
12069
- smk = hlsl::ShaderModel::Kind::Callable;
12070
- break;
12071
- default:
12072
- smk = hlsl::ShaderModel::Kind::Invalid;
12073
- break;
12074
- }
12075
- break;
12076
- case 'v':
12077
- smk = hlsl::ShaderModel::Kind::Vertex;
12078
- break;
12079
- case 'h':
12080
- smk = hlsl::ShaderModel::Kind::Hull;
12081
- break;
12082
- case 'd':
12083
- smk = hlsl::ShaderModel::Kind::Domain;
12084
- break;
12085
- case 'g':
12086
- smk = hlsl::ShaderModel::Kind::Geometry;
12087
- break;
12088
- case 'p':
12089
- smk = hlsl::ShaderModel::Kind::Pixel;
12090
- break;
12091
- case 'r':
12092
- smk = hlsl::ShaderModel::Kind::RayGeneration;
12093
- break;
12094
- case 'i':
12095
- smk = hlsl::ShaderModel::Kind::Intersection;
12096
- break;
12097
- case 'a':
12098
- switch (stageName[1]) {
12099
- case 'm':
12100
- smk = hlsl::ShaderModel::Kind::Amplification;
12101
- break;
12102
- case 'n':
12103
- smk = hlsl::ShaderModel::Kind::AnyHit;
12104
- break;
12105
- }
12106
- break;
12107
- case 'm':
12108
- switch (stageName[1]) {
12109
- case 'e':
12110
- smk = hlsl::ShaderModel::Kind::Mesh;
12111
- break;
12112
- case 'i':
12113
- smk = hlsl::ShaderModel::Kind::Miss;
12114
- break;
12115
- }
12116
- break;
12117
- default:
12118
- smk = hlsl::ShaderModel::Kind::Invalid;
12119
- break;
12120
- }
12121
- if (smk == hlsl::ShaderModel::Kind::Invalid) {
12122
- llvm_unreachable("unknown stage name");
12123
- }
12124
- return smk;
12058
+ hlsl::ShaderModel::Kind SMK =
12059
+ llvm::StringSwitch<hlsl::ShaderModel::Kind>(stageName)
12060
+ .Case("pixel", hlsl::ShaderModel::Kind::Pixel)
12061
+ .Case("vertex", hlsl::ShaderModel::Kind::Vertex)
12062
+ .Case("geometry", hlsl::ShaderModel::Kind::Geometry)
12063
+ .Case("hull", hlsl::ShaderModel::Kind::Hull)
12064
+ .Case("domain", hlsl::ShaderModel::Kind::Domain)
12065
+ .Case("compute", hlsl::ShaderModel::Kind::Compute)
12066
+ .Case("raygeneration", hlsl::ShaderModel::Kind::RayGeneration)
12067
+ .Case("intersection", hlsl::ShaderModel::Kind::Intersection)
12068
+ .Case("anyhit", hlsl::ShaderModel::Kind::AnyHit)
12069
+ .Case("closesthit", hlsl::ShaderModel::Kind::ClosestHit)
12070
+ .Case("miss", hlsl::ShaderModel::Kind::Miss)
12071
+ .Case("callable", hlsl::ShaderModel::Kind::Callable)
12072
+ .Case("mesh", hlsl::ShaderModel::Kind::Mesh)
12073
+ .Case("amplification", hlsl::ShaderModel::Kind::Amplification)
12074
+ .Default(hlsl::ShaderModel::Kind::Invalid);
12075
+ assert(SMK != hlsl::ShaderModel::Kind::Invalid);
12076
+ return SMK;
12125
12077
}
12126
12078
12127
12079
spv::ExecutionModel
0 commit comments