diff options
author | alan-baker <alanbaker@google.com> | 2023-05-30 20:07:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-30 20:07:58 -0400 |
commit | 182fd9ebce072b3aa3dc2ebec179489bbbe7ceeb (patch) | |
tree | e336847610e272abae399209a81ecc6ec63d809e | |
parent | 226c3bbe6297f93966da4e23021d655cc27ea9c9 (diff) | |
download | spirv-tools-182fd9ebce072b3aa3dc2ebec179489bbbe7ceeb.tar.gz |
Allow physical storage buffer pointer in IO (#5251)
Follow up to #5249
* glslang tests that physical storage buffer pointers can be used as
varyings in shaders
* Allow physical storage buffer pointers in IO interfaces as a 64-bit
type
-rw-r--r-- | source/val/validate_interfaces.cpp | 18 | ||||
-rw-r--r-- | test/val/val_interfaces_test.cpp | 23 |
2 files changed, 41 insertions, 0 deletions
diff --git a/source/val/validate_interfaces.cpp b/source/val/validate_interfaces.cpp index 7699b014..291b4b82 100644 --- a/source/val/validate_interfaces.cpp +++ b/source/val/validate_interfaces.cpp @@ -173,6 +173,16 @@ spv_result_t NumConsumedLocations(ValidationState_t& _, const Instruction* type, } break; } + case spv::Op::OpTypePointer: { + if (_.addressing_model() == + spv::AddressingModel::PhysicalStorageBuffer64 && + type->GetOperandAs<spv::StorageClass>(1) == + spv::StorageClass::PhysicalStorageBuffer) { + *num_locations = 1; + break; + } + [[fallthrough]]; + } default: return _.diag(SPV_ERROR_INVALID_DATA, type) << "Invalid type to assign a location"; @@ -207,6 +217,14 @@ uint32_t NumConsumedComponents(ValidationState_t& _, const Instruction* type) { // Skip the array. return NumConsumedComponents(_, _.FindDef(type->GetOperandAs<uint32_t>(1))); + case spv::Op::OpTypePointer: + if (_.addressing_model() == + spv::AddressingModel::PhysicalStorageBuffer64 && + type->GetOperandAs<spv::StorageClass>(1) == + spv::StorageClass::PhysicalStorageBuffer) { + return 2; + } + break; default: // This is an error that is validated elsewhere. break; diff --git a/test/val/val_interfaces_test.cpp b/test/val/val_interfaces_test.cpp index 09203b35..d75c20cf 100644 --- a/test/val/val_interfaces_test.cpp +++ b/test/val/val_interfaces_test.cpp @@ -1599,6 +1599,29 @@ TEST_F(ValidateInterfacesTest, InvalidLocationTypePointer) { HasSubstr("Invalid type to assign a location")); } +TEST_F(ValidateInterfacesTest, ValidLocationTypePhysicalStorageBufferPointer) { + const std::string text = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Vertex %main "main" %var +OpDecorate %var Location 0 +OpDecorate %var RestrictPointer +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%ptr = OpTypePointer PhysicalStorageBuffer %int +%ptr2 = OpTypePointer Input %ptr +%var = OpVariable %ptr2 Input +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + CompileSuccessfully(text, SPV_ENV_VULKAN_1_3); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3)); +} + } // namespace } // namespace val } // namespace spvtools |