Skip to content

Commit a14486e

Browse files
spirv-val: Add VUID for SPV_EXT_ocp_microscaling_types (KhronosGroup#6779)
closes KhronosGroup#6774
1 parent 891df4c commit a14486e

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

source/val/validate_conversion.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ spv_result_t ValidateVulkanOCPMicroscalingFloatIntConversion(
5252
if (spvIsVulkanEnv(_.context()->target_env) &&
5353
_.ContainsOCPMicroscalingType(float_type)) {
5454
return _.diag(SPV_ERROR_INVALID_DATA, inst)
55-
<< spvOpcodeString(inst->opcode())
55+
<< _.VkErrorID(12465) << spvOpcodeString(inst->opcode())
5656
<< " must not consume or produce OCP microscaling types in the "
5757
"Vulkan environment.";
5858
}
@@ -355,15 +355,15 @@ spv_result_t ValidateFConvert(ValidationState_t& _, const Instruction* inst,
355355
if (spvIsVulkanEnv(_.context()->target_env)) {
356356
if (_.ContainsOCPMicroscalingType(result_type)) {
357357
return _.diag(SPV_ERROR_INVALID_DATA, inst)
358-
<< spvOpcodeString(opcode)
358+
<< _.VkErrorID(12466) << spvOpcodeString(opcode)
359359
<< " must not produce OCP microscaling types in the Vulkan "
360360
"environment.";
361361
}
362362
if (_.ContainsOCPMicroscalingType(input_type) &&
363363
!IsIEEEOrAlternativeFloatTypeAllowedForOCPMicroscalingFConvert(
364364
_, result_type)) {
365365
return _.diag(SPV_ERROR_INVALID_DATA, inst)
366-
<< spvOpcodeString(opcode)
366+
<< _.VkErrorID(12467) << spvOpcodeString(opcode)
367367
<< " consuming an OCP microscaling type in the Vulkan "
368368
"environment must produce IEEE 754, Float8E4M3EXT, "
369369
"Float8E5M2EXT, or BFloat16KHR.";
@@ -857,27 +857,31 @@ spv_result_t ValidateBitcastExtract(ValidationState_t& _,
857857

858858
if (!IsNumericScalarOrVectorType(_, result_type)) {
859859
return _.diag(SPV_ERROR_INVALID_DATA, inst)
860+
<< _.VkErrorID(12468)
860861
<< "Expected Result Type to be a numerical scalar or vector type: "
861862
<< spvOpcodeString(opcode);
862863
}
863864

864865
if (spvIsVulkanEnv(_.context()->target_env) &&
865866
!_.ContainsOCPMicroscalingNonByteType(result_type)) {
866867
return _.diag(SPV_ERROR_INVALID_DATA, inst)
868+
<< _.VkErrorID(12468)
867869
<< "Expected Result Type to be a Float4EXT or Float6EXT type in "
868870
"the Vulkan environment: "
869871
<< spvOpcodeString(opcode);
870872
}
871873

872874
if (!base_type || !IsNumericScalarOrVectorType(_, base_type)) {
873875
return _.diag(SPV_ERROR_INVALID_DATA, inst)
876+
<< _.VkErrorID(12469)
874877
<< "Expected Base to be a numerical scalar or vector type: "
875878
<< spvOpcodeString(opcode);
876879
}
877880

878881
if (spvIsVulkanEnv(_.context()->target_env) &&
879882
!_.IsIntScalarType(base_type) && !_.IsIntVectorType(base_type)) {
880883
return _.diag(SPV_ERROR_INVALID_DATA, inst)
884+
<< _.VkErrorID(12469)
881885
<< "Expected Base to be an integer scalar or vector type in the "
882886
"Vulkan environment: "
883887
<< spvOpcodeString(opcode);

source/val/validation_state.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,6 +3521,16 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
35213521
return VUID_WRAP(VUID-StandaloneSpirv-MemorySemantics-13556);
35223522
case 13557:
35233523
return VUID_WRAP(VUID-StandaloneSpirv-MemorySemantics-13557);
3524+
case 12465:
3525+
return VUID_WRAP(VUID-StandaloneSpirv-OpConvertFToU-12465);
3526+
case 12466:
3527+
return VUID_WRAP(VUID-StandaloneSpirv-OpFConvert-12466);
3528+
case 12467:
3529+
return VUID_WRAP(VUID-StandaloneSpirv-OpFConvert-12467);
3530+
case 12468:
3531+
return VUID_WRAP(VUID-StandaloneSpirv-Result-12468);
3532+
case 12469:
3533+
return VUID_WRAP(VUID-StandaloneSpirv-Base-12469);
35243534
default:
35253535
return ""; // unknown id
35263536
}

test/val/val_conversion_test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
731731
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
732732
SPV_ENV_VULKAN_1_3);
733733
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
734+
EXPECT_THAT(getDiagnosticString(),
735+
AnyVUID("VUID-StandaloneSpirv-OpFConvert-12466"));
734736
EXPECT_THAT(getDiagnosticString(),
735737
HasSubstr("FConvert must not produce OCP microscaling types"));
736738
}
@@ -751,6 +753,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
751753
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
752754
SPV_ENV_VULKAN_1_3);
753755
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
756+
EXPECT_THAT(getDiagnosticString(),
757+
AnyVUID("VUID-StandaloneSpirv-OpConvertFToU-12465"));
754758
EXPECT_THAT(getDiagnosticString(),
755759
HasSubstr("ConvertFToU must not consume or produce OCP "
756760
"microscaling types"));
@@ -772,6 +776,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
772776
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
773777
SPV_ENV_VULKAN_1_3);
774778
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
779+
EXPECT_THAT(getDiagnosticString(),
780+
AnyVUID("VUID-StandaloneSpirv-OpConvertFToU-12465"));
775781
EXPECT_THAT(getDiagnosticString(),
776782
HasSubstr("ConvertFToS must not consume or produce OCP "
777783
"microscaling types"));
@@ -792,6 +798,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
792798
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
793799
SPV_ENV_VULKAN_1_3);
794800
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
801+
EXPECT_THAT(getDiagnosticString(),
802+
AnyVUID("VUID-StandaloneSpirv-OpConvertFToU-12465"));
795803
EXPECT_THAT(getDiagnosticString(),
796804
HasSubstr("ConvertSToF must not consume or produce OCP "
797805
"microscaling types"));
@@ -812,6 +820,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
812820
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
813821
SPV_ENV_VULKAN_1_3);
814822
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
823+
EXPECT_THAT(getDiagnosticString(),
824+
AnyVUID("VUID-StandaloneSpirv-OpConvertFToU-12465"));
815825
EXPECT_THAT(getDiagnosticString(),
816826
HasSubstr("ConvertUToF must not consume or produce OCP "
817827
"microscaling types"));
@@ -901,6 +911,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
901911
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
902912
SPV_ENV_VULKAN_1_3);
903913
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
914+
EXPECT_THAT(getDiagnosticString(),
915+
AnyVUID("VUID-StandaloneSpirv-Result-12468"));
904916
EXPECT_THAT(getDiagnosticString(),
905917
HasSubstr("Expected Result Type to be a Float4EXT or "
906918
"Float6EXT type in the Vulkan environment"));
@@ -922,6 +934,8 @@ OpExtension "SPV_EXT_ocp_microscaling_types"
922934
CompileSuccessfully(GenerateShaderCode(body, extensions, "", types).c_str(),
923935
SPV_ENV_VULKAN_1_3);
924936
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
937+
EXPECT_THAT(getDiagnosticString(),
938+
AnyVUID("VUID-StandaloneSpirv-Base-12469"));
925939
EXPECT_THAT(getDiagnosticString(),
926940
HasSubstr("Expected Base to be an integer scalar or vector type "
927941
"in the Vulkan environment"));

0 commit comments

Comments
 (0)