Validate the total invocations within a work group
If the total number of invocations within a work group is greater than
MAX_COMPUTE_WORK_GROUP_INVOCATIONS, a compile-time error will occur.
BUG=angleproject:2572
TEST=dEQP.GLES31/functional_debug_negative_coverage_callbacks_compute_invalid_maximum_work_group_sizes
dEQP.GLES31/functional_debug_negative_coverage_log_compute_invalid_maximum_work_group_sizes
dEQP.GLES31/functional_debug_negative_coverage_get_error_compute_invalid_maximum_work_group_sizes
Change-Id: I8218b618d1b347df2c85cfc67ba82ae91d756e05
Reviewed-on: https://chromium-review.googlesource.com/1066076
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Shader.cpp b/src/libANGLE/Shader.cpp
index 874e1e4..9eb2d5b 100644
--- a/src/libANGLE/Shader.cpp
+++ b/src/libANGLE/Shader.cpp
@@ -398,6 +398,30 @@
case ShaderType::Compute:
{
mState.mLocalSize = sh::GetComputeShaderLocalGroupSize(compilerHandle);
+ if (mState.mLocalSize.isDeclared())
+ {
+ angle::CheckedNumeric<uint32_t> checked_local_size_product(mState.mLocalSize[0]);
+ checked_local_size_product *= mState.mLocalSize[1];
+ checked_local_size_product *= mState.mLocalSize[2];
+
+ if (!checked_local_size_product.IsValid())
+ {
+ WARN() << std::endl
+ << "Integer overflow when computing the product of local_size_x, "
+ << "local_size_y and local_size_z.";
+ mState.mCompileStatus = CompileStatus::NOT_COMPILED;
+ return;
+ }
+ if (checked_local_size_product.ValueOrDie() >
+ context->getCaps().maxComputeWorkGroupInvocations)
+ {
+ WARN() << std::endl
+ << "The total number of invocations within a work group exceeds "
+ << "MAX_COMPUTE_WORK_GROUP_INVOCATIONS.";
+ mState.mCompileStatus = CompileStatus::NOT_COMPILED;
+ return;
+ }
+ }
break;
}
case ShaderType::Vertex: