mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Extract plugin locating logic out of AMD ISA and reuse for counters
This commit is contained in:
@@ -85,6 +85,8 @@ set(sources
|
||||
core/replay_proxy.h
|
||||
core/android.cpp
|
||||
core/android.h
|
||||
core/plugins.cpp
|
||||
core/plugins.h
|
||||
core/resource_manager.cpp
|
||||
core/resource_manager.h
|
||||
core/socket_helpers.h
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 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 "core/plugins.h"
|
||||
#include "serialise/string_utils.h"
|
||||
|
||||
std::string LocatePluginFile(const std::string &path, const std::string &fileName)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
std::string exepath;
|
||||
FileIO::GetExecutableFilename(exepath);
|
||||
exepath = dirname(exepath);
|
||||
|
||||
std::vector<std::string> paths;
|
||||
|
||||
#if defined(RENDERDOC_PLUGINS_PATH)
|
||||
string customPath(RENDERDOC_PLUGINS_PATH);
|
||||
|
||||
if(FileIO::IsRelativePath(customPath))
|
||||
customPath = exepath + "/" + customPath;
|
||||
|
||||
paths.push_back(customPath);
|
||||
#endif
|
||||
|
||||
// windows installation
|
||||
paths.push_back(exepath + "/plugins");
|
||||
// linux installation
|
||||
paths.push_back(exepath + "/../share/renderdoc/plugins");
|
||||
// also search the appropriate OS-specific location in the root
|
||||
#if ENABLED(RDOC_WIN32) && ENABLED(RDOC_X64)
|
||||
paths.push_back(exepath + "/../../plugins-win64");
|
||||
#endif
|
||||
|
||||
#if ENABLED(RDOC_WIN32) && DISABLED(RDOC_X64)
|
||||
paths.push_back(exepath + "/../../plugins-win32");
|
||||
#endif
|
||||
|
||||
#if ENABLED(RDOC_LINUX)
|
||||
paths.push_back(exepath + "/../../plugins-linux64");
|
||||
#endif
|
||||
|
||||
// there is no standard path for local builds as we don't provide these plugins in the repository
|
||||
// directly. As a courtesy we search the root of the build, from the executable. The user can
|
||||
// always put the plugins folder relative to the exe where it would be in an installation too.
|
||||
paths.push_back(exepath + "/../../plugins");
|
||||
|
||||
// in future maybe we want to search a user-specific plugins folder? Like ~/.renderdoc/ on linux
|
||||
// or %APPDATA%/renderdoc on windows?
|
||||
|
||||
for(uint32_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
std::string check = paths[i] + "/" + path + "/" + fileName;
|
||||
if(FileIO::exists(check.c_str()))
|
||||
{
|
||||
ret = check;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't find it anywhere, just try running it directly in case it's in the PATH
|
||||
if(ret.empty())
|
||||
ret = fileName;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 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.
|
||||
******************************************************************************/
|
||||
|
||||
std::string LocatePluginFile(const std::string &path, const std::string &fileName);
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "amd_counters.h"
|
||||
#include <Windows.h>
|
||||
#include "common/common.h"
|
||||
#include "core/plugins.h"
|
||||
#include "official/GPUPerfAPI/Include/GPUPerfAPI.h"
|
||||
#include "official/GPUPerfAPI/Include/GPUPerfAPIFunctionTypes.h"
|
||||
|
||||
@@ -107,13 +108,15 @@ AMDCounters::AMDCounters() : m_pGPUPerfAPI(NULL)
|
||||
|
||||
bool AMDCounters::Init(void *pContext)
|
||||
{
|
||||
// first try in the location it will be in distributed builds
|
||||
HMODULE module = LoadLibraryA("plugins/amd/counters/GPUPerfAPIDX11-x64.dll");
|
||||
const char *dllName = "GPUPerfAPIDX11-x64.dll";
|
||||
|
||||
// first try in the plugin location it will be in distributed builds
|
||||
HMODULE module = LoadLibraryA(LocatePluginFile("amd/counters", dllName).c_str());
|
||||
|
||||
// if that failed then try checking for it just in the default search path
|
||||
if(module == NULL)
|
||||
{
|
||||
module = LoadLibraryA("GPUPerfAPIDX11-x64.dll");
|
||||
module = LoadLibraryA(dllName);
|
||||
}
|
||||
|
||||
if(module == NULL)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "amd_isa.h"
|
||||
#include "common/common.h"
|
||||
#include "core/plugins.h"
|
||||
#include "driver/shaders/spirv/spirv_common.h"
|
||||
#include "serialise/string_utils.h"
|
||||
#include "amd_isa_devices.h"
|
||||
@@ -38,72 +39,13 @@ static const std::string amdspv_name = "amdspv.sh";
|
||||
static const std::string virtualcontext_name = "VirtualContext";
|
||||
#endif
|
||||
|
||||
std::string LocatePlugin(const std::string &fileName)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
std::string exepath;
|
||||
FileIO::GetExecutableFilename(exepath);
|
||||
exepath = dirname(exepath);
|
||||
|
||||
std::vector<std::string> paths;
|
||||
|
||||
#if defined(RENDERDOC_PLUGINS_PATH)
|
||||
string customPath(RENDERDOC_PLUGINS_PATH);
|
||||
|
||||
if(FileIO::IsRelativePath(customPath))
|
||||
customPath = exepath + "/" + customPath;
|
||||
|
||||
paths.push_back(customPath);
|
||||
#endif
|
||||
|
||||
// windows installation
|
||||
paths.push_back(exepath + "/plugins");
|
||||
// linux installation
|
||||
paths.push_back(exepath + "/../share/renderdoc/plugins");
|
||||
// also search the appropriate OS-specific location in the root
|
||||
#if ENABLED(RDOC_WIN32) && ENABLED(RDOC_X64)
|
||||
paths.push_back(exepath + "/../../plugins-win64");
|
||||
#endif
|
||||
|
||||
#if ENABLED(RDOC_WIN32) && DISABLED(RDOC_X64)
|
||||
paths.push_back(exepath + "/../../plugins-win32");
|
||||
#endif
|
||||
|
||||
#if ENABLED(RDOC_LINUX)
|
||||
paths.push_back(exepath + "/../../plugins-linux64");
|
||||
#endif
|
||||
|
||||
// there is no standard path for local builds as we don't provide these plugins in the repository
|
||||
// directly. As a courtesy we search the root of the build, from the executable. The user can
|
||||
// always put the plugins folder relative to the exe where it would be in an installation too.
|
||||
paths.push_back(exepath + "/../../plugins");
|
||||
|
||||
// in future maybe we want to search a user-specific plugins folder? Like ~/.renderdoc/ on linux
|
||||
// or %APPDATA%/renderdoc on windows?
|
||||
|
||||
for(uint32_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
std::string check = paths[i] + "/amd/isa/" + fileName;
|
||||
if(FileIO::exists(check.c_str()))
|
||||
{
|
||||
ret = check;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't find it anywhere, just try running it directly in case it's in the PATH
|
||||
if(ret.empty())
|
||||
ret = fileName;
|
||||
|
||||
return ret;
|
||||
}
|
||||
std::string pluginPath = "amd/isa";
|
||||
|
||||
static bool IsSupported(GraphicsAPI api)
|
||||
{
|
||||
if(api == GraphicsAPI::OpenGL)
|
||||
{
|
||||
std::string vc = LocatePlugin(virtualcontext_name);
|
||||
std::string vc = LocatePluginFile(pluginPath, virtualcontext_name);
|
||||
|
||||
Process::ProcessResult result = {};
|
||||
Process::LaunchProcess(vc.c_str(), dirname(vc).c_str(), "", &result);
|
||||
@@ -118,7 +60,7 @@ static bool IsSupported(GraphicsAPI api)
|
||||
if(api == GraphicsAPI::Vulkan)
|
||||
{
|
||||
// TODO need to check if an AMD context is running
|
||||
std::string amdspv = LocatePlugin(amdspv_name);
|
||||
std::string amdspv = LocatePluginFile(pluginPath, amdspv_name);
|
||||
|
||||
Process::ProcessResult result = {};
|
||||
Process::LaunchProcess(amdspv.c_str(), dirname(amdspv).c_str(), "", &result);
|
||||
@@ -232,7 +174,7 @@ std::string Disassemble(const SPVModule *spv, const std::string &entry, const st
|
||||
FileIO::dump(inPath.c_str(), spv->spirv.data(), spv->spirv.size() * sizeof(uint32_t));
|
||||
|
||||
// try to locate the amdspv relative to our running program
|
||||
std::string amdspv = LocatePlugin(amdspv_name);
|
||||
std::string amdspv = LocatePluginFile(pluginPath, amdspv_name);
|
||||
|
||||
Process::ProcessResult result = {};
|
||||
Process::LaunchProcess(amdspv.c_str(), dirname(amdspv).c_str(), cmdLine.c_str(), &result);
|
||||
@@ -395,7 +337,7 @@ std::string Disassemble(ShaderStage stage, const std::vector<std::string> &glsl,
|
||||
FileIO::dump(inPath.c_str(), source.data(), source.size());
|
||||
|
||||
// try to locate the amdspv relative to our running program
|
||||
std::string vc = LocatePlugin(virtualcontext_name);
|
||||
std::string vc = LocatePluginFile(pluginPath, virtualcontext_name);
|
||||
|
||||
Process::ProcessResult result = {};
|
||||
Process::LaunchProcess(vc.c_str(), dirname(vc).c_str(), cmdLine.c_str(), &result);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "amd_isa.h"
|
||||
#include "core/plugins.h"
|
||||
#include "driver/shaders/dxbc/dxbc_inspect.h"
|
||||
#include "official/RGA/Common/AmdDxGsaCompile.h"
|
||||
#include "official/RGA/elf/elf32.h"
|
||||
@@ -44,13 +45,13 @@ https://github.com/baldurk/renderdoc/wiki/GCN-ISA)";
|
||||
|
||||
namespace GCNISA
|
||||
{
|
||||
std::string LocatePlugin(const std::string &fileName);
|
||||
extern std::string pluginPath;
|
||||
};
|
||||
|
||||
static HMODULE GetAMDModule()
|
||||
{
|
||||
// first try in the plugin locations
|
||||
HMODULE module = LoadLibraryA(GCNISA::LocatePlugin(DLL_NAME).c_str());
|
||||
HMODULE module = LoadLibraryA(LocatePluginFile(GCNISA::pluginPath, DLL_NAME).c_str());
|
||||
|
||||
// if that failed then try checking for it just in the default search path
|
||||
if(module == NULL)
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
<ClInclude Include="core\android.h" />
|
||||
<ClInclude Include="core\core.h" />
|
||||
<ClInclude Include="core\crash_handler.h" />
|
||||
<ClInclude Include="core\plugins.h" />
|
||||
<ClInclude Include="core\precompiled.h" />
|
||||
<ClInclude Include="core\replay_proxy.h" />
|
||||
<ClInclude Include="core\resource_manager.h" />
|
||||
@@ -212,6 +213,7 @@
|
||||
<ClCompile Include="core\android.cpp" />
|
||||
<ClCompile Include="core\core.cpp" />
|
||||
<ClCompile Include="core\image_viewer.cpp" />
|
||||
<ClCompile Include="core\plugins.cpp" />
|
||||
<ClCompile Include="core\precompiled.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
|
||||
@@ -282,6 +282,9 @@
|
||||
<ClInclude Include="core\android.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="core\plugins.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="maths\camera.cpp">
|
||||
@@ -471,6 +474,9 @@
|
||||
<Filter>PCH</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\android.cpp" />
|
||||
<ClCompile Include="core\plugins.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="os\win32\comexport.def">
|
||||
|
||||
Reference in New Issue
Block a user