From 5c055ac2ad0b30a7e240025afa698a7850d05e53 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Mar 2018 03:22:47 +0100 Subject: [PATCH] GLScope: suppress VLAs --- sdrgui/gui/glscope.cpp | 53 +++++++++++++++++++++++++++++++++--------- sdrgui/gui/glscope.h | 8 +++++++ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/sdrgui/gui/glscope.cpp b/sdrgui/gui/glscope.cpp index 29db0558a..cda180827 100644 --- a/sdrgui/gui/glscope.cpp +++ b/sdrgui/gui/glscope.cpp @@ -287,8 +287,9 @@ void GLScope::paintGL() if(!m_mutex.tryLock(2)) return; - if(m_configChanged) + if(m_configChanged) { applyConfig(); + } handleMode(); @@ -327,7 +328,8 @@ void GLScope::paintGL() tickList = &m_y1Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY1.m_array; int effectiveTicks = 0; for (int i= 0; i < tickList->count(); i++) @@ -357,7 +359,8 @@ void GLScope::paintGL() // Vertical X1 tickList = &m_x1Scale.getTickList(); - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX1.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -451,6 +454,7 @@ void GLScope::paintGL() if(m_displayTrace->size() > 0) { { + int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); if(end - start < 2) @@ -458,7 +462,9 @@ void GLScope::paintGL() float posLimit = 1.0 / m_amp1; float negLimit = -1.0 / m_amp1; - GLfloat q3[2*(end -start)]; + //GLfloat q3[2*(end -start)]; + m_q3Trace.allocate(2*(end - start)); + GLfloat *q3 = m_q3Trace.m_array; for (int i = start; i < end; i++) { @@ -525,6 +531,7 @@ void GLScope::paintGL() if (m_displayTrace->size() > 0) { { + int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); @@ -532,10 +539,13 @@ void GLScope::paintGL() start--; } + float posLimit = 1.0 / m_amp2; float negLimit = -1.0 / m_amp2; - GLfloat q3[2*(end - start)]; + //GLfloat q3[2*(end - start)]; + m_q3Trace.allocate(2*(end - start)); + GLfloat *q3 = m_q3Trace.m_array; for(int i = start; i < end; i++) { @@ -573,7 +583,8 @@ void GLScope::paintGL() // Horizontal Y2 tickList = &m_y2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -637,7 +648,8 @@ void GLScope::paintGL() // Horizontal Y2 tickList = &m_y2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -660,7 +672,8 @@ void GLScope::paintGL() // Vertical X2 tickList = &m_x2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -750,14 +763,19 @@ void GLScope::paintGL() { if (m_mode == ModeIQPolar) { + int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); if (end - start < 2) { start--; } - { - GLfloat q3[2*(end - start)]; + + + { + //GLfloat q3[2*(end - start)]; + m_q3Trace.allocate(2*(end - start)); + GLfloat *q3 = m_q3Trace.m_array; for(int i = start; i < end; i++) { @@ -802,10 +820,13 @@ void GLScope::paintGL() start--; } + float posLimit = 1.0 / m_amp2; float negLimit = -1.0 / m_amp2; - GLfloat q3[2*(end - start)]; + //GLfloat q3[2*(end - start)]; + m_q3Trace.allocate(2*(end - start)); + GLfloat *q3 = m_q3Trace.m_array; for(int i = start; i < end; i++) { float v = (*m_displayTrace)[i].imag(); @@ -2122,6 +2143,16 @@ void GLScope::applyConfig() } // X2 scale } // Secondary display only + + m_q3TickY1.allocate(4*m_y1Scale.getTickList().count()); + m_q3TickY2.allocate(4*m_y2Scale.getTickList().count()); + m_q3TickX1.allocate(4*m_x1Scale.getTickList().count()); + m_q3TickX2.allocate(4*m_x1Scale.getTickList().count()); +} + +void GLScope::applyTraceConfig(uint32_t size) +{ + m_q3Trace.allocate(2*size); } void GLScope::tick() diff --git a/sdrgui/gui/glscope.h b/sdrgui/gui/glscope.h index 9966e5ff3..8319583b6 100644 --- a/sdrgui/gui/glscope.h +++ b/sdrgui/gui/glscope.h @@ -34,6 +34,7 @@ #include "gui/glshadertextured.h" #include "util/export.h" #include "util/bitfieldindex.h" +#include "util/incrementalarray.h" class ScopeVis; class QPainter; @@ -167,6 +168,12 @@ private: GLShaderTextured m_glShaderBottom2Scale; GLShaderTextured m_glShaderPowerOverlay; + IncrementalArray m_q3Trace; + IncrementalArray m_q3TickY1; + IncrementalArray m_q3TickY2; + IncrementalArray m_q3TickX1; + IncrementalArray m_q3TickX2; + void initializeGL(); void resizeGL(int width, int height); void paintGL(); @@ -175,6 +182,7 @@ private: void handleMode(); void applyConfig(); + void applyTraceConfig(uint32_t size); void drawPowerOverlay(); protected slots: