Hash :
893325b8
Author :
Date :
2023-08-24T10:03:51
Perf tests: call base class SetUp in all tests https://crrev.com/c/4799388 moved code to SetUp assuming base class SetUp was always called but a few cases were missing this. Changes ASSERT to a check that is enabled in release builds (e.g. perf bots) Bug: b/291604008 Change-Id: I1c3fb123903f09631ef348e311f3dc1c77b4e221 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4810187 Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// VulkanCommandBufferPerf:
// Performance benchmark for Vulkan Primary/Secondary Command Buffer implementations.
// Can run just these tests by adding "--gtest_filter=VulkanCommandBufferPerfTest*"
// option to angle_white_box_perftests.
// When running on Android with run_angle_white_box_perftests, use "-v" option.
#include "ANGLEPerfTest.h"
#include "common/platform.h"
#include "test_utils/third_party/vulkan_command_buffer_utils.h"
#if defined(ANDROID)
# define NUM_CMD_BUFFERS 1000
// Android devices tend to be slower so only do 10 frames to avoid timeout
# define NUM_FRAMES 10
#else
# define NUM_CMD_BUFFERS 1000
# define NUM_FRAMES 100
#endif
// These are minimal shaders used to submit trivial draw commands to command
// buffers so that we can create large batches of cmd buffers with consistent
// draw patterns but size/type of cmd buffers can be varied to test cmd buffer
// differences across devices.
constexpr char kVertShaderText[] = R"(
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (std140, binding = 0) uniform bufferVals {
mat4 mvp;
} myBufferVals;
layout (location = 0) in vec4 pos;
layout (location = 1) in vec4 inColor;
layout (location = 0) out vec4 outColor;
void main() {
outColor = inColor;
gl_Position = myBufferVals.mvp * pos;
})";
constexpr char kFragShaderText[] = R"(
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec4 color;
layout (location = 0) out vec4 outColor;
void main() {
outColor = color;
})";
using CommandBufferImpl = void (*)(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers);
struct CommandBufferTestParams
{
CommandBufferImpl CBImplementation;
std::string story;
int frames = NUM_FRAMES;
int buffers = NUM_CMD_BUFFERS;
};
class VulkanCommandBufferPerfTest : public ANGLEPerfTest,
public ::testing::WithParamInterface<CommandBufferTestParams>
{
public:
VulkanCommandBufferPerfTest();
void SetUp() override;
void TearDown() override;
void step() override;
private:
VkClearValue mClearValues[2] = {};
VkSemaphore mImageAcquiredSemaphore = VK_NULL_HANDLE;
VkFence mDrawFence = VK_NULL_HANDLE;
VkResult res = VK_NOT_READY;
const bool mDepthPresent = true;
struct sample_info mInfo = {};
std::string mSampleTitle;
CommandBufferImpl mCBImplementation = nullptr;
int mFrames = 0;
int mBuffers = 0;
};
VulkanCommandBufferPerfTest::VulkanCommandBufferPerfTest()
: ANGLEPerfTest("VulkanCommandBufferPerfTest", "", GetParam().story, GetParam().frames)
{
mInfo = {};
mSampleTitle = "Draw Textured Cube";
mCBImplementation = GetParam().CBImplementation;
mFrames = GetParam().frames;
mBuffers = GetParam().buffers;
}
void VulkanCommandBufferPerfTest::SetUp()
{
ANGLEPerfTest::SetUp();
init_global_layer_properties(mInfo);
init_instance_extension_names(mInfo);
init_device_extension_names(mInfo);
init_instance(mInfo, mSampleTitle.c_str());
init_enumerate_device(mInfo);
init_window_size(mInfo, 500, 500);
init_connection(mInfo);
init_window(mInfo);
init_swapchain_extension(mInfo);
init_device(mInfo);
init_command_pool(mInfo, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
init_command_buffer(mInfo); // Primary command buffer to hold secondaries
init_command_buffer_array(mInfo, mBuffers); // Array of primary command buffers
init_command_buffer2_array(mInfo, mBuffers); // Array containing all secondary buffers
init_device_queue(mInfo);
init_swap_chain(mInfo);
init_depth_buffer(mInfo);
init_uniform_buffer(mInfo);
init_descriptor_and_pipeline_layouts(mInfo, false);
init_renderpass(mInfo, mDepthPresent);
init_shaders(mInfo, kVertShaderText, kFragShaderText);
init_framebuffers(mInfo, mDepthPresent);
init_vertex_buffer(mInfo, g_vb_solid_face_colors_Data, sizeof(g_vb_solid_face_colors_Data),
sizeof(g_vb_solid_face_colors_Data[0]), false);
init_descriptor_pool(mInfo, false);
init_descriptor_set(mInfo);
init_pipeline_cache(mInfo);
init_pipeline(mInfo, mDepthPresent);
mClearValues[0].color.float32[0] = 0.2f;
mClearValues[0].color.float32[1] = 0.2f;
mClearValues[0].color.float32[2] = 0.2f;
mClearValues[0].color.float32[3] = 0.2f;
mClearValues[1].depthStencil.depth = 1.0f;
mClearValues[1].depthStencil.stencil = 0;
VkSemaphoreCreateInfo imageAcquiredSemaphoreCreateInfo;
imageAcquiredSemaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
imageAcquiredSemaphoreCreateInfo.pNext = NULL;
imageAcquiredSemaphoreCreateInfo.flags = 0;
res = vkCreateSemaphore(mInfo.device, &imageAcquiredSemaphoreCreateInfo, NULL,
&mImageAcquiredSemaphore);
ASSERT_EQ(VK_SUCCESS, res);
VkFenceCreateInfo fenceInfo;
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.pNext = NULL;
fenceInfo.flags = 0;
res = vkCreateFence(mInfo.device, &fenceInfo, NULL, &mDrawFence);
ASSERT_EQ(VK_SUCCESS, res);
}
void VulkanCommandBufferPerfTest::step()
{
for (int x = 0; x < mFrames; x++)
{
mInfo.current_buffer = x % mInfo.swapchainImageCount;
// Get the index of the next available swapchain image:
res = vkAcquireNextImageKHR(mInfo.device, mInfo.swap_chain, UINT64_MAX,
mImageAcquiredSemaphore, VK_NULL_HANDLE, &mInfo.current_buffer);
// Deal with the VK_SUBOPTIMAL_KHR and VK_ERROR_OUT_OF_DATE_KHR
// return codes
ASSERT_EQ(VK_SUCCESS, res);
mCBImplementation(mInfo, mClearValues, mDrawFence, mImageAcquiredSemaphore, mBuffers);
}
}
void VulkanCommandBufferPerfTest::TearDown()
{
vkDestroySemaphore(mInfo.device, mImageAcquiredSemaphore, NULL);
vkDestroyFence(mInfo.device, mDrawFence, NULL);
destroy_pipeline(mInfo);
destroy_pipeline_cache(mInfo);
destroy_descriptor_pool(mInfo);
destroy_vertex_buffer(mInfo);
destroy_framebuffers(mInfo);
destroy_shaders(mInfo);
destroy_renderpass(mInfo);
destroy_descriptor_and_pipeline_layouts(mInfo);
destroy_uniform_buffer(mInfo);
destroy_depth_buffer(mInfo);
destroy_swap_chain(mInfo);
destroy_command_buffer2_array(mInfo, mBuffers);
destroy_command_buffer_array(mInfo, mBuffers);
destroy_command_buffer(mInfo);
destroy_command_pool(mInfo);
destroy_device(mInfo);
destroy_window(mInfo);
destroy_instance(mInfo);
ANGLEPerfTest::TearDown();
}
// Common code to present image used by all tests
void Present(sample_info &info, VkFence drawFence)
{
// Now present the image in the window
VkPresentInfoKHR present;
present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
present.pNext = NULL;
present.swapchainCount = 1;
present.pSwapchains = &info.swap_chain;
present.pImageIndices = &info.current_buffer;
present.pWaitSemaphores = NULL;
present.waitSemaphoreCount = 0;
present.pResults = NULL;
// Make sure command buffer is finished before presenting
VkResult res;
do
{
res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);
} while (res == VK_TIMEOUT);
vkResetFences(info.device, 1, &drawFence);
ASSERT_EQ(VK_SUCCESS, res);
res = vkQueuePresentKHR(info.present_queue, &present);
ASSERT_EQ(VK_SUCCESS, res);
}
// 100 separate primary cmd buffers, each with 1 Draw
void PrimaryCommandBufferBenchmarkHundredIndividual(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
VkResult res;
VkRenderPassBeginInfo rpBegin;
rpBegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rpBegin.pNext = NULL;
rpBegin.renderPass = info.render_pass;
rpBegin.framebuffer = info.framebuffers[info.current_buffer];
rpBegin.renderArea.offset.x = 0;
rpBegin.renderArea.offset.y = 0;
rpBegin.renderArea.extent.width = info.width;
rpBegin.renderArea.extent.height = info.height;
rpBegin.clearValueCount = 2;
rpBegin.pClearValues = clear_values;
VkCommandBufferBeginInfo cmdBufferInfo = {};
cmdBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cmdBufferInfo.pNext = NULL;
cmdBufferInfo.flags = 0;
cmdBufferInfo.pInheritanceInfo = NULL;
for (int x = 0; x < numBuffers; x++)
{
vkBeginCommandBuffer(info.cmds[x], &cmdBufferInfo);
vkCmdBeginRenderPass(info.cmds[x], &rpBegin, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(info.cmds[x], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);
vkCmdBindDescriptorSets(info.cmds[x], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout,
0, NUM_DESCRIPTOR_SETS, info.desc_set.data(), 0, NULL);
const VkDeviceSize offsets[1] = {0};
vkCmdBindVertexBuffers(info.cmds[x], 0, 1, &info.vertex_buffer.buf, offsets);
init_viewports_array(info, x);
init_scissors_array(info, x);
vkCmdDraw(info.cmds[x], 0, 1, 0, 0);
vkCmdEndRenderPass(info.cmds[x]);
res = vkEndCommandBuffer(info.cmds[x]);
ASSERT_EQ(VK_SUCCESS, res);
}
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo[1] = {};
submitInfo[0].pNext = NULL;
submitInfo[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo[0].waitSemaphoreCount = 1;
submitInfo[0].pWaitSemaphores = &imageAcquiredSemaphore;
submitInfo[0].pWaitDstStageMask = &pipe_stage_flags;
submitInfo[0].commandBufferCount = numBuffers;
submitInfo[0].pCommandBuffers = info.cmds.data();
submitInfo[0].signalSemaphoreCount = 0;
submitInfo[0].pSignalSemaphores = NULL;
// Queue the command buffer for execution
res = vkQueueSubmit(info.graphics_queue, 1, submitInfo, drawFence);
ASSERT_EQ(VK_SUCCESS, res);
Present(info, drawFence);
}
// 100 of the same Draw cmds in the same primary cmd buffer
void PrimaryCommandBufferBenchmarkOneWithOneHundred(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
VkResult res;
VkRenderPassBeginInfo rpBegin;
rpBegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rpBegin.pNext = NULL;
rpBegin.renderPass = info.render_pass;
rpBegin.framebuffer = info.framebuffers[info.current_buffer];
rpBegin.renderArea.offset.x = 0;
rpBegin.renderArea.offset.y = 0;
rpBegin.renderArea.extent.width = info.width;
rpBegin.renderArea.extent.height = info.height;
rpBegin.clearValueCount = 2;
rpBegin.pClearValues = clear_values;
VkCommandBufferBeginInfo cmdBufferInfo = {};
cmdBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cmdBufferInfo.pNext = NULL;
cmdBufferInfo.flags = 0;
cmdBufferInfo.pInheritanceInfo = NULL;
vkBeginCommandBuffer(info.cmd, &cmdBufferInfo);
for (int x = 0; x < numBuffers; x++)
{
vkCmdBeginRenderPass(info.cmd, &rpBegin, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);
vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0,
NUM_DESCRIPTOR_SETS, info.desc_set.data(), 0, NULL);
const VkDeviceSize offsets[1] = {0};
vkCmdBindVertexBuffers(info.cmd, 0, 1, &info.vertex_buffer.buf, offsets);
init_viewports(info);
init_scissors(info);
vkCmdDraw(info.cmd, 0, 1, 0, 0);
vkCmdEndRenderPass(info.cmd);
}
res = vkEndCommandBuffer(info.cmd);
ASSERT_EQ(VK_SUCCESS, res);
const VkCommandBuffer cmd_bufs[] = {info.cmd};
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo[1] = {};
submitInfo[0].pNext = NULL;
submitInfo[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo[0].waitSemaphoreCount = 1;
submitInfo[0].pWaitSemaphores = &imageAcquiredSemaphore;
submitInfo[0].pWaitDstStageMask = &pipe_stage_flags;
submitInfo[0].commandBufferCount = 1;
submitInfo[0].pCommandBuffers = cmd_bufs;
submitInfo[0].signalSemaphoreCount = 0;
submitInfo[0].pSignalSemaphores = NULL;
// Queue the command buffer for execution
res = vkQueueSubmit(info.graphics_queue, 1, submitInfo, drawFence);
ASSERT_EQ(VK_SUCCESS, res);
Present(info, drawFence);
}
// 100 separate secondary cmd buffers, each with 1 Draw
void SecondaryCommandBufferBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
VkResult res;
// Record Secondary Command Buffer
VkCommandBufferInheritanceInfo inheritInfo = {};
inheritInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
inheritInfo.pNext = NULL;
inheritInfo.renderPass = info.render_pass;
inheritInfo.subpass = 0;
inheritInfo.framebuffer = info.framebuffers[info.current_buffer];
inheritInfo.occlusionQueryEnable = false;
inheritInfo.queryFlags = 0;
inheritInfo.pipelineStatistics = 0;
VkCommandBufferBeginInfo secondaryCommandBufferInfo = {};
secondaryCommandBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
secondaryCommandBufferInfo.pNext = NULL;
secondaryCommandBufferInfo.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
secondaryCommandBufferInfo.pInheritanceInfo = &inheritInfo;
for (int x = 0; x < numBuffers; x++)
{
vkBeginCommandBuffer(info.cmd2s[x], &secondaryCommandBufferInfo);
vkCmdBindPipeline(info.cmd2s[x], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);
vkCmdBindDescriptorSets(info.cmd2s[x], VK_PIPELINE_BIND_POINT_GRAPHICS,
info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS, info.desc_set.data(),
0, NULL);
const VkDeviceSize offsets[1] = {0};
vkCmdBindVertexBuffers(info.cmd2s[x], 0, 1, &info.vertex_buffer.buf, offsets);
init_viewports2_array(info, x);
init_scissors2_array(info, x);
vkCmdDraw(info.cmd2s[x], 0, 1, 0, 0);
vkEndCommandBuffer(info.cmd2s[x]);
}
// Record Secondary Command Buffer End
// Record Primary Command Buffer Begin
VkRenderPassBeginInfo rpBegin;
rpBegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rpBegin.pNext = NULL;
rpBegin.renderPass = info.render_pass;
rpBegin.framebuffer = info.framebuffers[info.current_buffer];
rpBegin.renderArea.offset.x = 0;
rpBegin.renderArea.offset.y = 0;
rpBegin.renderArea.extent.width = info.width;
rpBegin.renderArea.extent.height = info.height;
rpBegin.clearValueCount = 2;
rpBegin.pClearValues = clear_values;
VkCommandBufferBeginInfo primaryCommandBufferInfo = {};
primaryCommandBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
primaryCommandBufferInfo.pNext = NULL;
primaryCommandBufferInfo.flags = 0;
primaryCommandBufferInfo.pInheritanceInfo = NULL;
vkBeginCommandBuffer(info.cmd, &primaryCommandBufferInfo);
for (int x = 0; x < numBuffers; x++)
{
vkCmdBeginRenderPass(info.cmd, &rpBegin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
vkCmdExecuteCommands(info.cmd, 1, &info.cmd2s[x]);
vkCmdEndRenderPass(info.cmd);
}
vkEndCommandBuffer(info.cmd);
// Record Primary Command Buffer End
const VkCommandBuffer cmd_bufs[] = {info.cmd};
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo[1] = {};
submitInfo[0].pNext = NULL;
submitInfo[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo[0].waitSemaphoreCount = 1;
submitInfo[0].pWaitSemaphores = &imageAcquiredSemaphore;
submitInfo[0].pWaitDstStageMask = &pipe_stage_flags;
submitInfo[0].commandBufferCount = 1;
submitInfo[0].pCommandBuffers = cmd_bufs;
submitInfo[0].signalSemaphoreCount = 0;
submitInfo[0].pSignalSemaphores = NULL;
// Queue the command buffer for execution
res = vkQueueSubmit(info.graphics_queue, 1, submitInfo, drawFence);
ASSERT_EQ(VK_SUCCESS, res);
Present(info, drawFence);
}
// Details on the following functions that stress various cmd buffer reset methods.
// All of these functions wrap the SecondaryCommandBufferBenchmark() test above,
// adding additional overhead with various reset methods.
// -CommandPoolDestroyBenchmark: Reset command buffers by destroying and re-creating
// command buffer pool.
// -CommandPoolHardResetBenchmark: Reset the command pool w/ the RELEASE_RESOURCES
// bit set.
// -CommandPoolSoftResetBenchmark: Reset to command pool w/o the RELEASE_RESOURCES
// bit set.
// -CommandBufferExplicitHardResetBenchmark: Reset each individual command buffer
// w/ the RELEASE_RESOURCES bit set.
// -CommandBufferExplicitSoftResetBenchmark: Reset each individual command buffer
// w/o the RELEASE_RESOURCES bit set.
// -CommandBufferImplicitResetBenchmark: Reset each individual command buffer
// implicitly by calling "Begin" on previously used cmd buffer.
void CommandPoolDestroyBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
// Save setup cmd buffer data to be restored
auto saved_cmd_pool = info.cmd_pool;
auto saved_cb = info.cmd;
auto saved_cb2s = info.cmd2s;
// Now re-allocate & destroy cmd buffers to stress those calls
init_command_pool(info, 0);
init_command_buffer2_array(info, numBuffers);
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
destroy_command_pool(info);
// Restore original cmd buffer data for cleanup
info.cmd_pool = saved_cmd_pool;
info.cmd = saved_cb;
info.cmd2s = saved_cb2s;
}
void CommandPoolHardResetBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
reset_command_pool(info, VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT);
}
void CommandPoolSoftResetBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
reset_command_pool(info, 0);
}
void CommandBufferExplicitHardResetBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
// Explicitly resetting cmd buffers
reset_command_buffer2_array(info, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
}
void CommandBufferExplicitSoftResetBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
// Explicitly resetting cmd buffers w/ soft reset (don't release resources)
reset_command_buffer2_array(info, 0);
}
void CommandBufferImplicitResetBenchmark(sample_info &info,
VkClearValue *clear_values,
VkFence drawFence,
VkSemaphore imageAcquiredSemaphore,
int numBuffers)
{
// Repeated call SCBBenchmark & BeginCmdBuffer calls will implicitly reset each cmd buffer
SecondaryCommandBufferBenchmark(info, clear_values, drawFence, imageAcquiredSemaphore,
numBuffers);
}
CommandBufferTestParams PrimaryCBHundredIndividualParams()
{
CommandBufferTestParams params;
params.CBImplementation = PrimaryCommandBufferBenchmarkHundredIndividual;
params.story = "_PrimaryCB_Submit_100_With_1_Draw";
return params;
}
CommandBufferTestParams PrimaryCBOneWithOneHundredParams()
{
CommandBufferTestParams params;
params.CBImplementation = PrimaryCommandBufferBenchmarkOneWithOneHundred;
params.story = "_PrimaryCB_Submit_1_With_100_Draw";
return params;
}
CommandBufferTestParams SecondaryCBParams()
{
CommandBufferTestParams params;
params.CBImplementation = SecondaryCommandBufferBenchmark;
params.story = "_SecondaryCB_Submit_1_With_100_Draw_In_Individual_Secondary";
return params;
}
CommandBufferTestParams CommandPoolDestroyParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolDestroyBenchmark;
params.story = "_Reset_CBs_With_Destroy_Command_Pool";
return params;
}
CommandBufferTestParams CommandPoolHardResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolHardResetBenchmark;
params.story = "_Reset_CBs_With_Hard_Reset_Command_Pool";
return params;
}
CommandBufferTestParams CommandPoolSoftResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolSoftResetBenchmark;
params.story = "_Reset_CBs_With_Soft_Reset_Command_Pool";
return params;
}
CommandBufferTestParams CommandBufferExplicitHardResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferExplicitHardResetBenchmark;
params.story = "_Reset_CBs_With_Explicit_Hard_Reset_Command_Buffers";
return params;
}
CommandBufferTestParams CommandBufferExplicitSoftResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferExplicitSoftResetBenchmark;
params.story = "_Reset_CBs_With_Explicit_Soft_Reset_Command_Buffers";
return params;
}
CommandBufferTestParams CommandBufferImplicitResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferImplicitResetBenchmark;
params.story = "_Reset_CBs_With_Implicit_Reset_Command_Buffers";
return params;
}
TEST_P(VulkanCommandBufferPerfTest, Run)
{
run();
}
INSTANTIATE_TEST_SUITE_P(,
VulkanCommandBufferPerfTest,
::testing::Values(PrimaryCBHundredIndividualParams(),
PrimaryCBOneWithOneHundredParams(),
SecondaryCBParams(),
CommandPoolDestroyParams(),
CommandPoolHardResetParams(),
CommandPoolSoftResetParams(),
CommandBufferExplicitHardResetParams(),
CommandBufferExplicitSoftResetParams(),
CommandBufferImplicitResetParams()));