#include "model/processor/strategies/DynCont.h" #include "model/processor/BIP.h" #include #include DynCont::DynCont(const Context context, const QString kernelPath, const QObject *parent = Q_NULLPTR) : IProcessStrategy(context, kernelPath, "DynCont", parent), _kernelFunctor(KernelFunctor(_kernel)) { memset(&_kernelParameters, 0, sizeof (DynCont_t)); } void DynCont::cpuProcess(ScenGenOutput_t parameters) { if(parameters.dynContGain.isUpdated) { _kernelParameters.gain = parameters.dynContGain.value; } if(parameters.dynContSelector.isUpdated) { _kernelParameters.dynContSelector = parameters.dynContSelector.value; } if(parameters.compressionType.isUpdated) { _kernelParameters.compressionType = parameters.compressionType.value; } } void DynCont::finalize() { } Image* DynCont::processKernel(Image *frames, Buffer* scratchPad) { auto format = frames->getImageInfo(); auto width = frames->getImageInfo(); auto height = frames->getImageInfo(); auto imageOutput = new Image2D(_CLContext, CL_MEM_READ_WRITE, ImageFormat(format.image_channel_order, format.image_channel_data_type), width, height); //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); delete frames; return imageOutput; }