@@ -1818,6 +1818,68 @@ OpFunctionEnd
18181818 HasSubstr (" Memory accesses with PhysicalStorageBuffer must use Aligned" ));
18191819}
18201820
1821+ TEST_F (ValidateMemory, PSBStoreAlignedZero) {
1822+ const std::string body = R"(
1823+ OpCapability PhysicalStorageBufferAddresses
1824+ OpCapability Shader
1825+ OpExtension "SPV_EXT_physical_storage_buffer"
1826+ OpMemoryModel PhysicalStorageBuffer64 GLSL450
1827+ OpEntryPoint Fragment %main "main"
1828+ OpExecutionMode %main OriginUpperLeft
1829+ %uint = OpTypeInt 32 0
1830+ %uint_1 = OpConstant %uint 1
1831+ %ptr = OpTypePointer PhysicalStorageBuffer %uint
1832+ %pptr_f = OpTypePointer Function %ptr
1833+ %void = OpTypeVoid
1834+ %voidfn = OpTypeFunction %void
1835+ %main = OpFunction %void None %voidfn
1836+ %entry = OpLabel
1837+ %val1 = OpVariable %pptr_f Function
1838+ %val2 = OpLoad %ptr %val1
1839+ OpStore %val2 %uint_1 Aligned 0
1840+ OpReturn
1841+ OpFunctionEnd
1842+ )" ;
1843+
1844+ CompileSuccessfully (body.c_str (), SPV_ENV_VULKAN_1_2);
1845+ ASSERT_EQ (SPV_ERROR_INVALID_ID, ValidateInstructions (SPV_ENV_VULKAN_1_2));
1846+ EXPECT_THAT (
1847+ getDiagnosticString (),
1848+ HasSubstr (
1849+ " Memory accesses Aligned operand value 0 is not a power of two" ));
1850+ }
1851+
1852+ TEST_F (ValidateMemory, PSBStoreAlignedNonPoT) {
1853+ const std::string body = R"(
1854+ OpCapability PhysicalStorageBufferAddresses
1855+ OpCapability Shader
1856+ OpExtension "SPV_EXT_physical_storage_buffer"
1857+ OpMemoryModel PhysicalStorageBuffer64 GLSL450
1858+ OpEntryPoint Fragment %main "main"
1859+ OpExecutionMode %main OriginUpperLeft
1860+ %uint = OpTypeInt 32 0
1861+ %uint_1 = OpConstant %uint 1
1862+ %ptr = OpTypePointer PhysicalStorageBuffer %uint
1863+ %pptr_f = OpTypePointer Function %ptr
1864+ %void = OpTypeVoid
1865+ %voidfn = OpTypeFunction %void
1866+ %main = OpFunction %void None %voidfn
1867+ %entry = OpLabel
1868+ %val1 = OpVariable %pptr_f Function
1869+ %val2 = OpLoad %ptr %val1
1870+ OpStore %val2 %uint_1 Aligned 3
1871+ OpReturn
1872+ OpFunctionEnd
1873+ )" ;
1874+
1875+ CompileSuccessfully (body.c_str (), SPV_ENV_VULKAN_1_2);
1876+ ASSERT_EQ (SPV_ERROR_INVALID_ID, ValidateInstructions (SPV_ENV_VULKAN_1_2));
1877+ EXPECT_THAT (
1878+ getDiagnosticString (),
1879+ HasSubstr (
1880+ " Memory accesses Aligned operand value 3 is not a power of two." ));
1881+ }
1882+
18211883TEST_F (ValidateMemory, PSBCopyMemoryAlignedSuccess) {
18221884 const std::string body = R"(
18231885OpCapability PhysicalStorageBufferAddresses
0 commit comments