Skip to content
This repository was archived by the owner on Apr 30, 2020. It is now read-only.

Commit 0a41aa0

Browse files
committed
Fixed a timestamp bug in Vulkan and renamed the conversion constants to fit their purpose
1 parent 92e9f01 commit 0a41aa0

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/ProfileSessionDataItem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ quint64 ProfileSessionDataItem::TimeMilliseconds(quint64 time) const
912912
{
913913
quint64 retVal = time;
914914

915-
if (m_itemType.m_itemMainType == DX12_API_PROFILE_ITEM || m_itemType.m_itemMainType == DX12_GPU_PROFILE_ITEM)
915+
if ((m_itemType.m_itemMainType == DX12_API_PROFILE_ITEM || m_itemType.m_itemMainType == DX12_GPU_PROFILE_ITEM) ||
916+
(m_itemType.m_itemMainType == VK_API_PROFILE_ITEM || m_itemType.m_itemMainType == VK_GPU_PROFILE_ITEM))
916917
{
917918
retVal = time / GP_NANOSECONDS_TO_MILLISECOND;
918919
}

CodeXL/Components/GpuProfiling/Backend/DX12Trace/DX12AtpFile.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const static std::string s_str_apiTypeHeaderPrefix = "//API=";
4141
const static std::string s_str_threadIDHeaderPrefix = "//ThreadID=";
4242
const static std::string s_str_threadAPICountHeaderPrefix = "//ThreadAPICount=";
4343

44-
// The DX12 timestamps are double number. The data structures expect long long numbers, so we multiply the double timestamp by a GP_DX_TIMESTAMP_FACTOR
44+
// The DX12 timestamps are double number. The data structures expect long long numbers, so we multiply the double timestamp by a GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR
4545
// to make sure that we get integer value. In the front-end, we will perform the opposite operation
46-
#define GP_DX_TIMESTAMP_FACTOR 1000000
46+
#define GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR 1000000
4747

4848
#define KILO_BYTE 1024
4949
#define MEGA_BYTE (KILO_BYTE * 1024)
@@ -201,8 +201,8 @@ bool DX12AtpFilePart::ParseGPUAPICallString(const std::string& apiStr, DX12GPUTr
201201

202202
// The timestamps are stored in a double number, in milliseconds units.
203203
// We multiply it by 1000000, to keep the accuracy, and we will refer to it as nanoseconds
204-
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_DX_TIMESTAMP_FACTOR);
205-
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_DX_TIMESTAMP_FACTOR);
204+
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
205+
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
206206

207207
pCurrentToken = strtok(nullptr, " ");
208208

@@ -385,8 +385,8 @@ bool DX12AtpFilePart::ParseCPUAPICallString(const std::string& apiStr, DX12APIIn
385385

386386
// The timestamps are stored in a double number, in milliseconds units.
387387
// We multiply it by 1000000, to keep the accuracy, and we will refer to it as nanoseconds
388-
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_DX_TIMESTAMP_FACTOR);
389-
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_DX_TIMESTAMP_FACTOR);
388+
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
389+
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_DX_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
390390

391391
pCurrentToken = strtok(nullptr, " ");
392392

CodeXL/Components/GpuProfiling/Backend/VulkanTrace/VulkanAtpFile.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const static std::string s_str_threadAPICountHeaderPrefix = "//ThreadAPICount=";
4141

4242
// The Vulkan timestamps are double number. The data structures expect long long numbers, so we multiply the double timestamp by a GP_VK_TIMESTAMP_FACTOR
4343
// to make sure that we get integer value. In the front-end, we will perform the opposite operation
44-
#define GP_VK_TIMESTAMP_FACTOR 100000
44+
#define GP_VK_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR 1000000
4545

4646
VKAtpFilePart::VKAtpFilePart(const Config& config, bool shouldReleaseMemory) : IAtpFilePart(config, shouldReleaseMemory),
4747
m_currentParsedTraceType(API), m_currentParsedThreadID(0), m_currentParsedThreadAPICount(0),
@@ -151,8 +151,8 @@ bool VKAtpFilePart::ParseGPUAPICallString(const std::string& apiStr, VKGPUTraceI
151151
ss >> timeEndDouble;
152152
CHECK_SS_ERROR(ss);
153153

154-
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_VK_TIMESTAMP_FACTOR);
155-
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_VK_TIMESTAMP_FACTOR);
154+
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_VK_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
155+
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_VK_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
156156

157157
/// Store the GPU start time if it is not stored yet
158158
/// GPU timestamps to fit the CPU timeline
@@ -291,8 +291,8 @@ bool VKAtpFilePart::ParseCPUAPICallString(const std::string& apiStr, VKAPIInfo&
291291
ss >> timeEndDouble;
292292
CHECK_SS_ERROR(ss);
293293

294-
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_VK_TIMESTAMP_FACTOR);
295-
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_VK_TIMESTAMP_FACTOR);
294+
apiInfo.m_ullStart = ULONGLONG(timeStartDouble * GP_VK_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
295+
apiInfo.m_ullEnd = ULONGLONG(timeEndDouble * GP_VK_TIMESTAMP_MILLISECONDS_TO_NANOSECONDS_FACTOR);
296296

297297
// Store the CPU start and end time (if not stored yet)
298298
if (m_cpuStart == 0)

0 commit comments

Comments
 (0)