Skip to content

Commit ea41741

Browse files
uysalereCQ Bot
authored andcommitted
[ui][escher] Preallocate reused struct in CommandBuffer::Submit
CommandBuffer::Submit has a struct that are allocated and destructed in each Submit. We should make them static to avoid the extra cost. Change-Id: I405daab97b94c7143b1d74294d96ab71d35bfaba Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1178498 Reviewed-by: Josh Gargus <[email protected]> Fuchsia-Auto-Submit: Emircan Uysaler <[email protected]> Commit-Queue: Auto-Submit <[email protected]>
1 parent 68b95a7 commit ea41741

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ui/lib/escher/impl/command_buffer.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ bool CommandBuffer::Submit(vk::Queue queue, CommandBufferFinishedCallback callba
5353
auto end_command_buffer_result = command_buffer_.end();
5454
FX_DCHECK(end_command_buffer_result == vk::Result::eSuccess);
5555

56-
auto protected_submit_info = vk::ProtectedSubmitInfo().setProtectedSubmit(true);
57-
vk::SubmitInfo submit_info;
58-
submit_info.commandBufferCount = 1;
59-
submit_info.pNext = use_protected_memory_ ? &protected_submit_info : nullptr;
60-
submit_info.pCommandBuffers = &command_buffer_;
61-
submit_info.waitSemaphoreCount = static_cast<uint32_t>(wait_semaphores_for_submit_.size());
62-
submit_info.pWaitSemaphores = wait_semaphores_for_submit_.data();
63-
submit_info.pWaitDstStageMask = wait_semaphore_stages_.data();
64-
submit_info.signalSemaphoreCount = static_cast<uint32_t>(signal_semaphores_for_submit_.size());
65-
submit_info.pSignalSemaphores = signal_semaphores_for_submit_.data();
66-
56+
static constexpr vk::ProtectedSubmitInfo kProtectedSubmitInfo =
57+
vk::ProtectedSubmitInfo().setProtectedSubmit(true);
58+
const vk::SubmitInfo submit_info(
59+
/*waitSemaphoreCount=*/static_cast<uint32_t>(wait_semaphores_for_submit_.size()),
60+
/*pWaitSemaphores*/ wait_semaphores_for_submit_.data(),
61+
/*pWaitDstStageMask=*/wait_semaphore_stages_.data(),
62+
/*commandBufferCount=*/1,
63+
/*pCommandBuffers=*/&command_buffer_,
64+
/*signalSemaphoreCount=*/static_cast<uint32_t>(signal_semaphores_for_submit_.size()),
65+
/*pSignalSemaphores=*/signal_semaphores_for_submit_.data(),
66+
/*pNext=*/use_protected_memory_ ? &kProtectedSubmitInfo : nullptr);
6767
auto submit_result = queue.submit(1, &submit_info, fence_);
6868
if (submit_result != vk::Result::eSuccess) {
6969
FX_LOGS(WARNING) << "failed queue submission: " << to_string(submit_result);

0 commit comments

Comments
 (0)