Allow ArrayStride on untyped pointers (#5746)

This commit is contained in:
alan-baker 2024-07-24 13:36:11 -04:00 committed by GitHub
parent ffb8d85eac
commit 8731673a5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -123,7 +123,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec,
case spv::Decoration::ArrayStride:
if (target->opcode() != spv::Op::OpTypeArray &&
target->opcode() != spv::Op::OpTypeRuntimeArray &&
target->opcode() != spv::Op::OpTypePointer) {
target->opcode() != spv::Op::OpTypePointer &&
target->opcode() != spv::Op::OpTypeUntypedPointerKHR) {
return fail(0) << "must be an array or pointer type";
}
break;

View File

@ -257,6 +257,22 @@ OpFunctionEnd
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(DecorationTest, ArrayStrideUntypedPointerKHR) {
const std::string text = R"(
OpCapability Shader
OpCapability Linkage
OpCapability UntypedPointersKHR
OpExtension "SPV_KHR_untyped_pointers"
OpExtension "SPV_KHR_storage_buffer_storage_class"
OpMemoryModel Logical GLSL450
OpDecorate %ptr ArrayStride 4
%ptr = OpTypeUntypedPointerKHR StorageBuffer
)";
CompileSuccessfully(text);
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
using MemberOnlyDecorations = spvtest::ValidateBase<std::string>;
TEST_P(MemberOnlyDecorations, MemberDecoration) {