@@ -403,14 +403,15 @@ class BuiltInsValidator {
403
403
// Validates that |built_in_inst| is not (even indirectly) referenced from
404
404
// within a function which can be called with |execution_model|.
405
405
//
406
+ // |vuid| - Vulkan ID for the error, or a negative value if none.
406
407
// |comment| - text explaining why the restriction was imposed.
407
408
// |decoration| - BuiltIn decoration which causes the restriction.
408
409
// |referenced_inst| - instruction which is dependent on |built_in_inst| and
409
410
// defines the id which was referenced.
410
411
// |referenced_from_inst| - instruction which references id defined by
411
412
// |referenced_inst| from within a function.
412
413
spv_result_t ValidateNotCalledWithExecutionModel (
413
- std::string comment, SpvExecutionModel execution_model,
414
+ int vuid, const char * comment, SpvExecutionModel execution_model,
414
415
const Decoration& decoration, const Instruction& built_in_inst,
415
416
const Instruction& referenced_inst,
416
417
const Instruction& referenced_from_inst);
@@ -909,7 +910,7 @@ spv_result_t BuiltInsValidator::ValidateF32ArrHelper(
909
910
}
910
911
911
912
spv_result_t BuiltInsValidator::ValidateNotCalledWithExecutionModel (
912
- std::string comment, SpvExecutionModel execution_model,
913
+ int vuid, const char * comment, SpvExecutionModel execution_model,
913
914
const Decoration& decoration, const Instruction& built_in_inst,
914
915
const Instruction& referenced_inst,
915
916
const Instruction& referenced_from_inst) {
@@ -920,7 +921,8 @@ spv_result_t BuiltInsValidator::ValidateNotCalledWithExecutionModel(
920
921
const char * built_in_str = _.grammar ().lookupOperandName (
921
922
SPV_OPERAND_TYPE_BUILT_IN, decoration.params ()[0 ]);
922
923
return _.diag (SPV_ERROR_INVALID_DATA, &referenced_from_inst)
923
- << comment << " " << GetIdDesc (referenced_inst) << " depends on "
924
+ << (vuid < 0 ? std::string (" " ) : _.VkErrorID (vuid)) << comment
925
+ << " " << GetIdDesc (referenced_inst) << " depends on "
924
926
<< GetIdDesc (built_in_inst) << " which is decorated with BuiltIn "
925
927
<< built_in_str << " ."
926
928
<< " Id <" << referenced_inst.id () << " > is later referenced by "
@@ -932,7 +934,7 @@ spv_result_t BuiltInsValidator::ValidateNotCalledWithExecutionModel(
932
934
// Propagate this rule to all dependant ids in the global scope.
933
935
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (
934
936
std::bind (&BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
935
- comment, execution_model, decoration, built_in_inst,
937
+ vuid, comment, execution_model, decoration, built_in_inst,
936
938
referenced_from_inst, std::placeholders::_1));
937
939
}
938
940
return SPV_SUCCESS;
@@ -968,7 +970,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference(
968
970
if (storage_class == SpvStorageClassInput) {
969
971
assert (function_id_ == 0 );
970
972
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
971
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
973
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , - 1 ,
972
974
" Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance to be "
973
975
" used for variables with Input storage class if execution model is "
974
976
" Vertex." ,
@@ -979,7 +981,7 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference(
979
981
if (storage_class == SpvStorageClassOutput) {
980
982
assert (function_id_ == 0 );
981
983
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
982
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
984
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , - 1 ,
983
985
" Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance to be "
984
986
" used for variables with Output storage class if execution model is "
985
987
" Fragment." ,
@@ -1619,12 +1621,10 @@ spv_result_t BuiltInsValidator::ValidatePointSizeAtReference(
1619
1621
if (storage_class == SpvStorageClassInput) {
1620
1622
assert (function_id_ == 0 );
1621
1623
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
1622
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
1623
- std::string (
1624
- _.VkErrorID (4315 ) +
1625
- " Vulkan spec doesn't allow BuiltIn PointSize to be used for "
1626
- " variables with Input storage class if execution model is "
1627
- " Vertex." ),
1624
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , 4315 ,
1625
+ " Vulkan spec doesn't allow BuiltIn PointSize to be used for "
1626
+ " variables with Input storage class if execution model is "
1627
+ " Vertex." ,
1628
1628
SpvExecutionModelVertex, decoration, built_in_inst,
1629
1629
referenced_from_inst, std::placeholders::_1));
1630
1630
}
@@ -1737,11 +1737,10 @@ spv_result_t BuiltInsValidator::ValidatePositionAtReference(
1737
1737
if (storage_class == SpvStorageClassInput) {
1738
1738
assert (function_id_ == 0 );
1739
1739
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
1740
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
1741
- std::string (_.VkErrorID (4320 ) +
1742
- " Vulkan spec doesn't allow BuiltIn Position to be used "
1743
- " for variables "
1744
- " with Input storage class if execution model is Vertex." ),
1740
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , 4320 ,
1741
+ " Vulkan spec doesn't allow BuiltIn Position to be used "
1742
+ " for variables "
1743
+ " with Input storage class if execution model is Vertex." ,
1745
1744
SpvExecutionModelVertex, decoration, built_in_inst,
1746
1745
referenced_from_inst, std::placeholders::_1));
1747
1746
}
@@ -1928,30 +1927,24 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveIdAtReference(
1928
1927
if (storage_class == SpvStorageClassOutput) {
1929
1928
assert (function_id_ == 0 );
1930
1929
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
1931
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
1932
- std::string (
1933
- _.VkErrorID (4334 ) +
1934
- " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1935
- " variables with Output storage class if execution model is "
1936
- " TessellationControl." ),
1930
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , 4334 ,
1931
+ " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1932
+ " variables with Output storage class if execution model is "
1933
+ " TessellationControl." ,
1937
1934
SpvExecutionModelTessellationControl, decoration, built_in_inst,
1938
1935
referenced_from_inst, std::placeholders::_1));
1939
1936
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
1940
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
1941
- std::string (
1942
- _.VkErrorID (4334 ) +
1943
- " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1944
- " variables with Output storage class if execution model is "
1945
- " TessellationEvaluation." ),
1937
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , 4334 ,
1938
+ " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1939
+ " variables with Output storage class if execution model is "
1940
+ " TessellationEvaluation." ,
1946
1941
SpvExecutionModelTessellationEvaluation, decoration, built_in_inst,
1947
1942
referenced_from_inst, std::placeholders::_1));
1948
1943
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
1949
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
1950
- std::string (
1951
- _.VkErrorID (4334 ) +
1952
- " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1953
- " variables with Output storage class if execution model is "
1954
- " Fragment." ),
1944
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , 4334 ,
1945
+ " Vulkan spec doesn't allow BuiltIn PrimitiveId to be used for "
1946
+ " variables with Output storage class if execution model is "
1947
+ " Fragment." ,
1955
1948
SpvExecutionModelFragment, decoration, built_in_inst,
1956
1949
referenced_from_inst, std::placeholders::_1));
1957
1950
}
@@ -2304,7 +2297,7 @@ spv_result_t BuiltInsValidator::ValidateTessLevelAtReference(
2304
2297
if (storage_class == SpvStorageClassInput) {
2305
2298
assert (function_id_ == 0 );
2306
2299
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
2307
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
2300
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , - 1 ,
2308
2301
" Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
2309
2302
" used "
2310
2303
" for variables with Input storage class if execution model is "
@@ -2316,7 +2309,7 @@ spv_result_t BuiltInsValidator::ValidateTessLevelAtReference(
2316
2309
if (storage_class == SpvStorageClassOutput) {
2317
2310
assert (function_id_ == 0 );
2318
2311
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
2319
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
2312
+ &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this , - 1 ,
2320
2313
" Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
2321
2314
" used "
2322
2315
" for variables with Output storage class if execution model is "
@@ -2605,32 +2598,30 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference(
2605
2598
{SpvExecutionModelVertex, SpvExecutionModelTessellationEvaluation,
2606
2599
SpvExecutionModelGeometry, SpvExecutionModelMeshNV}) {
2607
2600
id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (
2608
- std::bind (
2609
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
2610
- std::string (
2611
- _.VkErrorID ((operand == SpvBuiltInLayer) ? 4274 : 4406 ) +
2612
- " Vulkan spec doesn't allow BuiltIn Layer and "
2613
- " ViewportIndex to be "
2614
- " used for variables with Input storage class if "
2615
- " execution model is Vertex, TessellationEvaluation, "
2616
- " Geometry, or MeshNV." ),
2617
- em, decoration, built_in_inst, referenced_from_inst,
2618
- std::placeholders::_1));
2601
+ std::bind (&BuiltInsValidator::ValidateNotCalledWithExecutionModel,
2602
+ this , ((operand == SpvBuiltInLayer) ? 4274 : 4406 ),
2603
+ " Vulkan spec doesn't allow BuiltIn Layer and "
2604
+ " ViewportIndex to be "
2605
+ " used for variables with Input storage class if "
2606
+ " execution model is Vertex, TessellationEvaluation, "
2607
+ " Geometry, or MeshNV." ,
2608
+ em, decoration, built_in_inst, referenced_from_inst,
2609
+ std::placeholders::_1));
2619
2610
}
2620
2611
}
2621
2612
2622
2613
if (storage_class == SpvStorageClassOutput) {
2623
2614
assert (function_id_ == 0 );
2624
- id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (std::bind (
2625
- &BuiltInsValidator::ValidateNotCalledWithExecutionModel, this ,
2626
- std::string (_. VkErrorID (( operand == SpvBuiltInLayer) ? 4275 : 4407 ) +
2627
- " Vulkan spec doesn't allow BuiltIn Layer and "
2628
- " ViewportIndex to be "
2629
- " used for variables with Output storage class if "
2630
- " execution model is "
2631
- " Fragment." ) ,
2632
- SpvExecutionModelFragment, decoration, built_in_inst,
2633
- referenced_from_inst, std::placeholders::_1));
2615
+ id_to_at_reference_checks_[referenced_from_inst.id ()].push_back (
2616
+ std::bind ( &BuiltInsValidator::ValidateNotCalledWithExecutionModel,
2617
+ this , (( operand == SpvBuiltInLayer) ? 4275 : 4407 ),
2618
+ " Vulkan spec doesn't allow BuiltIn Layer and "
2619
+ " ViewportIndex to be "
2620
+ " used for variables with Output storage class if "
2621
+ " execution model is "
2622
+ " Fragment." ,
2623
+ SpvExecutionModelFragment, decoration, built_in_inst,
2624
+ referenced_from_inst, std::placeholders::_1));
2634
2625
}
2635
2626
2636
2627
for (const SpvExecutionModel execution_model : execution_models_) {
0 commit comments