From bf23ed887c7c3c94ccedba183bbe617f2c33b0e3 Mon Sep 17 00:00:00 2001 From: Sarah <9856269+sarahM0@users.noreply.github.com> Date: Wed, 20 Feb 2019 11:00:58 -0500 Subject: [PATCH] OpAtomicLoad, OpAtomicStore, OpAtomicExchange can operate on int or float value. Except for Vulkan environment that only operates on int value. (#2385) To fix: #2128. Already implemented. This PR adds witness tests. --- test/val/val_atomics_test.cpp | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/val/val_atomics_test.cpp b/test/val/val_atomics_test.cpp index 1f3001886..2090c1324 100644 --- a/test/val/val_atomics_test.cpp +++ b/test/val/val_atomics_test.cpp @@ -225,7 +225,7 @@ TEST_F(ValidateAtomics, AtomicLoadKernelSuccess) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } -TEST_F(ValidateAtomics, AtomicLoadVulkanSuccess) { +TEST_F(ValidateAtomics, AtomicLoadInt32VulkanSuccess) { const std::string body = R"( %val1 = OpAtomicLoad %u32 %u32_var %device %relaxed %val2 = OpAtomicLoad %u32 %u32_var %workgroup %acquire @@ -235,6 +235,41 @@ TEST_F(ValidateAtomics, AtomicLoadVulkanSuccess) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); } +TEST_F(ValidateAtomics, AtomicLoadFloatVulkan) { + const std::string body = R"( +%val1 = OpAtomicLoad %f32 %f32_var %device %relaxed +%val2 = OpAtomicLoad %f32 %f32_var %workgroup %acquire +)"; + + CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("expected Result Type to be int scalar type")); +} + +TEST_F(ValidateAtomics, AtomicLoadInt64WithCapabilityVulkanSuccess) { + const std::string body = R"( + %val1 = OpAtomicLoad %u64 %u64_var %device %relaxed + %val2 = OpAtomicLoad %u64 %u64_var %workgroup %acquire + )"; + + CompileSuccessfully(GenerateShaderCode(body, "OpCapability Int64Atomics\n"), + SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); +} + +TEST_F(ValidateAtomics, AtomicLoadInt64WithoutCapabilityVulkan) { + const std::string body = R"( + %val1 = OpAtomicLoad %u64 %u64_var %device %relaxed + %val2 = OpAtomicLoad %u64 %u64_var %workgroup %acquire + )"; + + CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("64-bit atomics require the Int64Atomics capability")); +} + TEST_F(ValidateAtomics, AtomicStoreOpenCLFunctionPointerStorageTypeSuccess) { const std::string body = R"( %f32_var_function = OpVariable %f32_ptr_function Function