diff options
author | Mark Janes <mark.a.janes@intel.com> | 2017-09-22 09:47:45 -0700 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-09-22 09:56:10 -0700 |
commit | 58b16daa395854e26bb26c138bb3350d0067df22 (patch) | |
tree | 9fe783ab28ebffbe7ec4b679e3fbcc9e91f5ae98 /retrace | |
parent | 72ef7ceeadcf28f23aa2387df6a5d1ac052c2775 (diff) |
Shaders: Limit shader retrace to succesfully compiled shaders
Any shader compilation, even failures, caused the shader source window
to be reset to index zero. Maintain the last selected index, and
attempt to restore it when successful compiles generate new shader
retrace events.
Diffstat (limited to 'retrace')
-rw-r--r-- | retrace/daemon/ui/glframe_shader_model.cpp | 28 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_shader_model.hpp | 1 |
2 files changed, 22 insertions, 7 deletions
diff --git a/retrace/daemon/ui/glframe_shader_model.cpp b/retrace/daemon/ui/glframe_shader_model.cpp index c45db629..964bfce5 100644 --- a/retrace/daemon/ui/glframe_shader_model.cpp +++ b/retrace/daemon/ui/glframe_shader_model.cpp @@ -113,6 +113,11 @@ QRenderShadersList::onShaderAssembly(RenderId renderId, if (m_render_strings.size() == 1) // first shader assembly for a new selection. update shader display setIndexDirect(0); + if (m_render_strings.size() == m_index + 1) + // attempt to maintain the same index for the displayed shaders, + // so the UI does not reset to the zero index when shader + // compilation delivers new content. + setIndexDirect(m_index); emit onRendersChanged(); } @@ -136,6 +141,9 @@ QRenderShadersList::setIndexDirect(int index) { void QRenderShadersList::setIndex(int index) { ScopedLock s(m_protect); + // maintain the selected index, so stable content can be displayed + // when new experiments cause shaders to be retraced. + m_index = index; setIndexDirect(index); } @@ -155,8 +163,6 @@ QRenderShadersList::overrideShaders(int index, const QString &comp) { { ScopedLock s(m_protect); - ++m_experiment_count; - const std::string &vss = vs.toStdString(), &fss = fs.toStdString(), &tess_control_s = tess_control.toStdString(), @@ -174,11 +180,7 @@ QRenderShadersList::overrideShaders(int index, tess_control_s, tess_eval_s, geom_s, comp_s, m_retraceModel); } - m_renders.clear(); - m_shader_assemblies.clear(); - m_render_strings.clear(); } - emit shadersChanged(); } void @@ -197,8 +199,20 @@ QRenderShadersList::onShaderCompile(RenderId renderId, ExperimentId experimentCount, bool status, const std::string &errorString) { - if (errorString.size()) + if (errorString.size()) { GRLOGF(WARN, "Compilation error: %s", errorString.c_str()); + } else { + // successful shader compile. New shader retrace is required to + // display modified assemblies. + { + ScopedLock s(m_protect); + m_renders.clear(); + m_shader_assemblies.clear(); + m_render_strings.clear(); + } + // triggers experiment increment, retrace + emit shadersChanged(); + } m_shader_compile_error = errorString.c_str(); emit onShaderCompileError(); } diff --git a/retrace/daemon/ui/glframe_shader_model.hpp b/retrace/daemon/ui/glframe_shader_model.hpp index 97416efd..b3c9824d 100644 --- a/retrace/daemon/ui/glframe_shader_model.hpp +++ b/retrace/daemon/ui/glframe_shader_model.hpp @@ -218,6 +218,7 @@ class QRenderShadersList : public QObject, SelectionId m_current_selection; ExperimentId m_experiment_count; QString m_shader_compile_error; + int m_index; IFrameRetrace *m_retracer; FrameRetraceModel *m_retraceModel; }; |