Skip to content

Commit 973343d

Browse files
test: Fix PerformanceIncompletePasses
1 parent 4066b98 commit 973343d

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

tests/unit/query.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ TEST_F(NegativeQuery, PerformanceIncompletePasses) {
500500
perf_query_pool_ci.pCounterIndices = &counterIndices[0];
501501
VkQueryPoolCreateInfo query_pool_ci = vku::InitStructHelper(&perf_query_pool_ci);
502502
query_pool_ci.queryType = VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR;
503-
query_pool_ci.queryCount = 1;
503+
// The stride VUs tested below only apply when queryCount is greater than one, so a second query is needed
504+
query_pool_ci.queryCount = 2;
504505
vkt::QueryPool query_pool(*m_device, query_pool_ci);
505506

506507
VkQueue queue = VK_NULL_HANDLE;
@@ -520,12 +521,16 @@ TEST_F(NegativeQuery, PerformanceIncompletePasses) {
520521
VkCommandBufferBeginInfo command_buffer_begin_info = vku::InitStructHelper();
521522
command_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
522523

523-
vk::ResetQueryPoolEXT(device(), query_pool, 0, 1);
524+
vk::ResetQueryPoolEXT(device(), query_pool, 0, 2);
524525

525526
m_command_buffer.Begin(&command_buffer_begin_info);
526527
vk::CmdBeginQuery(m_command_buffer, query_pool, 0, 0);
527528
vk::CmdFillBuffer(m_command_buffer, buffer, 0, buf_size, 0);
528529
vk::CmdEndQuery(m_command_buffer, query_pool, 0);
530+
// Both queries have to be written in every pass or reading them back reports incomplete passes
531+
vk::CmdBeginQuery(m_command_buffer, query_pool, 1, 0);
532+
vk::CmdFillBuffer(m_command_buffer, buffer, 0, buf_size, 0);
533+
vk::CmdEndQuery(m_command_buffer, query_pool, 1);
529534
m_command_buffer.End();
530535

531536
// Invalid pass index
@@ -541,7 +546,8 @@ TEST_F(NegativeQuery, PerformanceIncompletePasses) {
541546
submit_info.signalSemaphoreCount = 0;
542547
submit_info.pSignalSemaphores = NULL;
543548

544-
m_errorMonitor->SetDesiredError("VUID-VkPerformanceQuerySubmitInfoKHR-counterPassIndex-03221");
549+
// Reported once per vkCmdBeginQuery recorded in the command buffer, and there are two queries
550+
m_errorMonitor->SetDesiredError("VUID-VkPerformanceQuerySubmitInfoKHR-counterPassIndex-03221", 2);
545551
vk::QueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
546552
m_errorMonitor->VerifyFound();
547553
}
@@ -590,23 +596,24 @@ TEST_F(NegativeQuery, PerformanceIncompletePasses) {
590596

591597
vk::QueueWaitIdle(queue);
592598

593-
// The stride is too small to return the data
599+
// The stride is too small to hold one query worth of counters
594600
if (counterIndices.size() > 2) {
601+
const VkDeviceSize small_stride = sizeof(VkPerformanceCounterResultKHR) * (results.size() - 1);
602+
std::vector<VkPerformanceCounterResultKHR> results_small_stride(results.size() * 2);
595603
m_errorMonitor->SetDesiredError("VUID-vkGetQueryPoolResults-queryType-04519");
596-
vk::GetQueryPoolResults(device(), query_pool, 0, 1, sizeof(VkPerformanceCounterResultKHR) * results.size(), &results[0],
597-
sizeof(VkPerformanceCounterResultKHR) * (results.size() - 1), 0);
604+
vk::GetQueryPoolResults(device(), query_pool, 0, 2, sizeof(VkPerformanceCounterResultKHR) * results_small_stride.size(),
605+
&results_small_stride[0], small_stride, 0);
598606
m_errorMonitor->VerifyFound();
599607
}
600608

601-
// Invalid stride
609+
// Stride is not a multiple of sizeof(VkPerformanceCounterResultKHR)
602610
{
603-
std::vector<VkPerformanceCounterResultKHR> results_invalid_stride;
604-
results_invalid_stride.resize(counterIndices.size() * 2);
605-
m_errorMonitor->SetDesiredError("VUID-vkGetQueryPoolResults-queryType-03229");
606-
vk::GetQueryPoolResults(
607-
device(), query_pool, 0, 1, sizeof(VkPerformanceCounterResultKHR) * results_invalid_stride.size(),
608-
&results_invalid_stride[0], sizeof(VkPerformanceCounterResultKHR) * results_invalid_stride.size() + 4,
609-
VK_QUERY_RESULT_WAIT_BIT);
611+
const VkDeviceSize unaligned_stride = sizeof(VkPerformanceCounterResultKHR) * results.size() + 4;
612+
std::vector<VkPerformanceCounterResultKHR> results_invalid_stride(results.size() * 3);
613+
m_errorMonitor->SetDesiredError("VUID-vkGetQueryPoolResults-queryCount-12253");
614+
vk::GetQueryPoolResults(device(), query_pool, 0, 2,
615+
sizeof(VkPerformanceCounterResultKHR) * results_invalid_stride.size(),
616+
&results_invalid_stride[0], unaligned_stride, 0);
610617
m_errorMonitor->VerifyFound();
611618
}
612619

0 commit comments

Comments
 (0)