Added NVIDIA ray tracing storage classes in ValidateVariable. (#2254)

* Added additional changes for the new AccelerationStructureNV type.

* Added NVIDIA ray tracing storage classes for checking in ValidateVariable.

* For NVIDIA ray tracing storage classes added test to load bool type (allowed) in new storage class.
This commit is contained in:
kholtnv 2018-12-27 12:08:11 -08:00 committed by David Neto
parent f70e9e2a1f
commit 980ae1d1cd
2 changed files with 29 additions and 1 deletions

View File

@ -372,7 +372,12 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
if (storage_class != SpvStorageClassWorkgroup &&
storage_class != SpvStorageClassCrossWorkgroup &&
storage_class != SpvStorageClassPrivate &&
storage_class != SpvStorageClassFunction) {
storage_class != SpvStorageClassFunction &&
storage_class != SpvStorageClassRayPayloadNV &&
storage_class != SpvStorageClassIncomingRayPayloadNV &&
storage_class != SpvStorageClassHitAttributeNV &&
storage_class != SpvStorageClassCallableDataNV &&
storage_class != SpvStorageClassIncomingCallableDataNV) {
const auto storage_index = 2;
const auto storage_id = result_type->GetOperandAs<uint32_t>(storage_index);
const auto storage = _.FindDef(storage_id);

View File

@ -2104,6 +2104,29 @@ OpFunctionEnd
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateIdWithMessage, OpVariableContainsRayPayloadBoolGood) {
std::string spirv = R"(
OpCapability RayTracingNV
OpCapability Shader
OpCapability Linkage
OpExtension "SPV_NV_ray_tracing"
OpMemoryModel Logical GLSL450
%bool = OpTypeBool
%PerRayData = OpTypeStruct %bool
%_ptr_PerRayData = OpTypePointer RayPayloadNV %PerRayData
%var = OpVariable %_ptr_PerRayData RayPayloadNV
%void = OpTypeVoid
%fnty = OpTypeFunction %void
%main = OpFunction %void None %fnty
%entry = OpLabel
%load = OpLoad %PerRayData %var
OpReturn
OpFunctionEnd
)";
CompileSuccessfully(spirv.c_str());
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateIdWithMessage, OpVariablePointerNoVariablePointersBad) {
const std::string spirv = R"(
OpCapability Shader