-
Notifications
You must be signed in to change notification settings - Fork 680
spirv-val: Fix Offset not checking if in struct #6701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1144,7 +1144,10 @@ TEST_F(ValidateSpvEXTDescriptorHeap, BufferPointerEXTStorageClass) { | |
| "type with a Storage Class of Uniform or StorageBuffer.")); | ||
| } | ||
|
|
||
| TEST_F(ValidateSpvEXTDescriptorHeap, BufferPointerEXTLayout) { | ||
| // TODO - Seems like VUID-StandaloneSpirv-Result-11346 is wrong because | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://gitlab.khronos.org/vulkan/vulkan/-/issues/4837 something is wrong here |
||
| // AllowsLayout() shows Uniform and StorageBuffer (the only two allowed) | ||
| // are always explicit layout | ||
| TEST_F(ValidateSpvEXTDescriptorHeap, DISABLED_BufferPointerEXTLayout) { | ||
| const std::string str = R"( | ||
| OpCapability Shader | ||
| OpCapability UntypedPointersKHR | ||
|
|
@@ -1167,12 +1170,13 @@ TEST_F(ValidateSpvEXTDescriptorHeap, BufferPointerEXTLayout) { | |
| OpDecorate %U Block | ||
| OpMemberDecorate %U 0 Offset 0 | ||
| OpDecorateId %_runtimearr_17 ArrayStrideIdEXT %18 | ||
| OpDecorate %_ptr_UniformConstant Offset 0 | ||
| ; OpDecorate %_ptr_Uniform Offset 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree this shouldn't be there.
|
||
| %void = OpTypeVoid | ||
| %3 = OpTypeFunction %void | ||
| %uint = OpTypeInt 32 0 | ||
| %_ptr_Output_uint = OpTypePointer Output %uint | ||
| %o = OpVariable %_ptr_Output_uint Output | ||
| %_ptr_Uniform = OpTypeUntypedPointerKHR Uniform | ||
| %_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant | ||
| %resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant | ||
| %int = OpTypeInt 32 1 | ||
|
|
@@ -1185,8 +1189,8 @@ TEST_F(ValidateSpvEXTDescriptorHeap, BufferPointerEXTLayout) { | |
| %main = OpFunction %void None %3 | ||
| %5 = OpLabel | ||
| %16 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_17 %resource_heap %int_9 | ||
| %20 = OpBufferPointerEXT %_ptr_UniformConstant %16 | ||
| %21 = OpUntypedAccessChainKHR %_ptr_UniformConstant %U %20 %int_0 | ||
| %20 = OpBufferPointerEXT %_ptr_Uniform %16 | ||
| %21 = OpUntypedAccessChainKHR %_ptr_Uniform %U %20 %int_0 | ||
| %22 = OpLoad %uint %21 | ||
| OpStore %o %22 | ||
| OpReturn | ||
|
|
@@ -2417,6 +2421,47 @@ TEST_F(ValidateSpvEXTDescriptorHeap, ArrayStrideSpecConstantZero) { | |
| EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_4)); | ||
| } | ||
|
|
||
| // https://github.com/KhronosGroup/SPIRV-Tools/issues/6696 | ||
| TEST_F(ValidateSpvEXTDescriptorHeap, OffsetIdOnArray) { | ||
| const std::string str = R"( | ||
| OpCapability Shader | ||
| OpCapability UntypedPointersKHR | ||
| OpCapability DescriptorHeapEXT | ||
| OpCapability Sampled1D | ||
| OpExtension "SPV_KHR_untyped_pointers" | ||
| OpExtension "SPV_EXT_descriptor_heap" | ||
| OpMemoryModel Logical GLSL450 | ||
| OpEntryPoint GLCompute %1 "main" %2 | ||
| OpExecutionMode %1 LocalSize 1 1 1 | ||
| OpDecorate %2 BuiltIn ResourceHeapEXT | ||
| OpDecorateId %7 OffsetIdEXT %4 | ||
| %11 = OpTypeVoid | ||
| %12 = OpTypeFunction %11 | ||
| %13 = OpTypeInt 32 0 | ||
| %16 = OpConstant %13 0 | ||
| %4 = OpConstant %13 0 | ||
| %20 = OpTypeImage %13 1D 0 0 0 1 Unknown | ||
| %21 = OpTypeBufferEXT StorageBuffer | ||
| %22 = OpTypeSampler | ||
| %23 = OpTypeSampledImage %20 | ||
| %7 = OpTypeRuntimeArray %20 | ||
| %24 = OpTypeUntypedPointerKHR UniformConstant | ||
| %25 = OpTypeUntypedPointerKHR StorageBuffer | ||
| %2 = OpUntypedVariableKHR %24 UniformConstant | ||
| %1 = OpFunction %11 None %12 | ||
| %26 = OpLabel | ||
| %27 = OpUntypedAccessChainKHR %24 %7 %2 %16 | ||
| %28 = OpLoad %20 %27 | ||
| OpReturn | ||
| OpFunctionEnd | ||
| )"; | ||
| CompileSuccessfully(str.c_str(), SPV_ENV_VULKAN_1_4); | ||
| EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_4)); | ||
| EXPECT_THAT( | ||
| getDiagnosticString(), | ||
| HasSubstr("OffsetIdEXT can only be applied to structure members")); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace val | ||
| } // namespace spvtools | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... not sure where this is coming from, probably something when someone gets to #6594
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... guess the smoke test found more
@alan-baker what do you want to do here, clearly something is wrong as the
Offsetis not following theunless it was modified for all these various extension cases, but I guess don't understand what
even means and where the memory for these offsets are all defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to double check this PR against CTS. I remember the lack of spec language and existing tests was frustrating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/937