From abe645f03139331f76d7897a7d644c89b2afe454 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 12 May 2022 15:06:39 +0100 Subject: [PATCH] Add support for saving and loading structure definitions --- qrenderdoc/Code/Interface/PersistantConfig.h | 9 +- qrenderdoc/Code/QRDUtils.cpp | 11 + qrenderdoc/Code/QRDUtils.h | 11 + qrenderdoc/Code/Resources.h | 1 + qrenderdoc/Resources/help.png | Bin 0 -> 761 bytes qrenderdoc/Resources/help@2x.png | Bin 0 -> 2271 bytes qrenderdoc/Resources/resources.qrc | 2 + qrenderdoc/Widgets/BufferFormatSpecifier.cpp | 293 +++++++++++++++++-- qrenderdoc/Widgets/BufferFormatSpecifier.h | 42 ++- qrenderdoc/Widgets/BufferFormatSpecifier.ui | 242 ++++++++++++--- qrenderdoc/Widgets/Extended/RDTreeWidget.cpp | 9 +- qrenderdoc/Widgets/Extended/RDTreeWidget.h | 3 +- qrenderdoc/Windows/BufferViewer.cpp | 2 +- qrenderdoc/Windows/ShaderViewer.cpp | 10 - qrenderdoc/Windows/ShaderViewer.h | 11 - qrenderdoc/qrenderdoc_local.vcxproj | 2 + qrenderdoc/qrenderdoc_local.vcxproj.filters | 6 + 17 files changed, 558 insertions(+), 96 deletions(-) create mode 100644 qrenderdoc/Resources/help.png create mode 100644 qrenderdoc/Resources/help@2x.png diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index a0a1399c6..3fae31eb5 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -404,10 +404,11 @@ DECLARE_REFLECTION_STRUCT(BugReport); CONFIG_SETTING_VAL(public, int, int, LocalProxyAPI, -1) \ \ DOCUMENT( \ - "``True`` if the buffer formatter's help section should be shown.\n" \ - "\n:" \ - "Defaults to ``True``."); \ - CONFIG_SETTING_VAL(public, bool, bool, BufferFormatter_ShowHelp, true) \ + "A list of strings with saved formats for the buffer formatter. The first line is the " \ + "name and the rest of the contents are the formats.\n" \ + "\n" \ + ":type: List[str]"); \ + CONFIG_SETTING(public, QVariantList, rdcarray, BufferFormatter_SavedFormats) \ \ DOCUMENT( \ "The :class:`TimeUnit` to use to display the duration column in the " \ diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index 9e15b01b3..302ed036c 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1189,6 +1190,16 @@ QString RichResourceTextFormat(ICaptureContext &ctx, QVariant var) return var.toString(); } +FullEditorDelegate::FullEditorDelegate(QWidget *parent) : QStyledItemDelegate(parent) +{ +} + +QWidget *FullEditorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + return new QLineEdit(parent); +} + RichTextViewDelegate::RichTextViewDelegate(QAbstractItemView *parent) : m_widget(parent), ForwardingDelegate(parent) { diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index ba8604b01..f560cb82e 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -698,6 +698,17 @@ private: QAbstractItemDelegate *m_delegate = NULL; }; +class FullEditorDelegate : public QStyledItemDelegate +{ +private: + Q_OBJECT + +public: + FullEditorDelegate(QWidget *parent); + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; +}; + // delegate that will handle painting, hovering and clicking on rich text items. // owning view needs to call linkHover, and adjust its cursor and repaint as necessary. class RichTextViewDelegate : public ForwardingDelegate diff --git a/qrenderdoc/Code/Resources.h b/qrenderdoc/Code/Resources.h index e25eabb88..64783f8cb 100644 --- a/qrenderdoc/Code/Resources.h +++ b/qrenderdoc/Code/Resources.h @@ -69,6 +69,7 @@ RESOURCE_DEF(flip_y, "flip_y.png") \ RESOURCE_DEF(folder, "folder.png") \ RESOURCE_DEF(folder_page_white, "folder_page_white.png") \ + RESOURCE_DEF(help, "help.png") \ RESOURCE_DEF(hourglass, "hourglass.png") \ RESOURCE_DEF(house, "house.png") \ RESOURCE_DEF(information, "information.png") \ diff --git a/qrenderdoc/Resources/help.png b/qrenderdoc/Resources/help.png new file mode 100644 index 0000000000000000000000000000000000000000..723c404a958b001ba12c30407dc2314ae81410d6 GIT binary patch literal 761 zcmVR+YLf&;Ka{(Y7A^YOg|-N+phX*N;Ud&U3l%DdeimW`_Jb1+ z<=BAJj5#x8Z^oJTI_J(0S_dwdbI$jD_nhwl>$|U{f`!{E`4n2I8pOGl0VZ#% zl%rQqH6gK_!}zBJzC_bl&N`?t1$Ni?aI`UiK!po^gVR_@W|RmEXe{8Omv5ihhj-yL z9=?oV|299q^&Up-UW>Zf=Q!sX$M{m^8u#3Fya5xlNleWp;WjngY;Qm?w1~Q%AYRQZ zDqk9!$}^7f%u@okZJ({(T#5JJ(^RgDj-izMMk5HUljwgjuY76fD$h8^Gp|rRgq%xe z;h`63+At~7(mSOFXj1G}TfGusvfEG{gYnEOwhtt&9Hev=yV4Ye&33o!D;gOBv8fX`z<*9rtp(~!$i1;i^1(Mk+Qqf4leI#r?53^X+d7ZIOd+5<^G ze*unjo^gz4o)U;ZJJ<7hW&sxU<)N3{Gz*gkCe6Z3_-3EuoM#;4nWqGJsJY0S?(vBk zWULi<-3Gh__R-KT42IRsKF2xFIL0#%#a&_ZuRnC9Q{Qr+zj^Og?5wYb-)ok4A@w_p z&}~ErS`py000000NkvXXu0mjf=X+i@ literal 0 HcmV?d00001 diff --git a/qrenderdoc/Resources/help@2x.png b/qrenderdoc/Resources/help@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..68f51bac41f5c0f5b1c9580bc9ee012c480aadc6 GIT binary patch literal 2271 zcmV<52q5=~P)g4LrApCOKh#d!=@; zWh)jmd$6Fz1B<30m&?O2a>yBZ#FIL%`6e(lI*GHF{V=k6kCdF)6#UzZgQO?_RRAc} zPw)GaqFG*e`iT`-yRrp#3*fW^b{l!iTJr@V`^e^iNZi0gB!dvinZ6r1dc2>3{3ZDQ z)|cpd?tTDhmD@h_Em_!5|J+ln(O9FRsvJ0RDU1`n{ zUW=t|RT#OMM87YL&pz+Rs6R9|vG=JKx~AU?0IhuM{^2c;uV`4mZUGuSz%_pYzx(JM z!qXXOiVRtiDBse|%XtxvyhuehXQ13+#r6%IsIPM1{6GjNFOK4ivxEN0_qTX&2cg{Q z`TpyhA74?=#=Z5x?jwWPd8kiVv0GGVsvJzlSdRG(68?N(0H2>9Lzz`0!zvUqAc?q3 zB>^l5#RM{g5#VG2)Hgnjsb~t1KGck4I*;+mxHIqlPD7%n`;b|fCIG48kyqQb%9gi( z_Ut#&)~I6NQ6K(&!A}Lp#tX_h=~)VOiabn`cPZUKn*Qn(dV|g-j)VYF5RQm{GC{_5 ztm&*nJS$O`Os%wf7JiT%IyT9MRWtN*O;`8k^~)*eR`>!*{PWBxd0z0Ee+C)R$*{+1 z!Ed%K#L5=;tlXXUMe+KfAq?D1z*dqP27dDLI6A%6=U=ZXV+Up!R^2=3s80X(AI{WaY#li3dowJ!$CIrJqDoII=;Vs&9Wx)7&t!^B~rJj%=z9QFGH51#qXF=;1s6PSqudtsI9c4uGWpRC7ZUhZ3bY; zYtCo9O;vC?6!cu1BGd)+GgU5V7VvuP!iY|2e)Mi1E>U~-`D1u?XD>!V=|UyTh3ew_ zGXRR+am^n_y~hQIgP6?XdWLOt4cPLsrK7pA5-!p|G!`bBRYeh*KPqb2DXhQPKY)&U z2mIkQohfi?lBkO+s`&D@lh?wLQkm%Ss0ZBV`iy! zi_aw0q>~&eWW_3lmWkwc0Hr^s+zgGDzy72P6~)j8r**t?U=Y_s8H%eq%X?L+D^ld1@+APWhJ>~AZ*jq!$NZu$Y?ix6j=gtTS$7s0(r;c9V;#BVz_5P` z6JZ_A^IXLqmhURuRs+G*jPfw?hK)K$Q!E7ZXo zW34~;Pb4tE-c9`)6)Bj@84*dsee7xkhkK{QnUjjHj6z@9y0^c>`I%Sg#F_p8(kUI; z@W?^7%>Yud)9>!NQrjT_EN-cXt4u@sE@|Lg>ZJ08b@lk}(kgNGkBcGfK6$gSBS>?H z-%bmf>a3e%@{?qS=q=)hqAcrFzm?7JGE3lV&6X`>jh(j2K^J}{`5Oym6H z|MM9?o9jM@znyl;QjqTISC6<4-uw*w7TF6{oa7m=xH zWT!?BM2`RQJ$l3ilq+3roFuKDAM882cu`Yz=b}11wz>&dN5dEiMoFPOlV9c$o&h|R zOz#V8T1nB-ztt`WjrTI_I(!jhGzsW{^COMJED# zwrwOEBP3CCFH~;pmJCnZL~r+}>4x=BPDRr8(J3A-Dwem^iYivbFd^3DW;FK&(qbc{ zZl?{kvBE(;%ll)7u=5*eEI5h^}folder@2x.png folder_page_white.png folder_page_white@2x.png + help.png + help@2x.png hourglass.png hourglass@2x.png house.png diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp index 42c773ebc..a290c51ae 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp @@ -24,32 +24,89 @@ #include "BufferFormatSpecifier.h" #include +#include +#include +#include +#include +#include #include "Code/QRDUtils.h" #include "ui_BufferFormatSpecifier.h" +BufferFormatList *globalFormatList = NULL; + +BufferFormatList::BufferFormatList(ICaptureContext &ctx, QObject *parent) + : m_Ctx(ctx), QObject(parent) +{ + rdcarray saved = m_Ctx.Config().BufferFormatter_SavedFormats; + + for(rdcstr f : saved) + { + int idx = f.indexOf('\n'); + + formats[QString(f.substr(0, idx))] = QString(f.substr(idx + 1)).trimmed(); + } +} + +void BufferFormatList::setFormat(QString name, QString format) +{ + bool newFmt = !formats.contains(name); + if(format.isEmpty()) + formats.remove(name); + else + formats[name] = format; + if(newFmt || (!newFmt && format.isEmpty())) + emit formatListUpdated(); + + QStringList keys = formats.keys(); + keys.sort(Qt::CaseInsensitive); + rdcarray saved; + for(QString k : keys) + saved.push_back(k + lit("\n") + formats[k]); + m_Ctx.Config().BufferFormatter_SavedFormats = saved; +} + BufferFormatSpecifier::BufferFormatSpecifier(QWidget *parent) : QWidget(parent), ui(new Ui::BufferFormatSpecifier) { ui->setupUi(this); - QObject::connect(ui->toggleHelp, &QPushButton::clicked, this, &BufferFormatSpecifier::toggleHelp); - setErrors(QString()); + on_showHelp_toggled(false); + + ui->savedList->setItemDelegate(new FullEditorDelegate(ui->savedList)); + ui->formatText->setFont(Formatter::FixedFont()); + ui->savedList->setFont(Formatter::PreferredFont()); + + ui->savedList->setColumns({tr("Saved formats")}); } BufferFormatSpecifier::~BufferFormatSpecifier() { - if(m_Ctx) - m_Ctx->Config().BufferFormatter_ShowHelp = ui->helpText->isVisible(); delete ui; } +void BufferFormatSpecifier::setAutoFormat(QString autoFormat) +{ + m_AutoFormat = autoFormat; + + updateFormatList(); + + setFormat(autoFormat); +} + void BufferFormatSpecifier::setContext(ICaptureContext *ctx) { m_Ctx = ctx; - showHelp(m_Ctx->Config().BufferFormatter_ShowHelp); + + if(!globalFormatList) + globalFormatList = new BufferFormatList(*ctx, ctx->GetMainWindow()->Widget()); + + QObject::connect(globalFormatList, &BufferFormatList::formatListUpdated, this, + &BufferFormatSpecifier::updateFormatList); + + updateFormatList(); } void BufferFormatSpecifier::setTitle(QString title) @@ -57,16 +114,6 @@ void BufferFormatSpecifier::setTitle(QString title) ui->formatGroup->setTitle(title); } -void BufferFormatSpecifier::toggleHelp() -{ - ui->helpText->setVisible(!ui->helpText->isVisible()); - - if(ui->helpText->isVisible()) - showHelp(true); - else - showHelp(false); -} - void BufferFormatSpecifier::setFormat(const QString &format) { ui->formatText->setText(format); @@ -81,22 +128,224 @@ void BufferFormatSpecifier::setErrors(const QString &errors) ui->errors->setVisible(true); } -void BufferFormatSpecifier::showHelp(bool help) +void BufferFormatSpecifier::updateFormatList() { - ui->helpText->setVisible(help); + QString sel; + + RDTreeWidgetItem *item = ui->savedList->selectedItem(); + if(item) + sel = item->text(0); - if(help) { - ui->gridLayout->removeWidget(ui->formatGroup); - ui->gridLayout->addWidget(ui->formatGroup, 1, 0, 1, 3); + QSignalBlocker block(ui->savedList); + int vs = ui->savedList->verticalScrollBar()->value(); + ui->savedList->beginUpdate(); + + ui->savedList->clear(); + + int selidx = -1; + + if(!m_AutoFormat.isEmpty()) + { + item = new RDTreeWidgetItem({tr("")}); + item->setItalic(true); + ui->savedList->addTopLevelItem(item); + + if(item->text(0) == sel) + selidx = 0; + } + + QStringList formats = globalFormatList->getFormats(); + + for(QString f : formats) + { + if(f == sel) + selidx = ui->savedList->topLevelItemCount(); + + ui->savedList->addTopLevelItem(new RDTreeWidgetItem({f})); + } + + { + item = new RDTreeWidgetItem({tr("New...")}); + if(item->text(0) == sel) + selidx = ui->savedList->topLevelItemCount(); + item->setEditable(0, true); + ui->savedList->addTopLevelItem(item); + } + + if(selidx >= 0) + ui->savedList->setSelectedItem(ui->savedList->topLevelItem(selidx)); + + ui->savedList->resizeColumnToContents(0); + + ui->savedList->endUpdate(); + ui->savedList->verticalScrollBar()->setValue(vs); + } + + on_savedList_itemSelectionChanged(); +} + +void BufferFormatSpecifier::on_savedList_keyPress(QKeyEvent *event) +{ + if(event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace) + { + on_delDef_clicked(); + } +} + +void BufferFormatSpecifier::on_savedList_itemChanged(RDTreeWidgetItem *item, int column) +{ + // ignore updates for anything but the last one + if(ui->savedList->indexOfTopLevelItem(item) != ui->savedList->topLevelItemCount() - 1) + return; + + QString name = item->text(0); + + // prevent recursion + { + QSignalBlocker block(ui->savedList); + + // if they didn't actually edit it, ignore + if(name == tr("New...")) + return; + + if(globalFormatList->hasFormat(name)) + { + RDDialog::critical(this, tr("Name already in use"), + tr("The definition name '%1' is already in used.\n" + "To update this definition, select it and click update.")); + item->setText(0, tr("New...")); + return; + } + } + + globalFormatList->setFormat(name, ui->formatText->toPlainText()); +} + +void BufferFormatSpecifier::on_savedList_itemDoubleClicked(RDTreeWidgetItem *item, int column) +{ + ui->savedList->setSelectedItem(item); + + if(ui->loadDef->isEnabled()) + on_loadDef_clicked(); +} + +void BufferFormatSpecifier::on_savedList_itemSelectionChanged() +{ + RDTreeWidgetItem *item = ui->savedList->selectedItem(); + + ui->saveDef->setEnabled(item != NULL); + ui->loadDef->setEnabled(item != NULL); + ui->delDef->setEnabled(item != NULL); + + // auto format is always the first, and can't be saved to or deleted + if(!m_AutoFormat.isEmpty() && ui->savedList->indexOfTopLevelItem(item) == 0) + { + ui->saveDef->setEnabled(false); + ui->delDef->setEnabled(false); + } + + // the 'new' format is always the last, and can't be loaded from or deleted + if(ui->savedList->indexOfTopLevelItem(item) == ui->savedList->topLevelItemCount() - 1) + { + ui->loadDef->setEnabled(false); + ui->delDef->setEnabled(false); + + ui->saveDef->setToolTip(tr("Create new current structure definition")); } else { - ui->gridLayout->removeWidget(ui->formatGroup); - ui->gridLayout->addWidget(ui->formatGroup, 0, 0, 2, 3); + ui->saveDef->setToolTip(tr("Update selected with current structure definition")); } } +void BufferFormatSpecifier::on_showHelp_toggled(bool help) +{ + ui->helpText->setVisible(help); + ui->formatText->setVisible(!help); +} + +void BufferFormatSpecifier::on_loadDef_clicked() +{ + RDTreeWidgetItem *item = ui->savedList->selectedItem(); + + if(!item) + return; + + QString name = item->text(0); + + QString format; + if(!m_AutoFormat.isEmpty() && ui->savedList->indexOfTopLevelItem(item) == 0) + format = m_AutoFormat; + else + format = globalFormatList->getFormat(name); + + { + QSignalBlocker block(ui->formatText); + + QTextDocument *doc = ui->formatText->document(); + QTextCursor cur(doc); + cur.select(QTextCursor::Document); + cur.insertText(format); + } + + emit processFormat(format); +} + +void BufferFormatSpecifier::on_saveDef_clicked() +{ + RDTreeWidgetItem *item = ui->savedList->selectedItem(); + + if(!item) + return; + + // for the 'new...' just trigger an edit and let the user do it that way. This reduces + // duplication, avoids need for a prompt for the name, and educates the user that they can edit + // directly + if(ui->savedList->indexOfTopLevelItem(item) == ui->savedList->topLevelItemCount() - 1) + { + ui->savedList->editItem(item); + return; + } + + QString name = item->text(0); + + QMessageBox::StandardButton res = RDDialog::question( + this, tr("Updating definition"), + tr("Are you sure you wish to overwrite definition '%1'?").arg(name), RDDialog::YesNoCancel); + + if(res != QMessageBox::Yes) + return; + + globalFormatList->setFormat(name, ui->formatText->toPlainText()); +} + +void BufferFormatSpecifier::on_delDef_clicked() +{ + RDTreeWidgetItem *item = ui->savedList->selectedItem(); + + if(!item) + return; + + QString name = item->text(0); + + QMessageBox::StandardButton res = RDDialog::question( + this, tr("Deleting definition"), + tr("Are you sure you wish to delete definition '%1'?").arg(name), RDDialog::YesNoCancel); + + if(res != QMessageBox::Yes) + return; + + ui->savedList->clearSelection(); + + globalFormatList->setFormat(name, QString()); +} + +void BufferFormatSpecifier::on_formatText_textChanged() +{ + ui->savedList->clearSelection(); +} + void BufferFormatSpecifier::on_apply_clicked() { setErrors(QString()); diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.h b/qrenderdoc/Widgets/BufferFormatSpecifier.h index 1f529de1a..661bc96f5 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.h +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.h @@ -24,15 +24,38 @@ #pragma once +#include #include struct ICaptureContext; +class RDTreeWidgetItem; + namespace Ui { class BufferFormatSpecifier; } +class BufferFormatList : public QObject +{ + Q_OBJECT + + ICaptureContext &m_Ctx; + QMap formats; + +public: + explicit BufferFormatList(ICaptureContext &ctx, QObject *parent = 0); + QStringList getFormats() { return formats.keys(); } + QString getFormat(QString name) { return formats[name]; } + bool hasFormat(QString name) { return formats.contains(name); } + void setFormat(QString name, QString format); + +signals: + void formatListUpdated(); +}; + +extern BufferFormatList *globalFormatList; + class BufferFormatSpecifier : public QWidget { Q_OBJECT @@ -41,6 +64,8 @@ public: explicit BufferFormatSpecifier(QWidget *parent = 0); ~BufferFormatSpecifier(); + void setAutoFormat(QString autoFormat); + void setContext(ICaptureContext *ctx); void setTitle(QString title); @@ -48,10 +73,21 @@ signals: void processFormat(const QString &format); public slots: - void toggleHelp(); + // automatic slots + void on_showHelp_toggled(bool help); + void on_loadDef_clicked(); + void on_saveDef_clicked(); + void on_delDef_clicked(); + void on_formatText_textChanged(); + void on_savedList_keyPress(QKeyEvent *event); + void on_savedList_itemChanged(RDTreeWidgetItem *item, int column); + void on_savedList_itemDoubleClicked(RDTreeWidgetItem *item, int column); + void on_savedList_itemSelectionChanged(); + + // manual slots void setFormat(const QString &format); void setErrors(const QString &errors); - void showHelp(bool help); + void updateFormatList(); private slots: void on_apply_clicked(); @@ -59,4 +95,6 @@ private slots: private: Ui::BufferFormatSpecifier *ui; ICaptureContext *m_Ctx; + + QString m_AutoFormat; }; diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.ui b/qrenderdoc/Widgets/BufferFormatSpecifier.ui index 4690b46e2..e4f0eecbb 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.ui +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.ui @@ -6,8 +6,8 @@ 0 0 - 713 - 633 + 800 + 600 @@ -30,30 +30,6 @@ 0 - - - Type in a buffer format declaration. C and C++ comments are skipped, semantics are ignored. - -Structs can be defined and nested, and if no variables are 'loose' the last struct specified will be used. - -Declare each element as an hlsl/glsl variable, e.g: "float4 first; float2 second; uint2 third;" or vec4/vec2. - -Basic types accepted: bool, byte, short, int, half, float, double. -Unsigned integer types: ubyte, ushort, uint -Hex-formatted integer types: xbyte, xshort, xint - -Additionally special formats: unorm[hb] (half, byte) and snorm[hb], uintten/unormten (10:10:10:2 packing), floateleven (11:11:10F packing) - -You can prepend 'rgb' onto an element to colour backgrounds with the RGB values, e.g. 'rgb xbyte4 pixels[256]'. - -Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension arrays (float[16]) are supported. - - - true - - - - @@ -64,7 +40,10 @@ Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension array Format - + + + 2 + 2 @@ -80,10 +59,188 @@ Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension array + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Exhaustive documentation can be found in the </span><a href="https://renderdoc.org/docs/how/how_buffer_format.html"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">online docs</span></a><span style=" font-size:8pt;">.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Buffer format declarations are similar to HLSL or GLSL struct definitions with normal vector, matrix and base types (e.g. <code>float</code>, <code>float4</code> or <code>vec4</code>, etc). In many cases these can be copied and pasted from shader source.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You can define and use structs. The buffer format is defined by all global variables. If there are no globals defined, the last struct defined will be used.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Most types that can be declared in shaders can be used, including half, short, as well as the usual int, float. All of these can be matrices or arrays.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Packing/padding rules can be specified with <code>#pack(rules)</code>. Supported D3D rules: <code>cbuffer</code>, <code>uav</code>. Supported GL/VK rules: <code>std140</code>, <code>std430</code>, <code>scalar</code>.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Bitfields are supported using C syntax, enums can be defined but all enum values must have explicit decimal or hexadecimal numerical values.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Annotations are supported for explicit layout, bitpacked types like R10G10B10A2, or alternate displays of values including RGB/hexadecimal/octal display. For a complete list see </span><a href="https://renderdoc.org/docs/how/how_buffer_format.html"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">the documentation linked above</span></a><span style=" font-size:8pt;">.</span></p></body></html> + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustIgnored + + + 0 + + + false + + + false + + + false + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + 2 + + + 0 + + + + + Show buffer definition help + + + + :/help.png:/help.png + + + true + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 100 + 20 + + + + + + + + Delete selected structure definition + + + + :/del.png:/del.png + + + true + + + + + + + Update selected with current structure definition + + + + :/save.png:/save.png + + + true + + + + + + + Load selected structure definition + + + + :/action_hover.png:/action_hover.png + + + true + + + + + + + + - + @@ -133,9 +290,12 @@ Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension array 14 + + true + - + @@ -150,19 +310,6 @@ Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension array - - - - - 0 - 0 - - - - Toggle Help - - - @@ -180,6 +327,15 @@ Vectors (e.g. float4), matrices ([row_major] half3x4) and single-dimension array - + + + RDTreeWidget + QTreeView +
Widgets/Extended/RDTreeWidget.h
+
+
+ + + diff --git a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp index 07e7b076e..4207e68d9 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp @@ -774,9 +774,14 @@ void RDTreeWidget::collapseAllItems(RDTreeWidgetItem *item) collapseAll(m_model->indexForItem(item, 0)); } -void RDTreeWidget::scrollToItem(RDTreeWidgetItem *node) +void RDTreeWidget::scrollToItem(RDTreeWidgetItem *item) { - scrollTo(m_model->indexForItem(node, 0)); + scrollTo(m_model->indexForItem(item, 0)); +} + +void RDTreeWidget::editItem(RDTreeWidgetItem *item) +{ + edit(m_model->indexForItem(item, 0)); } void RDTreeWidget::clear() diff --git a/qrenderdoc/Widgets/Extended/RDTreeWidget.h b/qrenderdoc/Widgets/Extended/RDTreeWidget.h index 396001410..2e84a62fa 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeWidget.h +++ b/qrenderdoc/Widgets/Extended/RDTreeWidget.h @@ -269,7 +269,8 @@ public: void expandAllItems(RDTreeWidgetItem *item); void collapseItem(RDTreeWidgetItem *item); void collapseAllItems(RDTreeWidgetItem *item); - void scrollToItem(RDTreeWidgetItem *node); + void scrollToItem(RDTreeWidgetItem *item); + void editItem(RDTreeWidgetItem *item); void clear(); diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index e504fe98b..63894b1a5 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -4166,7 +4166,7 @@ void BufferViewer::ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId m_PagingByteOffset = 0; - ui->formatSpecifier->setFormat(format); + ui->formatSpecifier->setAutoFormat(format); processFormat(format); } diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 50f3bb017..8fdb16755 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -65,16 +65,6 @@ struct AccessedResourceTag Q_DECLARE_METATYPE(VariableTag); Q_DECLARE_METATYPE(AccessedResourceTag); -FullEditorDelegate::FullEditorDelegate(QWidget *parent) : QStyledItemDelegate(parent) -{ -} - -QWidget *FullEditorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - return new QLineEdit(parent); -} - ShaderViewer::ShaderViewer(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::ShaderViewer), m_Ctx(ctx) { diff --git a/qrenderdoc/Windows/ShaderViewer.h b/qrenderdoc/Windows/ShaderViewer.h index f940e21be..f0b09ffcf 100644 --- a/qrenderdoc/Windows/ShaderViewer.h +++ b/qrenderdoc/Windows/ShaderViewer.h @@ -70,17 +70,6 @@ struct AccessedResourceData rdcarray steps; }; -class FullEditorDelegate : public QStyledItemDelegate -{ -private: - Q_OBJECT - -public: - FullEditorDelegate(QWidget *parent); - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; -}; - enum class WatchVarState : int { Invalid = 0, diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 25cbea7a0..ed3ce5815 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -1992,6 +1992,8 @@ + + diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 44558565f..e04ec9129 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -1963,6 +1963,12 @@ Resources\Files + + Resources\Files + + + Resources\Files +