Skip to content

Commit 05ac2f3

Browse files
spirv-val: Label VU 11165 OpCopyMemorySized (KhronosGroup#6577)
New error > [VUID-RuntimeSpirv-Size-11165] Size must be a multiple of 4. This is valid if Source (StorageBuffer) and Target (StorageBuffer) storage classes both support either 8-bit or 16-bit 1. This adds the VUID to be tracked in VVL 2. The current error message didn't make it obvious **why** it must be a multiple of 2 or 4
1 parent 7d8d9e5 commit 05ac2f3

3 files changed

Lines changed: 49 additions & 2 deletions

File tree

source/val/validate_memory.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,12 +1684,21 @@ spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) {
16841684
}
16851685
if (!int8 && !int16 && !(source_int16_match && target_int16_match)) {
16861686
return _.diag(SPV_ERROR_INVALID_ID, inst)
1687-
<< "Size must be a multiple of 4";
1687+
<< _.VkErrorID(11165)
1688+
<< "Size must be a multiple of 4. This is valid if Source ("
1689+
<< StorageClassToString(source_sc) << ") and Target ("
1690+
<< StorageClassToString(source_sc)
1691+
<< ") storage classes both support either 8-bit or 16-bit";
16881692
}
16891693
if (value % 2 != 0) {
16901694
if (!int8 && !(source_int8_match && target_int8_match)) {
16911695
return _.diag(SPV_ERROR_INVALID_ID, inst)
1692-
<< "Size must be a multiple of 2";
1696+
<< _.VkErrorID(11165)
1697+
<< "Size must be a multiple of 2. This is valid if Source "
1698+
"("
1699+
<< StorageClassToString(source_sc) << ") and Target ("
1700+
<< StorageClassToString(source_sc)
1701+
<< ") storage classes both support 8-bit";
16931702
}
16941703
}
16951704
}

source/val/validation_state.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,6 +2930,9 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
29302930
return VUID_WRAP(VUID-StandaloneSpirv-UnequalMemorySemantics-10879);
29312931
case 10880:
29322932
return VUID_WRAP(VUID-StandaloneSpirv-TessLevelInner-10880);
2933+
case 11165:
2934+
// Validation (via GPU-AV) will catch this if a non-constant
2935+
return VUID_WRAP(VUID-RuntimeSpirv-Size-11165);
29332936
case 11167:
29342937
return VUID_WRAP(VUID-StandaloneSpirv-OpUntypedVariableKHR-11167);
29352938
case 11239:

test/val/val_memory_test.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7755,6 +7755,41 @@ OpFunctionEnd
77557755
EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 2"));
77567756
}
77577757

7758+
TEST_F(ValidateMemory, CopyMemorySizedVulkanConstant) {
7759+
const std::string spirv = R"(
7760+
OpCapability Shader
7761+
OpCapability UntypedPointersKHR
7762+
OpExtension "SPV_KHR_untyped_pointers"
7763+
OpMemoryModel Logical GLSL450
7764+
OpEntryPoint GLCompute %main "main" %v1 %v2
7765+
OpExecutionMode %main LocalSize 1 1 1
7766+
OpDecorate %struct Block
7767+
OpDecorate %v1 DescriptorSet 0
7768+
OpDecorate %v1 Binding 0
7769+
OpDecorate %v2 DescriptorSet 0
7770+
OpDecorate %v2 Binding 0
7771+
OpMemberDecorate %struct 0 Offset 0
7772+
%void = OpTypeVoid
7773+
%int = OpTypeInt 32 0
7774+
%int_2 = OpConstant %int 2
7775+
%struct = OpTypeStruct %int
7776+
%ptr = OpTypeUntypedPointerKHR StorageBuffer
7777+
%v1 = OpUntypedVariableKHR %ptr StorageBuffer %struct
7778+
%v2 = OpUntypedVariableKHR %ptr StorageBuffer %struct
7779+
%void_fn = OpTypeFunction %void
7780+
%main = OpFunction %void None %void_fn
7781+
%entry = OpLabel
7782+
OpCopyMemorySized %v2 %v1 %int_2
7783+
OpReturn
7784+
OpFunctionEnd
7785+
)";
7786+
7787+
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3);
7788+
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_3));
7789+
EXPECT_THAT(getDiagnosticString(), HasSubstr("Size must be a multiple of 4"));
7790+
EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-RuntimeSpirv-Size-11165"));
7791+
}
7792+
77587793
TEST_F(ValidateMemory, PtrEqualUntypedPointersGood) {
77597794
const std::string spirv = R"(
77607795
OpCapability Shader

0 commit comments

Comments
 (0)