Browse Source

Add scratchPad feature

test-kernel
sono 5 years ago
parent
commit
224048d516
  1. 7
      MainWindow.cpp
  2. 3
      MainWindow.h
  3. 6
      header/IProcessStrategy.h
  4. 2
      header/strategies/Rejection.h
  5. 2
      header/strategies/ScanConversion.h
  6. 4
      source/IProcessStrategy.cpp
  7. 2
      source/strategies/Rejection.cpp
  8. 2
      source/strategies/ScanConversion.cpp

7
MainWindow.cpp

@ -28,6 +28,10 @@ MainWindow::MainWindow(QWidget *parent)
.getDevicesByContext(
_CLContext)[0]);
_scratchPad = new Buffer(_CLContext, CL_MEM_READ_WRITE, 1024);
_scratch = new double[128];
CLQueue.enqueueWriteBuffer(*_scratchPad, CL_TRUE, 0, 1024, _scratch);
registerStrategies();
_strategy = Q_NULLPTR;
}
@ -182,7 +186,8 @@ void MainWindow::on_btn_test_clicked()
update_field(&_scenGenOutput.outputWidth, OUT_WIDTH);
update_field(&_scenGenOutput.outputHeight, OUT_HEIGHT);
_strategy->cpuProcess(_scenGenOutput);
auto outFrame = _strategy->processKernel(inFrame);
auto outFrame = _strategy->processKernel(inFrame, _scratchPad);
char *out;
out = (char*)malloc(OUT_WIDTH * OUT_WIDTH * sizeof (char) * sizeof (myflt));

3
MainWindow.h

@ -64,5 +64,8 @@ private:
IProcessStrategy* _strategy;
ScenGenOutput_t _scenGenOutput;
Buffer* _scratchPad;
double* _scratch;
};
#endif // MAINWINDOW_H

6
header/IProcessStrategy.h

@ -23,7 +23,7 @@ public:
virtual void cpuProcess(ScenGenOutput_t parameters) = 0;
virtual void finalize() = 0;
virtual void ReadParams(QString path, ScenGenOutput_t* params) = 0;
virtual Image* processKernel(Image* inputFrame) = 0;
virtual Image* processKernel(Image* inputFrame, Buffer* scratchPad) = 0;
protected:
Kernel _kernel;
@ -39,10 +39,10 @@ protected:
OpenCLHelper _openCLHelper;
signals:
void sgl_outputReady(Image* frames);
void sgl_outputReady(Image* frames, Buffer* scratchPad);
public slots:
void slt_process(Image* frames);
void slt_process(Image* frames, Buffer* scratchPad);
};

2
header/strategies/Rejection.h

@ -23,7 +23,7 @@ public:
private:
KernelFunctor<Image2D, Image2D, Rejection_t> _kernelFunctor;
virtual Image* processKernel(Image *frames) override;
virtual Image* processKernel(Image *frames, Buffer* scratchPad) override;
Rejection_t _kernelParameters;
double _rejectionThr;

2
header/strategies/ScanConversion.h

@ -25,7 +25,7 @@ public:
private:
KernelFunctor<Image2D, Image2D, Buffer, Buffer, Buffer, Buffer, ScanConversion_t> _kernelFunctor;
virtual Image* processKernel(Image *frames) override;
virtual Image* processKernel(Image *frames, Buffer* scratchPad) override;
ScanConversion_t _kernelParameters;
quint64 _width;
quint64 _height;

4
source/IProcessStrategy.cpp

@ -2,9 +2,9 @@
#include <QImage>
#include <QPixmap>
void IProcessStrategy::slt_process(Image* inputFrame)
void IProcessStrategy::slt_process(Image* inputFrame, Buffer* scratchPad)
{
emit sgl_outputReady(processKernel(inputFrame));
}
IProcessStrategy::IProcessStrategy(const Context context,

2
source/strategies/Rejection.cpp

@ -43,7 +43,7 @@ void Rejection::ReadParams(QString path, ScenGenOutput_t *params)
}
Image* Rejection::processKernel(Image *frames)
Image* Rejection::processKernel(Image *frames, Buffer* scratchPad)
{
Context context = _openCLHelper.getContext();
auto format = frames->getImageInfo<CL_IMAGE_FORMAT>();

2
source/strategies/ScanConversion.cpp

@ -226,7 +226,7 @@ void ScanConversion::ReadParams(QString path, ScenGenOutput_t *params)
}
Image* ScanConversion::processKernel(Image *frames)
Image* ScanConversion::processKernel(Image *frames, Buffer* scratchPad)
{
Context context = _openCLHelper.getContext();
auto format = frames->getImageInfo<CL_IMAGE_FORMAT>();

Loading…
Cancel
Save