Skip to content

Commit 3e3781b

Browse files
author
Evgeny Gorodetsky
committed
Fix exception on inverted time range of command list execution on GPU
1 parent 167152a commit 3e3781b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ class CommandListDX
171171
{
172172
META_CHECK_ARG_EQUAL_DESCR(GetState(), CommandListBase::State::Pending, "can not get GPU time range of encoding, executing or not committed command list");
173173
return in_cpu_nanoseconds
174-
? Data::TimeRange(m_begin_timestamp_query_ptr->GetCpuNanoseconds(), m_end_timestamp_query_ptr->GetCpuNanoseconds())
175-
: Data::TimeRange(m_begin_timestamp_query_ptr->GetGpuTimestamp(), m_end_timestamp_query_ptr->GetGpuTimestamp());
174+
? GetNormalTimeRange(m_begin_timestamp_query_ptr->GetCpuNanoseconds(), m_end_timestamp_query_ptr->GetCpuNanoseconds())
175+
: GetNormalTimeRange(m_begin_timestamp_query_ptr->GetGpuTimestamp(), m_end_timestamp_query_ptr->GetGpuTimestamp());
176176
}
177177
return CommandListBase::GetGpuTimeRange(in_cpu_nanoseconds);
178178
}
@@ -240,6 +240,11 @@ class CommandListDX
240240
}
241241

242242
private:
243+
static Data::TimeRange GetNormalTimeRange(Timestamp start, Timestamp end)
244+
{
245+
return Data::TimeRange(std::min(start, end), std::max(start, end));
246+
}
247+
243248
Ptr<TimestampQueryBuffer::TimestampQuery> m_begin_timestamp_query_ptr;
244249
Ptr<TimestampQueryBuffer::TimestampQuery> m_end_timestamp_query_ptr;
245250
wrl::ComPtr<ID3D12CommandAllocator> m_cp_command_allocator;

0 commit comments

Comments
 (0)