diff options
author | Mark Janes <mark.a.janes@intel.com> | 2017-05-05 10:35:12 -0700 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-06-19 14:10:03 -0700 |
commit | 742836e0fcd44c9990c77a93180eb19d705b594c (patch) | |
tree | 57bfc2d335a5d47a9d935741e7f4962c1096a4d5 /retrace | |
parent | 2b1c48def74fd8ac7e4566633d37e3407552f5d6 (diff) |
RenderTarget: refactor RT methods into separate model
The render target model will have to maintain several images, and expose
them to the render target control.
Diffstat (limited to 'retrace')
-rw-r--r-- | retrace/daemon/ui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_rendertarget_model.cpp | 120 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_rendertarget_model.hpp | 81 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_retrace_model.cpp | 96 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_retrace_model.hpp | 25 | ||||
-rw-r--r-- | retrace/daemon/ui/main.cpp | 3 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/mainwin.qml | 2 |
7 files changed, 232 insertions, 97 deletions
diff --git a/retrace/daemon/ui/CMakeLists.txt b/retrace/daemon/ui/CMakeLists.txt index 32cce748..ef5d2450 100644 --- a/retrace/daemon/ui/CMakeLists.txt +++ b/retrace/daemon/ui/CMakeLists.txt @@ -31,6 +31,8 @@ set (UI_SRC glframe_metrics_model.cpp glframe_qutil.hpp glframe_qutil.cpp + glframe_rendertarget_model.cpp + glframe_rendertarget_model.hpp glframe_retrace_images.hpp glframe_retrace_images.cpp glframe_retrace_model.hpp diff --git a/retrace/daemon/ui/glframe_rendertarget_model.cpp b/retrace/daemon/ui/glframe_rendertarget_model.cpp new file mode 100644 index 00000000..4bfc5708 --- /dev/null +++ b/retrace/daemon/ui/glframe_rendertarget_model.cpp @@ -0,0 +1,120 @@ +/************************************************************************** + * + * Copyright 2017 Intel Corporation + * 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 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 + * AUTHORS OR COPYRIGHT HOLDERS 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_rendertarget_model.hpp" + +#include <sstream> +#include <vector> + +#include "glframe_retrace_images.hpp" +#include "glframe_retrace_model.hpp" + +using glretrace::ExperimentId; +using glretrace::FrameRetraceModel; +using glretrace::QRenderTargetModel; +using glretrace::RenderOptions; +using glretrace::RenderTargetType; +using glretrace::SelectionId; + +QRenderTargetModel::QRenderTargetModel() {} + +QRenderTargetModel::QRenderTargetModel(FrameRetraceModel *retrace) + : m_retrace(retrace), + m_clear_before_render(false), + m_stop_at_render(false), + m_highlight_render(false) +{} + +void +QRenderTargetModel::onRenderTarget(SelectionId selectionCount, + ExperimentId experimentCount, + const std::vector<unsigned char> &data) { + glretrace::FrameImages::instance()->SetImage(data); + emit onRenderTarget(); +} + + +RenderOptions +QRenderTargetModel::options() { + RenderOptions opt = DEFAULT_RENDER; + if (m_clear_before_render) + opt = (RenderOptions) (opt | CLEAR_BEFORE_RENDER); + if (m_stop_at_render) + opt = (RenderOptions) (opt | STOP_AT_RENDER); + return opt; +} + + +RenderTargetType +QRenderTargetModel::type() { + if (m_highlight_render) + return HIGHLIGHT_RENDER; + return NORMAL_RENDER; +} + +QString +QRenderTargetModel::renderTargetImage() const { + static int i = 0; + std::stringstream ss; + ss << "image://myimageprovider/image" << ++i << ".png"; + return ss.str().c_str(); +} + +bool +QRenderTargetModel::clearBeforeRender() const { + return m_clear_before_render; +} + +void +QRenderTargetModel::setClearBeforeRender(bool v) { + m_clear_before_render = v; + m_retrace->retraceRendertarget(); +} + +bool +QRenderTargetModel::stopAtRender() const { + return m_stop_at_render; +} + +void +QRenderTargetModel::setStopAtRender(bool v) { + m_stop_at_render = v; + m_retrace->retraceRendertarget(); +} + +bool +QRenderTargetModel::highlightRender() const { + return m_highlight_render; +} + +void +QRenderTargetModel::setHighlightRender(bool v) { + m_highlight_render = v; + m_retrace->retraceRendertarget(); +} + + diff --git a/retrace/daemon/ui/glframe_rendertarget_model.hpp b/retrace/daemon/ui/glframe_rendertarget_model.hpp new file mode 100644 index 00000000..ca554e53 --- /dev/null +++ b/retrace/daemon/ui/glframe_rendertarget_model.hpp @@ -0,0 +1,81 @@ +/************************************************************************** + * + * Copyright 2017 Intel Corporation + * 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 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 + * AUTHORS OR COPYRIGHT HOLDERS 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_RENDERTARGET_MODEL_HPP_ +#define _GLFRAME_RENDERTARGET_MODEL_HPP_ + +#include <QObject> + +#include <vector> + +#include "glframe_retrace_interface.hpp" + +namespace glretrace { + +class FrameRetraceModel; + +class QRenderTargetModel : public QObject { + Q_OBJECT + Q_PROPERTY(QString renderTargetImage READ renderTargetImage + NOTIFY onRenderTarget) + Q_PROPERTY(bool clearBeforeRender READ clearBeforeRender + WRITE setClearBeforeRender) + Q_PROPERTY(bool stopAtRender READ stopAtRender + WRITE setStopAtRender) + Q_PROPERTY(bool highlightRender READ highlightRender + WRITE setHighlightRender) + + public: + QRenderTargetModel(); + explicit QRenderTargetModel(FrameRetraceModel *retrace); + void onRenderTarget(SelectionId selectionCount, + ExperimentId experimentCount, + const std::vector<unsigned char> &data); + QString renderTargetImage() const; + bool clearBeforeRender() const; + void setClearBeforeRender(bool v); + bool stopAtRender() const; + void setStopAtRender(bool v); + bool highlightRender() const; + void setHighlightRender(bool v); + RenderTargetType type(); + RenderOptions options(); + + signals: + void onRenderTarget(); + + private: + FrameRetraceModel *m_retrace; + bool m_clear_before_render, m_stop_at_render, m_highlight_render; +}; + + +} // namespace glretrace + +#endif // _GLFRAME_RENDERTARGET_MODEL_HPP_ + diff --git a/retrace/daemon/ui/glframe_retrace_model.cpp b/retrace/daemon/ui/glframe_retrace_model.cpp index 4c02a97e..5c9ca455 100644 --- a/retrace/daemon/ui/glframe_retrace_model.cpp +++ b/retrace/daemon/ui/glframe_retrace_model.cpp @@ -27,7 +27,6 @@ #include "glframe_retrace_model.hpp" -#include <QQuickImageProvider> #include <QtConcurrentRun> #include <QFileInfo> @@ -37,9 +36,9 @@ #include "glframe_qbargraph.hpp" #include "glframe_retrace.hpp" -#include "glframe_retrace_images.hpp" #include "glframe_logger.hpp" #include "glframe_qutil.hpp" +#include "glframe_rendertarget_model.hpp" #include "glframe_socket.hpp" using glretrace::DEBUG; @@ -60,19 +59,18 @@ using glretrace::SelectionId; using glretrace::ServerSocket; using glretrace::ShaderAssembly; -FrameRetraceModel::FrameRetraceModel() : m_experiment(&m_retrace), - m_state(NULL), - m_selection(NULL), - m_selection_count(0), - m_experiment_count(0), - m_shader_compile_error(""), - m_open_percent(0), - m_frame_count(0), - m_max_metric(0), - m_clear_before_render(false), - m_stop_at_render(false), - m_highlight_render(false), - m_severity(Warning) { +FrameRetraceModel::FrameRetraceModel() + : m_experiment(&m_retrace), + m_rendertarget(new QRenderTargetModel(this)), + m_state(NULL), + m_selection(NULL), + m_selection_count(0), + m_experiment_count(0), + m_shader_compile_error(""), + m_open_percent(0), + m_frame_count(0), + m_max_metric(0), + m_severity(Warning) { m_metrics_model.push_back(new QMetric(MetricId(0), "No metric")); filterMetrics(""); connect(this, &glretrace::FrameRetraceModel::updateMetricList, @@ -218,8 +216,7 @@ FrameRetraceModel::onRenderTarget(SelectionId selectionCount, ExperimentId experimentCount, const std::vector<unsigned char> &data) { ScopedLock s(m_protect); - glretrace::FrameImages::instance()->SetImage(data); - emit onRenderTarget(); + m_rendertarget->onRenderTarget(selectionCount, experimentCount, data); } void @@ -234,17 +231,11 @@ FrameRetraceModel::onShaderCompile(RenderId renderId, } void -FrameRetraceModel::retrace_rendertarget() { - RenderOptions opt = DEFAULT_RENDER; - if (m_clear_before_render) - opt = (RenderOptions) (opt | CLEAR_BEFORE_RENDER); - if (m_stop_at_render) - opt = (RenderOptions) (opt | STOP_AT_RENDER); - RenderTargetType rt_type = glretrace::NORMAL_RENDER; - if (m_highlight_render) - rt_type = HIGHLIGHT_RENDER; +FrameRetraceModel::retraceRendertarget() { if (m_cached_selection.empty()) return; + RenderOptions opt = m_rendertarget->options(); + RenderTargetType rt_type = m_rendertarget->type(); RenderSelection rs; glretrace::renderSelectionFromList(m_selection_count, m_cached_selection, @@ -267,16 +258,6 @@ FrameRetraceModel::retrace_shader_assemblies() { m_retrace.retraceShaderAssembly(rs, m_experiment_count, this); } - -QString -FrameRetraceModel::renderTargetImage() const { - ScopedLock s(m_protect); - static int i = 0; - std::stringstream ss; - ss << "image://myimageprovider/image" << ++i << ".png"; - return ss.str().c_str(); -} - void FrameRetraceModel::retrace_api() { RenderSelection sel; @@ -438,51 +419,12 @@ FrameRetraceModel::onSelect(SelectionId id, QList<int> selection) { ScopedLock s(m_protect); m_cached_selection = selection; m_selection_count = id; - retrace_rendertarget(); + retraceRendertarget(); retrace_shader_assemblies(); retrace_api(); retrace_batch(); } -bool -FrameRetraceModel::clearBeforeRender() const { - ScopedLock s(m_protect); - return m_clear_before_render; -} - -void -FrameRetraceModel::setClearBeforeRender(bool v) { - ScopedLock s(m_protect); - m_clear_before_render = v; - retrace_rendertarget(); -} - -bool -FrameRetraceModel::stopAtRender() const { - ScopedLock s(m_protect); - return m_stop_at_render; -} - -void -FrameRetraceModel::setStopAtRender(bool v) { - ScopedLock s(m_protect); - m_stop_at_render = v; - retrace_rendertarget(); -} - -bool -FrameRetraceModel::highlightRender() const { - ScopedLock s(m_protect); - return m_highlight_render; -} - -void -FrameRetraceModel::setHighlightRender(bool v) { - ScopedLock s(m_protect); - m_highlight_render = v; - retrace_rendertarget(); -} - void FrameRetraceModel::refreshBarMetrics() { // sending a second null metric to be retraced will result in two @@ -583,7 +525,7 @@ void FrameRetraceModel::onExperiment(ExperimentId experiment_count) { ScopedLock s(m_protect); m_experiment_count = experiment_count; - retrace_rendertarget(); + retraceRendertarget(); refreshBarMetrics(); retrace_shader_assemblies(); retrace_batch(); diff --git a/retrace/daemon/ui/glframe_retrace_model.hpp b/retrace/daemon/ui/glframe_retrace_model.hpp index 21b96748..46cbbf17 100644 --- a/retrace/daemon/ui/glframe_retrace_model.hpp +++ b/retrace/daemon/ui/glframe_retrace_model.hpp @@ -29,7 +29,6 @@ #ifndef _GLFRAME_RETRACE_MODEL_HPP_ #define _GLFRAME_RETRACE_MODEL_HPP_ -#include <QQuickImageProvider> // NOLINT #include <QtConcurrentRun> // NOLINT #include <QObject> @@ -55,6 +54,7 @@ namespace glretrace { class FrameRetrace; class QSelection; +class QRenderTargetModel; class QRenderBookmark : public QObject { Q_OBJECT @@ -100,16 +100,8 @@ class FrameRetraceModel : public QObject, READ metricList NOTIFY onQMetricList); Q_PROPERTY(glretrace::QSelection* selection READ selection WRITE setSelection); - Q_PROPERTY(QString renderTargetImage READ renderTargetImage - NOTIFY onRenderTarget) Q_PROPERTY(int frameCount READ frameCount NOTIFY onFrameCount) Q_PROPERTY(float maxMetric READ maxMetric NOTIFY onMaxMetric) - Q_PROPERTY(bool clearBeforeRender READ clearBeforeRender - WRITE setClearBeforeRender) - Q_PROPERTY(bool stopAtRender READ stopAtRender - WRITE setStopAtRender) - Q_PROPERTY(bool highlightRender READ highlightRender - WRITE setHighlightRender) Q_PROPERTY(glretrace::QRenderShadersList* shaders READ shaders CONSTANT) Q_PROPERTY(glretrace::QApiModel* api READ api CONSTANT) Q_PROPERTY(glretrace::QBatchModel* batch READ batch CONSTANT) @@ -126,6 +118,8 @@ class FrameRetraceModel : public QObject, NOTIFY onGeneralError) Q_PROPERTY(glretrace::QExperimentModel* experimentModel READ experiments CONSTANT) + Q_PROPERTY(glretrace::QRenderTargetModel* rendertarget + READ rendertarget CONSTANT) public: FrameRetraceModel(); @@ -176,7 +170,6 @@ class FrameRetraceModel : public QObject, ExperimentId experimentCount, RenderId renderId, const std::string &batch); - QString renderTargetImage() const; int frameCount() const { ScopedLock s(m_protect); return m_frame_count; } float maxMetric() const { ScopedLock s(m_protect); return m_max_metric; } QString apiCalls(); @@ -184,6 +177,7 @@ class FrameRetraceModel : public QObject, QExperimentModel *experiments() { return &m_experiment; } QApiModel *api() { return &m_api; } QBatchModel *batch() { return &m_batch; } + QRenderTargetModel *rendertarget() { return m_rendertarget; } QString shaderCompileError() { return m_shader_compile_error; } QString argvZero() { return main_exe; } void setArgvZero(const QString &a) { main_exe = a; emit onArgvZero(); } @@ -191,18 +185,13 @@ class FrameRetraceModel : public QObject, QString generalError() { return m_general_error; } QString generalErrorDetails() { return m_general_error_details; } - bool clearBeforeRender() const; - void setClearBeforeRender(bool v); - bool stopAtRender() const; - void setStopAtRender(bool v); - bool highlightRender() const; - void setHighlightRender(bool v); enum Severity { Warning, Fatal }; Q_ENUM(Severity); Severity errorSeverity() const { return m_severity; } + void retraceRendertarget(); public slots: void onUpdateMetricList(); void onSelect(glretrace::SelectionId id, QList<int> selection); @@ -211,7 +200,6 @@ class FrameRetraceModel : public QObject, void onQMetricList(); void onQMetricData(QList<glretrace::BarMetrics> metrics); void onRenders(); - void onRenderTarget(); void onFrameCount(); void onMaxMetric(); void onShaderCompileError(); @@ -222,7 +210,6 @@ class FrameRetraceModel : public QObject, // thread. The handler generates QObjects which are passed to qml void updateMetricList(); private: - void retrace_rendertarget(); void retrace_shader_assemblies(); void retrace_api(); void retrace_batch(); @@ -234,6 +221,7 @@ class FrameRetraceModel : public QObject, QApiModel m_api; QBatchModel m_batch; QExperimentModel m_experiment; + QRenderTargetModel *m_rendertarget; FrameState *m_state; QSelection *m_selection; SelectionId m_selection_count; @@ -256,7 +244,6 @@ class FrameRetraceModel : public QObject, std::vector<MetricId> m_active_metrics; float m_max_metric; - bool m_clear_before_render, m_stop_at_render, m_highlight_render; QString m_general_error, m_general_error_details; Severity m_severity; }; diff --git a/retrace/daemon/ui/main.cpp b/retrace/daemon/ui/main.cpp index 371e5b37..da5e8886 100644 --- a/retrace/daemon/ui/main.cpp +++ b/retrace/daemon/ui/main.cpp @@ -46,6 +46,7 @@ #include "glframe_logger.hpp" #include "glframe_os.hpp" #include "glframe_qbargraph.hpp" +#include "glframe_rendertarget_model.hpp" #include "glframe_retrace_images.hpp" #include "glframe_retrace_model.hpp" #include "glframe_retrace_skeleton.hpp" @@ -118,6 +119,8 @@ int main(int argc, char *argv[]) { "QBatchModel"); qmlRegisterType<glretrace::QExperimentModel>("ApiTrace", 1, 0, "QExperimentModel"); + qmlRegisterType<glretrace::QRenderTargetModel>("ApiTrace", 1, 0, + "QRenderTargetModel"); glretrace::FrameImages::Create(); diff --git a/retrace/daemon/ui/qml/mainwin.qml b/retrace/daemon/ui/qml/mainwin.qml index f62e0d13..1acf8649 100644 --- a/retrace/daemon/ui/qml/mainwin.qml +++ b/retrace/daemon/ui/qml/mainwin.qml @@ -335,7 +335,7 @@ ApplicationWindow { Tab { title: "RenderTarget" RenderTargetControl { - model: frameRetrace + model: frameRetrace.rendertarget } } Tab { |