summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/apitracecall.cpp8
-rw-r--r--gui/apitracecall.h2
-rw-r--r--gui/mainwindow.cpp91
-rw-r--r--gui/ui/mainwindow.ui33
4 files changed, 134 insertions, 0 deletions
diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp
index 0f5f4bb9..7c22c4ea 100644
--- a/gui/apitracecall.cpp
+++ b/gui/apitracecall.cpp
@@ -483,6 +483,9 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
m_buffers = parsedJson[QLatin1String("buffers")].toMap();
+ m_shaderStorageBufferBlocks =
+ parsedJson[QLatin1String("shaderstoragebufferblocks")].toMap();
+
{
QVariantMap textures =
parsedJson[QLatin1String("textures")].toMap();
@@ -541,6 +544,11 @@ const QVariantMap & ApiTraceState::buffers() const
return m_buffers;
}
+const QVariantMap &ApiTraceState::shaderStorageBufferBlocks() const
+{
+ return m_shaderStorageBufferBlocks;
+}
+
bool ApiTraceState::isEmpty() const
{
return m_parameters.isEmpty() &&
diff --git a/gui/apitracecall.h b/gui/apitracecall.h
index e4db6ae5..5ad2e3f8 100644
--- a/gui/apitracecall.h
+++ b/gui/apitracecall.h
@@ -149,6 +149,7 @@ public:
const QMap<QString, QString> & shaderSources() const;
const QVariantMap & uniforms() const;
const QVariantMap & buffers() const;
+ const QVariantMap & shaderStorageBufferBlocks() const;
const QList<ApiTexture> & textures() const;
const QList<ApiFramebuffer> & framebuffers() const;
@@ -158,6 +159,7 @@ private:
QMap<QString, QString> m_shaderSources;
QVariantMap m_uniforms;
QVariantMap m_buffers;
+ QVariantMap m_shaderStorageBufferBlocks;
QList<ApiTexture> m_textures;
QList<ApiFramebuffer> m_framebuffers;
};
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()
diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui
index 89fc378c..238920ad 100644
--- a/gui/ui/mainwindow.ui
+++ b/gui/ui/mainwindow.ui
@@ -298,6 +298,39 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="ssbTab">
+ <attribute name="title">
+ <string>SSBBs</string>
+ </attribute>
+ <attribute name="toolTip">
+ <string>Shader Storage Buffer Blocks</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_8">
+ <item>
+ <widget class="QTreeWidget" name="ssbsTreeWidget">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>