mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-23 07:20:28 +00:00
Variable pointers cannot be an operand to OpArrayLength
This commit is contained in:
parent
2ac348b5c0
commit
da5a780ff9
@ -21,7 +21,8 @@ set -e
|
||||
set -x
|
||||
|
||||
BUILD_ROOT=$PWD
|
||||
SRC=$PWD/github/SPIRV-Tools
|
||||
SRC=/usr/local/google/home/sarahmashay/Desktop/SPIRV/spirv2
|
||||
|
||||
|
||||
# Get clang-format-5.0.0.
|
||||
# Once kokoro upgrades the Ubuntu VMs, we can use 'apt-get install clang-format'
|
||||
@ -30,10 +31,10 @@ tar xf clang-llvm.tar.xz
|
||||
export PATH=$PWD/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin:$PATH
|
||||
|
||||
cd $SRC
|
||||
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
|
||||
git clone --depth=1 https://github.com/google/googletest external/googletest
|
||||
git clone --depth=1 https://github.com/google/effcee external/effcee
|
||||
git clone --depth=1 https://github.com/google/re2 external/re2
|
||||
# git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
|
||||
# git clone --depth=1 https://github.com/google/googletest external/googletest
|
||||
# git clone --depth=1 https://github.com/google/effcee external/effcee
|
||||
# git clone --depth=1 https://github.com/google/re2 external/re2
|
||||
curl -L http://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py -o utils/clang-format-diff.py;
|
||||
|
||||
echo $(date): Check formatting...
|
||||
|
@ -1181,6 +1181,21 @@ spv_result_t ValidateArrayLength(ValidationState_t& state,
|
||||
<< state.getIdName(inst->id()) << "' must be an OpTypeRuntimeArray.";
|
||||
}
|
||||
|
||||
const bool uses_variable_pointers =
|
||||
state.features().variable_pointers ||
|
||||
state.features().variable_pointers_storage_buffer;
|
||||
|
||||
if (!pointer_type ||
|
||||
((state.addressing_model() == SpvAddressingModelLogical) &&
|
||||
((!uses_variable_pointers &&
|
||||
!spvOpcodeReturnsLogicalPointer(pointer->opcode())) ||
|
||||
(uses_variable_pointers &&
|
||||
spvOpcodeReturnsLogicalVariablePointer(pointer->opcode()))))) {
|
||||
return state.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "A variable pointer with the Logical addressing model cannot"
|
||||
<< "be an operand to an OpArrayLength instruction";
|
||||
}
|
||||
|
||||
// The array member must the the index of the last element (the run time
|
||||
// array).
|
||||
if (inst->GetOperandAs<uint32_t>(3) != num_of_members - 1) {
|
||||
|
@ -2129,6 +2129,38 @@ OpFunctionEnd
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpVariablePointerAsOpArrayLengthOperandBad) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpCapability Linkage
|
||||
OpCapability VariablePointersStorageBuffer
|
||||
OpExtension "SPV_KHR_variable_pointers"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpDecorate %block Block
|
||||
OpMemberDecorate %block 0 Offset 0
|
||||
%void = OpTypeVoid
|
||||
%int = OpTypeInt 32 0
|
||||
%run_arr = OpTypeRuntimeArray %int
|
||||
%block = OpTypeStruct %run_arr
|
||||
%ptr_ssbo_block = OpTypePointer StorageBuffer %block
|
||||
%null = OpConstantNull %ptr_ssbo_block
|
||||
%voidfn = OpTypeFunction %void
|
||||
%func = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%length = OpArrayLength %int %null 0
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
)";
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("A variable pointer with the Logical addressing model cannot"
|
||||
"be an operand to an OpArrayLength instruction"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpVariablePointerNoVariablePointersBad) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
|
Loading…
Reference in New Issue
Block a user