Commit cd946a03 by Michael Spang Committed by Commit Bot

Vulkan: Fix out of bounds access of pWaitDstStageMask

Since a6242e4d ("Vulkan: Support submitting multiple semaphores"), we can submit up to 2 semaphores at a time, but pWaitDstStageMask is still a single value. Change it to an array of two elements to prevent an out of bounds access. Bug: angleproject:3289 Change-Id: I5147802ce350af7b78dbf54cfa4a9519dd495f01 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1666347 Commit-Queue: Michael Spang <spang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 9420fa06
......@@ -64,7 +64,7 @@ class FixedVector final
bool empty() const;
size_type size() const;
size_type max_size() const;
static constexpr size_type max_size();
void clear();
......@@ -233,7 +233,7 @@ typename FixedVector<T, N, Storage>::size_type FixedVector<T, N, Storage>::size(
}
template <class T, size_t N, class Storage>
typename FixedVector<T, N, Storage>::size_type FixedVector<T, N, Storage>::max_size() const
constexpr typename FixedVector<T, N, Storage>::size_type FixedVector<T, N, Storage>::max_size()
{
return N;
}
......
......@@ -75,19 +75,27 @@ constexpr size_t kInFlightCommandsLimit = 100u;
// Initially dumping the command graphs is disabled.
constexpr bool kEnableCommandGraphDiagnostics = false;
constexpr VkPipelineStageFlags kSubmitInfoWaitDstStageMask[] = {
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
};
void InitializeSubmitInfo(VkSubmitInfo *submitInfo,
const vk::PrimaryCommandBuffer &commandBuffer,
const std::vector<VkSemaphore> &waitSemaphores,
VkPipelineStageFlags *waitStageMask,
const SignalSemaphoreVector &signalSemaphores)
{
submitInfo->sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo->commandBufferCount = commandBuffer.valid() ? 1 : 0;
submitInfo->pCommandBuffers = commandBuffer.ptr();
static_assert(std::extent<decltype(kSubmitInfoWaitDstStageMask)>::value ==
std::decay_t<decltype(signalSemaphores)>::max_size(),
"Wrong size for waitStageMask");
submitInfo->waitSemaphoreCount = waitSemaphores.size();
submitInfo->pWaitSemaphores = waitSemaphores.data();
submitInfo->pWaitDstStageMask = waitStageMask;
submitInfo->pWaitDstStageMask = kSubmitInfoWaitDstStageMask;
submitInfo->signalSemaphoreCount = signalSemaphores.size();
submitInfo->pSignalSemaphores = signalSemaphores.data();
......@@ -907,8 +915,7 @@ angle::Result ContextVk::synchronizeCpuGpuTime()
// Submit the command buffer
VkSubmitInfo submitInfo = {};
VkPipelineStageFlags waitMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
InitializeSubmitInfo(&submitInfo, commandBatch.get(), {}, &waitMask, {});
InitializeSubmitInfo(&submitInfo, commandBatch.get(), {}, {});
ANGLE_TRY(submitFrame(submitInfo, std::move(commandBuffer)));
......@@ -2098,9 +2105,7 @@ angle::Result ContextVk::flushImpl(const gl::Semaphore *clientSignalSemaphore)
}
VkSubmitInfo submitInfo = {};
VkPipelineStageFlags waitMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
InitializeSubmitInfo(&submitInfo, commandBatch.get(), mWaitSemaphores, &waitMask,
signalSemaphores);
InitializeSubmitInfo(&submitInfo, commandBatch.get(), mWaitSemaphores, signalSemaphores);
ANGLE_TRY(submitFrame(submitInfo, commandBatch.release()));
......
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