mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[host] added tracing class to help profile slow code points
This commit is contained in:
parent
db52a55b36
commit
16e804b068
@ -21,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
using namespace Capture;
|
using namespace Capture;
|
||||||
|
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
|
#include "TraceUtil.h"
|
||||||
|
|
||||||
DXGI::DXGI() :
|
DXGI::DXGI() :
|
||||||
m_options(NULL),
|
m_options(NULL),
|
||||||
@ -264,6 +265,7 @@ void DXGI::WaitForDesktop()
|
|||||||
|
|
||||||
GrabStatus DXGI::GrabFrame(FrameInfo & frame)
|
GrabStatus DXGI::GrabFrame(FrameInfo & frame)
|
||||||
{
|
{
|
||||||
|
TRACE;
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return GRAB_STATUS_ERROR;
|
return GRAB_STATUS_ERROR;
|
||||||
|
|
||||||
@ -446,7 +448,9 @@ GrabStatus DXGI::GrabFrame(FrameInfo & frame)
|
|||||||
frame.stride = m_mapping.RowPitch / 4;
|
frame.stride = m_mapping.RowPitch / 4;
|
||||||
unsigned int size = m_height * m_mapping.RowPitch;
|
unsigned int size = m_height * m_mapping.RowPitch;
|
||||||
|
|
||||||
|
TRACE_START("DXGI Memory Copy");
|
||||||
m_memcpy.Copy(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
|
m_memcpy.Copy(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
|
||||||
|
TRACE_END;
|
||||||
|
|
||||||
return GRAB_STATUS_OK;
|
return GRAB_STATUS_OK;
|
||||||
}
|
}
|
@ -25,6 +25,11 @@ OBJS = main.o \
|
|||||||
Service.o \
|
Service.o \
|
||||||
Capture/DXGI.o
|
Capture/DXGI.o
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_TRACING),1)
|
||||||
|
CFLAGS += -DENABLE_TRACING
|
||||||
|
OBJS += TraceUtil.o
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_CAPTURE_NVFBC),1)
|
ifeq ($(CONFIG_CAPTURE_NVFBC),1)
|
||||||
CFLAGS += -DCONFIG_CAPTURE_NVFBC=1 -I../vendor
|
CFLAGS += -DCONFIG_CAPTURE_NVFBC=1 -I../vendor
|
||||||
OBJS += Capture/NvFBC.o
|
OBJS += Capture/NvFBC.o
|
||||||
|
25
host/TraceUtil.cpp
Normal file
25
host/TraceUtil.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||||
|
Copyright (C) 2017 Geoffrey McRae <geoff@hostfission.com>
|
||||||
|
https://looking-glass.hostfission.com
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TraceUtil.h"
|
||||||
|
|
||||||
|
double TraceUtil::m_freq;
|
||||||
|
LARGE_INTEGER TraceUtil::m_last;
|
||||||
|
LARGE_INTEGER TraceUtil::m_start;
|
||||||
|
const char * TraceUtil::m_traceName;
|
79
host/TraceUtil.h
Normal file
79
host/TraceUtil.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||||
|
Copyright (C) 2017 Geoffrey McRae <geoff@hostfission.com>
|
||||||
|
https://looking-glass.hostfission.com
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "common/debug.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_TRACING
|
||||||
|
#define TRACE TraceUtil::Trace(__FUNCTION__, __LINE__)
|
||||||
|
#define TRACE_START(x) TraceUtil::TraceStart(x)
|
||||||
|
#define TRACE_END TraceUtil::TraceEnd()
|
||||||
|
#else
|
||||||
|
#define TRACE
|
||||||
|
#define TRACE_START(x)
|
||||||
|
#define TRACE_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TraceUtil
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static double m_freq;
|
||||||
|
static LARGE_INTEGER m_last;
|
||||||
|
static LARGE_INTEGER m_start;
|
||||||
|
static const char * m_traceName;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void Initialize()
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_TRACING
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
QueryPerformanceFrequency(&now);
|
||||||
|
m_freq = (double)now.QuadPart / 1000.0;
|
||||||
|
QueryPerformanceCounter(&m_last);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void Trace(const char * function, const unsigned int line)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
QueryPerformanceCounter(&now);
|
||||||
|
const double diff = (now.QuadPart - m_last.QuadPart) / m_freq;
|
||||||
|
m_last = now;
|
||||||
|
|
||||||
|
DEBUG_INFO("Trace [%8.4f] %s:%u", diff, function, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void TraceStart(const char * traceName)
|
||||||
|
{
|
||||||
|
QueryPerformanceCounter(&m_start);
|
||||||
|
m_traceName = traceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void TraceEnd()
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
QueryPerformanceCounter(&now);
|
||||||
|
const double diff = (now.QuadPart - m_start.QuadPart) / m_freq;
|
||||||
|
|
||||||
|
DEBUG_INFO("Trace [%8.4f] %s", diff, m_traceName);
|
||||||
|
}
|
||||||
|
};
|
@ -158,7 +158,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);DEBUG</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ENABLE_TRACING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -178,7 +178,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ENABLE_TRACING;CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -198,7 +198,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions);DEBUG</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ENABLE_TRACING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -218,7 +218,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ENABLE_TRACING;CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -337,6 +337,7 @@
|
|||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="MultiMemcpy.cpp" />
|
<ClCompile Include="MultiMemcpy.cpp" />
|
||||||
<ClCompile Include="Service.cpp" />
|
<ClCompile Include="Service.cpp" />
|
||||||
|
<ClCompile Include="TraceUtil.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CaptureFactory.h" />
|
<ClInclude Include="CaptureFactory.h" />
|
||||||
@ -347,6 +348,7 @@
|
|||||||
<ClInclude Include="ivshmem.h" />
|
<ClInclude Include="ivshmem.h" />
|
||||||
<ClInclude Include="MultiMemcpy.h" />
|
<ClInclude Include="MultiMemcpy.h" />
|
||||||
<ClInclude Include="Service.h" />
|
<ClInclude Include="Service.h" />
|
||||||
|
<ClInclude Include="TraceUtil.h" />
|
||||||
<ClInclude Include="Util.h" />
|
<ClInclude Include="Util.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<ClCompile Include="MultiMemcpy.cpp">
|
<ClCompile Include="MultiMemcpy.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="TraceUtil.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="ivshmem.h">
|
<ClInclude Include="ivshmem.h">
|
||||||
@ -74,5 +77,8 @@
|
|||||||
<ClInclude Include="MultiMemcpy.h">
|
<ClInclude Include="MultiMemcpy.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="TraceUtil.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -24,6 +24,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "vendor/getopt/getopt.h"
|
#include "vendor/getopt/getopt.h"
|
||||||
|
|
||||||
#include "CrashHandler.h"
|
#include "CrashHandler.h"
|
||||||
|
#include "TraceUtil.h"
|
||||||
#include "CaptureFactory.h"
|
#include "CaptureFactory.h"
|
||||||
#include "Service.h"
|
#include "Service.h"
|
||||||
|
|
||||||
@ -50,6 +51,8 @@ struct StartupArgs
|
|||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow)
|
||||||
{
|
{
|
||||||
CrashHandler::Initialize();
|
CrashHandler::Initialize();
|
||||||
|
TraceUtil::Initialize();
|
||||||
|
|
||||||
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
|
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
|
||||||
|
|
||||||
struct StartupArgs args;
|
struct StartupArgs args;
|
||||||
|
Loading…
Reference in New Issue
Block a user