summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMartin Schulze <schulmar@hrz.tu-chemnitz.de>2016-05-01 08:02:20 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-05-01 08:09:45 +0100
commitfbfe7a6f38498c2dd18bf7b896c84171198dc7e9 (patch)
tree81adec795945f70421e31dbdd0a4cecb8c3e83ee /gui
parent3e75cd9f3c43d4dc9f72cee9055de79b1277afd4 (diff)
gui: Split finding referencing shaders and name shortening into own functions.
Diffstat (limited to 'gui')
-rw-r--r--gui/mainwindow.cpp55
1 files changed, 33 insertions, 22 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 37d373fb..cbd31cb7 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -815,8 +815,35 @@ void MainWindow::addSurfaces(const QList<Surface> &surfaces, const char *label)
}
}
-static void setValueOfSSBBItem(const ApiTraceState &state,
- QTreeWidgetItem *bufferItem)
+QStringList shortenReferencingShaderNames(QStringList referencingShaders)
+{
+ 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"}};
+ for (auto &referencingShader : referencingShaders) {
+ assert(map.count(referencingShader));
+ referencingShader = map[referencingShader];
+ }
+ return referencingShaders;
+}
+
+QStringList getReferencingShaders(QTreeWidgetItem *bufferItem)
+{
+ QStringList referencingShaders;
+ 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);
+ }
+ }
+ return referencingShaders;
+}
+
+void setValueOfSSBBItem(const ApiTraceState &state, QTreeWidgetItem *bufferItem)
{
assert(bufferItem);
const auto &bufferBindingItem = bufferItem->child(0);
@@ -843,28 +870,12 @@ static void setValueOfSSBBItem(const ApiTraceState &state,
assert(SSB.count("GL_SHADER_STORAGE_BUFFER_BINDING"));
auto bufferName = SSB["GL_SHADER_STORAGE_BUFFER_BINDING"].toInt();
+ // Build overview text like:
+ // "Binding 1 in VS, FS; Buffer 16 (6 Bytes starting at 2)"
QString bindingText = QString("Binding %0").arg(bufferBindingIndex);
- QStringList referencingShaders;
- 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];
- }
+ QStringList referencingShaders =
+ shortenReferencingShaderNames(getReferencingShaders(bufferItem));
if (!referencingShaders.empty()) {
bindingText += " in ";
bindingText += referencingShaders.join(", ");