mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
Merge pull request #6514 from JJenkx/test/gpu-timing-incomplete-batch
test(agc): cover incomplete GPU timing batch completion
This commit is contained in:
2 files changed
+54
-1
No files matched your search
@@ -1191,8 +1191,12 @@ configure_windows_unwind(agc_driver_recorder_tests)
|
||||
if(BUILD_TESTING)
|
||||
set_target_properties(agc_driver_recorder_tests PROPERTIES EXCLUDE_FROM_ALL OFF)
|
||||
add_test(NAME agc_recorder_device_selection COMMAND agc_driver_recorder_tests --device-selection-only)
|
||||
add_test(NAME agc_gpu_timing_complete COMMAND agc_driver_recorder_tests --gpu-timing-complete-only)
|
||||
add_test(NAME agc_gpu_timing_incomplete COMMAND agc_driver_recorder_tests --gpu-timing-incomplete-only)
|
||||
set_tests_properties(agc_gpu_timing_complete agc_gpu_timing_incomplete PROPERTIES
|
||||
ENVIRONMENT "APS5_PROFILE_GPU=1" TIMEOUT 15 SKIP_RETURN_CODE 77)
|
||||
if(WIN32)
|
||||
set_tests_properties(agc_recorder_device_selection PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
set_tests_properties(agc_recorder_device_selection agc_gpu_timing_complete agc_gpu_timing_incomplete PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_test(NAME agc_pipeline_cache COMMAND agc_driver_recorder_tests --pipeline-cache-only)
|
||||
|
||||
@@ -392,6 +392,14 @@ public:
|
||||
bool NullDescriptors() const { return nullDescriptors; }
|
||||
const Context& GetContext() const { return context; }
|
||||
bool Graphics() const { return graphics; }
|
||||
bool Timestamps() const {
|
||||
std::uint32_t count = 0;
|
||||
const auto queues = function<PFN_vkGetPhysicalDeviceQueueFamilyProperties>("vkGetPhysicalDeviceQueueFamilyProperties");
|
||||
queues(context.physical, &count, nullptr);
|
||||
std::vector<VkQueueFamilyProperties> families(count);
|
||||
queues(context.physical, &count, families.data());
|
||||
return families.at(context.queueFamily).timestampValidBits != 0;
|
||||
}
|
||||
VkPhysicalDeviceProperties Properties() const {
|
||||
VkPhysicalDeviceProperties properties{};
|
||||
function<PFN_vkGetPhysicalDeviceProperties>("vkGetPhysicalDeviceProperties")(context.physical, &properties);
|
||||
@@ -1195,6 +1203,44 @@ void afterRecordedWorkTests(const Device& device, Recorder& recorder) {
|
||||
Require(seen == 1, "an action ran before the completion label recorded ahead of it");
|
||||
}
|
||||
|
||||
int gpuTimingCompletionTests(const Device& device, bool incomplete) {
|
||||
const auto& context = device.GetContext();
|
||||
if (!device.Timestamps()) {
|
||||
std::cout << "skipped, queue timestamp queries unavailable\n";
|
||||
return 77;
|
||||
}
|
||||
Require(Recorder::GpuTimingEnabled(), "GPU timing completion test requires APS5_PROFILE_GPU");
|
||||
std::unique_lock gpu(GpuMutex());
|
||||
int completed = 0;
|
||||
Recorder recorder(context);
|
||||
recorder.Activate();
|
||||
for (int round = 0; round < 3; ++round) {
|
||||
const bool missingEnd = incomplete && round == 1;
|
||||
const auto first = recorder.BeginGpuTiming(0x12340);
|
||||
Require(first != Recorder::NoTiming, "first GPU timing range was not allocated");
|
||||
if (!missingEnd) recorder.EndGpuTiming(first);
|
||||
const auto second = recorder.BeginGpuTiming(0x12341);
|
||||
Require(second != Recorder::NoTiming && second != first, "second GPU timing range was not allocated");
|
||||
recorder.EndGpuTiming(second);
|
||||
recorder.OnComplete([&] { ++completed; });
|
||||
const auto serial = recorder.Submissions() + 1;
|
||||
recorder.Submit();
|
||||
recorder.Sync();
|
||||
Require(completed == round + 1 && recorder.Idle(), "GPU timing prevented batch completion");
|
||||
std::size_t missing = 0;
|
||||
const auto batches = recorder.CompletedBatches(serial - 1, serial, missing);
|
||||
Require(missing == 0 && batches.size() == 1 && batches.front().serial == serial, "GPU timing batch completion record is missing");
|
||||
const auto& batch = batches.front();
|
||||
if (missingEnd) {
|
||||
Require(batch.gpuStartNs == 0 && batch.gpuEndNs == 0, "incomplete query batch published GPU timings");
|
||||
} else {
|
||||
Require(batch.gpuStartNs > 0 && batch.gpuEndNs >= batch.gpuStartNs, "complete query batch lost GPU timings");
|
||||
}
|
||||
}
|
||||
std::cout << "GPU timing batch completion checked, incomplete=" << incomplete << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
void batchStampTests(Recorder& recorder) {
|
||||
Require(recorder.Idle(), "batch stamps: the recorder is busy");
|
||||
double previousEnd = 0;
|
||||
@@ -8960,6 +9006,9 @@ int main(int argc, char** argv) {
|
||||
Device& device = *created;
|
||||
if (argc == 2 && std::string_view(argv[1]) == "--host-import-lifetime-only") return RunHostImportLifetimeTests(device.GetContext());
|
||||
if (argc == 2 && std::string_view(argv[1]) == "--host-import-mutation-race-only") return RunHostImportMutationRaceTests(device.GetContext());
|
||||
if (argc == 2 && (std::string_view(argv[1]) == "--gpu-timing-complete-only" || std::string_view(argv[1]) == "--gpu-timing-incomplete-only")) {
|
||||
return gpuTimingCompletionTests(device, std::string_view(argv[1]) == "--gpu-timing-incomplete-only");
|
||||
}
|
||||
if (argc == 2 && std::string_view(argv[1]) == "--import-watch-only") {
|
||||
importWatchTests(device);
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user