mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
In physical addressing, functions can return pointers
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/229
This commit is contained in:
parent
10dba91781
commit
3ed641df39
@ -1710,12 +1710,11 @@ bool idUsage::isValid<SpvOpReturnValue>(const spv_instruction_t* inst,
|
|||||||
<< value.second.type_id << "' is missing or void.";
|
<< value.second.type_id << "' is missing or void.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (SpvOpTypePointer == valueType.second.opcode) {
|
if (addressingModel == SpvAddressingModelLogical &&
|
||||||
DIAG(valueIndex) << "OpReturnValue value's type <id> '"
|
SpvOpTypePointer == valueType.second.opcode) {
|
||||||
<< value.second.type_id
|
DIAG(valueIndex)
|
||||||
<< "' is a pointer, but a pointer can only be an operand "
|
<< "OpReturnValue value's type <id> '" << value.second.type_id
|
||||||
"to OpLoad, OpStore, OpAccessChain, or "
|
<< "' is a pointer, which is invalid in the Logical addressing model.";
|
||||||
"OpInBoundsAccessChain.";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// NOTE: Find OpFunction
|
// NOTE: Find OpFunction
|
||||||
|
@ -1564,8 +1564,26 @@ TEST_F(ValidateID, OpReturnValueIsVoid) {
|
|||||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidateID, OpReturnValueIsVariable) {
|
TEST_F(ValidateID, OpReturnValueIsVariableInPhysical) {
|
||||||
|
// It's valid to return a pointer in a physical addressing model.
|
||||||
const char* spirv = R"(
|
const char* spirv = R"(
|
||||||
|
OpMemoryModel Physical32 OpenCL
|
||||||
|
%1 = OpTypeVoid
|
||||||
|
%2 = OpTypeInt 32 0
|
||||||
|
%3 = OpTypePointer Private %2
|
||||||
|
%4 = OpTypeFunction %3
|
||||||
|
%5 = OpFunction %3 None %4
|
||||||
|
%6 = OpLabel
|
||||||
|
%7 = OpVariable %3 Function
|
||||||
|
OpReturnValue %7
|
||||||
|
OpFunctionEnd)";
|
||||||
|
CHECK(spirv, SPV_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ValidateID, OpReturnValueIsVariableInLogical) {
|
||||||
|
// It's invalid to return a pointer in a physical addressing model.
|
||||||
|
const char* spirv = R"(
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
%1 = OpTypeVoid
|
%1 = OpTypeVoid
|
||||||
%2 = OpTypeInt 32 0
|
%2 = OpTypeInt 32 0
|
||||||
%3 = OpTypePointer Private %2
|
%3 = OpTypePointer Private %2
|
||||||
|
Loading…
Reference in New Issue
Block a user