summaryrefslogtreecommitdiff
path: root/gui/mainwindow.cpp
diff options
context:
space:
mode:
authorMartin Schulze <schulmar@hrz.tu-chemnitz.de>2016-03-23 17:03:16 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-03-29 16:25:37 +0100
commite9e8578d85c8d309fb294f22c8376167f0cdf082 (patch)
treebfcd4f7607bc25d789bb06cbe24f23c15b29f741 /gui/mainwindow.cpp
parent6d38481f1b2c01379ef083302f5ef4a309ad630b (diff)
gui: Show Shader Storage Buffer Blocks.
https://github.com/apitrace/apitrace/pull/437
Diffstat (limited to 'gui/mainwindow.cpp')
-rw-r--r--gui/mainwindow.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index e1859973..afbd09f2 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -797,6 +797,84 @@ void MainWindow::addSurfaces(const QList<Surface> &surfaces, const char *label)
}
}
+static void setValueOfSSBBItem(const ApiTraceState &state,
+ QTreeWidgetItem *bufferItem)
+{
+ assert(bufferItem);
+ const auto &bufferBindingItem = bufferItem->child(0);
+ assert(bufferBindingItem->text(0) == "GL_BUFFER_BINDING");
+ const int bufferBindingIndex = bufferBindingItem->text(1).toInt();
+ qDebug() << bufferBindingIndex;
+ assert(state.parameters().count("GL_SHADER_STORAGE_BUFFER"));
+ assert(state.parameters()["GL_SHADER_STORAGE_BUFFER"].toMap().count("i"));
+ assert(bufferBindingIndex < state.parameters()["GL_SHADER_STORAGE_BUFFER"]
+ .toMap()["i"]
+ .toList()
+ .size());
+ const auto &SSB = state.parameters()["GL_SHADER_STORAGE_BUFFER"]
+ .toMap()["i"]
+ .toList()[bufferBindingIndex]
+ .toMap();
+
+ assert(SSB.count("GL_SHADER_STORAGE_BUFFER_START"));
+ auto start = SSB["GL_SHADER_STORAGE_BUFFER_START"].toInt();
+
+ assert(SSB.count("GL_SHADER_STORAGE_BUFFER_SIZE"));
+ auto size = SSB["GL_SHADER_STORAGE_BUFFER_SIZE"].toInt();
+
+ assert(SSB.count("GL_SHADER_STORAGE_BUFFER_BINDING"));
+ auto bufferName = SSB["GL_SHADER_STORAGE_BUFFER_BINDING"].toInt();
+
+ QString bindingText = QString("Binding %0").arg(bufferBindingIndex);
+ QStringList referencingShaders = {"GL_REFERENCED_BY_VERTEX_SHADER"};
+
+ for(int i = 0; i < bufferItem->childCount(); ++i) {
+ const auto &text = bufferItem->child(i)->text(0);
+ if (text.startsWith("GL_REFERENCED_BY_") && text.endsWith("_SHADER")) {
+ referencingShaders.append(text);
+ }
+ }
+
+ static QMap<QString, QString> map = {
+ {"GL_REFERENCED_BY_VERTEX_SHADER", "VS"},
+ {"GL_REFERENCED_BY_TESS_CONTROL_SHADER", "TCS"},
+ {"GL_REFERENCED_BY_TESS_EVALUATION_SHADER", "TES"},
+ {"GL_REFERENCED_BY_GEOMETRY_SHADER", "GS"},
+ {"GL_REFERENCED_BY_FRAGMENT_SHADER", "FS"},
+ {"GL_REFERENCED_BY_COMPUTE_SHADER", "CS"}};
+ // shorten list
+ for(auto &referencingShader: referencingShaders) {
+ assert(map.count(referencingShader));
+ referencingShader = map[referencingShader];
+ }
+ if (!referencingShaders.empty()) {
+ bindingText += " in ";
+ bindingText += referencingShaders.join(", ");
+ }
+
+ QString bufferText;
+ if (bufferName != 0) {
+ bufferText = QString("Buffer %0").arg(bufferName);
+ if (size != 0) {
+ if (start != 0) {
+ bufferText +=
+ QString(" (%0 Bytes starting at %1)").arg(size).arg(start);
+ } else {
+ bufferText += QString(" (first %0 Bytes)").arg(size);
+ }
+ } else {
+ if (start != 0) {
+ bufferText += QString(" (starting at offset %0)").arg(start);
+ }
+ }
+ }
+ if (bufferText.isEmpty()) {
+ bufferItem->setText(1, bindingText);
+ } else {
+ bufferItem->setText(1, bindingText + "; " + bufferText);
+ }
+}
+
void MainWindow::fillStateForFrame()
{
if (!m_selectedEvent || !m_selectedEvent->hasState()) {
@@ -854,6 +932,19 @@ void MainWindow::fillStateForFrame()
m_ui.surfacesTab->setEnabled(true);
}
m_ui.stateDock->show();
+
+ {
+ m_ui.ssbsTreeWidget->clear();
+ QList<QTreeWidgetItem *> buffersItems;
+ variantMapToItems(state.shaderStorageBufferBlocks(), QVariantMap(),
+ buffersItems);
+ const bool hasSSBs = buffersItems.size() > 0;
+ for (auto const &bufferItem : buffersItems) {
+ setValueOfSSBBItem(state, bufferItem);
+ }
+ m_ui.ssbsTreeWidget->insertTopLevelItems(0, buffersItems);
+ m_ui.ssbTab->setEnabled(hasSSBs);
+ }
}
void MainWindow::showSettings()