Skip to content

Commit 6493b0d

Browse files
committed
Refactored ScopeDeskewWizard shaders. Updated to latest scopehal.
1 parent a0a059c commit 6493b0d

5 files changed

Lines changed: 32 additions & 19 deletions

File tree

src/ngscopeclient/ScopeDeskewWizard.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,11 @@ void ScopeDeskewWizard::DoProcessWaveformUniform4xRateVulkan(
856856
m_uniform4xRatePipeline->BindBufferNonblocking(0, m_corrOut, m_cmdBuf, true);
857857
m_uniform4xRatePipeline->BindBufferNonblocking(1, ppri->m_samples, m_cmdBuf);
858858
m_uniform4xRatePipeline->BindBufferNonblocking(2, psec->m_samples, m_cmdBuf);
859-
m_uniform4xRatePipeline->Dispatch(m_cmdBuf, args, GetComputeBlockCount(2*m_maxSkewSamples, 64));
859+
860+
const uint32_t compute_block_count = GetComputeBlockCount(2*m_maxSkewSamples, 64);
861+
m_uniform4xRatePipeline->Dispatch(m_cmdBuf, args,
862+
min(compute_block_count, 32768u),
863+
compute_block_count / 32768 + 1);
860864

861865
m_cmdBuf.end();
862866
m_queue->SubmitAndBlock(m_cmdBuf);
@@ -886,7 +890,10 @@ void ScopeDeskewWizard::DoProcessWaveformUniformUnequalRateVulkan(
886890
m_uniformUnequalRatePipeline->BindBufferNonblocking(0, m_corrOut, m_cmdBuf, true);
887891
m_uniformUnequalRatePipeline->BindBufferNonblocking(1, ppri->m_samples, m_cmdBuf);
888892
m_uniformUnequalRatePipeline->BindBufferNonblocking(2, psec->m_samples, m_cmdBuf);
889-
m_uniformUnequalRatePipeline->Dispatch(m_cmdBuf, args, GetComputeBlockCount(2*m_maxSkewSamples, 64));
893+
const uint32_t compute_block_count = GetComputeBlockCount(2*m_maxSkewSamples, 64);
894+
m_uniformUnequalRatePipeline->Dispatch(m_cmdBuf, args,
895+
min(compute_block_count, 32768u),
896+
compute_block_count / 32768 + 1);
890897

891898
m_cmdBuf.end();
892899
m_queue->SubmitAndBlock(m_cmdBuf);
@@ -916,7 +923,10 @@ void ScopeDeskewWizard::DoProcessWaveformUniformEqualRateVulkan(
916923
m_uniformEqualRatePipeline->BindBufferNonblocking(0, m_corrOut, m_cmdBuf, true);
917924
m_uniformEqualRatePipeline->BindBufferNonblocking(1, ppri->m_samples, m_cmdBuf);
918925
m_uniformEqualRatePipeline->BindBufferNonblocking(2, psec->m_samples, m_cmdBuf);
919-
m_uniformEqualRatePipeline->Dispatch(m_cmdBuf, args, GetComputeBlockCount(2*m_maxSkewSamples, 64));
926+
const uint32_t compute_block_count = GetComputeBlockCount(2*m_maxSkewSamples, 64);
927+
m_uniformEqualRatePipeline->Dispatch(m_cmdBuf, args,
928+
min(compute_block_count, 32768u),
929+
compute_block_count / 32768 + 1);
920930

921931
m_cmdBuf.end();
922932
m_queue->SubmitAndBlock(m_cmdBuf);

src/ngscopeclient/shaders/ScopeDeskewUniform4xRate.glsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -81,11 +81,12 @@ shared float priSampleCache[X_BLOCK_SIZE];
8181

8282
void main()
8383
{
84-
if(gl_GlobalInvocationID.x >= numDeltas)
84+
uint nthread = (gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x) + gl_GlobalInvocationID.x;
85+
if(nthread >= numDeltas)
8586
return;
8687

8788
//Convert delta from samples of the primary waveform to femtoseconds
88-
int d = int(gl_GlobalInvocationID.x) + startingDelta;
89+
int d = int(nthread) + startingDelta;
8990

9091
int phaseshift = int(trigPhaseDelta / priTimescale);
9192

@@ -124,5 +125,5 @@ void main()
124125
}
125126

126127
//Output the final correlation
127-
corrOut[gl_GlobalInvocationID.x] = sum / samplesProcessed;
128+
corrOut[nthread] = sum / samplesProcessed;
128129
}

src/ngscopeclient/shaders/ScopeDeskewUniformEqualRate.glsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -81,11 +81,12 @@ shared float priSampleCache[X_BLOCK_SIZE];
8181

8282
void main()
8383
{
84-
if(gl_GlobalInvocationID.x >= numDeltas)
84+
uint nthread = (gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x) + gl_GlobalInvocationID.x;
85+
if(nthread >= numDeltas)
8586
return;
8687

8788
//Convert delta from samples of the primary waveform to femtoseconds
88-
int d = int(gl_GlobalInvocationID.x) + startingDelta;
89+
int d = int(nthread) + startingDelta;
8990
int64_t deltaFs = (priTimescale * int64_t(d)) + trigPhaseDelta;
9091
int phaseshift = int(deltaFs / priTimescale);
9192

@@ -125,5 +126,5 @@ void main()
125126
}
126127

127128
//Output the final correlation
128-
corrOut[gl_GlobalInvocationID.x] = sum / samplesProcessed;
129+
corrOut[nthread] = sum / samplesProcessed;
129130
}

src/ngscopeclient/shaders/ScopeDeskewUniformUnequalRate.glsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -81,11 +81,12 @@ shared float priSampleCache[X_BLOCK_SIZE];
8181

8282
void main()
8383
{
84-
if(gl_GlobalInvocationID.x >= numDeltas)
84+
uint nthread = (gl_GlobalInvocationID.y * gl_NumWorkGroups.x * gl_WorkGroupSize.x) + gl_GlobalInvocationID.x;
85+
if(nthread >= numDeltas)
8586
return;
8687

8788
//Convert delta from samples of the primary waveform to femtoseconds
88-
int d = int(gl_GlobalInvocationID.x) + startingDelta;
89+
int d = int(nthread) + startingDelta;
8990
int64_t deltaFs = (priTimescale * int64_t(d)) + trigPhaseDelta;
9091

9192
//Loop over samples in the primary waveform, then correlate to secondary samples
@@ -127,5 +128,5 @@ void main()
127128
}
128129

129130
//Output the final correlation
130-
corrOut[gl_GlobalInvocationID.x] = sum / samplesProcessed;
131+
corrOut[nthread] = sum / samplesProcessed;
131132
}

0 commit comments

Comments
 (0)