Save machine ident in captures and compare to machine ident on open

* If the machine idents differ in significant ways that we'd consider
  it to be a different platform (currently just OS), and if so mark it
  as supported but suggested to be replayed remotely.
This commit is contained in:
baldurk
2016-08-19 12:44:20 +02:00
parent 52a754d4c1
commit d2faf76356
19 changed files with 155 additions and 28 deletions
+2 -2
View File
@@ -594,8 +594,8 @@ extern "C" RENDERDOC_API uint32_t RENDERDOC_CC Topology_VertexOffset(PrimitiveTo
// Takes the filename of the log. Returns NULL in the case of any error.
//////////////////////////////////////////////////////////////////////////
extern "C" RENDERDOC_API bool32 RENDERDOC_CC RENDERDOC_SupportLocalReplay(const char *logfile,
rdctype::str *driverName);
extern "C" RENDERDOC_API ReplaySupport RENDERDOC_CC RENDERDOC_SupportLocalReplay(
const char *logfile, rdctype::str *driverName, rdctype::str *recordMachineIdent);
extern "C" RENDERDOC_API ReplayCreateStatus RENDERDOC_CC
RENDERDOC_CreateReplayRenderer(const char *logfile, float *progress, ReplayRenderer **rend);
+7
View File
@@ -492,6 +492,13 @@ enum CounterUnits
eUnits_Percentage,
};
enum ReplaySupport
{
eReplaySupport_Unsupported,
eReplaySupport_Supported,
eReplaySupport_SuggestRemote,
};
enum ReplayCreateStatus
{
eReplayCreate_Success = 0,
+5 -1
View File
@@ -633,7 +633,8 @@ Serialiser *RenderDoc::OpenWriteSerialiser(uint32_t frameNum, RDCInitParams *par
}
ReplayCreateStatus RenderDoc::FillInitParams(const char *logFile, RDCDriver &driverType,
string &driverName, RDCInitParams *params)
string &driverName, uint64_t &fileMachineIdent,
RDCInitParams *params)
{
Serialiser ser(logFile, Serialiser::READING, true);
@@ -659,6 +660,7 @@ ReplayCreateStatus RenderDoc::FillInitParams(const char *logFile, RDCDriver &dri
{
driverType = RDC_Image;
driverName = "Image";
fileMachineIdent = 0;
return eReplayCreate_Success;
}
}
@@ -678,6 +680,8 @@ ReplayCreateStatus RenderDoc::FillInitParams(const char *logFile, RDCDriver &dri
ser.Rewind();
fileMachineIdent = ser.GetSavedMachineIdent();
{
int chunkType = ser.PushContext(NULL, NULL, 1, false);
+1 -1
View File
@@ -229,7 +229,7 @@ public:
}
ReplayCreateStatus FillInitParams(const char *logfile, RDCDriver &driverType, string &driverName,
RDCInitParams *params);
uint64_t &fileMachineIdent, RDCInitParams *params);
void RegisterReplayProvider(RDCDriver driver, const char *name, ReplayDriverProvider provider);
void RegisterRemoteProvider(RDCDriver driver, const char *name, RemoteDriverProvider provider);
+3 -2
View File
@@ -322,8 +322,9 @@ static void ActiveRemoteClientThread(void *data)
RDCDriver driverType = RDC_Unknown;
string driverName = "";
ReplayCreateStatus status =
RenderDoc::Inst().FillInitParams(cap_file.c_str(), driverType, driverName, NULL);
uint64_t fileMachineIdent = 0;
ReplayCreateStatus status = RenderDoc::Inst().FillInitParams(
cap_file.c_str(), driverType, driverName, fileMachineIdent, NULL);
if(status != eReplayCreate_Success)
{
+2 -1
View File
@@ -1978,10 +1978,11 @@ ReplayCreateStatus D3D11_CreateReplayDevice(const char *logfile, IReplayDriver *
D3D11InitParams initParams;
RDCDriver driverFileType = RDC_D3D11;
string driverName = "D3D11";
uint64_t machineIdent = 0;
if(logfile)
{
auto status = RenderDoc::Inst().FillInitParams(logfile, driverFileType, driverName,
(RDCInitParams *)&initParams);
machineIdent, (RDCInitParams *)&initParams);
if(status != eReplayCreate_Success)
return status;
}
+2 -1
View File
@@ -547,10 +547,11 @@ ReplayCreateStatus D3D12_CreateReplayDevice(const char *logfile, IReplayDriver *
D3D12InitParams initParams;
RDCDriver driverFileType = RDC_D3D12;
string driverName = "D3D12";
uint64_t machineIdent = 0;
if(logfile)
{
auto status = RenderDoc::Inst().FillInitParams(logfile, driverFileType, driverName,
(RDCInitParams *)&initParams);
machineIdent, (RDCInitParams *)&initParams);
if(status != eReplayCreate_Success)
return status;
}
+2 -1
View File
@@ -265,9 +265,10 @@ ReplayCreateStatus GL_CreateReplayDevice(const char *logfile, IReplayDriver **dr
GLInitParams initParams;
RDCDriver driverType = RDC_OpenGL;
string driverName = "OpenGL";
uint64_t machineIdent = 0;
if(logfile)
{
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName,
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, machineIdent,
(RDCInitParams *)&initParams);
if(status != eReplayCreate_Success)
return status;
+2 -1
View File
@@ -261,9 +261,10 @@ ReplayCreateStatus GL_CreateReplayDevice(const char *logfile, IReplayDriver **dr
GLInitParams initParams;
RDCDriver driverType = RDC_OpenGL;
string driverName = "OpenGL";
uint64_t machineIdent = 0;
if(logfile)
{
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName,
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, machineIdent,
(RDCInitParams *)&initParams);
if(status != eReplayCreate_Success)
return status;
+3 -1
View File
@@ -5557,8 +5557,10 @@ ReplayCreateStatus Vulkan_CreateReplayDevice(const char *logfile, IReplayDriver
VkInitParams initParams;
RDCDriver driverType = RDC_Vulkan;
string driverName = "VulkanReplay";
uint64_t machineIdent = 0;
if(logfile)
RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, (RDCInitParams *)&initParams);
RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, machineIdent,
(RDCInitParams *)&initParams);
if(initParams.SerialiseVersion != VkInitParams::VK_SERIALISE_VERSION)
{
+41
View File
@@ -127,3 +127,44 @@ string Callstack::AddressDetails::formattedString(const char *commonPath)
return fmt;
}
string OSUtility::MakeMachineIdentString(uint64_t ident)
{
string ret = "";
if(ident & MachineIdent_Windows)
ret += "Windows ";
else if(ident & MachineIdent_Linux)
ret += "Linux ";
else if(ident & MachineIdent_macOS)
ret += "macOS ";
else if(ident & MachineIdent_Android)
ret += "Android ";
else if(ident & MachineIdent_iOS)
ret += "iOS ";
if(ident & MachineIdent_Arch_x86)
ret += "x86 ";
else if(ident & MachineIdent_Arch_ARM)
ret += "ARM ";
if(ident & MachineIdent_32bit)
ret += "32-bit ";
else if(ident & MachineIdent_64bit)
ret += "64-bit ";
switch(ident & MachineIdent_GPU_Mask)
{
case MachineIdent_GPU_ARM: ret += "ARM GPU "; break;
case MachineIdent_GPU_AMD: ret += "AMD GPU "; break;
case MachineIdent_GPU_IMG: ret += "Imagination GPU "; break;
case MachineIdent_GPU_Intel: ret += "Intel GPU "; break;
case MachineIdent_GPU_NV: ret += "nVidia GPU "; break;
case MachineIdent_GPU_QUALCOMM: ret += "QUALCOMM GPU "; break;
case MachineIdent_GPU_Samsung: ret += "Samsung GPU "; break;
case MachineIdent_GPU_Verisilicon: ret += "Verisilicon GPU "; break;
default: break;
}
return ret;
}
+1
View File
@@ -411,6 +411,7 @@ enum MachineIdentBits
};
uint64_t GetMachineIdent();
string MakeMachineIdentString(uint64_t ident);
};
namespace Bits
+23 -5
View File
@@ -315,20 +315,38 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerExceptionHandler(voi
}
}
extern "C" RENDERDOC_API bool32 RENDERDOC_CC RENDERDOC_SupportLocalReplay(const char *logfile,
rdctype::str *driver)
extern "C" RENDERDOC_API ReplaySupport RENDERDOC_CC RENDERDOC_SupportLocalReplay(
const char *logfile, rdctype::str *driver, rdctype::str *recordMachineIdent)
{
if(logfile == NULL)
return false;
return eReplaySupport_Unsupported;
RDCDriver driverType = RDC_Unknown;
string driverName = "";
RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, NULL);
uint64_t fileMachineIdent = 0;
RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, fileMachineIdent, NULL);
if(driver)
*driver = driverName;
return RenderDoc::Inst().HasReplayDriver(driverType);
bool supported = RenderDoc::Inst().HasReplayDriver(driverType);
if(!supported)
return eReplaySupport_Unsupported;
if(fileMachineIdent != 0)
{
uint64_t machineIdent = OSUtility::GetMachineIdent();
if(recordMachineIdent)
*recordMachineIdent = OSUtility::MakeMachineIdentString(fileMachineIdent);
if((machineIdent & OSUtility::MachineIdent_OS_Mask) !=
(fileMachineIdent & OSUtility::MachineIdent_OS_Mask))
return eReplaySupport_SuggestRemote;
}
return eReplaySupport_Supported;
}
extern "C" RENDERDOC_API ReplayCreateStatus RENDERDOC_CC
+3 -1
View File
@@ -1552,7 +1552,9 @@ ReplayCreateStatus ReplayRenderer::CreateDevice(const char *logfile)
RDCDriver driverType = RDC_Unknown;
string driverName = "";
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, NULL);
uint64_t fileMachineIdent = 0;
auto status =
RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, fileMachineIdent, NULL);
if(driverType == RDC_Unknown || driverName == "" || status != eReplayCreate_Success)
{
+18
View File
@@ -1450,6 +1450,24 @@ void Serialiser::FlushToDisk()
SAFE_DELETE_ARRAY(symbolDB);
}
// write the machine identifier as an ASCII section
{
const char sectionName[] = "renderdoc/internal/machineid";
uint64_t machineID = OSUtility::GetMachineIdent();
BinarySectionHeader section = {0};
section.isASCII = 0; // redundant but explicit
section.sectionNameLength = sizeof(sectionName); // includes null terminator
section.sectionType = eSectionType_MachineID;
section.sectionFlags = eSectionFlag_None;
section.sectionLength = sizeof(machineID);
FileIO::fwrite(&section, 1, offsetof(BinarySectionHeader, name), binFile);
FileIO::fwrite(sectionName, 1, sizeof(sectionName), binFile);
FileIO::fwrite(&machineID, 1, sizeof(machineID), binFile);
}
FileIO::fclose(binFile);
}
}
+17
View File
@@ -180,6 +180,7 @@ public:
eSectionType_Unknown = 0,
eSectionType_FrameCapture, // renderdoc/internal/framecapture
eSectionType_ResolveDatabase, // renderdoc/internal/resolvedb
eSectionType_MachineID, // renderdoc/internal/machineid
eSectionType_FrameBookmarks, // renderdoc/ui/bookmarks
eSectionType_Notes, // renderdoc/ui/notes
eSectionType_Num,
@@ -281,6 +282,22 @@ public:
Callstack::StackResolver *GetCallstackResolver() { return m_pResolver; }
void SetCallstack(uint64_t *levels, size_t numLevels);
uint64_t GetSavedMachineIdent()
{
Section *id = m_KnownSections[eSectionType_MachineID];
// section might not be present on older captures (or if it was stripped out
// by someone over-eager to remove information)
if(id != NULL && id->data.size() >= sizeof(uint64_t))
{
uint64_t ident = 0;
memcpy(&ident, &id->data[0], sizeof(ident));
return ident;
}
return 0;
}
// get the callstack associated with the last scope
Callstack::Stackwalk *GetLastCallstack()
{
+7
View File
@@ -504,6 +504,13 @@ namespace renderdoc
Percentage,
};
public enum ReplaySupport
{
Unsupported,
Supported,
SuggestRemote,
};
public enum ReplayCreateStatus
{
Success = 0,
+10 -6
View File
@@ -49,7 +49,7 @@ namespace renderdoc
class StaticExports
{
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool RENDERDOC_SupportLocalReplay(IntPtr logfile, IntPtr outdriver);
private static extern ReplaySupport RENDERDOC_SupportLocalReplay(IntPtr logfile, IntPtr outdriver, IntPtr outident);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern ReplayCreateStatus RENDERDOC_CreateReplayRenderer(IntPtr logfile, ref float progress, ref IntPtr rendPtr);
@@ -110,19 +110,23 @@ namespace renderdoc
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern void RENDERDOC_FreeEnvironmentModificationList(IntPtr mem);
public static bool SupportLocalReplay(string logfile, out string driverName)
public static ReplaySupport SupportLocalReplay(string logfile, out string driverName, out string recordMachineIdent)
{
IntPtr mem = CustomMarshal.Alloc(typeof(templated_array));
IntPtr name_mem = CustomMarshal.Alloc(typeof(templated_array));
IntPtr ident_mem = CustomMarshal.Alloc(typeof(templated_array));
IntPtr logfile_mem = CustomMarshal.MakeUTF8String(logfile);
bool ret = RENDERDOC_SupportLocalReplay(logfile_mem, mem);
ReplaySupport ret = RENDERDOC_SupportLocalReplay(logfile_mem, name_mem, ident_mem);
CustomMarshal.Free(logfile_mem);
driverName = CustomMarshal.TemplatedArrayToString(mem, true);
driverName = CustomMarshal.TemplatedArrayToString(name_mem, true);
recordMachineIdent = CustomMarshal.TemplatedArrayToString(ident_mem, true);
CustomMarshal.Free(name_mem);
CustomMarshal.Free(ident_mem);
CustomMarshal.Free(mem);
return ret;
}
+6 -5
View File
@@ -625,24 +625,25 @@ namespace renderdocui.Windows
if (m_Core.LogLoading) return;
string driver = "";
bool support = false;
string machineIdent = "";
ReplaySupport support = ReplaySupport.Unsupported;
bool remoteReplay = !local || (m_Core.Renderer.Remote != null && m_Core.Renderer.Remote.Connected);
if (local)
{
support = StaticExports.SupportLocalReplay(filename, out driver);
support = StaticExports.SupportLocalReplay(filename, out driver, out machineIdent);
if (remoteReplay)
{
support = false;
support = ReplaySupport.Unsupported;
string[] remoteDrivers = m_Core.Renderer.GetRemoteSupport();
for (int i = 0; i < remoteDrivers.Length; i++)
{
if (driver == remoteDrivers[i])
support = true;
support = ReplaySupport.Supported;
}
}
}
@@ -651,7 +652,7 @@ namespace renderdocui.Windows
// if driver is empty something went wrong loading the log, let it be handled as usual
// below. Otherwise indicate that support is missing.
if (driver.Length > 0 && !support)
if (driver.Length > 0 && support == ReplaySupport.Unsupported)
{
if (remoteReplay)
{