Skip to content

Commit 627e400

Browse files
authored
NFC: Fix switch with missing default case in DxilShaderModel.cpp (microsoft#6288)
This missing default case statement would cause build break when compiling with additional warning settings, such as /W4 /WX in VC++. Fixes microsoft#6287.
1 parent 30f45bc commit 627e400

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

include/dxc/DXIL/DxilConstants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ enum class ShaderKind {
230230
Last_1_8 = Node,
231231
LastValid = Last_1_8,
232232
};
233+
static_assert((unsigned)DXIL::ShaderKind::LastValid + 1 ==
234+
(unsigned)DXIL::ShaderKind::Invalid,
235+
"otherwise, enum needs updating.");
233236

234237
// clang-format off
235238
// Python lines need to be not formatted.

lib/DXIL/DxilShaderModel.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,22 @@ bool ShaderModel::AllowDerivatives(DXIL::ShaderKind sk) const {
504504
case DXIL::ShaderKind::Amplification:
505505
case DXIL::ShaderKind::Mesh:
506506
return IsSM66Plus();
507+
case DXIL::ShaderKind::Vertex:
508+
case DXIL::ShaderKind::Geometry:
509+
case DXIL::ShaderKind::Hull:
510+
case DXIL::ShaderKind::Domain:
511+
case DXIL::ShaderKind::RayGeneration:
512+
case DXIL::ShaderKind::Intersection:
513+
case DXIL::ShaderKind::AnyHit:
514+
case DXIL::ShaderKind::ClosestHit:
515+
case DXIL::ShaderKind::Miss:
516+
case DXIL::ShaderKind::Callable:
517+
case DXIL::ShaderKind::Invalid:
518+
return false;
507519
}
508-
return false;
520+
static_assert(DXIL::ShaderKind::LastValid == DXIL::ShaderKind::Node,
521+
"otherwise, switch needs to be updated.");
522+
llvm_unreachable("unknown ShaderKind");
509523
}
510524

511525
typedef ShaderModel SM;

0 commit comments

Comments
 (0)