summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--retrace/daemon/CMakeLists.txt2
-rw-r--r--retrace/daemon/glframe_retrace_render.cpp42
-rw-r--r--retrace/daemon/glframe_retrace_render.hpp2
-rw-r--r--retrace/daemon/glframe_state_enums.cpp151
-rw-r--r--retrace/daemon/glframe_state_enums.hpp45
-rw-r--r--retrace/daemon/ui/glframe_state_model.cpp16
6 files changed, 204 insertions, 54 deletions
diff --git a/retrace/daemon/CMakeLists.txt b/retrace/daemon/CMakeLists.txt
index 237f60de..bd86fde7 100644
--- a/retrace/daemon/CMakeLists.txt
+++ b/retrace/daemon/CMakeLists.txt
@@ -73,6 +73,8 @@ set (RETRACE_SOURCES
glframe_socket.cpp
glframe_state.cpp
glframe_state.hpp
+ glframe_state_enums.cpp
+ glframe_state_enums.hpp
glframe_stderr.hpp
glframe_thread.hpp
glframe_traits.hpp
diff --git a/retrace/daemon/glframe_retrace_render.cpp b/retrace/daemon/glframe_retrace_render.cpp
index a0ebfff1..5b2f3427 100644
--- a/retrace/daemon/glframe_retrace_render.cpp
+++ b/retrace/daemon/glframe_retrace_render.cpp
@@ -36,6 +36,7 @@
#include "glframe_logger.hpp"
#include "glframe_metrics.hpp"
#include "glframe_state.hpp"
+#include "glframe_state_enums.hpp"
#include "glframe_uniforms.hpp"
#include "retrace.hpp"
#include "glstate_internal.hpp"
@@ -51,6 +52,7 @@ using glretrace::RenderTargetType;
using glretrace::RenderId;
using glretrace::OnFrameRetrace;
using glretrace::state_name_to_enum;
+using glretrace::state_enum_to_name;
static const std::string simple_fs =
"void main(void) {\n"
@@ -148,35 +150,12 @@ class RetraceRender::UniformOverride {
std::map<UniformKey, std::string> m_uniform_overrides;
};
-uint32_t
-glretrace::state_name_to_enum(const std::string &value) {
- static const std::map<std::string, uint32_t> names {
- {"CULL_FACE", GL_CULL_FACE},
- {"CULL_FACE_MODE", GL_CULL_FACE_MODE}
- };
- 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) {
- static const std::map<std::string, uint32_t> lookup = {
- {"GL_FRONT", GL_FRONT},
- {"GL_BACK", GL_BACK},
- {"GL_FRONT_AND_BACK", GL_FRONT_AND_BACK},
- {"true", 1},
- {"false", 0}
- };
- return lookup.find(value)->second;
-}
-
class RetraceRender::StateOverride {
public:
StateOverride() {}
void setState(const StateKey &item,
const std::string &value) {
- m_overrides[item] = value_to_int(value);
+ m_overrides[item] = state_name_to_enum(value);
}
void saveState();
void overrideState() const;
@@ -557,19 +536,6 @@ RetraceRender::setUniform(const std::string &name, int index,
m_uniform_override->setUniform(name, index, data);
}
-std::string value_to_string(GLint value) {
- switch (value) {
- case GL_FRONT:
- return std::string("GL_FRONT");
- case GL_BACK:
- return std::string("GL_BACK");
- case GL_FRONT_AND_BACK:
- return std::string("GL_FRONT_AND_BACK");
- default:
- assert(false);
- }
-}
-
void
RetraceRender::onState(SelectionId selId,
ExperimentId experimentCount,
@@ -591,7 +557,7 @@ RetraceRender::onState(SelectionId selId,
GlFunctions::GetIntegerv(GL_CULL_FACE_MODE, &cull);
GLenum e = GL::GetError();
if (e == GL_NO_ERROR) {
- const std::string cull_str = value_to_string(cull);
+ const std::string cull_str = state_enum_to_name(cull);
if (cull_str.size() > 0) {
callback->onState(selId, experimentCount, renderId,
StateKey("Rendering", "Cull State",
diff --git a/retrace/daemon/glframe_retrace_render.hpp b/retrace/daemon/glframe_retrace_render.hpp
index 0b7318ff..70d7a8a1 100644
--- a/retrace/daemon/glframe_retrace_render.hpp
+++ b/retrace/daemon/glframe_retrace_render.hpp
@@ -49,8 +49,6 @@ class ExperimentId;
class MetricId;
class PerfMetrics;
-uint32_t state_name_to_enum(const std::string &value);
-
class RetraceRender {
public:
RetraceRender(trace::AbstractParser *parser,
diff --git a/retrace/daemon/glframe_state_enums.cpp b/retrace/daemon/glframe_state_enums.cpp
new file mode 100644
index 00000000..59719d05
--- /dev/null
+++ b/retrace/daemon/glframe_state_enums.cpp
@@ -0,0 +1,151 @@
+// Copyright (C) Intel Corp. 2017. All Rights Reserved.
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+
+// The above copyright notice and this permission notice (including the
+// next paragraph) shall be included in all copies or substantial
+// portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// **********************************************************************/
+// * Authors:
+// * Mark Janes <mark.a.janes@intel.com>
+// **********************************************************************/
+
+#include "glframe_state_enums.hpp"
+
+#include <assert.h>
+#include <map>
+#include <string>
+#include <vector>
+
+uint32_t
+glretrace::state_name_to_enum(const std::string &value) {
+ static const std::map<std::string, uint32_t> names {
+ {"GL_CULL_FACE", GL_CULL_FACE},
+ {"GL_CULL_FACE_MODE", GL_CULL_FACE_MODE},
+ {"GL_FRONT", GL_FRONT},
+ {"GL_BACK", GL_BACK},
+ {"GL_FRONT_AND_BACK", GL_FRONT_AND_BACK},
+ {"GL_BLEND", GL_BLEND},
+ {"GL_BLEND_SRC", GL_BLEND_SRC},
+ {"GL_BLEND_DST", GL_BLEND_DST},
+ {"GL_ZERO", GL_ZERO},
+ {"GL_ONE", GL_ONE},
+ {"GL_SRC_COLOR", GL_SRC_COLOR},
+ {"GL_ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR},
+ {"GL_DST_COLOR", GL_DST_COLOR},
+ {"GL_ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR},
+ {"GL_SRC_ALPHA", GL_SRC_ALPHA},
+ {"GL_ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA},
+ {"GL_DST_ALPHA", GL_DST_ALPHA},
+ {"GL_ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA},
+ {"GL_CONSTANT_COLOR", GL_CONSTANT_COLOR},
+ {"GL_ONE_MINUS_CONSTANT_COLOR", GL_ONE_MINUS_CONSTANT_COLOR},
+ {"GL_CONSTANT_ALPHA", GL_CONSTANT_ALPHA},
+ {"GL_ONE_MINUS_CONSTANT_ALPHA", GL_ONE_MINUS_CONSTANT_ALPHA},
+ {"true", 1},
+ {"false", 0}
+ };
+ const auto i = names.find(value);
+ if (i == names.end())
+ return GL_INVALID_ENUM;
+ return i->second;
+}
+
+
+std::string
+glretrace::state_enum_to_name(GLint value) {
+ switch (value) {
+ case GL_CULL_FACE:
+ return std::string("CULL_FACE");
+ case GL_CULL_FACE_MODE:
+ return std::string("CULL_FACE_MODE");
+ case GL_FRONT:
+ return std::string("GL_FRONT");
+ case GL_BACK:
+ return std::string("GL_BACK");
+ case GL_FRONT_AND_BACK:
+ return std::string("GL_FRONT_AND_BACK");
+ case GL_BLEND:
+ return std::string("GL_BLEND");
+ case GL_BLEND_SRC:
+ return std::string("GL_BLEND_SRC");
+ case GL_BLEND_DST:
+ return std::string("GL_BLEND_DST");
+ case GL_ZERO:
+ return std::string("GL_ZERO");
+ case GL_ONE:
+ return std::string("GL_ONE");
+ case GL_SRC_COLOR:
+ return std::string("GL_SRC_COLOR");
+ case GL_ONE_MINUS_SRC_COLOR:
+ return std::string("GL_ONE_MINUS_SRC_COLOR");
+ case GL_DST_COLOR:
+ return std::string("GL_DST_COLOR");
+ case GL_ONE_MINUS_DST_COLOR:
+ return std::string("GL_ONE_MINUS_DST_COLOR");
+ case GL_SRC_ALPHA:
+ return std::string("GL_SRC_ALPHA");
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return std::string("GL_ONE_MINUS_SRC_ALPHA");
+ case GL_DST_ALPHA:
+ return std::string("GL_DST_ALPHA");
+ case GL_ONE_MINUS_DST_ALPHA:
+ return std::string("GL_ONE_MINUS_DST_ALPHA");
+ case GL_CONSTANT_COLOR:
+ return std::string("GL_CONSTANT_COLOR");
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ return std::string("GL_ONE_MINUS_CONSTANT_COLOR");
+ case GL_CONSTANT_ALPHA:
+ return std::string("GL_CONSTANT_ALPHA");
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ return std::string("GL_ONE_MINUS_CONSTANT_ALPHA");
+ default:
+ assert(false);
+ }
+}
+
+std::vector<std::string>
+glretrace::state_name_to_choices(const std::string &n) {
+ switch (state_name_to_enum(n)) {
+ case GL_CULL_FACE:
+ case GL_BLEND:
+ return {"true", "false"};
+ case GL_CULL_FACE_MODE:
+ return {"GL_FRONT", "GL_BACK", "GL_FRONT_AND_BACK"};
+ case GL_BLEND_SRC:
+ case GL_BLEND_DST:
+ return {"GL_ZERO",
+ "GL_ONE",
+ "GL_SRC_COLOR",
+ "GL_ONE_MINUS_SRC_COLOR",
+ "GL_DST_COLOR",
+ "GL_ONE_MINUS_DST_COLOR",
+ "GL_SRC_ALPHA",
+ "GL_ONE_MINUS_SRC_ALPHA",
+ "GL_DST_ALPHA",
+ "GL_ONE_MINUS_DST_ALPHA",
+ "GL_CONSTANT_COLOR",
+ "GL_ONE_MINUS_CONSTANT_COLOR",
+ "GL_CONSTANT_ALPHA",
+ "GL_ONE_MINUS_CONSTANT_ALPHA"};
+ case GL_INVALID_ENUM:
+ default:
+ assert(false);
+ }
+}
+
diff --git a/retrace/daemon/glframe_state_enums.hpp b/retrace/daemon/glframe_state_enums.hpp
new file mode 100644
index 00000000..daeee8de
--- /dev/null
+++ b/retrace/daemon/glframe_state_enums.hpp
@@ -0,0 +1,45 @@
+// Copyright (C) Intel Corp. 2017. All Rights Reserved.
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+
+// The above copyright notice and this permission notice (including the
+// next paragraph) shall be included in all copies or substantial
+// portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// **********************************************************************/
+// * Authors:
+// * Mark Janes <mark.a.janes@intel.com>
+// **********************************************************************/
+
+#ifndef _GLFRAME_STATE_ENUMS_HPP__
+#define _GLFRAME_STATE_ENUMS_HPP__
+
+#include <stdint.h>
+#include <GL/gl.h>
+
+#include <string>
+#include <vector>
+
+namespace glretrace {
+
+uint32_t state_name_to_enum(const std::string &value);
+std::string state_enum_to_name(GLint value);
+std::vector<std::string> state_name_to_choices(const std::string &n);
+
+} // namespace glretrace
+
+#endif
diff --git a/retrace/daemon/ui/glframe_state_model.cpp b/retrace/daemon/ui/glframe_state_model.cpp
index 741643f1..e94ce39f 100644
--- a/retrace/daemon/ui/glframe_state_model.cpp
+++ b/retrace/daemon/ui/glframe_state_model.cpp
@@ -34,6 +34,7 @@
#include "glframe_os.hpp"
#include "glframe_retrace_render.hpp"
+#include "glframe_state_enums.hpp"
using glretrace::QStateModel;
using glretrace::QStateValue;
@@ -99,19 +100,6 @@ QQmlListProperty<QStateValue> QStateModel::state() {
return QQmlListProperty<glretrace::QStateValue>(this, m_states);
}
-std::vector<std::string>
-name_to_choices(const std::string &n) {
- switch (state_name_to_enum(n)) {
- case GL_CULL_FACE:
- return {"true", "false"};
- case GL_CULL_FACE_MODE:
- return {"GL_FRONT", "GL_BACK", "GL_FRONT_AND_BACK"};
- case GL_INVALID_ENUM:
- default:
- assert(false);
- }
-}
-
void
QStateModel::clear() {
// QObjects being displayed in the UI must be cleared from the UI
@@ -189,7 +177,7 @@ void QStateModel::onState(SelectionId selectionCount,
item.group,
item.path,
name,
- name_to_choices(name));
+ state_name_to_choices(name));
m_state_by_name[item] = i;
state_value = m_state_by_name.find(item);
m_for_deletion.push_back(i);