@@ -233,7 +233,10 @@ impl VaryingContext<'_> {
233233 let required = match built_in {
234234 Bi :: ClipDistance => Capabilities :: CLIP_DISTANCE ,
235235 Bi :: CullDistance => Capabilities :: CULL_DISTANCE ,
236- Bi :: PrimitiveIndex => Capabilities :: PRIMITIVE_INDEX ,
236+ // Primitive index is allowed w/o any other extensions in any- and closest-hit shaders
237+ Bi :: PrimitiveIndex if !matches ! ( ep. stage, St :: AnyHit | St :: ClosestHit ) => {
238+ Capabilities :: PRIMITIVE_INDEX
239+ } ,
237240 Bi :: Barycentric => Capabilities :: SHADER_BARYCENTRICS ,
238241 Bi :: ViewIndex => Capabilities :: MULTIVIEW ,
239242 Bi :: SampleIndex => Capabilities :: MULTISAMPLED_SHADING ,
@@ -256,10 +259,14 @@ impl VaryingContext<'_> {
256259 }
257260
258261 let ( visible, type_good) = match built_in {
259- Bi :: BaseInstance | Bi :: BaseVertex | Bi :: InstanceIndex | Bi :: VertexIndex => (
262+ Bi :: BaseInstance | Bi :: BaseVertex | Bi :: VertexIndex => (
260263 self . stage == St :: Vertex && !self . output ,
261264 * ty_inner == Ti :: Scalar ( crate :: Scalar :: U32 ) ,
262265 ) ,
266+ Bi :: InstanceIndex => (
267+ matches ! ( self . stage, St :: Vertex | St :: AnyHit | St :: ClosestHit ) && !self . output ,
268+ * ty_inner == Ti :: Scalar ( crate :: Scalar :: U32 ) ,
269+ ) ,
263270 Bi :: DrawID => (
264271 // Always allowed in task/vertex stage. Allowed in mesh stage if there is no task stage in the pipeline.
265272 ( self . stage == St :: Vertex
@@ -326,7 +333,7 @@ impl VaryingContext<'_> {
326333 * ty_inner == Ti :: Scalar ( crate :: Scalar :: BOOL ) ,
327334 ) ,
328335 Bi :: PrimitiveIndex => (
329- ( self . stage == St :: Fragment && !self . output )
336+ ( matches ! ( self . stage, St :: Fragment | St :: AnyHit | St :: ClosestHit ) && !self . output )
330337 || ( self . stage == St :: Mesh
331338 && self . output
332339 && self . mesh_output_type == MeshOutputType :: PrimitiveOutput ) ,
0 commit comments