Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e0dde4c9fdc7
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e51ce6286fae
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Aug 9, 2020

  1. Refactoring: split PrepareGeometry into PrepareGeometry (parallelizab…

    …le) + DownloadGeometry (must run in render thread)
    azonenberg committed Aug 9, 2020
    Copy the full SHA
    7367430 View commit details
  2. Copy the full SHA
    4d44724 View commit details
  3. WaveformArea::PrepareGeometry now outputs directly to OpenGL memory r…

    …ather than doing separate glBufferData operations
    azonenberg committed Aug 9, 2020
    Copy the full SHA
    e51ce62 View commit details
20 changes: 19 additions & 1 deletion src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -2011,10 +2011,28 @@ void OscilloscopeWindow::OnAllWaveformsUpdated()
for(auto a : m_analyzers)
a->OnWaveformDataReady();

//Update the views
//Make a vector of our waveform areas so we can parallelize PrepareAllGeometry() calls
//(OpenMP can't iterate over a set)
vector<WaveformArea*> areas;
for(auto w : m_waveformAreas)
areas.push_back(w);

//Map all GL buffers for every waveform area (has to be done in main thread)
for(auto w : m_waveformAreas)
w->MapAllBuffers();

//Do geometry conversion in as many threads as we can
double start = GetTime();
#pragma omp parallel for
for(size_t i=0; i<areas.size(); i++)
areas[i]->PrepareAllGeometry();

//Unmap the buffers (has to be done in main thread) and tell them to update
for(auto w : m_waveformAreas)
{
w->UnmapAllBuffers();
w->OnWaveformDataReady();
}
m_tView += GetTime() - start;

//Update the trigger sync wizard, if it's active
15 changes: 15 additions & 0 deletions src/glscopeclient/ShaderStorageBuffer.h
Original file line number Diff line number Diff line change
@@ -71,6 +71,21 @@ class ShaderStorageBuffer

static void BulkInit(std::vector<ShaderStorageBuffer*>& arr);

//Map this buffer for direct memory access
void* Map(size_t size, GLenum access = GL_WRITE_ONLY)
{
Bind();
glBufferData(GL_SHADER_STORAGE_BUFFER, size, NULL, GL_STREAM_DRAW);
return glMapBuffer(GL_SHADER_STORAGE_BUFFER, access);
}

//Unmap the buffer
void Unmap()
{
Bind();
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}

protected:

/**
10 changes: 4 additions & 6 deletions src/glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -77,7 +77,6 @@ void WaveformArea::SharedCtorInit()
m_frameCount = 0;
m_renderTime = 0;
m_prepareTime = 0;
m_downloadTime = 0;
m_cairoTime = 0;
m_texDownloadTime = 0;
m_compositeTime = 0;
@@ -94,7 +93,8 @@ void WaveformArea::SharedCtorInit()
m_persistenceClear = true;
m_firstFrame = false;
m_waveformRenderData = NULL;
m_dragOverlayPosition = 0;
m_dragOverlayPosition = 0;
m_geometryDirty = false;

m_decodeDialog = NULL;
m_pendingDecode = NULL;
@@ -145,8 +145,6 @@ WaveformArea::~WaveformArea()
m_prepareTime * 1000, m_prepareTime * 1000 / m_frameCount, m_prepareTime * 100 / m_renderTime);
LogDebug("Build index | %10.1f | %10.3f | %.1f %%\n",
m_indexTime * 1000, m_indexTime * 1000 / m_frameCount, m_indexTime * 100 / m_renderTime);
LogDebug("Geometry download | %10.1f | %10.3f | %.1f %%\n",
m_downloadTime * 1000, m_downloadTime * 1000 / m_frameCount, m_downloadTime * 100 / m_renderTime);
LogDebug("Composite | %10.1f | %10.3f | %.1f %%\n",
m_compositeTime * 1000, m_compositeTime * 1000 / m_frameCount, m_compositeTime * 100 / m_renderTime);
}
@@ -457,7 +455,7 @@ void WaveformArea::on_realize()
//Let the base class create the GL context, then select it
Gtk::GLArea::on_realize();
make_current();

// Initialize GLEW
if(!m_isGlewInitialized)
{
@@ -467,7 +465,7 @@ void WaveformArea::on_realize()
LogError("Error: Failed to initialize GLEW");
return;
}

m_isGlewInitialized = true;
}

30 changes: 26 additions & 4 deletions src/glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ class WaveformRenderData
WaveformRenderData(OscilloscopeChannel* channel)
: m_channel(channel)
, m_geometryOK(false)
, m_count(0)
{}

//The channel of interest
@@ -103,6 +104,20 @@ class WaveformRenderData

//RGBA32 but only alpha actually used
Texture m_waveformTexture;

//Number of samples in the buffer
size_t m_count;

//OpenGL-mapped buffers for the data
float* m_mappedXBuffer;
float* m_mappedYBuffer;
uint32_t* m_mappedIndexBuffer;
uint32_t* m_mappedConfigBuffer;
float* m_mappedFloatConfigBuffer;

//Map all buffers for download
void MapBuffers(size_t width);
void UnmapBuffers();
};

float sinc(float x, float width);
@@ -123,11 +138,13 @@ class WaveformArea : public Gtk::GLArea
{ return m_channel; }

void ClearPersistence()
{ m_persistenceClear = true; }
{
m_persistenceClear = true;
SetGeometryDirty();
}

//TODO: dirtiness needs complete revamp
void SetGeometryDirty()
{ }
{ m_geometryDirty = true; }

WaveformGroup* m_group;

@@ -158,6 +175,11 @@ class WaveformArea : public Gtk::GLArea
m_overlays.push_back(decode);
}

//Calls PrepareGeometry() for all waveforms
void PrepareAllGeometry();
void MapAllBuffers();
void UnmapAllBuffers();

protected:
void SharedCtorInit();

@@ -397,7 +419,6 @@ class WaveformArea : public Gtk::GLArea

double m_prepareTime;
double m_indexTime;
double m_downloadTime;

float m_pixelsPerVolt;
float m_padding;
@@ -447,6 +468,7 @@ class WaveformArea : public Gtk::GLArea
int m_dragOverlayPosition;

bool m_firstFrame;
bool m_geometryDirty;
};

#endif
3 changes: 1 addition & 2 deletions src/glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -878,8 +878,7 @@ void WaveformArea::OnWaveformDataReady()
}
}

//Update our measurements and redraw the waveform
SetGeometryDirty();
//Redraw everything
queue_draw();
m_group->m_timeline.queue_draw();
}
Loading