Add validation for ExecutionMode in WebGPU (#2443)

Fixes #2437
This commit is contained in:
Ryan Harrison 2019-03-12 14:50:25 -04:00 committed by GitHub
parent b1ff15f220
commit b75f4362f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 5 deletions

View File

@ -412,6 +412,21 @@ spv_result_t ValidateExecutionMode(ValidationState_t& _,
}
}
if (spvIsWebGPUEnv(_.context()->target_env)) {
if (mode != SpvExecutionModeOriginUpperLeft &&
mode != SpvExecutionModeDepthReplacing &&
mode != SpvExecutionModeDepthGreater &&
mode != SpvExecutionModeDepthLess &&
mode != SpvExecutionModeDepthUnchanged &&
mode != SpvExecutionModeLocalSize &&
mode != SpvExecutionModeLocalSizeHint) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< "Execution mode must be one of OriginUpperLeft, "
"DepthReplacing, DepthGreater, DepthLess, DepthUnchanged, "
"LocalSize, or LocalSizeHint for WebGPU environment.";
}
}
return SPV_SUCCESS;
}

View File

@ -531,16 +531,24 @@ TEST_P(ValidateModeExecution, ExecutionMode) {
std::ostringstream sstr;
sstr << "OpCapability Shader\n";
sstr << "OpCapability Geometry\n";
sstr << "OpCapability Tessellation\n";
sstr << "OpCapability TransformFeedback\n";
if (!spvIsVulkanEnv(env)) {
if (!spvIsWebGPUEnv(env)) {
sstr << "OpCapability Geometry\n";
sstr << "OpCapability Tessellation\n";
sstr << "OpCapability TransformFeedback\n";
}
if (!spvIsVulkanOrWebGPUEnv(env)) {
sstr << "OpCapability Kernel\n";
if (env == SPV_ENV_UNIVERSAL_1_3) {
sstr << "OpCapability SubgroupDispatch\n";
}
}
sstr << "OpMemoryModel Logical GLSL450\n";
if (spvIsWebGPUEnv(env)) {
sstr << "OpCapability VulkanMemoryModelKHR\n";
sstr << "OpExtension \"SPV_KHR_vulkan_memory_model\"\n";
sstr << "OpMemoryModel Logical VulkanKHR\n";
} else {
sstr << "OpMemoryModel Logical GLSL450\n";
}
sstr << "OpEntryPoint " << model << " %main \"main\"\n";
if (mode.find("LocalSizeId") == 0 || mode.find("LocalSizeHintId") == 0 ||
mode.find("SubgroupsPerWorkgroupId") == 0) {
@ -706,6 +714,39 @@ INSTANTIATE_TEST_SUITE_P(
"SubgroupsPerWorkgroup 1", "SubgroupsPerWorkgroupId %int1"),
Values(SPV_ENV_UNIVERSAL_1_3)));
INSTANTIATE_TEST_SUITE_P(ValidateModeGLComputeWebGPUWhitelistGood,
ValidateModeExecution,
Combine(Values(SPV_SUCCESS), Values(""),
Values("GLCompute"), Values("LocalSize 1 1 1"),
Values(SPV_ENV_WEBGPU_0)));
INSTANTIATE_TEST_SUITE_P(
ValidateModeGLComputeWebGPUWhitelistBad, ValidateModeExecution,
Combine(Values(SPV_ERROR_INVALID_DATA),
Values("Execution mode must be one of OriginUpperLeft, "
"DepthReplacing, DepthGreater, DepthLess, DepthUnchanged, "
"LocalSize, or LocalSizeHint for WebGPU environment"),
Values("GLCompute"), Values("LocalSizeId %int1 %int1 %int1"),
Values(SPV_ENV_WEBGPU_0)));
INSTANTIATE_TEST_SUITE_P(
ValidateModeFragmentWebGPUWhitelistGood, ValidateModeExecution,
Combine(Values(SPV_SUCCESS), Values(""), Values("Fragment"),
Values("OriginUpperLeft", "DepthReplacing", "DepthGreater",
"DepthLess", "DepthUnchanged"),
Values(SPV_ENV_WEBGPU_0)));
INSTANTIATE_TEST_SUITE_P(
ValidateModeFragmentWebGPUWhitelistBad, ValidateModeExecution,
Combine(Values(SPV_ERROR_INVALID_DATA),
Values("Execution mode must be one of OriginUpperLeft, "
"DepthReplacing, DepthGreater, DepthLess, DepthUnchanged, "
"LocalSize, or LocalSizeHint for WebGPU environment"),
Values("Fragment"),
Values("PixelCenterInteger", "OriginLowerLeft",
"EarlyFragmentTests"),
Values(SPV_ENV_WEBGPU_0)));
TEST_F(ValidateModeExecution, MeshNVLocalSize) {
const std::string spirv = R"(
OpCapability Shader