Skip to content

Commit

Permalink
Allow ArrayStride on untyped pointers (KhronosGroup#5746)
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-baker authored Jul 24, 2024
1 parent ffb8d85 commit 8731673
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/val/validate_annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions test/val/val_annotation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8731673

Please sign in to comment.