Skip to content

Commit 8731673

Browse files
authored
Allow ArrayStride on untyped pointers (KhronosGroup#5746)
1 parent ffb8d85 commit 8731673

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

source/val/validate_annotation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, spv::Decoration dec,
123123
case spv::Decoration::ArrayStride:
124124
if (target->opcode() != spv::Op::OpTypeArray &&
125125
target->opcode() != spv::Op::OpTypeRuntimeArray &&
126-
target->opcode() != spv::Op::OpTypePointer) {
126+
target->opcode() != spv::Op::OpTypePointer &&
127+
target->opcode() != spv::Op::OpTypeUntypedPointerKHR) {
127128
return fail(0) << "must be an array or pointer type";
128129
}
129130
break;

test/val/val_annotation_test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,22 @@ OpFunctionEnd
257257
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
258258
}
259259

260+
TEST_F(DecorationTest, ArrayStrideUntypedPointerKHR) {
261+
const std::string text = R"(
262+
OpCapability Shader
263+
OpCapability Linkage
264+
OpCapability UntypedPointersKHR
265+
OpExtension "SPV_KHR_untyped_pointers"
266+
OpExtension "SPV_KHR_storage_buffer_storage_class"
267+
OpMemoryModel Logical GLSL450
268+
OpDecorate %ptr ArrayStride 4
269+
%ptr = OpTypeUntypedPointerKHR StorageBuffer
270+
)";
271+
272+
CompileSuccessfully(text);
273+
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
274+
}
275+
260276
using MemberOnlyDecorations = spvtest::ValidateBase<std::string>;
261277

262278
TEST_P(MemberOnlyDecorations, MemberDecoration) {

0 commit comments

Comments
 (0)