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.
This commit is contained in:
Sarah 2019-02-20 11:00:58 -05:00 committed by GitHub
parent 80496f42a5
commit bf23ed887c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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