Skip to content

Commit 4e92160

Browse files
committed
Remove incorrect Vulkan-only restriction on mesh EXT builtins
PrimitivePointIndicesEXT, PrimitiveLineIndicesEXT, PrimitiveTriangleIndicesEXT, and CullPrimitiveEXT are not restricted to Vulkan environments in the C++ validator. They only require the MeshEXT execution model, which is validated separately.
1 parent b74e4e6 commit 4e92160

2 files changed

Lines changed: 65 additions & 12 deletions

File tree

rust/spirv-tools-core/src/validation/rules/builtins.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,6 @@ impl ValidationRule for BuiltinStorageClassRule {
174174
{
175175
return Err(ValidationError::BuiltInDisallowedForEnv { builtin, env }.into());
176176
}
177-
if !env.is_vulkan()
178-
&& matches!(
179-
builtin,
180-
BuiltIn::PrimitivePointIndicesEXT
181-
| BuiltIn::PrimitiveLineIndicesEXT
182-
| BuiltIn::PrimitiveTriangleIndicesEXT
183-
| BuiltIn::CullPrimitiveEXT
184-
)
185-
{
186-
return Err(ValidationError::BuiltInDisallowedForEnv { builtin, env }.into());
187-
}
188-
189177
// Basic storage class check
190178
let allowed = matches!(storage_class, StorageClass::Input | StorageClass::Output);
191179
if !allowed {

rust/spirv-tools-core/src/validation/tests/builtins.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)