@@ -3020,3 +3020,68 @@ OpFunctionEnd
30203020 "expected BuiltInRequiresExecutionModel, got {err:?}"
30213021 ) ;
30223022}
3023+
3024+ #[ test]
3025+ fn primitive_triangle_indices_ext_allowed_in_universal_env ( ) {
3026+ // PrimitiveTriangleIndicesEXT is not restricted to Vulkan — it should be
3027+ // accepted in any target environment when used with MeshEXT.
3028+ let text = r#"
3029+ OpCapability Shader
3030+ OpCapability MeshShadingEXT
3031+ OpExtension "SPV_EXT_mesh_shader"
3032+ OpMemoryModel Logical GLSL450
3033+ OpEntryPoint MeshEXT %main "main" %indices
3034+ OpExecutionMode %main LocalSize 1 1 1
3035+ OpExecutionMode %main OutputVertices 3
3036+ OpExecutionMode %main OutputPrimitivesEXT 1
3037+ OpExecutionMode %main OutputTrianglesEXT
3038+ OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT
3039+ %void = OpTypeVoid
3040+ %fn = OpTypeFunction %void
3041+ %uint = OpTypeInt 32 0
3042+ %v3uint = OpTypeVector %uint 3
3043+ %uint_1 = OpConstant %uint 1
3044+ %arr = OpTypeArray %v3uint %uint_1
3045+ %ptr = OpTypePointer Output %arr
3046+ %indices = OpVariable %ptr Output
3047+ %main = OpFunction %void None %fn
3048+ %entry = OpLabel
3049+ OpReturn
3050+ OpFunctionEnd
3051+ "# ;
3052+ assemble_and_validate_with_env ( text, TargetEnv :: Universal1_4 )
3053+ . expect ( "PrimitiveTriangleIndicesEXT should be allowed in Universal env" ) ;
3054+ }
3055+
3056+ #[ test]
3057+ fn primitive_triangle_indices_ext_requires_mesh_ext_execution_model ( ) {
3058+ // PrimitiveTriangleIndicesEXT is only valid with MeshEXT execution model,
3059+ // not with other models like GLCompute.
3060+ let text = r#"
3061+ OpCapability Shader
3062+ OpCapability MeshShadingEXT
3063+ OpExtension "SPV_EXT_mesh_shader"
3064+ OpMemoryModel Logical GLSL450
3065+ OpEntryPoint GLCompute %main "main" %indices
3066+ OpExecutionMode %main LocalSize 1 1 1
3067+ OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT
3068+ %void = OpTypeVoid
3069+ %fn = OpTypeFunction %void
3070+ %uint = OpTypeInt 32 0
3071+ %v3uint = OpTypeVector %uint 3
3072+ %uint_1 = OpConstant %uint 1
3073+ %arr = OpTypeArray %v3uint %uint_1
3074+ %ptr = OpTypePointer Output %arr
3075+ %indices = OpVariable %ptr Output
3076+ %main = OpFunction %void None %fn
3077+ %entry = OpLabel
3078+ OpReturn
3079+ OpFunctionEnd
3080+ "# ;
3081+ let err = assemble_and_validate_with_env ( text, TargetEnv :: Universal1_4 )
3082+ . expect_err ( "PrimitiveTriangleIndicesEXT requires MeshEXT execution model" ) ;
3083+ assert ! (
3084+ matches!( err, ValidationError :: BuiltInRequiresExecutionModel { .. } ) ,
3085+ "expected BuiltInRequiresExecutionModel, got {err:?}"
3086+ ) ;
3087+ }
0 commit comments