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/+/2318046
Reviewed-by: Mohan Maiya <m.maiya@samsung.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2020-07-24 14:54:37 -04:00 коммит произвёл Commit Bot
Родитель 07ae186b5e
Коммит 3f851efa2a
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -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
// 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 value is limited to INT_MAX to avoid overflow when queried from glGetIntegerv().
const uint64_t maxCombinedUniformComponents =
static_cast<uint64_t>(maxPerStageUniformBuffers +
kReservedPerStageDefaultUniformBindingCount) *
maxUniformComponents;
std::min<uint64_t>(static_cast<uint64_t>(maxPerStageUniformBuffers +
kReservedPerStageDefaultUniformBindingCount) *
maxUniformComponents,
std::numeric_limits<GLint>::max());
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
mNativeCaps.maxCombinedShaderUniformComponents[shaderType] = maxCombinedUniformComponents;