summaryrefslogtreecommitdiff
path: root/retrace
diff options
context:
space:
mode:
authorMark Janes <mark.a.janes@intel.com>2017-10-19 13:55:59 -0700
committerMark Janes <mark.a.janes@intel.com>2017-11-27 11:17:07 -0800
commit710f41356207a94ec178444039a870ff908e9417 (patch)
treee241f3be1cfb3c9a46ed21d9c1ec41c586fbfaf2 /retrace
parented3a98881b365f079793b6d022bb7c525bc1fcf6 (diff)
State: Identify state items by group, path, and name
State group designates which tab will hold the item. Path is reflected in the nested directories of state used to organize the tree view.
Diffstat (limited to 'retrace')
-rw-r--r--retrace/daemon/glframe_retrace_interface.hpp30
-rw-r--r--retrace/daemon/glframe_retrace_render.cpp36
-rw-r--r--retrace/daemon/glframe_retrace_skeleton.cpp16
-rw-r--r--retrace/daemon/glframe_retrace_stub.cpp11
-rw-r--r--retrace/daemon/playback.proto11
-rw-r--r--retrace/daemon/ui/glframe_state_model.cpp55
-rw-r--r--retrace/daemon/ui/glframe_state_model.hpp10
-rw-r--r--retrace/daemon/ui/qml/StateControl.qml59
8 files changed, 93 insertions, 135 deletions
diff --git a/retrace/daemon/glframe_retrace_interface.hpp b/retrace/daemon/glframe_retrace_interface.hpp
index 8badec99..61fba458 100644
--- a/retrace/daemon/glframe_retrace_interface.hpp
+++ b/retrace/daemon/glframe_retrace_interface.hpp
@@ -259,29 +259,31 @@ enum UniformDimension {
k4x4
};
-// Serializable asynchronous callbacks made from remote
-// implementations of IFrameRetrace.
-enum StateItem {
- CULL_FACE = 0x0B44,
- CULL_FACE_MODE = 0x0B45,
- INVALID_NAME = -1,
-};
-
struct StateKey {
- StateItem name;
- int index;
-
- StateKey() : name(INVALID_NAME), index(0) {}
- StateKey(StateItem n, int i) : name(n), index(i) {}
+ std::string group;
+ std::string path;
+ std::string name;
+
+ StateKey() {}
+ StateKey(const std::string _group,
+ const std::string _path,
+ const std::string _name)
+ : group(_group), path(_path), name(_name) {}
bool operator<(const StateKey &o) const {
if (name < o.name)
return true;
if (name > o.name)
return false;
- return index < o.index;
+ if (path < o.path)
+ return true;
+ if (path > o.path)
+ return false;
+ return group < o.group;
}
};
+// Serializable asynchronous callbacks made from remote
+// implementations of IFrameRetrace.
class OnFrameRetrace {
public:
typedef std::vector<unsigned char> uvec;
diff --git a/retrace/daemon/glframe_retrace_render.cpp b/retrace/daemon/glframe_retrace_render.cpp
index c39069d4..dcb73284 100644
--- a/retrace/daemon/glframe_retrace_render.cpp
+++ b/retrace/daemon/glframe_retrace_render.cpp
@@ -50,8 +50,6 @@ using glretrace::StateTrack;
using glretrace::RenderTargetType;
using glretrace::RenderId;
using glretrace::OnFrameRetrace;
-using glretrace::CULL_FACE;
-using glretrace::CULL_FACE_MODE;
using glretrace::state_name_to_enum;
static const std::string simple_fs =
@@ -153,10 +151,13 @@ class RetraceRender::UniformOverride {
uint32_t
glretrace::state_name_to_enum(const std::string &value) {
static const std::map<std::string, uint32_t> names {
- {"CULL_FACE", CULL_FACE},
- {"CULL_FACE_MODE", CULL_FACE_MODE}
+ {"CULL_FACE", GL_CULL_FACE},
+ {"CULL_FACE_MODE", GL_CULL_FACE_MODE}
};
- return names.find(value)->second;
+ const auto i = names.find(value);
+ if (i == names.end())
+ return GL_INVALID_ENUM;
+ return i->second;
}
uint32_t value_to_int(const std::string &value) {
@@ -205,13 +206,13 @@ RetraceRender::StateOverride::saveState() {
for (auto i : m_overrides) {
if (m_saved_state.find(i.first) != m_saved_state.end())
continue;
- switch (i.first.name) {
- case CULL_FACE:
+ switch (glretrace::state_name_to_enum(i.first.name)) {
+ case GL_CULL_FACE:
assert(GL::GetError() == GL_NO_ERROR);
m_saved_state[i.first] = GlFunctions::IsEnabled(GL_CULL_FACE);
assert(GL::GetError() == GL_NO_ERROR);
break;
- case CULL_FACE_MODE: {
+ case GL_CULL_FACE_MODE: {
assert(GL::GetError() == GL_NO_ERROR);
GLint cull;
GlFunctions::GetIntegerv(GL_CULL_FACE_MODE, &cull);
@@ -219,7 +220,8 @@ RetraceRender::StateOverride::saveState() {
m_saved_state[i.first] = cull;
break;
}
- case INVALID_NAME:
+ case GL_INVALID_ENUM:
+ default:
assert(false);
break;
}
@@ -238,23 +240,23 @@ RetraceRender::StateOverride::restoreState() const {
void
RetraceRender::StateOverride::enact_state(const KeyMap &m) const {
+ GL::GetError();
for (auto i : m) {
- switch (i.first.name) {
- case CULL_FACE:
- assert(GL::GetError() == GL_NO_ERROR);
+ switch (glretrace::state_name_to_enum(i.first.name)) {
+ case GL_CULL_FACE:
if (i.second)
GlFunctions::Enable(GL_CULL_FACE);
else
GlFunctions::Disable(GL_CULL_FACE);
assert(GL::GetError() == GL_NO_ERROR);
break;
- case CULL_FACE_MODE: {
- assert(GL::GetError() == GL_NO_ERROR);
+ case GL_CULL_FACE_MODE: {
GlFunctions::CullFace(i.second);
assert(GL::GetError() == GL_NO_ERROR);
break;
}
- case INVALID_NAME:
+ case GL_INVALID_ENUM:
+ default:
assert(false);
break;
}
@@ -579,7 +581,7 @@ RetraceRender::onState(SelectionId selId,
GLenum e = GL::GetError();
if (e == GL_NO_ERROR) {
callback->onState(selId, experimentCount, renderId,
- StateKey(CULL_FACE, 0),
+ StateKey("", "", "CULL_FACE"),
cull_enabled ? "true" : "false");
}
}
@@ -592,7 +594,7 @@ RetraceRender::onState(SelectionId selId,
const std::string cull_str = value_to_string(cull);
if (cull_str.size() > 0) {
callback->onState(selId, experimentCount, renderId,
- StateKey(CULL_FACE_MODE, 0), cull_str);
+ StateKey("", "", "CULL_FACE_MODE"), cull_str);
}
}
}
diff --git a/retrace/daemon/glframe_retrace_skeleton.cpp b/retrace/daemon/glframe_retrace_skeleton.cpp
index a66f9e20..4b3ae135 100644
--- a/retrace/daemon/glframe_retrace_skeleton.cpp
+++ b/retrace/daemon/glframe_retrace_skeleton.cpp
@@ -402,8 +402,9 @@ FrameRetraceSkeleton::Run() {
state_resp->set_experiment_count(-1);
state_resp->set_value("");
auto r_item = state_resp->mutable_item();
- r_item->set_name(ApiTrace::StateItem(ApiTrace::INVALID_STATE_ITEM));
- r_item->set_index(0);
+ r_item->set_group("");
+ r_item->set_path("");
+ r_item->set_name("");
writeResponse(m_socket, proto_response, &m_buf);
break;
}
@@ -413,8 +414,10 @@ FrameRetraceSkeleton::Run() {
auto state = request.set_state();
RenderSelection selection;
makeRenderSelection(state.selection(), &selection);
- glretrace::StateKey k((glretrace::StateItem)state.item().name(),
- state.item().index());
+ auto &item = state.item();
+ glretrace::StateKey k(item.group(),
+ item.path(),
+ item.name());
m_frame->setState(selection, k, state.value());
break;
}
@@ -648,8 +651,9 @@ FrameRetraceSkeleton::onState(SelectionId selectionCount,
response->set_selection_count(selectionCount());
response->set_experiment_count(experimentCount.count());
auto r_item = response->mutable_item();
- r_item->set_name(ApiTrace::StateItem(item.name));
- r_item->set_index(item.index);
+ r_item->set_group(item.group);
+ r_item->set_path(item.path);
+ r_item->set_name(item.name);
response->set_value(value);
writeResponse(m_socket, proto_response, &m_buf);
}
diff --git a/retrace/daemon/glframe_retrace_stub.cpp b/retrace/daemon/glframe_retrace_stub.cpp
index 8199f999..1bddfcde 100644
--- a/retrace/daemon/glframe_retrace_stub.cpp
+++ b/retrace/daemon/glframe_retrace_stub.cpp
@@ -999,9 +999,8 @@ class StateRequest : public IRetraceRequest {
continue;
}
const RenderId rid(state_response.render_id());
- glretrace::StateKey k((glretrace::StateItem)state_response.item().name(),
- state_response.item().index());
-
+ auto &item = state_response.item();
+ glretrace::StateKey k(item.group(), item.path(), item.name());
m_callback->onState(selection, experiment, rid,
k, state_response.value());
}
@@ -1028,13 +1027,15 @@ class SetStateRequest : public IRetraceRequest {
msg.set_requesttype(ApiTrace::SET_STATE_REQUEST);
auto req = msg.mutable_set_state();
auto item = req->mutable_item();
- item->set_name(static_cast<ApiTrace::StateItem>(m_item.name));
- item->set_index(m_item.index);
+ item->set_group(m_item.group);
+ item->set_path(m_item.path);
+ item->set_name(m_item.name);
auto selection = req->mutable_selection();
makeRenderSelection(m_selection, selection);
req->set_value(m_value);
sock->request(msg);
}
+
private:
const RenderSelection m_selection;
const StateKey m_item;
diff --git a/retrace/daemon/playback.proto b/retrace/daemon/playback.proto
index b21d76b8..503831b7 100644
--- a/retrace/daemon/playback.proto
+++ b/retrace/daemon/playback.proto
@@ -231,15 +231,10 @@ message StateRequest {
required uint32 experiment_count = 2;
}
-enum StateItem {
- CULL_FACE = 0x0B44;
- CULL_FACE_MODE = 0x0B45;
- INVALID_STATE_ITEM = 0x0;
-}
-
message StateKey {
- required StateItem name = 1;
- required uint32 index = 2;
+ required string group = 1;
+ required string path = 2;
+ required string name = 3;
}
message StateResponse {
diff --git a/retrace/daemon/ui/glframe_state_model.cpp b/retrace/daemon/ui/glframe_state_model.cpp
index 97e971e2..da0063e7 100644
--- a/retrace/daemon/ui/glframe_state_model.cpp
+++ b/retrace/daemon/ui/glframe_state_model.cpp
@@ -26,6 +26,7 @@
**************************************************************************/
#include "glframe_state_model.hpp"
+#include <GL/gl.h>
#include <string>
#include <vector>
@@ -35,18 +36,21 @@
using glretrace::QStateModel;
using glretrace::QStateValue;
-using glretrace::StateItem;
using glretrace::state_name_to_enum;
+static const int kUninitializedValue = -2;
+static const int kMixedValue = -1;
+
QStateValue::QStateValue(const std::string &_name,
const std::vector<std::string> &_choices)
- : m_name(_name.c_str()) {
+ : m_name(_name.c_str()),
+ m_value(kUninitializedValue) {
for (auto c : _choices)
m_choices.append(QVariant(c.c_str()));
}
void
-QStateValue::insert(int index, const std::string &value) {
+QStateValue::insert(const std::string &value) {
int value_index = 0;
QVariant qvalue(value.c_str());
for (auto c : m_choices) {
@@ -57,13 +61,15 @@ QStateValue::insert(int index, const std::string &value) {
// value must be found
assert(value_index < m_choices.size());
- while (m_values.size() < index)
- m_values.append(0);
- if (m_values.size() == index)
- m_values.append(value_index);
- else if (m_values[index] != value_index)
+ if (m_value == kUninitializedValue) {
+ // selected renders have different values
+ m_value = value_index;
+ return;
+ }
+
+ if (m_value != value_index)
// selected renders have different values
- m_values[index] = -1;
+ m_value = kMixedValue;
}
QStateModel::QStateModel() {}
@@ -77,25 +83,14 @@ QQmlListProperty<QStateValue> QStateModel::state() {
return QQmlListProperty<glretrace::QStateValue>(this, m_states);
}
-std::string
-state_name_to_string(StateItem n) {
- switch (n) {
- case glretrace::CULL_FACE:
- return std::string("CULL_FACE");
- case glretrace::CULL_FACE_MODE:
- return std::string("CULL_FACE_MODE");
- default:
- assert(false);
- }
-}
-
std::vector<std::string>
-name_to_choices(StateItem n) {
- switch (n) {
- case glretrace::CULL_FACE:
+name_to_choices(const std::string &n) {
+ switch (state_name_to_enum(n)) {
+ case GL_CULL_FACE:
return {"true", "false"};
- case glretrace::CULL_FACE_MODE:
+ case GL_CULL_FACE_MODE:
return {"GL_FRONT", "GL_BACK", "GL_FRONT_AND_BACK"};
+ case GL_INVALID_ENUM:
default:
assert(false);
}
@@ -156,20 +151,19 @@ void QStateModel::onState(SelectionId selectionCount,
}
if (m_renders.empty() || renderId != m_renders.back())
m_renders.push_back(renderId);
- const auto name = state_name_to_string(item.name);
+ auto &name = item.name;
auto state_value = m_state_by_name.find(name);
if (state_value == m_state_by_name.end()) {
QStateValue *i = new QStateValue(name,
- name_to_choices(item.name));
+ name_to_choices(name));
m_state_by_name[name] = i;
state_value = m_state_by_name.find(name);
}
- state_value->second->insert(item.index, value);
+ state_value->second->insert(value);
}
void
QStateModel::setState(const QString &name,
- const int index,
const QString &value) {
RenderSelection sel;
sel.id = m_sel_count;
@@ -184,8 +178,7 @@ QStateModel::setState(const QString &name,
++r;
}
- StateItem i = static_cast<StateItem>(state_name_to_enum(name.toStdString()));
- StateKey key(i, index);
+ StateKey key("", "", name.toStdString());
m_retrace->setState(sel, key, value.toStdString());
emit stateExperiment();
}
diff --git a/retrace/daemon/ui/glframe_state_model.hpp b/retrace/daemon/ui/glframe_state_model.hpp
index 0532e017..6c764382 100644
--- a/retrace/daemon/ui/glframe_state_model.hpp
+++ b/retrace/daemon/ui/glframe_state_model.hpp
@@ -48,22 +48,23 @@ class QStateValue : public QObject, NoCopy, NoAssign, NoMove {
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT)
- Q_PROPERTY(QList<QVariant> values READ values CONSTANT)
+ Q_PROPERTY(QVariant value READ value CONSTANT)
Q_PROPERTY(QList<QVariant> choices READ choices CONSTANT)
public:
QStateValue() {}
QStateValue(const std::string &_name,
const std::vector<std::string> &_choices);
- void insert(int index, const std::string &value);
+ void insert(const std::string &value);
QString name() const { return m_name; }
- QList<QVariant> values() const { return m_values; }
+ QVariant value() const { return m_value; }
QList<QVariant> choices() const { return m_choices; }
private:
QString m_name;
- QList<QVariant> m_values, m_choices;
+ QVariant m_value;
+ QList<QVariant> m_choices;
};
class QStateModel : public QObject,
@@ -83,7 +84,6 @@ class QStateModel : public QObject,
const std::string &value);
void clear();
Q_INVOKABLE void setState(const QString &name,
- const int index,
const QString &value);
signals:
diff --git a/retrace/daemon/ui/qml/StateControl.qml b/retrace/daemon/ui/qml/StateControl.qml
index c54f8b40..2eda8a85 100644
--- a/retrace/daemon/ui/qml/StateControl.qml
+++ b/retrace/daemon/ui/qml/StateControl.qml
@@ -5,35 +5,6 @@ import ApiTrace 1.0
Item {
property QStateModel stateModel
- function getWidth(choices) {
- console.warn("getWidth called: " + choices.length.toString());
- var len = 0;
- for (var i = 0; i < choices.length; i++) {
- console.warn("getWidth: " + choices[i]);
- var choice_len = choices[i].length;
- if (choice_len > len) {
- len = choice_len;
- }
- }
- console.warn("getWidth returned: " + len.toString());
- return len;
- }
-
- function getLongest(choices) {
- console.warn("getLongest called: " + choices.length.toString());
- var len = 0;
- var longest = 0;
- for (var i = 0; i < choices.length; i++) {
- console.warn("getLongest: " + choices[i]);
- var choice_len = choices[i].length;
- if (choice_len > len) {
- len = choice_len;
- longest = i;
- }
- }
- console.warn("getLongest returned: " + choices[longest]);
- return choices[longest];
- }
ScrollView {
anchors.fill: parent
@@ -42,29 +13,19 @@ Item {
model: stateModel.state
anchors.fill: parent
delegate: Component {
- Column {
+ Row {
Text {
id: nameText
- text: modelData.name
+ anchors.verticalCenter: parent.verticalCenter
+ text: modelData.name + " : "
}
- Row {
- id: stateGrid
- anchors.left: parent.left
- anchors.right: parent.right
- Repeater {
- model: modelData.values
- property var choices: modelData.choices
- property var name: modelData.name
- ComboBoxFitContents {
- model: choices
- property int stateIndex : index
- currentIndex: modelData
- onActivated: {
- stateModel.setState(name,
- stateIndex,
- choices[currentIndex]);
- }
- }
+ ComboBoxFitContents {
+ anchors.verticalCenter: parent.verticalCenter
+ model: modelData.choices
+ currentIndex: modelData.value
+ onActivated: {
+ stateModel.setState(modelData.name,
+ modelData.choices[currentIndex]);
}
}
}