mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Implement CSV export in constant buffer previewer. Refs #646
This commit is contained in:
@@ -160,6 +160,51 @@ void ConstantBufferPreviewer::on_setFormat_toggled(bool checked)
|
||||
|
||||
void ConstantBufferPreviewer::on_saveCSV_clicked()
|
||||
{
|
||||
QString filename = RDDialog::getSaveFileName(this, tr("Export buffer data as CSV"), QString(),
|
||||
tr("CSV Files (*.csv)"));
|
||||
|
||||
if(!filename.isEmpty())
|
||||
{
|
||||
QDir dirinfo = QFileInfo(filename).dir();
|
||||
if(dirinfo.exists())
|
||||
{
|
||||
QFile f(filename, this);
|
||||
if(f.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
QTextStream ts(&f);
|
||||
|
||||
ts << tr("Name,Value,Type\n");
|
||||
|
||||
for(int i = 0; i < ui->variables->topLevelItemCount(); i++)
|
||||
exportCSV(ts, QString(), ui->variables->topLevelItem(i));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RDDialog::critical(
|
||||
this, tr("Error exporting buffer data"),
|
||||
tr("Couldn't open path %1 for write.\n%2").arg(filename).arg(f.errorString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
RDDialog::critical(this, tr("Invalid directory"),
|
||||
tr("Cannot find target directory to save to"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConstantBufferPreviewer::exportCSV(QTextStream &ts, const QString &prefix, RDTreeWidgetItem *item)
|
||||
{
|
||||
if(item->childCount() == 0)
|
||||
{
|
||||
ts << QFormatStr("%1,\"%2\",%3\n").arg(item->text(0)).arg(item->text(1)).arg(item->text(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
ts << QFormatStr("%1,,%2\n").arg(item->text(0)).arg(item->text(2));
|
||||
for(int i = 0; i < item->childCount(); i++)
|
||||
exportCSV(ts, item->text(0) + lit("."), item->child(i));
|
||||
}
|
||||
}
|
||||
|
||||
void ConstantBufferPreviewer::processFormat(const QString &format)
|
||||
|
||||
@@ -73,6 +73,8 @@ private:
|
||||
uint32_t m_slot = 0;
|
||||
uint32_t m_arrayIdx = 0;
|
||||
|
||||
void exportCSV(QTextStream &ts, const QString &prefix, RDTreeWidgetItem *item);
|
||||
|
||||
rdctype::array<ShaderVariable> applyFormatOverride(const rdctype::array<byte> &data);
|
||||
|
||||
void addVariables(RDTreeWidgetItem *root, const rdctype::array<ShaderVariable> &vars);
|
||||
|
||||
Reference in New Issue
Block a user