Commit 3f851efa by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix overflow in maxCombinedUniformComponents

The value is capped to INT_MAX to avoid overflow when queried with glGetIntegerv(). Bug: angleproject:4554 Bug: angleproject:4788 Change-Id: I36d52fc608ef5adc2bc0b73e379db66cbfd9bb54 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2318046Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 07ae186b
...@@ -450,10 +450,13 @@ void RendererVk::ensureCapsInitialized() const ...@@ -450,10 +450,13 @@ void RendererVk::ensureCapsInitialized() const
// There is no additional limit to the combined number of components. We can have up to a // There is no additional limit to the combined number of components. We can have up to a
// maximum number of uniform buffers, each having the maximum number of components. Note that // maximum number of uniform buffers, each having the maximum number of components. Note that
// this limit includes both components in and out of uniform buffers. // this limit includes both components in and out of uniform buffers.
//
// This value is limited to INT_MAX to avoid overflow when queried from glGetIntegerv().
const uint64_t maxCombinedUniformComponents = const uint64_t maxCombinedUniformComponents =
static_cast<uint64_t>(maxPerStageUniformBuffers + std::min<uint64_t>(static_cast<uint64_t>(maxPerStageUniformBuffers +
kReservedPerStageDefaultUniformBindingCount) * kReservedPerStageDefaultUniformBindingCount) *
maxUniformComponents; maxUniformComponents,
std::numeric_limits<GLint>::max());
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
mNativeCaps.maxCombinedShaderUniformComponents[shaderType] = maxCombinedUniformComponents; mNativeCaps.maxCombinedShaderUniformComponents[shaderType] = maxCombinedUniformComponents;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment