ngscopeclient 0.1-dev+51fbda87c
VulkanFFTPlan.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 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
36#ifndef VulkanFFTPlan_h
37#define VulkanFFTPlan_h
38
39//Lots of warnings here, disable them
40#pragma GCC diagnostic push
41#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
42#pragma GCC diagnostic ignored "-Wunused-variable"
43#pragma GCC diagnostic ignored "-Wunused-parameter"
44#pragma GCC diagnostic ignored "-Wpedantic"
45#pragma GCC diagnostic ignored "-Wshadow"
46#pragma GCC diagnostic ignored "-Wsign-compare"
47#include <vkFFT.h>
48#pragma GCC diagnostic pop
49
50#include "AcceleratorBuffer.h"
51#include "PipelineCacheManager.h"
52
58{
61
63 uint32_t npoints;
64
66 uint32_t offsetIn;
67
69 uint32_t offsetOut;
70
72 float scale;
73
75 float alpha0;
76
78 float alpha1;
79};
80
86{
88 uint32_t outlen;
89
91 uint32_t istart;
92
94 float scale;
95};
96
102{
103public:
104
107 {
110
113 };
114
117 {
120
123 };
124
126 size_t npoints,
127 size_t nouts,
129 size_t numBatches = 1,
132
133 void AppendForward(
136 vk::raii::CommandBuffer& cmdBuf);
137
138 void AppendReverse(
141 vk::raii::CommandBuffer& cmdBuf);
142
144 size_t size() const
145 { return m_size; }
146
147protected:
148
150 VkFFTApplication m_app;
151
153 VkFFTConfiguration m_config;
154
156 size_t m_size;
157
158 //this is ugly but apparently we can't take a pointer to the underlying vk:: c++ wrapper objects?
160 VkPhysicalDevice m_physicalDevice;
161
163 VkDevice m_device;
164
166 VkPipelineCache m_pipelineCache;
167
169 vk::raii::Fence m_fence;
170
172 VkFence m_rawfence;
173
175 uint64_t m_bsize;
176
178 uint64_t m_tsize;
179
181 uint64_t m_isize;
182};
183
184#endif
Declaration of AcceleratorBuffer.
RAII wrapper around a VkFFTApplication and VkFFTConfiguration.
Definition: VulkanFFTPlan.h:102
void AppendReverse(AcceleratorBuffer< float > &dataIn, AcceleratorBuffer< float > &dataOut, vk::raii::CommandBuffer &cmdBuf)
Appends an inverse FFT to a command buffer.
Definition: VulkanFFTPlan.cpp:253
VulkanFFTDataType
Data type of a FFT input or output.
Definition: VulkanFFTPlan.h:117
@ TYPE_REAL
Real float32 values.
Definition: VulkanFFTPlan.h:119
@ TYPE_COMPLEX
Complex float32 values.
Definition: VulkanFFTPlan.h:122
vk::raii::Fence m_fence
Fence for synchronizing FFTs.
Definition: VulkanFFTPlan.h:169
size_t size() const
Return the number of points in the FFT.
Definition: VulkanFFTPlan.h:144
VulkanFFTPlanDirection
Direction of a FFT.
Definition: VulkanFFTPlan.h:107
@ DIRECTION_FORWARD
Normal FFT.
Definition: VulkanFFTPlan.h:109
@ DIRECTION_REVERSE
Inverse FFT.
Definition: VulkanFFTPlan.h:112
uint64_t m_bsize
Byte size of the output buffer (for forward) or input (for reverse)
Definition: VulkanFFTPlan.h:175
VkFFTApplication m_app
VkFFT application handle.
Definition: VulkanFFTPlan.h:150
VkPipelineCache m_pipelineCache
Pipeline cache for precompiled shader binaries.
Definition: VulkanFFTPlan.h:166
VulkanFFTPlan(size_t npoints, size_t nouts, VulkanFFTPlanDirection dir, size_t numBatches=1, VulkanFFTDataType timeDomainType=VulkanFFTPlan::TYPE_REAL)
Creates a new FFT plan.
Definition: VulkanFFTPlan.cpp:54
VkFence m_rawfence
The underlying VkFence of m_fence (we need to be able to take a pointer to it)
Definition: VulkanFFTPlan.h:172
VkDevice m_device
Device the FFT is runnning on.
Definition: VulkanFFTPlan.h:163
size_t m_size
Number of points in the FFT.
Definition: VulkanFFTPlan.h:156
VkFFTConfiguration m_config
VkFFT configuration state.
Definition: VulkanFFTPlan.h:153
void AppendForward(AcceleratorBuffer< float > &dataIn, AcceleratorBuffer< float > &dataOut, vk::raii::CommandBuffer &cmdBuf)
Appends a forward FFT to a command buffer.
Definition: VulkanFFTPlan.cpp:219
VkPhysicalDevice m_physicalDevice
Physical device the FFT is runnning on.
Definition: VulkanFFTPlan.h:160
uint64_t m_tsize
Byte size of the temporary working buffer.
Definition: VulkanFFTPlan.h:178
uint64_t m_isize
Byte size of the input buffer (for forward) or output (for reverse)
Definition: VulkanFFTPlan.h:181
Arguments for normalizing output of a de-embed.
Definition: VulkanFFTPlan.h:86
uint32_t outlen
Length of the output buffer, in samples.
Definition: VulkanFFTPlan.h:88
float scale
Scaling factor for normalization.
Definition: VulkanFFTPlan.h:94
uint32_t istart
Starting sample index.
Definition: VulkanFFTPlan.h:91
Arguments to a window function for FFT processing.
Definition: VulkanFFTPlan.h:58
uint32_t offsetOut
Offset from start of the output buffer to start writing to.
Definition: VulkanFFTPlan.h:69
float scale
Scaling factor for normalization.
Definition: VulkanFFTPlan.h:72
uint32_t numActualSamples
Number of samples in the input.
Definition: VulkanFFTPlan.h:60
uint32_t npoints
Number of FFT points.
Definition: VulkanFFTPlan.h:63
float alpha0
Alpha0 factor for cosine-sum windows, ignored for others.
Definition: VulkanFFTPlan.h:75
uint32_t offsetIn
Offset from start of the input buffer to start reading from.
Definition: VulkanFFTPlan.h:66
float alpha1
Alpha1 factor for cosine-sum windows, ignored for others.
Definition: VulkanFFTPlan.h:78