@@ -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,15 @@ 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 )
268+ && !self . output ,
269+ * ty_inner == Ti :: Scalar ( crate :: Scalar :: U32 ) ,
270+ ) ,
263271 Bi :: DrawID => (
264272 // Always allowed in task/vertex stage. Allowed in mesh stage if there is no task stage in the pipeline.
265273 ( self . stage == St :: Vertex
@@ -326,7 +334,8 @@ impl VaryingContext<'_> {
326334 * ty_inner == Ti :: Scalar ( crate :: Scalar :: BOOL ) ,
327335 ) ,
328336 Bi :: PrimitiveIndex => (
329- ( self . stage == St :: Fragment && !self . output )
337+ ( matches ! ( self . stage, St :: Fragment | St :: AnyHit | St :: ClosestHit )
338+ && !self . output )
330339 || ( self . stage == St :: Mesh
331340 && self . output
332341 && self . mesh_output_type == MeshOutputType :: PrimitiveOutput ) ,
0 commit comments