diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index 4a08e9f18..424a74f13 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -91,6 +91,9 @@ pub(super) struct EntryPointInterface { #[derive(Clone, Eq, PartialEq, PartialOrd, Ord)] enum InterfaceKey { Location(u32), + // FXC doesn't consider SV_PrimitiveID a system value, so it must appear + // before any other SVs in the struct. + PrimitiveIndex, BuiltIn(crate::BuiltIn), Other, } @@ -99,6 +102,7 @@ impl InterfaceKey { const fn new(binding: Option<&crate::Binding>) -> Self { match binding { Some(&crate::Binding::Location { location, .. }) => Self::Location(location), + Some(&crate::Binding::BuiltIn(crate::BuiltIn::PrimitiveIndex)) => Self::PrimitiveIndex, Some(&crate::Binding::BuiltIn(built_in)) => Self::BuiltIn(built_in), None => Self::Other, } diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index f63ebf3ae..98b06dffc 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -401,11 +401,6 @@ pub enum AddressSpace { #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] pub enum BuiltIn { - // This must be at the top so that it gets sorted to the top. PrimitiveIndex is considered a non SV - // by FXC so it must appear before any other SVs. - /// Read in fragment shaders, written in mesh shaders, read in any and closest hit shaders. - PrimitiveIndex, - /// Written in vertex/mesh shaders, read in fragment shaders Position { invariant: bool }, /// Read in task, mesh, vertex, and fragment shaders @@ -434,6 +429,8 @@ pub enum BuiltIn { PointCoord, /// Read in fragment shaders FrontFacing, + /// Read in fragment shaders, written in mesh shaders, read in any and closest hit shaders. + PrimitiveIndex, /// Read in fragment shaders Barycentric { perspective: bool }, /// Read in fragment shaders