Skip to content

Commit

Permalink
OpAtomicLoad, OpAtomicStore, OpAtomicExchange can operate on int or …
Browse files Browse the repository at this point in the history
…float value. Except for Vulkan environment that only operates on int value. (#2385)

To fix: #2128. Already implemented. This PR adds witness tests.
  • Loading branch information
sarahM0 authored Feb 20, 2019
1 parent 80496f4 commit bf23ed8
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion test/val/val_atomics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bf23ed8

Please sign in to comment.