From 3e3781b2f8d99117f4b94ae8c88e67ef56f2fcaf Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetsky Date: Mon, 26 Apr 2021 22:29:05 +0300 Subject: [PATCH] Fix exception on inverted time range of command list execution on GPU --- .../Sources/Methane/Graphics/DirectX12/CommandListDX.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp index a7aeb3c0b..453bce54d 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp @@ -171,8 +171,8 @@ class CommandListDX { META_CHECK_ARG_EQUAL_DESCR(GetState(), CommandListBase::State::Pending, "can not get GPU time range of encoding, executing or not committed command list"); return in_cpu_nanoseconds - ? Data::TimeRange(m_begin_timestamp_query_ptr->GetCpuNanoseconds(), m_end_timestamp_query_ptr->GetCpuNanoseconds()) - : Data::TimeRange(m_begin_timestamp_query_ptr->GetGpuTimestamp(), m_end_timestamp_query_ptr->GetGpuTimestamp()); + ? GetNormalTimeRange(m_begin_timestamp_query_ptr->GetCpuNanoseconds(), m_end_timestamp_query_ptr->GetCpuNanoseconds()) + : GetNormalTimeRange(m_begin_timestamp_query_ptr->GetGpuTimestamp(), m_end_timestamp_query_ptr->GetGpuTimestamp()); } return CommandListBase::GetGpuTimeRange(in_cpu_nanoseconds); } @@ -240,6 +240,11 @@ class CommandListDX } private: + static Data::TimeRange GetNormalTimeRange(Timestamp start, Timestamp end) + { + return Data::TimeRange(std::min(start, end), std::max(start, end)); + } + Ptr m_begin_timestamp_query_ptr; Ptr m_end_timestamp_query_ptr; wrl::ComPtr m_cp_command_allocator;