Add socket-based interop with RGP and profile embedding in captures

This commit is contained in:
baldurk
2018-04-25 19:10:51 +01:00
parent 79637f6caa
commit 2d0f675ca8
17 changed files with 913 additions and 125 deletions
+98
View File
@@ -286,6 +286,8 @@ MainWindow::MainWindow(ICaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Mai
});
ui->action_Start_Replay_Loop->setEnabled(false);
ui->action_Open_RGP_Profile->setEnabled(false);
ui->action_Create_RGP_Profile->setEnabled(false);
ui->action_Resolve_Symbols->setEnabled(false);
ui->action_Resolve_Symbols->setText(tr("Resolve Symbols"));
@@ -1817,6 +1819,9 @@ void MainWindow::OnCaptureLoaded()
ui->action_Recompress_Capture->setEnabled(true);
ui->action_Start_Replay_Loop->setEnabled(true);
ui->action_Open_RGP_Profile->setEnabled(
m_Ctx.Replay().GetCaptureAccess()->FindSectionByType(SectionType::AMDRGPProfile) >= 0);
ui->action_Create_RGP_Profile->setEnabled(m_Ctx.APIProps().RGPCapture && m_Ctx.IsCaptureLocal());
setCaptureHasErrors(!m_Ctx.DebugMessages().empty());
@@ -1847,6 +1852,8 @@ void MainWindow::OnCaptureClosed()
ui->menu_Export_As->setEnabled(false);
ui->action_Start_Replay_Loop->setEnabled(false);
ui->action_Open_RGP_Profile->setEnabled(false);
ui->action_Create_RGP_Profile->setEnabled(false);
contextChooser->setEnabled(true);
@@ -2246,6 +2253,97 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
m_Ctx.Replay().CancelReplayLoop();
}
void MainWindow::on_action_Open_RGP_Profile_triggered()
{
if(!m_Ctx.IsCaptureLoaded())
return;
int idx = m_Ctx.Replay().GetCaptureAccess()->FindSectionByType(SectionType::AMDRGPProfile);
if(idx < 0)
return;
QString path = QDir::temp().absoluteFilePath(lit("renderdoc_extracted.rgp"));
QFile f(path);
if(f.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
bytebuf buf = m_Ctx.Replay().GetCaptureAccess()->GetSectionContents(idx);
f.write((const char *)buf.data(), (qint64)buf.size());
f.flush();
}
else
{
qCritical() << "Couldn't open temporary file " << path << " for write";
return;
}
m_Ctx.OpenRGPProfile(path);
}
void MainWindow::on_action_Create_RGP_Profile_triggered()
{
if(!m_Ctx.IsCaptureLoaded())
return;
if(m_Ctx.Replay().GetCaptureAccess()->FindSectionByType(SectionType::AMDRGPProfile) >= 0)
{
QMessageBox::StandardButton res = RDDialog::question(
this, tr("Existing RGP profile"), tr("Capture already contains an RGP profile. Overwrite?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if(res != QMessageBox::Yes)
return;
}
QDialog popup;
popup.setWindowFlags(popup.windowFlags() & ~Qt::WindowContextHelpButtonHint);
popup.setWindowIcon(windowIcon());
popup.resize(128, 16);
popup.setWindowTitle(tr("Making RGP Profile from %1").arg(m_Ctx.GetCaptureFilename()));
WindowingData winData = m_Ctx.CreateWindowingData(popup.winId());
rdcstr path;
m_Ctx.Replay().AsyncInvoke([winData, &popup, &path](IReplayController *r) {
path = r->CreateRGPProfile(winData);
GUIInvoke::call([&popup]() { popup.close(); });
});
RDDialog::show(&popup);
qInfo() << "RGP Capture created at" << QString(path);
m_Ctx.OpenRGPProfile(path);
if(!path.isEmpty())
{
QFile f(path);
if(f.open(QIODevice::ReadOnly))
{
QByteArray contents = f.readAll();
bytebuf buf;
buf.resize(contents.count());
memcpy(&buf[0], contents.data(), contents.count());
SectionProperties props;
props.type = SectionType::AMDRGPProfile;
props.version = 1;
props.flags = SectionFlags::ZstdCompressed;
m_Ctx.Replay().GetCaptureAccess()->WriteSection(props, buf);
ui->action_Open_RGP_Profile->setEnabled(true);
}
else
{
qCritical() << "Couldn't read from temporary RGP capture at " << QString(path);
}
}
}
void MainWindow::on_action_Attach_to_Running_Instance_triggered()
{
on_action_Manage_Remote_Servers_triggered();