Add wrapper around RGP interface to expose to replay drivers

This commit is contained in:
baldurk
2018-04-20 12:31:13 +01:00
parent b0f4aebaa9
commit d016aacb92
5 changed files with 329 additions and 2 deletions
+2
View File
@@ -100,11 +100,13 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="amd_isa_win32.cpp" />
<ClCompile Include="amd_rgp.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="amd_counters.h" />
<ClInclude Include="amd_isa.h" />
<ClInclude Include="amd_isa_devices.h" />
<ClInclude Include="amd_rgp.h" />
<ClInclude Include="official\DXExt\AmdDxExt.h" />
<ClInclude Include="official\DXExt\AmdDxExtApi.h" />
<ClInclude Include="official\DXExt\AmdDxExtIface.h" />
@@ -25,6 +25,9 @@
<Filter Include="official\RGA\Common">
<UniqueIdentifier>{47a6fd91-f76e-4faa-9e5c-4bb899be9796}</UniqueIdentifier>
</Filter>
<Filter Include="RGP">
<UniqueIdentifier>{9977fd12-32d0-49d3-b20d-c38b0df2dc95}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="amd_counters.cpp">
@@ -42,6 +45,9 @@
<ClCompile Include="amd_isa_devices.cpp">
<Filter>ISA</Filter>
</ClCompile>
<ClCompile Include="amd_rgp.cpp">
<Filter>RGP</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="amd_counters.h">
@@ -107,5 +113,6 @@
<ClInclude Include="official\GPUPerfAPI\Include\GPUPerfAPI-VK.h">
<Filter>official\GPUPerfAPI</Filter>
</ClInclude>
<ClInclude Include="amd_rgp.h" />
</ItemGroup>
</Project>
+76 -2
View File
@@ -5,8 +5,82 @@ set(sources
amd_isa.h
amd_isa_devices.cpp
amd_isa_devices.h
amd_isa_posix.cpp)
amd_isa_posix.cpp
amd_rgp.cpp
amd_rgp.h)
set(rgp_sources
official/RGP/DevDriverAPI/RGPClientInProcessModel.cpp
official/RGP/DevDriverAPI/RGPClientInProcessModel.h
official/RGP/DevDriverAPI/DevDriverAPI.cpp
official/RGP/DevDriverAPI/DevDriverAPI.h)
set(dev_driver_sources
official/RGP/DevDriverComponents/listener/ddListenerURIService.cpp
official/RGP/DevDriverComponents/listener/ddListenerURIService.h
official/RGP/DevDriverComponents/listener/hostMsgTransport.h
official/RGP/DevDriverComponents/listener/hostMsgTransport.cpp
official/RGP/DevDriverComponents/listener/listenerServer.h
official/RGP/DevDriverComponents/listener/listenerServer.cpp
official/RGP/DevDriverComponents/listener/transports/hostTransport.h
official/RGP/DevDriverComponents/listener/transports/hostTransport.cpp
official/RGP/DevDriverComponents/listener/routerCore.h
official/RGP/DevDriverComponents/listener/routerCore.cpp
official/RGP/DevDriverComponents/listener/listenerCore.h
official/RGP/DevDriverComponents/listener/listenerCore.cpp
official/RGP/DevDriverComponents/listener/transportThread.h
official/RGP/DevDriverComponents/listener/transportThread.cpp
official/RGP/DevDriverComponents/listener/transports/abstractListenerTransport.h
official/RGP/DevDriverComponents/listener/transports/socketTransport.h
official/RGP/DevDriverComponents/listener/transports/socketTransport.cpp
official/RGP/DevDriverComponents/listener/clientmanagers/abstractClientManager.h
official/RGP/DevDriverComponents/listener/clientmanagers/listenerClientManager.h
official/RGP/DevDriverComponents/listener/clientmanagers/listenerClientManager.cpp
official/RGP/DevDriverComponents/src/baseProtocolClient.cpp
official/RGP/DevDriverComponents/src/baseProtocolServer.cpp
official/RGP/DevDriverComponents/src/ddClientURIService.cpp
official/RGP/DevDriverComponents/src/ddClientURIService.h
official/RGP/DevDriverComponents/src/ddSocket.h
official/RGP/DevDriverComponents/src/ddTransferManager.cpp
official/RGP/DevDriverComponents/src/devDriverClient.cpp
official/RGP/DevDriverComponents/src/devDriverServer.cpp
official/RGP/DevDriverComponents/src/messageChannel.h
official/RGP/DevDriverComponents/src/messageChannel.inl
official/RGP/DevDriverComponents/src/session.h
official/RGP/DevDriverComponents/src/session.cpp
official/RGP/DevDriverComponents/src/sessionManager.h
official/RGP/DevDriverComponents/src/sessionManager.cpp
official/RGP/DevDriverComponents/src/socketMsgTransport.h
official/RGP/DevDriverComponents/src/socketMsgTransport.cpp
official/RGP/DevDriverComponents/src/protocols/ddGpuCrashDumpClient.cpp
official/RGP/DevDriverComponents/src/protocols/ddGpuCrashDumpServer.cpp
official/RGP/DevDriverComponents/src/protocols/ddTransferClient.cpp
official/RGP/DevDriverComponents/src/protocols/ddTransferServer.cpp
official/RGP/DevDriverComponents/src/protocols/ddURIClient.cpp
official/RGP/DevDriverComponents/src/protocols/ddURIServer.cpp
official/RGP/DevDriverComponents/src/protocols/ddURIServer.h
official/RGP/DevDriverComponents/src/protocols/driverControlClient.cpp
official/RGP/DevDriverComponents/src/protocols/driverControlServer.cpp
official/RGP/DevDriverComponents/src/protocols/loggingClient.cpp
official/RGP/DevDriverComponents/src/protocols/loggingServer.cpp
official/RGP/DevDriverComponents/src/protocols/rgpClient.cpp
official/RGP/DevDriverComponents/src/protocols/rgpServer.cpp
official/RGP/DevDriverComponents/src/protocols/settingsClient.cpp
official/RGP/DevDriverComponents/src/protocols/settingsServer.cpp
official/RGP//DevDriverComponents/src/posix/ddPosixPlatform.cpp
official/RGP//DevDriverComponents/src/posix/ddPosixSocket.cpp
)
set(include_dirs ${RDOC_INCLUDES})
if(UNIX AND NOT ANDROID AND NOT APPLE)
add_compile_options(-D_LINUX -DGPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION=30)
list(APPEND sources ${dev_driver_sources} ${rgp_sources})
list(APPEND include_dirs official/RGP/DevDriverComponents/inc)
endif()
add_library(rdoc_amd OBJECT ${sources})
target_compile_definitions(rdoc_amd ${RDOC_DEFINITIONS})
target_include_directories(rdoc_amd ${RDOC_INCLUDES})
target_include_directories(rdoc_amd ${include_dirs})
+190
View File
@@ -0,0 +1,190 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2018 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "amd_rgp.h"
#include "common/common.h"
#include "official/RGP/DevDriverAPI/DevDriverAPI.h"
uint64_t MakeTagFromMarker(const char *marker)
{
if(!marker)
return 0;
uint64_t ret = 0;
for(int i = 0; i < 7 && marker && marker[i]; i++)
ret |= uint64_t(marker[i]) << (i * 8);
return ret;
}
const char *AMDRGPControl::GetBeginMarker()
{
return "BeginRenderDocRGPCapture======";
}
const char *AMDRGPControl::GetEndMarker()
{
return "EndRenderDocRGPCapture======";
}
uint64_t AMDRGPControl::GetBeginTag()
{
return MakeTagFromMarker(GetBeginMarker());
}
uint64_t AMDRGPControl::GetEndTag()
{
return MakeTagFromMarker(GetEndMarker());
}
AMDRGPControl::AMDRGPControl()
{
m_RGPDispatchTable = new DevDriverAPI;
m_RGPDispatchTable->majorVersion = DEV_DRIVER_API_MAJOR_VERSION;
m_RGPDispatchTable->minorVersion = DEV_DRIVER_API_MINOR_VERSION;
m_RGPContext = NULL;
#if ENABLED(RDOC_WIN32) || ENABLED(RDOC_LINUX)
DevDriverStatus rgpStatus = DevDriverGetFuncTable(m_RGPDispatchTable);
if(rgpStatus == DEV_DRIVER_STATUS_SUCCESS)
{
DevDriverFeatures initOptions[] = {
{DEV_DRIVER_FEATURE_ENABLE_RGP, sizeof(DevDriverFeatureRGP)},
};
int numFeatures = sizeof(initOptions) / sizeof(initOptions[0]);
rgpStatus = m_RGPDispatchTable->DevDriverInit(initOptions, numFeatures, &m_RGPContext);
// check the driver version if initialization succeeded.
bool supportsInterop = false;
if(rgpStatus == DEV_DRIVER_STATUS_SUCCESS)
{
supportsInterop = DriverSupportsInterop();
}
// if initialization failed or driver doesn't support interop
if(supportsInterop == false)
{
if(m_RGPContext != NULL)
m_RGPDispatchTable->DevDriverFinish(m_RGPContext);
m_RGPContext = NULL;
}
}
else
#endif
{
m_RGPContext = NULL;
}
}
AMDRGPControl::~AMDRGPControl()
{
if(m_RGPContext != NULL)
m_RGPDispatchTable->DevDriverFinish(m_RGPContext);
delete m_RGPDispatchTable;
m_RGPContext = NULL;
m_RGPDispatchTable = NULL;
}
bool AMDRGPControl::Initialised()
{
return m_RGPContext != NULL;
}
bool AMDRGPControl::TriggerCapture(const std::string &path)
{
if(m_RGPContext == NULL)
return false;
// set up for capturing
RGPProfileOptions profileOptions = {};
profileOptions.m_pProfileFilePath = path.c_str();
profileOptions.m_beginFrameTerminatorTag = GetBeginTag();
profileOptions.m_endFrameTerminatorTag = GetEndTag();
profileOptions.m_pBeginFrameTerminatorString = GetBeginMarker();
profileOptions.m_pEndFrameTerminatorString = GetEndMarker();
DevDriverStatus result = m_RGPDispatchTable->TriggerRgpProfile(m_RGPContext, &profileOptions);
if(result == DEV_DRIVER_STATUS_SUCCESS)
return true;
else
return false;
}
bool AMDRGPControl::HasCapture()
{
if(m_RGPContext == NULL)
return false;
return m_RGPDispatchTable->IsRgpProfileCaptured(m_RGPContext) == DEV_DRIVER_STATUS_SUCCESS;
}
bool AMDRGPControl::DriverSupportsInterop()
{
// interop is supported on AMD driver version 18.10 or newer
if(m_RGPContext == NULL)
return false;
unsigned int majorVersion = 0;
unsigned int minorVersion = 0;
if(m_RGPDispatchTable->GetDriverVersion(m_RGPContext, majorVersion, minorVersion) ==
DEV_DRIVER_STATUS_SUCCESS)
{
if(majorVersion > 18 || (majorVersion == 18 && minorVersion >= 10))
{
return true;
}
}
return false;
}
#if ENABLED(ENABLE_UNIT_TESTS)
#undef None
#include "3rdparty/catch/catch.hpp"
TEST_CASE("Check that markers are distinct for begin and end", "[amd]")
{
std::string beginMark = AMDRGPControl::GetBeginMarker();
std::string endMark = AMDRGPControl::GetEndMarker();
CHECK(beginMark != endMark);
CHECK(beginMark != "");
CHECK(endMark != "");
uint64_t beginTag = AMDRGPControl::GetBeginTag();
uint64_t endTag = AMDRGPControl::GetEndTag();
CHECK(beginTag != endTag);
CHECK(beginTag != 0);
CHECK(endTag != 0);
}
#endif
+54
View File
@@ -0,0 +1,54 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2018 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
#include <string>
typedef void *DevDriverAPIContext;
struct DevDriverAPI;
class AMDRGPControl
{
public:
AMDRGPControl();
~AMDRGPControl();
bool Initialised();
bool TriggerCapture(const std::string &path);
bool HasCapture();
bool DriverSupportsInterop();
static const char *GetBeginMarker();
static const char *GetEndMarker();
static uint64_t GetBeginTag();
static uint64_t GetEndTag();
private:
DevDriverAPIContext m_RGPContext = NULL;
DevDriverAPI *m_RGPDispatchTable = NULL;
};