| 2035 | } |
| 2036 | |
| 2037 | static TimingStats RunVulkanDirectBenchmark(const BenchmarkOptions& options, const QImage& overlay_image, |
| 2038 | bool& used_hw_decode) { |
| 2039 | TimingStats stats; |
| 2040 | const auto total_start = Clock::now(); |
| 2041 | |
| 2042 | GenericDecodeReader decoder(options, DecodeKind::Vulkan); |
| 2043 | decoder.Open(); |
| 2044 | |
| 2045 | ScopedFrame first_frame; |
| 2046 | double decode_ms = 0.0; |
| 2047 | if (!decoder.NextFrame(first_frame, decode_ms)) { |
| 2048 | decoder.Close(); |
| 2049 | used_hw_decode = false; |
| 2050 | return stats; |
| 2051 | } |
| 2052 | |
| 2053 | used_hw_decode = decoder.UsingHwDecode(); |
| 2054 | if (!used_hw_decode || first_frame.get()->format != AV_PIX_FMT_VULKAN || !first_frame.get()->hw_frames_ctx) { |
| 2055 | decoder.Close(); |
| 2056 | throw std::runtime_error("direct Vulkan row requires real Vulkan hw decode; try RADV_PERFTEST=video_decode"); |
| 2057 | } |
| 2058 | |
| 2059 | stats.decode_ms += decode_ms; |
| 2060 | |
| 2061 | try { |
| 2062 | DirectVulkanPreviewCompositor compositor(options, overlay_image, first_frame.get()->hw_frames_ctx); |
| 2063 | |
| 2064 | const int frame_limit = options.max_frames; |
| 2065 | ScopedFrame current_frame = std::move(first_frame); |
| 2066 | int frame_index = 0; |
| 2067 | while (current_frame && frame_index < frame_limit) { |
| 2068 | if (current_frame.get()->format != AV_PIX_FMT_VULKAN) |
| 2069 | throw std::runtime_error("decode fell back away from Vulkan during direct row"); |
| 2070 | |
| 2071 | ScopedFrame main_input_frame(av_frame_clone(current_frame.get())); |
| 2072 | if (!main_input_frame) |
| 2073 | throw std::runtime_error("Unable to clone direct Vulkan frame"); |
| 2074 | |
| 2075 | const auto submit_start = Clock::now(); |
| 2076 | compositor.Submit(main_input_frame.get()); |
| 2077 | const auto submit_end = Clock::now(); |
| 2078 | stats.composite_ms += std::chrono::duration<double, std::milli>(submit_end - submit_start).count(); |
| 2079 | |
| 2080 | ScopedFrame next_frame; |
| 2081 | double next_decode_ms = 0.0; |
| 2082 | if (frame_index + 1 < frame_limit && decoder.NextFrame(next_frame, next_decode_ms)) { |
| 2083 | stats.decode_ms += next_decode_ms; |
| 2084 | used_hw_decode = used_hw_decode || decoder.UsingHwDecode(); |
| 2085 | } |
| 2086 | |
| 2087 | const auto wait_start = Clock::now(); |
| 2088 | compositor.WaitForPendingSubmission("direct compositor"); |
| 2089 | const auto wait_end = Clock::now(); |
| 2090 | stats.composite_ms += std::chrono::duration<double, std::milli>(wait_end - wait_start).count(); |
| 2091 | if (ShouldDumpFrame(options, frame_index + 1)) { |
| 2092 | SaveDumpImage(options, "VulkanDirect->Vk", frame_index + 1, compositor.ReadbackOutput()); |
| 2093 | } |
| 2094 | stats.frames++; |
no test coverage detected