From 66ebeb24fbe4d649399be3e801324ecf8bda7454 Mon Sep 17 00:00:00 2001 From: mmtalaie Date: Wed, 13 May 2020 14:59:44 +0430 Subject: [PATCH] create repo --- MainWindow.cpp | 10 ++++ kernels/Cri.cl | 16 ++++++ source/model/processor/strategies/Cri.cpp | 31 ++++++++++- .../processor/strategies/Cri.cpp.autosave | 53 ------------------- .../processor/strategies/ScanConversion.cpp | 2 +- source/model/processor/strategies/Sri.cpp | 2 +- 6 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 kernels/Cri.cl delete mode 100644 source/model/processor/strategies/Cri.cpp.autosave diff --git a/MainWindow.cpp b/MainWindow.cpp index e40929f..b9c2265 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -309,7 +309,17 @@ void MainWindow::on_btn_test_clicked() width * sizeof (myflt), 0, arr.data()); + if(ui->cb_kernelName->currentText() == "Cri") + { + Image2D* criBuffer[16]; + auto bufferPath = inputDir.path() + "/buffer"; + for (int i = 1; i <= 16; ++i) + { + auto bfname = QString("%1\%2\") + } + + } update_field(&_scenGenOutput.outputWidth, (uint)OUT_WIDTH); update_field(&_scenGenOutput.outputHeight, (uint)OUT_HEIGHT); _strategy->cpuProcess(_scenGenOutput); diff --git a/kernels/Cri.cl b/kernels/Cri.cl new file mode 100644 index 0000000..2fcc43e --- /dev/null +++ b/kernels/Cri.cl @@ -0,0 +1,16 @@ + +struct input +{ + int criFilterMode; + int frameCntr; + int scenariFrameNo; +}; + +kernel void Cri(read_only image2d_array_t input_frame, read_write image2d_t output_frame, struct input params) +{ + const int rows = get_image_height(input_frame); + const int cols = get_image_width(input_frame); + int4 f = read_imagei(input_frame, (rows,cols,1,1)); + printf("out: %a | ", f.x); + // printf(" :hi! I am the cri kernel"); +} \ No newline at end of file diff --git a/source/model/processor/strategies/Cri.cpp b/source/model/processor/strategies/Cri.cpp index 5c51c60..fabaf50 100644 --- a/source/model/processor/strategies/Cri.cpp +++ b/source/model/processor/strategies/Cri.cpp @@ -33,13 +33,42 @@ Image* Cri::processKernel(Image *frames, Buffer* scratchPad) auto height = frames->getImageInfo(); _criBuffer[_kernelParameters.scenariFrameNo] = static_cast(frames); + int err = 100; + +// Image2DArray bufferframes = Image2DArray(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), +// 16, +// width, +// height, +// 0,0); +// BIP::getInstance()->CLQueue.enqueueWriteImage(*bufferframes, CL_TRUE, array {0, 0, 0}, +// array {width, height, 1}, +// width * sizeof (myflt), +// 0, +// _criBuffer); + auto imgs = new Image2DArray(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), + 16, + width, + height, + width *4* sizeof (myflt), + 0, + _criBuffer, + &err); + qDebug()<<"erro is : " << err; +// cl::enqueueReadImage() auto imageOutput = new Image2D(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), width, height); + cl::EnqueueArgs eargs(BIP::getInstance()->CLQueue, cl::NDRange(width, height)); + + _openCLHelper.runKernelFunctor(_kernelFunctor, + eargs, + *imgs, + *imageOutput, + _kernelParameters); - delete frames; + delete imgs; return imageOutput; } diff --git a/source/model/processor/strategies/Cri.cpp.autosave b/source/model/processor/strategies/Cri.cpp.autosave deleted file mode 100644 index c71a773..0000000 --- a/source/model/processor/strategies/Cri.cpp.autosave +++ /dev/null @@ -1,53 +0,0 @@ -#include "model/processor/strategies/Cri.h" -#include "model/processor/BIP.h" -#include -#include - -Cri::Cri(const Context context,const QString kernelPath,const QObject *parent = Q_NULLPTR) : - IProcessStrategy(context, kernelPath, "Cri", parent), - _kernelFunctor(KernelFunctor(_kernel)) -{ - memset(&_kernelParameters, 0, sizeof (Cri_t)); -// _criBuffer = new Image2D()[CRI_MAX_BUFFER_SIZE]; -} - -void Cri::cpuProcess(ScenGenOutput_t params) -{ - if(params.criFilterMode.isUpdated) - _kernelParameters.criFilterMode = params.criFilterMode.value; - if(params.scenarioFrameNo.isUpdated) - _kernelParameters.scenariFrameNo = params.scenarioFrameNo.value; - if(params.frameCntr.isUpdated) - _kernelParameters.frameCntr = params.frameCntr.value; -} - -void Cri::finalize() -{ -} - - -Image* Cri::processKernel(Image *frames, Buffer* scratchPad) -{ - auto format = frames->getImageInfo(); - auto width = frames->getImageInfo(); - auto height = frames->getImageInfo(); - - _criBuffer[_kernelParameters.scenariFrameNo] = static_cast(frames); - - auto im = Image2DArray(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), - 16, - 1000, - 1000, - 1000 * sizeof (myflt), - 1000 * sizeof (myflt)); - cl::enqueueReadImage() - - auto imageOutput = new Image2D(_CLContext, - CL_MEM_READ_WRITE, - ImageFormat(format.image_channel_order, format.image_channel_data_type), - width, - height); - - delete frames; - return imageOutput; -} diff --git a/source/model/processor/strategies/ScanConversion.cpp b/source/model/processor/strategies/ScanConversion.cpp index 6809a7e..dc92770 100644 --- a/source/model/processor/strategies/ScanConversion.cpp +++ b/source/model/processor/strategies/ScanConversion.cpp @@ -216,7 +216,7 @@ void ScanConversion::cpuProcess(ScenGenOutput_t params) static_cast(params.rxLineNo.value) * sizeof (myflt)); - queue.enqueueWriteBuffer(*_gridX, CL_TRUE, 0, + queue.enqueueWriteBuffer(*_gridX, CL_TRUE, 0, static_cast(params.rxLineNo.value) * sizeof (myflt), _scanXPos); diff --git a/source/model/processor/strategies/Sri.cpp b/source/model/processor/strategies/Sri.cpp index acb1343..d1090bf 100644 --- a/source/model/processor/strategies/Sri.cpp +++ b/source/model/processor/strategies/Sri.cpp @@ -38,7 +38,7 @@ Image* Sri::processKernel(Image *frames, Buffer* scratchPad) auto imageOutput = new Image2D(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), - width, + width, height); if(_kernelParameters.sri != 0) {