Update memory scope rules for WebGPU (#2725)

Fixes #2721
This commit is contained in:
Ryan Harrison 2019-07-10 10:34:50 -04:00 committed by GitHub
parent 0c4feb643b
commit 3a252a267b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 17 deletions

View File

@ -229,12 +229,12 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst,
// WebGPU specific rules
if (spvIsWebGPUEnv(_.context()->target_env)) {
if (value != SpvScopeWorkgroup && value != SpvScopeSubgroup &&
if (value != SpvScopeWorkgroup && value != SpvScopeInvocation &&
value != SpvScopeQueueFamilyKHR) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< spvOpcodeString(opcode)
<< ": in WebGPU environment Memory Scope is limited to "
<< "Workgroup, Subgroup and QueuFamilyKHR";
<< "Workgroup, Invocation, and QueueFamilyKHR";
}
}

View File

@ -397,7 +397,7 @@ TEST_F(ValidateAtomics, AtomicLoadWebGPUNonRelaxedFailure) {
TEST_F(ValidateAtomics, AtomicLoadWebGPUSequentiallyConsistentFailure) {
const std::string body = R"(
%val3 = OpAtomicLoad %u32 %u32_var %subgroup %sequentially_consistent
%val3 = OpAtomicLoad %u32 %u32_var %invocation %sequentially_consistent
)";
CompileSuccessfully(GenerateWebGPUShaderCode(body), SPV_ENV_WEBGPU_0);
@ -1916,7 +1916,7 @@ TEST_F(ValidateAtomics, WebGPUCrossDeviceMemoryScopeBad) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("AtomicLoad: in WebGPU environment Memory Scope is limited to "
"Workgroup, Subgroup and QueuFamilyKHR\n"
"Workgroup, Invocation, and QueueFamilyKHR\n"
" %34 = OpAtomicLoad %uint %29 %uint_0_0 %uint_0_1\n"));
}
@ -1930,7 +1930,7 @@ TEST_F(ValidateAtomics, WebGPUDeviceMemoryScopeBad) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("AtomicLoad: in WebGPU environment Memory Scope is limited to "
"Workgroup, Subgroup and QueuFamilyKHR\n"
"Workgroup, Invocation, and QueueFamilyKHR\n"
" %34 = OpAtomicLoad %uint %29 %uint_1_0 %uint_0_1\n"));
}
@ -1943,18 +1943,9 @@ TEST_F(ValidateAtomics, WebGPUWorkgroupMemoryScopeGood) {
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_WEBGPU_0));
}
TEST_F(ValidateAtomics, WebGPUSubgroupMemoryScopeGood) {
TEST_F(ValidateAtomics, WebGPUSubgroupMemoryScopeBad) {
const std::string body = R"(
%val1 = OpAtomicLoad %u32 %u32_var %subgroup %relaxed
)";
CompileSuccessfully(GenerateWebGPUShaderCode(body), SPV_ENV_WEBGPU_0);
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_WEBGPU_0));
}
TEST_F(ValidateAtomics, WebGPUInvocationMemoryScopeBad) {
const std::string body = R"(
%val1 = OpAtomicLoad %u32 %u32_var %invocation %relaxed
)";
CompileSuccessfully(GenerateWebGPUShaderCode(body), SPV_ENV_WEBGPU_0);
@ -1962,8 +1953,17 @@ TEST_F(ValidateAtomics, WebGPUInvocationMemoryScopeBad) {
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("AtomicLoad: in WebGPU environment Memory Scope is limited to "
"Workgroup, Subgroup and QueuFamilyKHR\n"
" %34 = OpAtomicLoad %uint %29 %uint_4 %uint_0_1\n"));
"Workgroup, Invocation, and QueueFamilyKHR\n"
" %34 = OpAtomicLoad %uint %29 %uint_3 %uint_0_1\n"));
}
TEST_F(ValidateAtomics, WebGPUInvocationMemoryScopeGood) {
const std::string body = R"(
%val1 = OpAtomicLoad %u32 %u32_var %invocation %relaxed
)";
CompileSuccessfully(GenerateWebGPUShaderCode(body), SPV_ENV_WEBGPU_0);
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_WEBGPU_0));
}
TEST_F(ValidateAtomics, WebGPUQueueFamilyMemoryScopeGood) {