diff options
author | Pasi Keränen <pasi.keranen@qt.io> | 2019-04-17 15:08:15 +0300 |
---|---|---|
committer | Pasi Keränen <pasi.keranen@qt.io> | 2019-04-29 10:15:50 +0000 |
commit | 87477a7ed556e7ee575d4376d4d72026bd5ce3e1 (patch) | |
tree | 4e9f45c10237a45c0fefaca4c8d72c9680a69b71 /src/Runtime/Source/viewer | |
parent | 34948f16dab26d876635f46842244f9ff54f5912 (diff) |
Remove unused code
Remove stateapplication (Architect integration) code. Remove perflog
code.
Task-number: QT3DS-3331
Change-Id: I208cce7551b3d332fb7905ae7cd4151c883b3728
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Runtime/Source/viewer')
10 files changed, 0 insertions, 1880 deletions
diff --git a/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.cpp b/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.cpp deleted file mode 100644 index b8e290f8..00000000 --- a/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> - -#define ADDRINFO struct addrinfo -#define INVALID_SOCKET -1 -#define closesocket close -#define SD_BOTH SHUT_RDWR -#define SOCKET_ERROR -1 - -#endif - -#include "SimpleTCPClientSocket.h" - -//============================================================================== -/** - * CTOR - * Accepts a buffer size for internal storage and a flag to indicate if - * Recv should return fixed sized packets or not. - */ -SimpleTCPClientSocket::SimpleTCPClientSocket(long inBufferSize, bool inWaitForFull) - : m_ClientSocket(NULL) - , m_Data(NULL) - , m_BytesRead(0) - , m_BufferSize(inBufferSize) - , m_WaitForFull(inWaitForFull) -{ - m_Data = new char[m_BufferSize]; -} - -//============================================================================== -/** - * DTOR - */ -SimpleTCPClientSocket::~SimpleTCPClientSocket() -{ - if (m_ClientSocket) - Disconnect(); - - delete[] m_Data; -} - -//============================================================================== -/** - * Initializes TCP communications. - * Needs to be called once per app. - */ -bool SimpleTCPClientSocket::Initialize() -{ -#ifdef _PCPLATFORM - WSADATA theWsaData; - - if (WSAStartup(WINSOCK_VERSION, &theWsaData)) { - // WSAStartup failed - return false; - } -#endif - return true; -} - -//============================================================================== -/** - * Deinitializes TCP communications. - * Needs to be called once per app. - */ -void SimpleTCPClientSocket::DeInitialize() -{ -#ifdef _PCPLATFORM - WSACleanup(); -#endif -} - -//============================================================================== -/** - * Attempts to connect at the specified address and port. - */ -bool SimpleTCPClientSocket::Connect(const char *inServerAddress, const char *inServerPort) -{ - bool theReturn = false; - ADDRINFO theHints; - ADDRINFO *theAddrInfo = NULL; - ADDRINFO *theAddrInfoPtr = NULL; - - memset(&theHints, 0, sizeof(theHints)); - theHints.ai_family = PF_INET; - theHints.ai_socktype = SOCK_STREAM; - - if (getaddrinfo(inServerAddress, inServerPort, &theHints, &theAddrInfo) == 0) { - for (theAddrInfoPtr = theAddrInfo; theAddrInfoPtr != NULL; - theAddrInfoPtr = theAddrInfoPtr->ai_next) { - if ((theAddrInfoPtr->ai_family == PF_INET) - || (theAddrInfoPtr->ai_family == PF_INET6)) // only want PF_INET or PF_INET6 - { - m_ClientSocket = socket(theAddrInfoPtr->ai_family, theAddrInfoPtr->ai_socktype, - theAddrInfoPtr->ai_protocol); - - if (m_ClientSocket != INVALID_SOCKET) { - if (theAddrInfoPtr->ai_socktype == SOCK_STREAM) { - if (connect(m_ClientSocket, theAddrInfoPtr->ai_addr, - theAddrInfoPtr->ai_addrlen) - == 0) { -// Set this up to be a non-blocking socket -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - int theFlags = fcntl(m_ClientSocket, F_GETFL, 0); - fcntl(m_ClientSocket, F_SETFL, theFlags | O_NONBLOCK); -#endif - -#ifdef _PCPLATFORM - u_long theBlockMode = 1; - ioctlsocket(m_ClientSocket, FIONBIO, &theBlockMode); -#endif - - theReturn = true; - break; - } - - // Connect failed - closesocket(m_ClientSocket); - } - } - } - } - } - - freeaddrinfo(theAddrInfo); - return theReturn; -} - -//============================================================================== -/** - * Disconnect and closes the TCP connection. - */ -void SimpleTCPClientSocket::Disconnect() -{ - shutdown(m_ClientSocket, SD_BOTH); - closesocket(m_ClientSocket); - m_BytesRead = 0; - m_ClientSocket = 0; -} - -//============================================================================== -/** - * Receives a data packet from the socket. - * If m_WaitForFull is true, Recv will always return 0 until it reads m_BufferSize - * bytes. - * Else, it will return the number of bytes read (if any) per call. - */ -long SimpleTCPClientSocket::Recv() -{ - long theReturnValue = 0; - - if (m_WaitForFull) { - theReturnValue = recv(m_ClientSocket, m_Data + m_BytesRead, m_BufferSize - m_BytesRead, 0); - - if (theReturnValue > 0) - m_BytesRead += theReturnValue; - - if (m_BytesRead < m_BufferSize) - theReturnValue = 0; - else { - m_BytesRead = 0; - theReturnValue = m_BufferSize; - } - } else { - theReturnValue = recv(m_ClientSocket, m_Data, m_BufferSize, 0); - if (theReturnValue == SOCKET_ERROR) - theReturnValue = 0; - } - - return theReturnValue; -} - -//============================================================================== -/** - * Sends a data packet to the socket. - * If m_WaitForFull is true, Send will always return 0 until it receives m_BufferSize - * bytes. - * Else, it will return the number of bytes sent (if any) per call. - */ -long SimpleTCPClientSocket::Send() -{ - long theReturnValue = 0; - - if (m_WaitForFull) { - theReturnValue = send(m_ClientSocket, m_Data + m_BytesSent, m_BufferSize - m_BytesSent, 0); - - if (theReturnValue > 0) - m_BytesSent += theReturnValue; - - if (m_BytesSent < m_BufferSize) - theReturnValue = 0; - else { - m_BytesSent = 0; - theReturnValue = m_BufferSize; - } - } else { - theReturnValue = send(m_ClientSocket, m_Data, m_BufferSize, 0); - if (theReturnValue == SOCKET_ERROR) - theReturnValue = 0; - } - - return theReturnValue; -} diff --git a/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.h b/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.h deleted file mode 100644 index c320f7fd..00000000 --- a/src/Runtime/Source/viewer/perflog/SimpleTCPClientSocket.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#pragma once - -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) -#define SOCKET int -#endif - -#ifdef _PCPLATFORM -#include <winsock2.h> -#include <ws2tcpip.h> -#endif - -//============================================================================== -// Creates a TCP socket to an address and port. -// Can return either fixed sized packets or variable sized ones. -//============================================================================== -class SimpleTCPClientSocket -{ -public: - SimpleTCPClientSocket(long inBufferSize, bool inWaitForFull); - ~SimpleTCPClientSocket(); - -public: - static bool Initialize(); - static void DeInitialize(); - - // Client side - bool Connect(const char *inServerAddress, const char *inServerPort); - void Disconnect(); - - // General - long Recv(); - long Send(); - - // operator char*( ){ return m_Data; } - void *GetData() { return m_Data; } - -protected: - SOCKET m_ClientSocket; - char *m_Data; - long m_BytesRead; - long m_BytesSent; - const long m_BufferSize; - bool m_WaitForFull; -}; diff --git a/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.cpp b/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.cpp deleted file mode 100644 index 44202739..00000000 --- a/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> - -#define ADDRINFO struct addrinfo -#define INVALID_SOCKET -1 -#define closesocket close -#define SD_BOTH SHUT_RDWR -#define SOCKET_ERROR -1 - -#endif - -#include "SimpleTCPServerSocket.h" - -//============================================================================== -/** - * CTOR - * Accepts a buffer size for internal storage and a flag to indicate if - * Recv should return fixed sized packets or not. - */ -SimpleTCPServerSocket::SimpleTCPServerSocket(long inBufferSize, bool inWaitForFull) - : m_ServerSocket(NULL) - , m_ClientSocket(NULL) - , m_Data(NULL) - , m_BytesRead(0) - , m_BytesSent(0) - , m_BufferSize(inBufferSize) - , m_WaitForFull(inWaitForFull) - , m_Initialized(false) -{ - m_Data = new char[m_BufferSize]; -} - -//============================================================================== -/** - * DTOR - */ -SimpleTCPServerSocket::~SimpleTCPServerSocket() -{ - if (m_ClientSocket) - Disconnect(); - - delete[] m_Data; -} - -//============================================================================== -/** - * Initializes TCP communications. - * Needs to be called once per app. - */ -bool SimpleTCPServerSocket::Initialize() -{ -#ifdef _PCPLATFORM - WSADATA theWsaData; - - if (WSAStartup(WINSOCK_VERSION, &theWsaData)) { - // WSAStartup failed - return false; - } -#endif - return true; -} - -//============================================================================== -/** - * Deinitializes TCP communications. - * Needs to be called once per app. - */ -void SimpleTCPServerSocket::DeInitialize() -{ -#ifdef _PCPLATFORM - WSACleanup(); -#endif -} - -//============================================================================== -/** - * Creates server socket, bind it and listen for incoming connection from a client. - */ -bool SimpleTCPServerSocket::Accept(const char *inServerAddress /*=NULL*/, - unsigned short inServerPort /*=0*/) -{ - bool theReturn = false; - struct sockaddr_in sockaddrServer; - struct sockaddr_in sockaddrClient; - - if (!m_Initialized) { - /* Create the TCP socket */ - if ((m_ServerSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) != INVALID_SOCKET) { - /* Construct the server sockaddr_in structure */ - memset(&sockaddrServer, 0, sizeof(sockaddrServer)); /* Clear struct */ - sockaddrServer.sin_family = AF_INET; /* Internet/IP */ - sockaddrServer.sin_addr.s_addr = htonl(INADDR_ANY); /* Incoming addr */ - sockaddrServer.sin_port = htons(inServerPort); /* server port */ - - /* Bind the server socket */ - if (bind(m_ServerSocket, (struct sockaddr *)&sockaddrServer, sizeof(sockaddrServer)) - == 0) - m_Initialized = true; - } - } - - /* Listen on the server socket */ - if (listen(m_ServerSocket, 1) == 0) { - socklen_t theClientLen = sizeof(sockaddrClient); - /* Wait for client connection */ - if ((m_ClientSocket = - accept(m_ServerSocket, (struct sockaddr *)&sockaddrClient, &theClientLen)) - == 0) { - SetNonBlocking(m_ClientSocket); - theReturn = true; - } - } - - return theReturn; -} - -//============================================================================== -/** - * Sets socket to non blocking state - */ -bool SimpleTCPServerSocket::SetNonBlocking(SOCKET inSocket) -{ -// Set this up to be a non-blocking socket -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - int theFlags = fcntl(inSocket, F_GETFL, 0); - return fcntl(m_ClientSocket, F_SETFL, theFlags | O_NONBLOCK) == 0; -#endif - -#ifdef _PCPLATFORM - u_long theBlockMode = 1; - return ioctlsocket(inSocket, FIONBIO, &theBlockMode) == 0; -#endif -} - -//============================================================================== -/** - * Disconnect and closes the TCP connection. - */ -void SimpleTCPServerSocket::Disconnect(bool inShutdown /*= false*/) -{ - shutdown(m_ClientSocket, SD_BOTH); - closesocket(m_ClientSocket); - m_BytesRead = 0; - m_BytesSent = 0; - m_ClientSocket = 0; - - if (inShutdown) { - shutdown(m_ServerSocket, SD_BOTH); - closesocket(m_ServerSocket); - m_ServerSocket = 0; - } -} - -//============================================================================== -/** - * Receives a data packet from the socket. - * If m_WaitForFull is true, Recv will always return 0 until it reads m_BufferSize - * bytes. - * Else, it will return the number of bytes read (if any) per call. - */ -long SimpleTCPServerSocket::Recv() -{ - long theReturnValue = 0; - - if (m_WaitForFull) { - theReturnValue = recv(m_ClientSocket, m_Data + m_BytesRead, m_BufferSize - m_BytesRead, 0); - - if (theReturnValue > 0) - m_BytesRead += theReturnValue; - - if (m_BytesRead < m_BufferSize) - theReturnValue = 0; - else { - m_BytesRead = 0; - theReturnValue = m_BufferSize; - } - } else { - theReturnValue = recv(m_ClientSocket, m_Data, m_BufferSize, 0); - if (theReturnValue == SOCKET_ERROR) - theReturnValue = 0; - } - - return theReturnValue; -} - -//============================================================================== -/** - * Sends a data packet to the socket. - * If m_WaitForFull is true, Send will always return 0 until it receives m_BufferSize - * bytes. - * Else, it will return the number of bytes sent (if any) per call. - */ -long SimpleTCPServerSocket::Send() -{ - long theReturnValue = 0; - - if (m_WaitForFull) { - theReturnValue = send(m_ClientSocket, m_Data + m_BytesSent, m_BufferSize - m_BytesSent, 0); - - if (theReturnValue > 0) - m_BytesSent += theReturnValue; - - if (m_BytesSent < m_BufferSize) - theReturnValue = 0; - else { - m_BytesSent = 0; - theReturnValue = m_BufferSize; - } - } else { - theReturnValue = send(m_ClientSocket, m_Data, m_BufferSize, 0); - if (theReturnValue == SOCKET_ERROR) - theReturnValue = 0; - } - - return theReturnValue; -} diff --git a/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.h b/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.h deleted file mode 100644 index 565dd736..00000000 --- a/src/Runtime/Source/viewer/perflog/SimpleTCPServerSocket.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#pragma once - -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) -#define SOCKET int -#endif - -#ifdef _PCPLATFORM -#include <winsock2.h> -#include <ws2tcpip.h> -#endif - -//============================================================================== -// Creates a TCP socket to an address and port. -// Can return either fixed sized packets or variable sized ones. -//============================================================================== -class SimpleTCPServerSocket -{ -public: - SimpleTCPServerSocket(long inBufferSize, bool inWaitForFull); - ~SimpleTCPServerSocket(); - -public: - static bool Initialize(); - static void DeInitialize(); - - // Client side - // bool Connect( const char* inServerAddress, const char* inServerPort ); - void Disconnect(bool inShutdown = false); - - bool Accept(const char *inServerAddress = 0, unsigned short inServerPort = 0); - - // General - long Recv(); - long Send(); - - // operator void*( ){ return m_Data; } - void *GetData() { return m_Data; } - -protected: - bool SetNonBlocking(SOCKET inSocket); - -protected: - SOCKET m_ServerSocket; - SOCKET m_ClientSocket; - char *m_Data; - long m_BytesRead; - long m_BytesSent; - const long m_BufferSize; - bool m_WaitForFull; - bool m_Initialized; -}; diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.cpp b/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.cpp deleted file mode 100644 index a8be5b27..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#include "TCPPerfLogClient.h" -#include "Qt3DSMacros.h" -#include "Qt3DSPlatformSpecific.h" -#include <stdio.h> -#include <string.h> - -//============================================================================== -// Statics -//============================================================================== -static TCPPerfLogClient *s_PerfLogClient = NULL; -static SPerfLogDataExtra s_LogDataExtra = { 0 }; -static const KDust s_OneSec = 1000000000; - -//============================================================================== -/** - * Extern function to create and initialize the TCPPerfLogClient. - */ -int InitializePerfLogClient(const char *inServerAddress, const char *inPort, KDust inLogFreqMsec, - const char *inLocalLogFilename) -{ - int theReturn = 1; - - if (!s_PerfLogClient) { - s_PerfLogClient = - new TCPPerfLogClient(inServerAddress, inPort, inLogFreqMsec, inLocalLogFilename); - theReturn = s_PerfLogClient->IsConnected() || s_PerfLogClient->IsLocal(); - } - - return theReturn; -} - -void PerfLogMarkBegin(KDust inCurrentTimeMsec) -{ - if (s_PerfLogClient) - s_PerfLogClient->MarkLogBegin(inCurrentTimeMsec); -} - -void PerfLogMarkEnd(KDust inCurrentTimeMsec) -{ - if (s_PerfLogClient) - s_PerfLogClient->MarkLogEnd(inCurrentTimeMsec); -} - -void InitializeNVPerfMon(EGLDisplay inDisplay) -{ - if (s_PerfLogClient) - s_PerfLogClient->InitializeNVPerfMon(inDisplay); -} - -void CleanupPerfLogClient(EGLDisplay inDisplay) -{ - if (s_PerfLogClient) - s_PerfLogClient->CleanupPerfLogClient(inDisplay); - - delete s_PerfLogClient; -} - -void PerfLogGetShortDisplay(char *outMessageBuffer) -{ - if (s_PerfLogClient) - s_PerfLogClient->GetShortDisplay(outMessageBuffer); -} - -//============================================================================== -/** - * Extern function to send a log given a timestamp and the currently measured - * FPS - */ -void PerfLogSend(unsigned long inTimeStamp, float inFPS) -{ - if (s_PerfLogClient) - s_PerfLogClient->SendLog(inTimeStamp, inFPS); -} - -//============================================================================== -/** - * Extern function to set string data into the log packet. - */ -void PerfLogSetStringData(const char *inStringData) -{ - if (s_PerfLogClient) - s_PerfLogClient->SetStringData(inStringData); -} - -//============================================================================== -/** - * CTOR - * Attempts to make a connection to a specified server address and port. - */ -TCPPerfLogClient::TCPPerfLogClient(const char *inServerAddress, const char *inServerPort, - KDust inLogFreqUSec, const char *inLocalLogFilename) - : m_Socket(sizeof(SPerfLogData), true) - , m_ProcMeminfo(NULL) - , m_ProcStatinfo(NULL) - , m_NvRmHandle(NULL) - , m_Connected(false) - , m_SendLog(false) - , m_LocalLogFile(NULL) - , m_RequiredPasses(1) - , m_CurrentPass(0) - , m_FrameCount(0) - , m_LogFreq(inLogFreqUSec) - , m_LastLogTime(0) - , m_LastExtraLogTime(0) - , m_NVPerfMonitor(NULL) - , m_NVGPUIdleCounter(NULL) -{ - //::memset( &m_Data, 0, sizeof( m_Data) ); - m_Connected = m_Socket.Connect(inServerAddress, inServerPort); - -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - // Open the meminfo procfs - m_ProcMeminfo = ::fopen("/proc/meminfo", "r"); - ::setvbuf(m_ProcMeminfo, NULL, _IONBF, 0); - - // Open the stat procfs - m_ProcStatinfo = ::fopen("/proc/stat", "r"); - ::setvbuf(m_ProcStatinfo, NULL, _IONBF, 0); -#endif - -#ifdef _TEGRA_LINUX - // Get a handle into vrm - NvRmOpen(m_NvRmHandle, 0); - - // Activate DFS so that we can retrieve the EMC utilization - if (NvRmDfsSetState(m_NvRmHandle, NvRmDfsRunState_ClosedLoop) != 0) - kdLogMessage("\nUnable to activate DFS"); -#endif - - if (inLocalLogFilename) - m_LocalLogFile = ::fopen(inLocalLogFilename, "w"); -} - -//============================================================================== -/** - * DTOR - * Closes opened handles. - */ -TCPPerfLogClient::~TCPPerfLogClient() -{ -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - fclose(m_ProcMeminfo); - fclose(m_ProcStatinfo); -#endif - -#ifdef _TEGRA_LINUX - NvRmClose(m_NvRmHandle); -#endif - m_Socket.Disconnect(); - - if (m_LocalLogFile) - ::fclose(m_LocalLogFile); -} - -//============================================================================== -/** - * Marks the beginning of perf logging. - */ -void TCPPerfLogClient::MarkLogBegin(KDust inCurrentTime) -{ - if (m_LogFreq > 0) { - if ((inCurrentTime - m_LastLogTime) > m_LogFreq) { - m_SendLog = true; // Signal to initiate logging (might required a few frames before log - // data is fully captured) - - // Starts the NV perf monitor for this frame - if (m_NVPerfMonitor) - m_NVPerfMonFuncs.eglPerfMonitorBeginExperimentNV(); - } - - if (m_SendLog) { - if (m_NVPerfMonitor) - m_NVPerfMonFuncs.eglPerfMonitorBeginPassNV(m_CurrentPass % m_RequiredPasses); - } - - if ((inCurrentTime - m_LastExtraLogTime) > s_OneSec) { - SPerfLogData *theData = static_cast<SPerfLogData *>(m_Socket.GetData()); - s_LogDataExtra.m_MinFPS = s_LogDataExtra.m_MaxFPS = theData->m_FPS; - s_LogDataExtra.m_MinCPULoad = s_LogDataExtra.m_MaxCPULoad = theData->m_CPULoad; - s_LogDataExtra.m_MinGPULoad = s_LogDataExtra.m_MaxGPULoad = theData->m_GPULoad; - m_LastExtraLogTime = inCurrentTime; - } - } -} - -//============================================================================== -/** - * Marks the end of perf logging. - */ -void TCPPerfLogClient::MarkLogEnd(KDust inCurrentTime) -{ - ++m_FrameCount; - - if (m_SendLog) { - if (m_NVPerfMonitor) { - // Signal the end of NV perf logging for this frame - m_NVPerfMonFuncs.eglPerfMonitorEndPassNV(); - ++m_CurrentPass; - } - - if ((m_CurrentPass % m_RequiredPasses == 0)) { - if (m_NVPerfMonitor) - m_NVPerfMonFuncs.eglPerfMonitorEndExperimentNV(); - - KDust theElaspedTime = inCurrentTime - m_LastLogTime; - SendLog(static_cast<unsigned long>(inCurrentTime / 1000000), - static_cast<float>(m_FrameCount / (theElaspedTime / 1000000000.0))); - m_LastLogTime = inCurrentTime; - m_FrameCount = 0; - m_SendLog = false; - } - } -} - -//============================================================================== -/** - * Sets timestamp and FPS into log and calls GatherStatistics. - * Sends log data into the socket. - */ -bool TCPPerfLogClient::SendLog(unsigned long inTimestamp, float inFPS) -{ - SPerfLogData *theData = static_cast<SPerfLogData *>(m_Socket.GetData()); - theData->m_Timestamp = inTimestamp; - theData->m_FPS = inFPS; - GatherStatistics(theData); - - s_LogDataExtra.m_MinFPS = Q3DStudio::Q3DStudio_min(inFPS, s_LogDataExtra.m_MinFPS); - s_LogDataExtra.m_MaxFPS = Q3DStudio::Q3DStudio_max(inFPS, s_LogDataExtra.m_MaxFPS); - - s_LogDataExtra.m_MinCPULoad = - Q3DStudio::Q3DStudio_min(theData->m_CPULoad, s_LogDataExtra.m_MinCPULoad); - s_LogDataExtra.m_MaxCPULoad = - Q3DStudio::Q3DStudio_max(theData->m_CPULoad, s_LogDataExtra.m_MaxCPULoad); - - s_LogDataExtra.m_MinGPULoad = - Q3DStudio::Q3DStudio_min(theData->m_GPULoad, s_LogDataExtra.m_MinGPULoad); - s_LogDataExtra.m_MaxGPULoad = - Q3DStudio::Q3DStudio_max(theData->m_GPULoad, s_LogDataExtra.m_MaxGPULoad); - - bool theResult = false; - - if (m_LocalLogFile) - theResult |= ::fputs(FormatPerfLogData(theData), m_LocalLogFile) > 0; - - if (IsConnected()) - theResult |= m_Socket.Send() > 0; - - return theResult; -} - -//============================================================================== -/** - * Sets string data into the next log packet to be sent. - */ -void TCPPerfLogClient::SetStringData(const char *inStringData) -{ - SPerfLogData *theData = static_cast<SPerfLogData *>(m_Socket.GetData()); - ::strcpy(theData->m_StringData, inStringData); -} - -//============================================================================== -/** - * Obtain memory usage using meminfo procfs. - */ -void TCPPerfLogClient::GetCPUMemoryUsage(unsigned long &outUsage) -{ - unsigned long theTotalMem = 0; - unsigned long theFreeMem = 0; - -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - rewind(m_ProcMeminfo); - fflush(m_ProcMeminfo); - - fscanf(m_ProcMeminfo, "MemTotal: %lu kB\nMemFree: %lu kB", &theTotalMem, &theFreeMem); -#endif - - outUsage = theTotalMem - theFreeMem; -} - -//============================================================================== -/** - * Obtain GPU memory usage from nvrm. - */ -void TCPPerfLogClient::GetGPUCarveoutUsage(unsigned long &outUsage) -{ - long theUsedCarveout = 0; - -#ifdef _TEGRA_LINUX - NvRmMemGetStat(NvRmMemStat_UsedCarveout, theUsedCarveout); -#endif - - outUsage = theUsedCarveout; -} - -//============================================================================== -/** - * Obtain CPU utilization from nvrm DFS. - */ -void TCPPerfLogClient::GetCPULoad(float &outPercentage) -{ -#ifdef _LINUXPLATFORM - // Get CPU load from /proc/stat - static SCPUInfo thePreviousInfo; - SCPUInfo theCurrentInfo; - - rewind(m_ProcStatinfo); - fflush(m_ProcStatinfo); - - // Read first line in /proc/stat which is a summary for all CPU cores on the system - fscanf(m_ProcStatinfo, "cpu %lu %lu %lu %lu %lu %lu %lu %lu", &theCurrentInfo.m_User, - &theCurrentInfo.m_Nice, &theCurrentInfo.m_System, &theCurrentInfo.m_Idle, - &theCurrentInfo.m_Wait, &theCurrentInfo.m_X, &theCurrentInfo.m_Y, &theCurrentInfo.m_Z); - - // Idle frames calculation - unsigned long theIdleFrames = theCurrentInfo.m_Idle - thePreviousInfo.m_Idle; - if (theIdleFrames < 0) - theIdleFrames = 0; // Appears to be a bug in 2.4.x kernels?? - - // Get the total number of timeslices - unsigned long theTotalFrames = (theCurrentInfo.m_User - thePreviousInfo.m_User) - + (theCurrentInfo.m_Nice - thePreviousInfo.m_Nice) - + (theCurrentInfo.m_System - thePreviousInfo.m_System) + theIdleFrames - + (theCurrentInfo.m_Wait - thePreviousInfo.m_Wait) - + (theCurrentInfo.m_X - thePreviousInfo.m_X) + (theCurrentInfo.m_Y - thePreviousInfo.m_Y) - + (theCurrentInfo.m_Z - thePreviousInfo.m_Z); - - if (theTotalFrames < 1) - theTotalFrames = 1; - - outPercentage = 1.0f - (theIdleFrames * 1.0f / theTotalFrames); - - thePreviousInfo = theCurrentInfo; // /proc/stat is an aggregation, so track this for the next - // time GetCPULoad is called - -#else - outPercentage = -.01f; -#endif -} - -//============================================================================== -/** - * Retrieve the GPU load performance counter - */ -void TCPPerfLogClient::GetGPULoad(long &outPercentage) -{ - EGLuint64NV theCycles = 0; - EGLuint64NV theGPUIdle = 0; - - if (m_NVPerfMonitor - && (m_NVPerfMonFuncs.eglGetPerfMarkerCounterNV(EGL_DEFAULT_PERFMARKER_NV, - m_NVGPUIdleCounter, &theGPUIdle, &theCycles) - == EGL_TRUE)) - outPercentage = static_cast<long>(100 - theGPUIdle); - else - outPercentage = 0; -} - -//============================================================================== -/** - * Retrieve the external memory controller load. - * DFS must be running first. - */ -void TCPPerfLogClient::GetEMCLoad(float &outPercentage) -{ -// Get CPU clock utilization from DFS -#ifdef _TEGRA_LINUX - NvRmDfsClockUsage theUsage; - ::memset(&theUsage, 0, sizeof(theUsage)); - if (NvRmDfsGetClockUtilization(m_NvRmHandle, NvRmDfsClockId_Emc, theUsage) == 0) - outPercentage = theUsage.AverageKHz * 1.0f / theUsage.CurrentKHz; - else -#endif - outPercentage = -0.01f; -} - -//============================================================================== -/** - * Helper function to gather various statistics. - */ -void TCPPerfLogClient::GatherStatistics(SPerfLogData *inLogData) -{ - // Grab and set statistics here - GetGPUCarveoutUsage(inLogData->m_GPUMemoryUsage); - GetCPUMemoryUsage(inLogData->m_CPUMemoryUsage); - GetCPULoad(inLogData->m_CPULoad); - GetGPULoad(inLogData->m_GPULoad); - GetEMCLoad(inLogData->m_EMCLoad); -} - -//============================================================================== -/** - * Initialize NV perf monitor counters - * Currently only one counter requested (GPU Idle) - */ -void TCPPerfLogClient::InitializeNVPerfMon(EGLDisplay inDisplay) -{ -#ifdef _TEGRA_LINUX - EGLPerfCounterNV theCounters[50]; - EGLint theReturnedCounterSize = 0; - - m_NVPerfMonitor = m_NVPerfMonFuncs.eglCreatePerfMonitorNV( - inDisplay, EGL_PERFMONITOR_HARDWARE_COUNTERS_BIT_NV); - m_NVPerfMonFuncs.eglMakeCurrentPerfMonitorNV(m_NVPerfMonitor); - - m_NVPerfMonFuncs.eglGetPerfCountersNV(m_NVPerfMonitor, theCounters, 100, - &theReturnedCounterSize); - for (long theIndex = 0; theIndex < theReturnedCounterSize; ++theIndex) { - const char *theCounterName = m_NVPerfMonFuncs.eglQueryPerfCounterStringNV( - m_NVPerfMonitor, theCounters[theIndex], EGL_COUNTER_NAME_NV); - - // Look for a counter with the name 'gpu idle' - if (Q3DStudio_stricmp(theCounterName, "GPU Idle") == 0) { - m_NVPerfMonFuncs.eglPerfMonitorAddCountersNV(1, &theCounters[theIndex]); - m_NVGPUIdleCounter = theCounters[theIndex]; - break; - } - } - - m_NVPerfMonFuncs.eglValidatePerfMonitorNV(&m_RequiredPasses); -#else - UNREFERENCED_PARAMETER(inDisplay); -#endif -} - -//============================================================================== -/** - * Deinitializes the NV perf monitor - */ -void TCPPerfLogClient::CleanupPerfLogClient(EGLDisplay inDisplay) -{ - if (m_NVPerfMonitor) - m_NVPerfMonFuncs.eglDestroyPerfMonitorNV(inDisplay, m_NVPerfMonitor); -} - -//============================================================================== -/** - * Retrieve a formatted output string containing performance statistics - */ -void TCPPerfLogClient::GetShortDisplay(char *inMessageBuffer) -{ - SPerfLogData *theData = static_cast<SPerfLogData *>(m_Socket.GetData()); - FormatPerfLogDataExtra(theData, &s_LogDataExtra, inMessageBuffer); -} diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.h b/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.h deleted file mode 100644 index 8a39dab6..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogClient.h +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#pragma once -//============================================================================== -// Includes -//============================================================================== -#include <stdio.h> -#include <EGL/egl.h> -#include "SimpleTCPClientSocket.h" -#include "TCPPerfLogCommon.h" -#include "TCPPerfLogClientStub.h" - -#ifdef _PCPLATFORM -#include <EGL/eglext.h> -#endif - -//============================================================================== -// Header definations copied from nvrm headers -//============================================================================== -extern "C" { - -/** - * NvRm heap statistics. See NvRmMemGetStat() for further details. - */ -enum NvRmMemStat { - /** - * Total number of bytes reserved for the carveout heap. - */ - NvRmMemStat_TotalCarveout = 1, - /** - * Number of bytes used in the carveout heap. - */ - NvRmMemStat_UsedCarveout, - /** - * Size of the largest free block in the carveout heap. - * Size can be less than the difference of total and - * used memory. - */ - NvRmMemStat_LargestFreeCarveoutBlock, - /** - * Total number of bytes in the GART heap. - */ - NvRmMemStat_TotalGart, - /** - * Number of bytes reserved from the GART heap. - */ - NvRmMemStat_UsedGart, - /** - * Size of the largest free block in GART heap. Size can be - * less than the difference of total and used memory. - */ - NvRmMemStat_LargestFreeGartBlock, -}; - -/** - * Defines SOC-wide clocks controlled by Dynamic Frequency Scaling (DFS) - * that can be targeted by Starvation and Busy hints - */ -enum NvRmDfsClockId { - /// Specifies CPU clock - NvRmDfsClockId_Cpu = 1, - - /// Specifies AVP clock - NvRmDfsClockId_Avp, - - /// Specifies System bus clock - NvRmDfsClockId_System, - - /// Specifies AHB bus clock - NvRmDfsClockId_Ahb, - - /// Specifies APB bus clock - NvRmDfsClockId_Apb, - - /// Specifies video pipe clock - NvRmDfsClockId_Vpipe, - - /// Specifies external memory controller clock - NvRmDfsClockId_Emc, -}; - -typedef unsigned long NvRmFreqKHz; - -/** - * Holds information on DFS clock domain utilization - */ -struct NvRmDfsClockUsage -{ - /// Minimum clock domain frequency - NvRmFreqKHz MinKHz; - - /// Maximum clock domain frequency - NvRmFreqKHz MaxKHz; - - /// Low corner frequency - current low boundary for DFS control algorithm. - /// Can be dynamically adjusted via APIs: NvRmDfsSetLowCorner() for all DFS - /// domains, NvRmDfsSetCpuEnvelope() for CPU, and NvRmDfsSetEmcEnvelope() - /// for EMC. When all DFS domains hit low corner, DFS stops waking up CPU - /// from low power state. - NvRmFreqKHz LowCornerKHz; - - /// High corner frequency - current high boundary for DFS control algorithm. - /// Can be dynamically adjusted via APIs: NvRmDfsSetCpuEnvelope() for Cpu, - /// NvRmDfsSetEmcEnvelope() for Emc, and NvRmDfsSetAvHighCorner() for other - // DFS domains. - NvRmFreqKHz HighCornerKHz; - - /// Current clock domain frequency - NvRmFreqKHz CurrentKHz; - - /// Average frequency of domain *activity* (not average frequency). For - /// domains that do not have activity monitors reported as unspecified. - NvRmFreqKHz AverageKHz; -}; - -/** - * Defines DFS manager run states - */ -enum NvRmDfsRunState { - /// DFS is in invalid, not initialized state - NvRmDfsRunState_Invalid = 0, - - /// DFS is disabled / not supported (terminal state) - NvRmDfsRunState_Disabled = 1, - - /// DFS is stopped - no automatic clock control. Starvation and Busy hints - /// are recorded but have no affect. - NvRmDfsRunState_Stopped, - - /// DFS is running in closed loop - full automatic control of SoC-wide - /// clocks based on clock activity measuremnets. Starvation and Busy hints - /// are functional as well. - NvRmDfsRunState_ClosedLoop, - - /// DFS is running in closed loop with profiling (can not be set on non - /// profiling build). - NvRmDfsRunState_ProfiledLoop, -}; - -typedef void *NvRmDeviceHandle; - -NvRmDfsRunState NvRmDfsGetState(NvRmDeviceHandle inRmDeviceHandle); -long NvRmDfsSetState(NvRmDeviceHandle inRmDeviceHandle, NvRmDfsRunState inDfsRunState); - -/** - * Gets information on DFS controlled clock utilization. If DFS is stopped - * or disabled the average frequency is always equal to current frequency. - * - * @param hRmDeviceHandle The RM device handle. - * @param ClockId The DFS ID of the clock targeted by this request. - * @param pClockInfo Output storage pointer for clock utilization information. - * - * @return NvSuccess if clock usage information is returned successfully. - */ -// NvError -// NvRmDfsGetClockUtilization( -// [in] NvRmDeviceHandle hRmDeviceHandle, -// [in] NvRmDfsClockId ClockId, -// [out] NvRmDfsClockUsage pClockUsage); -long NvRmDfsGetClockUtilization(NvRmDeviceHandle inRmDeviceHandle, NvRmDfsClockId inClockId, - NvRmDfsClockUsage &inClockUsage); - -/** - * Get a memory statistics value. - * - * Querying values may have an effect on system performance and may include - * processing, like heap traversal. - * - * @param Stat NvRmMemStat value that chooses the value to return. - * @param Result Result, if the call was successful. Otherwise value - * is not touched. - * @returns NvSuccess on success, NvError_BadParameter if Stat is - * not a valid value, NvError_NotSupported if the Stat is - * not available for some reason, or - * NvError_InsufficientMemory. - */ -// NvError -// NvRmMemGetStat([in] NvRmMemStat Stat, [out] NvS32 Result); -long NvRmMemGetStat(NvRmMemStat inStat, long &outResult); - -/** - * Opens the Resource Manager for a given device. - * - * Can be called multiple times for a given device. Subsequent - * calls will not necessarily return the same handle. Each call to - * NvRmOpen() must be paired with a corresponding call to NvRmClose(). - * - * Assert encountered in debug mode if DeviceId value is invalid. - * - * This call is not intended to perform any significant hardware - * initialization of the device; rather its primary purpose is to - * initialize RM's internal data structures that are involved in - * managing the device. - * - * @param pHandle the RM handle is stored here. - * @param DeviceId implementation-dependent value specifying the device - * to be opened. Currently must be set to zero. - * - * @retval NvSuccess Indicates that RM was successfully opened. - * @retval NvError_InsufficientMemory Indicates that RM was unable to allocate - * memory for its internal data structures. - */ -// NvError NvRmOpen( [out] NvRmDeviceHandle pHandle, [in] NvU32 DeviceId ); -long NvRmOpen(NvRmDeviceHandle &inHandle, unsigned long outDeviceId); - -/** - * Closes the Resource Manager for a given device. - * - * Each call to NvRmOpen() must be paired with a corresponding call - * to NvRmClose(). - * - * @param hDevice The RM handle. If hDevice is NULL, this API has no effect. - */ -// void NvRmClose( [in] NvRmDeviceHandle hDevice ); -void NvRmClose(void *inDevice); - -} // extern "C" - -// Represents information obtained from /proc/stat -typedef struct _SCPUInfo -{ - unsigned long m_User; // timeslices in userspace - unsigned long m_Nice; // timeslices for niced processed - unsigned long m_System; // timeslices in kernelspace - unsigned long m_Idle; // timeslices in idle - unsigned long m_Wait; // timeslices in wait - unsigned long m_X; // other timeslices - unsigned long m_Y; // other timeslices - unsigned long m_Z; // other timeslices - - _SCPUInfo() - : m_User(0) - , m_Nice(0) - , m_System(0) - , m_Idle(0) - , m_Wait(0) - , m_X(0) - , m_Y(0) - , m_Z(0) - { - } - -} SCPUInfo; - -//============================================================================== -// Utility function to grab EGL function pointers for NV perf monitor. -//============================================================================== -typedef struct _SNVPerfMonitorFuncs -{ - PFNEGLCREATEPERFMONITORNVPROC eglCreatePerfMonitorNV; - PFNEGLGETCURRENTPERFMONITORNVPROC eglGetCurrentPerfMonitorNV; - PFNEGLDESTROYPERFMONITORNVPROC eglDestroyPerfMonitorNV; - PFNEGLGETPERFCOUNTERSNVPROC eglGetPerfCountersNV; - PFNEGLQUERYPERFCOUNTERSTRINGNVPROC eglQueryPerfCounterStringNV; - PFNEGLPERFMONITORADDCOUNTERSNVPROC eglPerfMonitorAddCountersNV; - PFNEGLMAKECURRENTPERFMONITORNVPROC eglMakeCurrentPerfMonitorNV; - PFNEGLGETPERFMARKERCOUNTERNVPROC eglGetPerfMarkerCounterNV; - PFNEGLPERFMONITORBEGINEXPERIMENTNVPROC eglPerfMonitorBeginExperimentNV; - PFNEGLPERFMONITORENDEXPERIMENTNVPROC eglPerfMonitorEndExperimentNV; - PFNEGLPERFMONITORBEGINPASSNVPROC eglPerfMonitorBeginPassNV; - PFNEGLPERFMONITORENDPASSNVPROC eglPerfMonitorEndPassNV; - PFNEGLVALIDATEPERFMONITORNVPROC eglValidatePerfMonitorNV; - - _SNVPerfMonitorFuncs() - { - eglCreatePerfMonitorNV = - (PFNEGLCREATEPERFMONITORNVPROC)eglGetProcAddress("eglCreatePerfMonitorNV"); - eglDestroyPerfMonitorNV = - (PFNEGLDESTROYPERFMONITORNVPROC)eglGetProcAddress("eglDestroyPerfMonitorNV"); - eglGetCurrentPerfMonitorNV = - (PFNEGLGETCURRENTPERFMONITORNVPROC)eglGetProcAddress("eglGetCurrentPerfMonitorNV"); - eglGetPerfCountersNV = - (PFNEGLGETPERFCOUNTERSNVPROC)eglGetProcAddress("eglGetPerfCountersNV"); - eglQueryPerfCounterStringNV = - (PFNEGLQUERYPERFCOUNTERSTRINGNVPROC)eglGetProcAddress("eglQueryPerfCounterStringNV"); - eglPerfMonitorAddCountersNV = - (PFNEGLPERFMONITORADDCOUNTERSNVPROC)eglGetProcAddress("eglPerfMonitorAddCountersNV"); - eglMakeCurrentPerfMonitorNV = - (PFNEGLMAKECURRENTPERFMONITORNVPROC)eglGetProcAddress("eglMakeCurrentPerfMonitorNV"); - eglGetPerfMarkerCounterNV = - (PFNEGLGETPERFMARKERCOUNTERNVPROC)eglGetProcAddress("eglGetPerfMarkerCounterNV"); - eglPerfMonitorBeginExperimentNV = (PFNEGLPERFMONITORBEGINEXPERIMENTNVPROC)eglGetProcAddress( - "eglPerfMonitorBeginExperimentNV"); - eglPerfMonitorEndExperimentNV = (PFNEGLPERFMONITORENDEXPERIMENTNVPROC)eglGetProcAddress( - "eglPerfMonitorEndExperimentNV"); - eglPerfMonitorBeginPassNV = - (PFNEGLPERFMONITORBEGINPASSNVPROC)eglGetProcAddress("eglPerfMonitorBeginPassNV"); - eglPerfMonitorEndPassNV = - (PFNEGLPERFMONITORENDPASSNVPROC)eglGetProcAddress("eglPerfMonitorEndPassNV"); - eglValidatePerfMonitorNV = - (PFNEGLVALIDATEPERFMONITORNVPROC)eglGetProcAddress("eglValidatePerfMonitorNV"); - } - -} SNVPerfMonitorFuncs; - -//============================================================================== -// Handles gathering of performance statistics and sending them. -// Attempts to make a connection to a server that it will send data to. -//============================================================================== -class TCPPerfLogClient -{ -public: - TCPPerfLogClient(const char *inServerAddress, const char *inServerPort, KDust inLogFreqUSec, - const char *inLocalLogFilename); - ~TCPPerfLogClient(); - -public: - void MarkLogBegin(KDust inCurrentTime); - void MarkLogEnd(KDust inCurrentTime); - - bool SendLog(unsigned long inTimeStamp, float inFPS); - void SetStringData(const char *inStringData); - bool IsConnected() { return m_Connected; } - bool IsLocal() { return m_LocalLogFile != NULL; } - void InitializeNVPerfMon(EGLDisplay inDisplay); - void CleanupPerfLogClient(EGLDisplay inDisplay); - void GetShortDisplay(char *inMessageBuffer); - -protected: - void GatherStatistics(SPerfLogData *inLogData); - void GetCPUMemoryUsage(unsigned long &outUsage); - void GetGPUCarveoutUsage(unsigned long &outUsage); - void GetCPULoad(float &outPercentage); - void GetGPULoad(long &outPercentage); - void GetEMCLoad(float &outPercentage); - void GetGPUWaits(long &outPercentage); - -protected: - SimpleTCPClientSocket m_Socket; - FILE *m_ProcMeminfo; - FILE *m_ProcStatinfo; - void *m_NvRmHandle; - bool m_Connected; - bool m_SendLog; - FILE *m_LocalLogFile; - - EGLint m_RequiredPasses; - EGLint m_CurrentPass; - - long m_FrameCount; - KDust m_LogFreq; - KDust m_LastLogTime; - KDust m_LastExtraLogTime; - - const SNVPerfMonitorFuncs m_NVPerfMonFuncs; - EGLPerfMonitorNV m_NVPerfMonitor; - EGLPerfCounterNV m_NVGPUIdleCounter; -}; diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogClientStub.h b/src/Runtime/Source/viewer/perflog/TCPPerfLogClientStub.h deleted file mode 100644 index 2b6c0975..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogClientStub.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#pragma once - -//============================================================================== -// Includes -//============================================================================== - -//============================================================================== -// Extern interfaces -//============================================================================== - -#ifdef __cplusplus -extern "C" { -#endif - -int InitializePerfLogClient(const char *inServerAddress, const char *inPort, KDust inLogFreqMsec, - const char *inLocalLogFilename); -void InitializeNVPerfMon(EGLDisplay inDisplay); -void CleanupPerfLogClient(EGLDisplay inDisplay); - -void PerfLogMarkBegin(KDust inCurrentTimeMsec); -void PerfLogMarkEnd(KDust inCurrentTimeMsec); -void PerfLogSend(unsigned long inTimeStamp, float inFPS); -void PerfLogSetStringData(const char *inStringData); -void PerfLogGetShortDisplay(char *outMessageBuffer); - -#ifdef __cplusplus -} -#endif diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogCommon.h b/src/Runtime/Source/viewer/perflog/TCPPerfLogCommon.h deleted file mode 100644 index 23bc58f2..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogCommon.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#include <stdio.h> - -//============================================================================== -// Structs -//============================================================================== -typedef struct _SPerfLogData -{ - unsigned long m_Timestamp; - float m_FPS; - unsigned long m_GPUMemoryUsage; - unsigned long m_CPUMemoryUsage; - float m_CPULoad; - long m_GPULoad; - float m_EMCLoad; - char m_StringData[128]; -} SPerfLogData; - -typedef struct _SPerfLogDataExtra -{ - float m_MinFPS; - float m_MaxFPS; - float m_MinCPULoad; - float m_MaxCPULoad; - long m_MinGPULoad; - long m_MaxGPULoad; -} SPerfLogDataExtra; - -//============================================================================== -/** - * Formats SPerfLogData into a user readable form. - */ -const char *FormatPerfLogData(const SPerfLogData *inData) -{ - static char theMessageBuffer[256]; - theMessageBuffer[0] = 0; - - static unsigned long thePrevTimestamp = 0; - static unsigned long theTimestampDiff = 0; - if (thePrevTimestamp != 0) - theTimestampDiff = inData->m_Timestamp - thePrevTimestamp; - - ::sprintf(theMessageBuffer, "Timestamp: %lu\tTimediff: %lu\tFPS: %.2f\tUsecase: " - "%s\tGPUMemoryUsage: %lu\tCPUMemoryUsage: %lu\tCPULoad: " - "%.2f\tGPULoad: %ld\tEMCLoad: %.2f\n", - inData->m_Timestamp, theTimestampDiff, inData->m_FPS, inData->m_StringData, - inData->m_GPUMemoryUsage, inData->m_CPUMemoryUsage, inData->m_CPULoad * 100, - inData->m_GPULoad, inData->m_EMCLoad * 100); - - thePrevTimestamp = inData->m_Timestamp; - - return theMessageBuffer; -} - -//============================================================================== -/** - * Formats SPerfLogDataExtra into a user readable form. - */ -void FormatPerfLogDataExtra(const SPerfLogData *inData, const SPerfLogDataExtra *inExtraData, - char *inMessageBuffer) -{ - ::sprintf(inMessageBuffer, "FPS: %.0f/%.0f/%.0f CPU: %.0f/%.0f/%.0f GPU: %ld/%ld/%ld EMC: %.0f", - inData->m_FPS, inExtraData->m_MaxFPS, inExtraData->m_MinFPS, inData->m_CPULoad * 100, - inExtraData->m_MaxCPULoad * 100, inExtraData->m_MinCPULoad * 100, inData->m_GPULoad, - inExtraData->m_MaxGPULoad, inExtraData->m_MinGPULoad, inData->m_EMCLoad * 100); -} diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.cpp b/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.cpp deleted file mode 100644 index b62663b2..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Includes -//============================================================================== -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) -#include <termios.h> -#include <unistd.h> -#endif - -#ifdef _PCPLATFORM -#include <conio.h> -#endif - -#include <fcntl.h> -#include "TCPPerfLogServer.h" - -//============================================================================== -/** - * CTOR - * Sets up listening server at specificed address and port. - * Opens log file to be ready for writing. - */ -TCPPerfLogServer::TCPPerfLogServer(const char *inServerAddress, unsigned short inServerPort, - const char *inLogFilename) - : m_LogFileHandle(0) - , m_Socket(sizeof(SPerfLogData), true) -{ - m_LogFileHandle = ::fopen(inLogFilename, "w"); - m_Socket.Accept(inServerAddress, inServerPort); -} - -//============================================================================== -/** - * DTOR - * Closes log file and disconnects server. - */ -TCPPerfLogServer::~TCPPerfLogServer() -{ - ::fclose(m_LogFileHandle); - m_Socket.Disconnect(true); -} - -//============================================================================== -/** - * Checks for any received packets and write them into the log file - */ -const char *TCPPerfLogServer::Update() -{ - if (m_Socket.Recv() > 0) { - const char *theOutputMessage = Output(); - ::fputs(theOutputMessage, m_LogFileHandle); - return theOutputMessage; - } - - return NULL; -} - -//============================================================================== -/** - * Formats receieved data into a text string. - */ -const char *TCPPerfLogServer::Output() -{ - SPerfLogData *thePerfLogData = static_cast<SPerfLogData *>(m_Socket.GetData()); - - return FormatPerfLogData(thePerfLogData); -} - -//============================================================================== -/** - * Keyboard hittest for Linux - */ -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) -int kbhit(void) -{ - return 0; -} -#else -#define kbhit _kbhit -#endif - -//============================================================================== -/** - * Main - */ -int main(int argc, const char *argv[]) -{ - const char *theServerIP = "10.0.0.1"; - const char *theLogFile = "perf.log"; - if (argc > 1) - theServerIP = argv[1]; - - if (argc > 2) - theLogFile = argv[2]; - - SimpleTCPServerSocket::Initialize(); - - { - ::printf("\nLog file: %s", theLogFile); - ::printf("\nServer listening at: %s", theServerIP); - - ::printf("\nWaiting for client..."); - ::fflush(stdout); - TCPPerfLogServer theServer(theServerIP, 9997, theLogFile); - ::printf("\nClient connected..."); - ::fflush(stdout); - - while (true) { - const char *theReceivedMessage = theServer.Update(); - if (theReceivedMessage) - printf("\n%s", theReceivedMessage); - - if (kbhit()) { -#if defined(_LINUXPLATFORM) || defined(_INTEGRITYPLATFORM) - char theKey = getchar(); -#endif -#ifdef _PCPLATFORM - char theKey = (char)_getch(); -#endif - if (theKey == 'q') - break; - } - } - } - - SimpleTCPServerSocket::DeInitialize(); - return 0; -} diff --git a/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.h b/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.h deleted file mode 100644 index bfa6abcc..00000000 --- a/src/Runtime/Source/viewer/perflog/TCPPerfLogServer.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1993-2009 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#pragma once -//============================================================================== -// Includes -//============================================================================== -#include "SimpleTCPServerSocket.h" -#include "TCPPerfLogCommon.h" -#include <stdio.h> - -//============================================================================== -// Creates a polling server that listens for incoming log packets. -// Creates a write received log data into a file. -//============================================================================== -class TCPPerfLogServer -{ -public: - TCPPerfLogServer(const char *inServerAddress, unsigned short inServerPort, - const char *inLogFilename); - ~TCPPerfLogServer(); - - const char *Update(); - -protected: - const char *Output(); - -protected: - FILE *m_LogFileHandle; - SimpleTCPServerSocket m_Socket; -}; |