#include "model/processor/strategies/Sri.h" #include "model/processor/BIP.h" #include #include Sri::Sri(const Context context, const QString kernelPath, const QObject *parent = Q_NULLPTR) : IProcessStrategy(context, kernelPath, "Sri", parent), _kernelFunctor(KernelFunctor(_kernel)) { memset(&_kernelParameters, 0, sizeof (Sri_t)); } void Sri::cpuProcess(ScenGenOutput_t parameters) { if(parameters.sri.isUpdated) { _kernelParameters.sri = parameters.sri.value; } } void Sri::finalize() { } Image* Sri::processKernel(Image *frames, Buffer* scratchPad) { auto format = frames->getImageInfo(); auto width = frames->getImageInfo(); auto height = frames->getImageInfo(); _kernelParameters.width = width; _kernelParameters.height = height; auto imageOutput = new Image2D(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), width, height); if(_kernelParameters.sri != 0) { //width should be lass than CL_DEVICE_MAX_WORK_GROUP_SIZE(1024 for current machine) or this will break cl::EnqueueArgs eargs(BIP::getInstance()->CLQueue, cl::NDRange(width, height), cl::NDRange(width, 1)); _kernelParameters.state = 1; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs, *static_cast(frames), *imageOutput, Local(width * sizeof (myflt)), *scratchPad, _kernelParameters); cl::EnqueueArgs eargs2(BIP::getInstance()->CLQueue, cl::NDRange(height, 1), cl::NDRange(height, 1)); _kernelParameters.state = 2; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs2, *static_cast(frames), *imageOutput, Local(height * sizeof (myflt)), *scratchPad, _kernelParameters); _kernelParameters.state = 3; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs, *static_cast(frames), *imageOutput, Local(1), *scratchPad, _kernelParameters); _kernelParameters.state = 4; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs, *static_cast(imageOutput), *imageOutput, Local(width * sizeof (myflt)), *scratchPad, _kernelParameters); _kernelParameters.state = 5; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs2, *static_cast(frames), *imageOutput, Local(height * sizeof (myflt)), *scratchPad, _kernelParameters); cl::EnqueueArgs eargs3(BIP::getInstance()->CLQueue, cl::NDRange(width, height)); _kernelParameters.state = 6; _openCLHelper.runKernelFunctor(_kernelFunctor, eargs3, *static_cast(frames), *imageOutput, Local(1), *scratchPad, _kernelParameters); } else { cl::EnqueueArgs eargs(BIP::getInstance()->CLQueue, cl::NDRange(width, height)); _openCLHelper.runKernelFunctor(_kernelFunctor, eargs, *static_cast(frames), *imageOutput, Local(49 * sizeof (myflt)), *scratchPad, _kernelParameters); } delete frames; return imageOutput; }