ngscopeclient v0.2.1
Loading...
Searching...
No Matches
EyeWaveform.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
37#ifndef EyeWaveform_h
38#define EyeWaveform_h
39
40#include "../scopehal/DensityFunctionWaveform.h"
41
42#define EYE_ACCUM_SCALE 64
43
45{
46public:
47 uint32_t width;
48 uint32_t height;
49 float satLevel;
50};
51
66{
67public:
68 enum EyeType
69 {
70 EYE_NORMAL, //Eye is a normal measurement from a realtime or sampling scope
71 EYE_BER, //Eye is a SERDES BER measurement (scaled by 1e15)
72 };
73
74 EyeWaveform(size_t width, size_t height, float center, EyeWaveform::EyeType etype);
75 virtual ~EyeWaveform();
76
77 //not copyable or assignable
78 EyeWaveform(const EyeWaveform&) =delete;
79 EyeWaveform& operator=(const EyeWaveform&) =delete;
80
84
85 AcceleratorBuffer<int64_t>& GetAccumBuffer()
86 { return m_accumdata; }
87
88 void Normalize();
89 void Normalize(
90 vk::raii::CommandBuffer& cmdBuf,
91 std::shared_ptr<QueueHandle> queue,
92 std::shared_ptr<ComputePipeline> normalizeReducePipe,
93 std::shared_ptr<ComputePipeline> normalizeScalePipe,
95 );
96
98 size_t GetTotalUIs()
99 { return m_totalUIs; }
100
103 { return m_totalSamples; }
104
111 { return m_centerVoltage; }
112
123 void IntegrateUIs(size_t uis, size_t samples)
124 {
125 m_totalUIs += uis;
126 m_totalSamples += samples;
127 }
128
131 { return m_uiWidth; }
132
139
147
150 { return m_maskHitRate; }
151
158 { m_maskHitRate = rate; }
159
161
163 EyeType GetType()
164 { return m_type; }
165
170
174 std::vector<int> m_midpoints;
175
176 virtual void FreeGpuMemory() override
177 { m_accumdata.FreeGpuBuffer(); }
178
179 virtual bool HasGpuBuffer() override
180 { return m_accumdata.HasGpuBuffer(); }
181
182 virtual void PrepareForCpuAccessNonblocking(vk::raii::CommandBuffer& cmdBuf) override
183 {
184 m_outdata.PrepareForCpuAccessNonblocking(cmdBuf);
185 m_accumdata.PrepareForCpuAccessNonblocking(cmdBuf);
186 }
187
188 virtual void PrepareForCpuAccess() override
189 {
190 m_outdata.PrepareForCpuAccess();
191 m_accumdata.PrepareForCpuAccess();
192 }
193
194 virtual void PrepareForGpuAccess() override
195 {
196 m_outdata.PrepareForGpuAccess();
197 m_accumdata.PrepareForGpuAccess();
198 }
199
200 virtual void MarkSamplesModifiedFromCpu() override
201 {
202 m_outdata.MarkModifiedFromCpu();
203 m_accumdata.MarkModifiedFromCpu();
204 }
205
206 virtual void MarkSamplesModifiedFromGpu() override
207 {
208 m_outdata.MarkModifiedFromGpu();
209 m_accumdata.MarkModifiedFromGpu();
210 }
211
212 virtual void MarkModifiedFromCpu() override
213 {
214 m_outdata.MarkModifiedFromCpu();
215 m_accumdata.MarkModifiedFromCpu();
216 }
217
218 virtual void MarkModifiedFromGpu() override
219 {
220 m_outdata.MarkModifiedFromGpu();
221 m_accumdata.MarkModifiedFromGpu();
222 }
223
224 virtual size_t GetMemoryBytes() const override
226
227protected:
228
231
234
237
240
243
245 EyeType m_type;
246};
247
248#endif
Definition AcceleratorBuffer.h:204
size_t GetMemoryBytes() const
Returns the total size of the buffer (wherever it is), in bytes.
Definition AcceleratorBuffer.h:582
bool HasGpuBuffer() const
Returns true if there is currently a GPU-side buffer.
Definition AcceleratorBuffer.h:634
T * GetCpuPointer()
Gets a pointer to the CPU-side buffer.
Definition AcceleratorBuffer.h:659
Base class for waveforms such as eye patterns, spectrograms, and waterfalls which are conceptually a ...
Definition DensityFunctionWaveform.h:51
AcceleratorBuffer< float > m_outdata
Pixel buffer.
Definition DensityFunctionWaveform.h:137
Definition EyeWaveform.h:45
An eye-pattern waveform.
Definition EyeWaveform.h:66
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the GPU in the near future.
Definition EyeWaveform.h:194
virtual void PrepareForCpuAccessNonblocking(vk::raii::CommandBuffer &cmdBuf) override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition EyeWaveform.h:182
size_t GetTotalSamples()
Get the total number of samples integrated in this eye.
Definition EyeWaveform.h:102
size_t m_totalUIs
Total UIs integrated.
Definition EyeWaveform.h:233
double GetBERAtPoint(ssize_t pointx, ssize_t pointy, ssize_t xmid, ssize_t ymid)
Gets the BER at a single point, relative to the center of the eye opening.
Definition EyeWaveform.cpp:173
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition EyeWaveform.h:179
void Normalize()
Normalize the integrated integer buffer into float32 output buffer.
Definition EyeWaveform.cpp:85
virtual void FreeGpuMemory() override
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
Definition EyeWaveform.h:176
virtual void MarkSamplesModifiedFromGpu() override
Indicates that this waveform's sample data has been modified on the GPU and the CPU-side copy is no l...
Definition EyeWaveform.h:206
size_t GetTotalUIs()
Get the total number of UIs integrated in this eye.
Definition EyeWaveform.h:98
float m_saturationLevel
Saturation level for normalization.
Definition EyeWaveform.h:146
AcceleratorBuffer< int64_t > m_accumdata
Accumulator buffer.
Definition EyeWaveform.h:230
std::vector< int > m_midpoints
Midpoint levels for each eye opening.
Definition EyeWaveform.h:174
virtual void MarkSamplesModifiedFromCpu() override
Indicates that this waveform's sample data has been modified on the CPU and the GPU-side copy is no l...
Definition EyeWaveform.h:200
float m_uiWidth
Nominal unit interval width of the eye.
Definition EyeWaveform.h:138
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition EyeWaveform.h:188
int64_t * GetAccumData()
Returns a pointer to the raw (not normalized) accumulator data.
Definition EyeWaveform.h:82
virtual size_t GetMemoryBytes() const override
Gets the amount of memory consumed by the waveform (may be CPU, GPU, or mirrored)
Definition EyeWaveform.h:224
virtual void MarkModifiedFromCpu() override
Indicates that this waveform's sample data and timestamps have been modified on the CPU and the GPU-s...
Definition EyeWaveform.h:212
void SetMaskHitRate(float rate)
Set the mask hit rate (normally called by the filter or instrument owning the waveform)
Definition EyeWaveform.h:157
EyeType GetType()
Return the eye type (normal or BER)
Definition EyeWaveform.h:163
float m_centerVoltage
Voltage of the vertical midpoint of the plot.
Definition EyeWaveform.h:239
EyeType m_type
Type of the eye pattern.
Definition EyeWaveform.h:245
size_t m_numLevels
Number of modulation levels (2 = NRZ, 3 = MLT3/PAM3, 4 = PAM4, etc)
Definition EyeWaveform.h:169
float GetCenterVoltage()
Get the center voltage of the eye plot (not the center of the opening)
Definition EyeWaveform.h:110
float m_maskHitRate
Mask hit rate.
Definition EyeWaveform.h:242
virtual void MarkModifiedFromGpu() override
Indicates that this waveform's sample data and timestamps have been modified on the GPU and the CPU-s...
Definition EyeWaveform.h:218
void IntegrateUIs(size_t uis, size_t samples)
Marks a given number of UIs as integrated.
Definition EyeWaveform.h:123
float GetMaskHitRate()
Return the mask hit rate, or zero if there is no mask defined.
Definition EyeWaveform.h:149
size_t m_totalSamples
Total samples integrated.
Definition EyeWaveform.h:236
float GetUIWidth()
Return the UI width, in X axis units.
Definition EyeWaveform.h:130