diff options
-rw-r--r-- | retrace/daemon/glframe_retrace.cpp | 10 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace.hpp | 1 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_context.cpp | 8 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_context.hpp | 1 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_interface.hpp | 2 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_render.cpp | 41 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_render.hpp | 3 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_skeleton.cpp | 9 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_stub.cpp | 23 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_stub.hpp | 2 | ||||
-rw-r--r-- | retrace/daemon/glframe_state.cpp | 16 | ||||
-rw-r--r-- | retrace/daemon/glframe_state.hpp | 1 | ||||
-rw-r--r-- | retrace/daemon/playback.proto | 7 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_file_transfer_test.cpp | 2 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_experiment_model.cpp | 89 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_experiment_model.hpp | 13 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/ExperimentControl.qml | 19 |
17 files changed, 193 insertions, 54 deletions
diff --git a/retrace/daemon/glframe_retrace.cpp b/retrace/daemon/glframe_retrace.cpp index 6414488b..3d91330d 100644 --- a/retrace/daemon/glframe_retrace.cpp +++ b/retrace/daemon/glframe_retrace.cpp @@ -334,6 +334,16 @@ FrameRetrace::disableDraw(const RenderSelection &selection, bool disable) { } void +FrameRetrace::simpleShader(const RenderSelection &selection, bool simple) { + for (auto sequence : selection.series) { + for (auto render = sequence.begin; render < sequence.end; ++render) { + for (auto context : m_contexts) + context->simpleShader(render, simple); + } + } +} + +void FrameRetrace::retraceApi(const RenderSelection &selection, OnFrameRetrace *callback) { // reset to beginning of frame diff --git a/retrace/daemon/glframe_retrace.hpp b/retrace/daemon/glframe_retrace.hpp index c7738f8b..f5d7baf4 100644 --- a/retrace/daemon/glframe_retrace.hpp +++ b/retrace/daemon/glframe_retrace.hpp @@ -92,6 +92,7 @@ class FrameRetrace : public IFrameRetrace { const std::string &comp, OnFrameRetrace *callback); void disableDraw(const RenderSelection &selection, bool disable); + void simpleShader(const RenderSelection &selection, bool simple); // this is going to be ugly to serialize // void insertCall(const trace::Call &call, // uint32_t renderId,); diff --git a/retrace/daemon/glframe_retrace_context.cpp b/retrace/daemon/glframe_retrace_context.cpp index 90e37368..58084f42 100644 --- a/retrace/daemon/glframe_retrace_context.cpp +++ b/retrace/daemon/glframe_retrace_context.cpp @@ -368,6 +368,14 @@ RetraceContext::disableDraw(RenderId render, bool disable) { } void +RetraceContext::simpleShader(RenderId render, bool simple) { + auto render_iterator = m_renders.find(render); + if (render_iterator == m_renders.end()) + return; + render_iterator->second->simpleShader(simple); +} + +void RetraceContext::retraceApi(const RenderSelection &selection, OnFrameRetrace *callback) { if (selection.series.empty()) { diff --git a/retrace/daemon/glframe_retrace_context.hpp b/retrace/daemon/glframe_retrace_context.hpp index a83ffae4..c909d688 100644 --- a/retrace/daemon/glframe_retrace_context.hpp +++ b/retrace/daemon/glframe_retrace_context.hpp @@ -85,6 +85,7 @@ class RetraceContext { const std::string &comp, OnFrameRetrace *callback); void disableDraw(RenderId render, bool disable); + void simpleShader(RenderId render, bool simple); void retraceApi(const RenderSelection &selection, OnFrameRetrace *callback); void retraceShaderAssembly(const RenderSelection &selection, diff --git a/retrace/daemon/glframe_retrace_interface.hpp b/retrace/daemon/glframe_retrace_interface.hpp index e4697497..0921a61d 100644 --- a/retrace/daemon/glframe_retrace_interface.hpp +++ b/retrace/daemon/glframe_retrace_interface.hpp @@ -290,6 +290,8 @@ class IFrameRetrace { OnFrameRetrace *callback) = 0; virtual void disableDraw(const RenderSelection &selection, bool disable) = 0; + virtual void simpleShader(const RenderSelection &selection, + bool simple) = 0; virtual void retraceApi(const RenderSelection &selection, OnFrameRetrace *callback) = 0; virtual void retraceBatch(const RenderSelection &selection, diff --git a/retrace/daemon/glframe_retrace_render.cpp b/retrace/daemon/glframe_retrace_render.cpp index d15fc413..1848c125 100644 --- a/retrace/daemon/glframe_retrace_render.cpp +++ b/retrace/daemon/glframe_retrace_render.cpp @@ -99,7 +99,8 @@ RetraceRender::RetraceRender(trace::AbstractParser *parser, m_end_of_frame(false), m_highlight_rt(false), m_changes_context(false), - m_disabled(false) { + m_disabled(false), + m_simple_shader(false) { m_parser->getBookmark(m_bookmark.start); trace::Call *call = NULL; std::stringstream call_stream; @@ -177,10 +178,10 @@ RetraceRender::retraceRenderTarget(const StateTrack &tracker, } bool blend_enabled = false; - if ((type == HIGHLIGHT_RENDER) && (m_rt_program > -1)) { + if ((m_simple_shader || (type == HIGHLIGHT_RENDER)) && (m_rt_program > -1)) { blend_enabled = GlFunctions::IsEnabled(GL_BLEND); GlFunctions::Disable(GL_BLEND); - GlFunctions::UseProgram(m_rt_program); + StateTrack::useProgramGL(m_rt_program); GlFunctions::ValidateProgram(m_rt_program); GLint result; GlFunctions::GetProgramiv(m_rt_program, GL_VALIDATE_STATUS, &result); @@ -191,7 +192,7 @@ RetraceRender::retraceRenderTarget(const StateTrack &tracker, GRLOGF(ERR, "Highlight program not validated: %s", buf.data()); } } else if (m_retrace_program > -1) { - GlFunctions::UseProgram(m_retrace_program); + StateTrack::useProgramGL(m_retrace_program); } // retrace the final render @@ -200,11 +201,9 @@ RetraceRender::retraceRenderTarget(const StateTrack &tracker, if (!m_disabled) m_retracer->retrace(*call); delete(call); - if (type == HIGHLIGHT_RENDER || m_retrace_program > -1) { - if (blend_enabled) - GlFunctions::Enable(GL_BLEND); - GlFunctions::UseProgram(m_original_program); - } + if (blend_enabled) + GlFunctions::Enable(GL_BLEND); + StateTrack::useProgramGL(m_original_program); } @@ -230,8 +229,11 @@ RetraceRender::retrace(StateTrack *tracker) const { } // select the shader override if necessary - if (m_retrace_program > -1) { - GlFunctions::UseProgram(m_retrace_program); + if (m_simple_shader) { + StateTrack::useProgramGL(m_rt_program); + tracker->useProgram(m_rt_program); + } else if (m_retrace_program > -1) { + StateTrack::useProgramGL(m_retrace_program); if (tracker) { tracker->useProgram(m_retrace_program); } @@ -245,8 +247,7 @@ RetraceRender::retrace(StateTrack *tracker) const { if (tracker) tracker->track(*call); delete(call); - if (m_retrace_program) - GlFunctions::UseProgram(m_original_program); + StateTrack::useProgramGL(m_original_program); } void @@ -271,8 +272,10 @@ RetraceRender::retrace(const StateTrack &tracker) const { } // select the shader override if necessary - if (m_retrace_program > -1) { - GlFunctions::UseProgram(m_retrace_program); + if (m_simple_shader) { + StateTrack::useProgramGL(m_rt_program); + } else if (m_retrace_program > -1) { + StateTrack::useProgramGL(m_retrace_program); } // retrace the final render @@ -281,8 +284,7 @@ RetraceRender::retrace(const StateTrack &tracker) const { if (!m_disabled) m_retracer->retrace(*call); delete(call); - if (m_retrace_program) - GlFunctions::UseProgram(m_original_program); + StateTrack::useProgramGL(m_original_program); } @@ -332,3 +334,8 @@ void RetraceRender::disableDraw(bool disable) { m_disabled = disable; } + +void +RetraceRender::simpleShader(bool simple) { + m_simple_shader = simple; +} diff --git a/retrace/daemon/glframe_retrace_render.hpp b/retrace/daemon/glframe_retrace_render.hpp index 9445b043..2dd1b515 100644 --- a/retrace/daemon/glframe_retrace_render.hpp +++ b/retrace/daemon/glframe_retrace_render.hpp @@ -69,6 +69,7 @@ class RetraceRender { std::string *message); void revertShaders(); void disableDraw(bool disable); + void simpleShader(bool simple); void onApi(SelectionId selId, RenderId renderId, OnFrameRetrace *callback); @@ -90,7 +91,7 @@ class RetraceRender { int m_rt_program, m_retrace_program, m_original_program; bool m_end_of_frame, m_highlight_rt, m_changes_context; std::vector<std::string> m_api_calls; - bool m_disabled; + bool m_disabled, m_simple_shader; }; } // namespace glretrace diff --git a/retrace/daemon/glframe_retrace_skeleton.cpp b/retrace/daemon/glframe_retrace_skeleton.cpp index d8077fa2..1b7d28c8 100644 --- a/retrace/daemon/glframe_retrace_skeleton.cpp +++ b/retrace/daemon/glframe_retrace_skeleton.cpp @@ -328,6 +328,15 @@ FrameRetraceSkeleton::Run() { m_frame->disableDraw(selection, disable.disable()); break; } + case ApiTrace::SIMPLE_SHADER_REQUEST: + { + assert(request.has_simpleshader()); + auto simple = request.simpleshader(); + RenderSelection selection; + makeRenderSelection(simple.selection(), &selection); + m_frame->simpleShader(selection, simple.simple_shader()); + break; + } } } } diff --git a/retrace/daemon/glframe_retrace_stub.cpp b/retrace/daemon/glframe_retrace_stub.cpp index de92006f..6ebab6cb 100644 --- a/retrace/daemon/glframe_retrace_stub.cpp +++ b/retrace/daemon/glframe_retrace_stub.cpp @@ -562,6 +562,23 @@ class DisableDrawRequest : public IRetraceRequest { RetraceRequest m_proto_msg; }; +class SimpleShaderRequest : public IRetraceRequest { + public: + SimpleShaderRequest(const RenderSelection &selection, + bool simple_shader) { + auto simpleRequest = m_proto_msg.mutable_simpleshader(); + auto selectionRequest = simpleRequest->mutable_selection(); + makeRenderSelection(selection, selectionRequest); + simpleRequest->set_simple_shader(simple_shader); + m_proto_msg.set_requesttype(ApiTrace::SIMPLE_SHADER_REQUEST); + } + virtual void retrace(RetraceSocket *s) { + s->request(m_proto_msg); + } + private: + RetraceRequest m_proto_msg; +}; + class ApiRequest : public IRetraceRequest { public: ApiRequest(SelectionId *current_selection, @@ -889,6 +906,12 @@ FrameRetraceStub::disableDraw(const RenderSelection &selection, } void +FrameRetraceStub::simpleShader(const RenderSelection &selection, + bool simple) { + m_thread->push(new SimpleShaderRequest(selection, simple)); +} + +void FrameRetraceStub::retraceApi(const RenderSelection &selection, OnFrameRetrace *callback) { { diff --git a/retrace/daemon/glframe_retrace_stub.hpp b/retrace/daemon/glframe_retrace_stub.hpp index 099f55ac..994cf70b 100644 --- a/retrace/daemon/glframe_retrace_stub.hpp +++ b/retrace/daemon/glframe_retrace_stub.hpp @@ -79,6 +79,8 @@ class FrameRetraceStub : public IFrameRetrace { OnFrameRetrace *callback); virtual void disableDraw(const RenderSelection &selection, bool disable); + virtual void simpleShader(const RenderSelection &selection, + bool simple); virtual void retraceApi(const RenderSelection &selection, OnFrameRetrace *callback); virtual void retraceBatch(const RenderSelection &selection, diff --git a/retrace/daemon/glframe_state.cpp b/retrace/daemon/glframe_state.cpp index 44ee0f99..3df2c6f1 100644 --- a/retrace/daemon/glframe_state.cpp +++ b/retrace/daemon/glframe_state.cpp @@ -621,6 +621,15 @@ StateTrack::useProgram(int program) { } void +StateTrack::useProgramGL(int program) { + // glretrace keeps tabs on the current program and asserts if you + // don't correct its accounting. + glretrace::Context *currentContext = glretrace::getCurrentContext(); + GlFunctions::UseProgram(program); + currentContext->currentProgram = program; +} + +void StateTrack::retraceProgramSideEffects(int orig_program, trace::Call *c, retrace::Retracer *retracer) const { if (strncmp("glProgramUniform", c->sig->name, @@ -654,7 +663,6 @@ StateTrack::retraceProgramSideEffects(int orig_program, trace::Call *c, return; } if (strncmp("glUniform", c->sig->name, strlen("glUniform")) == 0) { - glretrace::Context *currentContext = glretrace::getCurrentContext(); const int retraced_program = orig_program; assert(retraced_program == orig_program); auto replacements = program_to_replacements.find(retraced_program); @@ -662,8 +670,7 @@ StateTrack::retraceProgramSideEffects(int orig_program, trace::Call *c, trace::Value * call_loc = c->args[0].value; const int call_loc_val = call_loc->toSInt(); for (auto replacement : replacements->second) { - GlFunctions::UseProgram(replacement); - currentContext->currentProgram = replacement; + useProgramGL(replacement); auto name_map = m_program_to_uniform_name.find(retraced_program); assert(name_map != m_program_to_uniform_name.end()); auto name_it = name_map->second.find(call_loc_val); @@ -678,8 +685,7 @@ StateTrack::retraceProgramSideEffects(int orig_program, trace::Call *c, retracer->retrace(*c); } c->args[0].value = call_loc; - GlFunctions::UseProgram(orig_program); - currentContext->currentProgram = orig_program; + useProgramGL(orig_program); } return; } diff --git a/retrace/daemon/glframe_state.hpp b/retrace/daemon/glframe_state.hpp index fe63972b..3684462a 100644 --- a/retrace/daemon/glframe_state.hpp +++ b/retrace/daemon/glframe_state.hpp @@ -110,6 +110,7 @@ class StateTrack { void useProgram(int program); void retraceProgramSideEffects(int orig_program, trace::Call *c, retrace::Retracer *retracer) const; + static void useProgramGL(int program); private: class TrackMap { diff --git a/retrace/daemon/playback.proto b/retrace/daemon/playback.proto index db82f6aa..dbe00a43 100644 --- a/retrace/daemon/playback.proto +++ b/retrace/daemon/playback.proto @@ -16,6 +16,7 @@ enum RequestType { API_REQUEST = 7; BATCH_REQUEST = 8; DISABLE_REQUEST = 9; + SIMPLE_SHADER_REQUEST = 10; }; message OpenFileRequest { @@ -171,6 +172,11 @@ message DisableRequest { required bool disable = 2; } +message SimpleRequest { + required RenderSelection selection = 1; + required bool simple_shader = 2; +} + message RetraceRequest { required RequestType requestType = 1; optional RenderTargetRequest renderTarget = 2; @@ -182,6 +188,7 @@ message RetraceRequest { optional ApiRequest api = 8; optional BatchRequest batch = 9; optional DisableRequest disable = 10; + optional SimpleRequest simpleShader = 11; } message RetraceResponse { diff --git a/retrace/daemon/test/retrace_file_transfer_test.cpp b/retrace/daemon/test/retrace_file_transfer_test.cpp index a8ebc386..efb82e4f 100644 --- a/retrace/daemon/test/retrace_file_transfer_test.cpp +++ b/retrace/daemon/test/retrace_file_transfer_test.cpp @@ -90,6 +90,8 @@ class FileTransfer : public IFrameRetrace { OnFrameRetrace *callback) {} void disableDraw(const RenderSelection &selection, bool disable) {} + void simpleShader(const RenderSelection &selection, + bool simple) {} void retraceApi(const RenderSelection &selection, OnFrameRetrace *callback) {} void retraceBatch(const RenderSelection &selection, diff --git a/retrace/daemon/ui/glframe_experiment_model.cpp b/retrace/daemon/ui/glframe_experiment_model.cpp index 9a6fda6f..69d55cbc 100644 --- a/retrace/daemon/ui/glframe_experiment_model.cpp +++ b/retrace/daemon/ui/glframe_experiment_model.cpp @@ -27,61 +27,98 @@ #include "glframe_experiment_model.hpp" +#include <map> + #include "glframe_qutil.hpp" using glretrace::IFrameRetrace; using glretrace::QExperimentModel; +using glretrace::RenderId; using glretrace::SelectionId; +using Qt::Checked; +using Qt::Unchecked; +using Qt::PartiallyChecked; +using Qt::CheckState; QExperimentModel::QExperimentModel() - : m_retrace(NULL), m_checkbox(Qt::Unchecked) { + : m_retrace(NULL), m_disabled_checkbox(Qt::Unchecked), + m_simple_checkbox(Unchecked) { assert(false); } QExperimentModel::QExperimentModel(IFrameRetrace *retrace) : m_retrace(retrace), - m_checkbox(Qt::Unchecked) {} + m_disabled_checkbox(Unchecked), + m_simple_checkbox(Unchecked) {} -void -QExperimentModel::onSelect(SelectionId count, QList<int> selection) { - m_selection = selection; - m_count = count; - Qt::CheckState new_value = Qt::CheckState(-1); +CheckState +isChecked(std::map<RenderId, bool> *_renders, + const QList<int> &selection) { + // if selection has both checked and unchecked experiments, return + // PartiallyChecked. + auto renders = *_renders; + CheckState new_value = CheckState(-1); for (auto sel : selection) { - const bool disabled = m_disabled[RenderId(sel)]; - if (disabled) { - if (new_value == Qt::Unchecked) { - new_value = Qt::PartiallyChecked; - break; + const bool checked = renders[RenderId(sel)]; + if (checked) { + if (new_value == Unchecked) { + return PartiallyChecked; } else { - new_value = Qt::Checked; + new_value = Checked; } - } else { // not disabled - if (new_value == Qt::Checked) { - new_value = Qt::PartiallyChecked; - break; + } else { // not checked + if (new_value == Checked) { + return PartiallyChecked; } else { - new_value = Qt::Unchecked; + new_value = Unchecked; } } } - m_checkbox = new_value; + return new_value; +} + +void +QExperimentModel::onSelect(SelectionId count, const QList<int> &selection) { + m_selection = selection; + m_count = count; + m_disabled_checkbox = isChecked(&m_disabled, selection); + m_simple_checkbox = isChecked(&m_simple, selection); emit onDisabled(); + emit onSimpleShader(); +} + +CheckState uncheckPartials(CheckState c) { + assert(c != PartiallyChecked); + // treat PartiallyChecked as Unchecked + if (c == Checked) + return Checked; + return Unchecked; } void -QExperimentModel::disableDraw(Qt::CheckState disable) { - if (disable != Qt::Unchecked) - m_checkbox = Qt::Checked; - else - m_checkbox = Qt::Unchecked; +QExperimentModel::disableDraw(CheckState disable) { + m_disabled_checkbox = uncheckPartials(disable); for (auto render : m_selection) - m_disabled[RenderId(render)] = (disable == Qt::Checked); + m_disabled[RenderId(render)] = m_disabled_checkbox; RenderSelection sel; glretrace::renderSelectionFromList(m_count, m_selection, &sel); - m_retrace->disableDraw(sel, (m_checkbox == Qt::Checked)); + m_retrace->disableDraw(sel, (m_disabled_checkbox == Checked)); emit onDisabled(); emit onExperiment(); } + +void +QExperimentModel::simpleShader(CheckState simple) { + m_simple_checkbox = uncheckPartials(simple); + for (auto render : m_selection) + m_simple[RenderId(render)] = m_simple_checkbox; + RenderSelection sel; + glretrace::renderSelectionFromList(m_count, + m_selection, + &sel); + m_retrace->simpleShader(sel, (m_simple_checkbox == Checked)); + emit onSimpleShader(); + emit onExperiment(); +} diff --git a/retrace/daemon/ui/glframe_experiment_model.hpp b/retrace/daemon/ui/glframe_experiment_model.hpp index ca8368ac..2fdfc88e 100644 --- a/retrace/daemon/ui/glframe_experiment_model.hpp +++ b/retrace/daemon/ui/glframe_experiment_model.hpp @@ -51,23 +51,28 @@ class QExperimentModel : public QObject, Q_OBJECT Q_PROPERTY(Qt::CheckState selectionDisabled READ selectionDisabled NOTIFY onDisabled) + Q_PROPERTY(Qt::CheckState selectionSimpleShader READ selectionSimpleShader + NOTIFY onSimpleShader) public: QExperimentModel(); explicit QExperimentModel(IFrameRetrace *retrace); ~QExperimentModel() {} - Qt::CheckState selectionDisabled() const { return m_checkbox; } - void onSelect(SelectionId selection_count, QList<int> selection); + Qt::CheckState selectionDisabled() const { return m_disabled_checkbox; } + Qt::CheckState selectionSimpleShader() const { return m_simple_checkbox; } + void onSelect(SelectionId selection_count, const QList<int> &selection); Q_INVOKABLE void disableDraw(Qt::CheckState disable); + Q_INVOKABLE void simpleShader(Qt::CheckState simple); signals: void onDisabled(); + void onSimpleShader(); void onExperiment(); private: IFrameRetrace *m_retrace; - std::map<RenderId, bool> m_disabled; + std::map<RenderId, bool> m_disabled, m_simple; QList<int> m_selection; SelectionId m_count; - Qt::CheckState m_checkbox; + Qt::CheckState m_disabled_checkbox, m_simple_checkbox; }; } // namespace glretrace diff --git a/retrace/daemon/ui/qml/ExperimentControl.qml b/retrace/daemon/ui/qml/ExperimentControl.qml index a595c2fb..25bf7f0d 100644 --- a/retrace/daemon/ui/qml/ExperimentControl.qml +++ b/retrace/daemon/ui/qml/ExperimentControl.qml @@ -8,6 +8,7 @@ Item { property QExperimentModel experimentModel Column { anchors.centerIn: parent + spacing: 5 CheckBox { text: "Disable Draw" checkedState: experimentModel.selectionDisabled @@ -17,12 +18,28 @@ Item { checkedState = Qt.Unchecked; experimentModel.disableDraw(checkedState); partiallyCheckedEnabled = false - // restore the binding, which is overwritten when the ui is clicked (not sure why they would do it that way) + // restore the binding, which is overwritten when the + // ui is clicked (not sure why they would do it that + // way) // http://stackoverflow.com/questions/23860270/binding-checkbox-checked-property-with-a-c-object-q-property checkedState = Qt.binding(function () { return experimentModel.selectionDisabled; }); } } + CheckBox { + text: "Simple Shader" + checkedState: experimentModel.selectionSimpleShader + partiallyCheckedEnabled : false + onClicked: { + if (checkedState == Qt.PartiallyChecked) + checkedState = Qt.Unchecked; + experimentModel.simpleShader(checkedState); + partiallyCheckedEnabled = false + checkedState = Qt.binding(function () { + return experimentModel.selectionSimpleShader; + }); + } + } } } |