You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
1.4 KiB

#include "model/processor/strategies/TintMap.h"
#include "model/processor/BIP.h"
#include <QPixmap>
#include <QImage>
TintMap::TintMap(const Context context,
const QString kernelPath,
const QObject *parent = Q_NULLPTR) :
IProcessStrategy(context, kernelPath, "TintMap", parent),
_kernelFunctor(KernelFunctor<Image2D, Image2D,
TintMap_t>(_kernel))
{
memset(&_kernelParameters, 0, sizeof (TintMap_t));
}
void TintMap::cpuProcess(ScenGenOutput_t parameters)
{
if(parameters.tintMapSelector.isUpdated)
{
_kernelParameters.tintMapSelector = parameters.tintMapSelector.value;
}
}
void TintMap::finalize()
{
}
Image* TintMap::processKernel(Image *frames, Buffer* scratchPad)
{
auto width = frames->getImageInfo<CL_IMAGE_WIDTH>();
auto height = frames->getImageInfo<CL_IMAGE_HEIGHT>();
ImageFormat format;
format.image_channel_order = CL_RGBA;
format.image_channel_data_type = CL_UNSIGNED_INT8;
auto imageOutput = new Image2D(_CLContext,
CL_MEM_READ_WRITE,
format,
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));
_openCLHelper.runKernelFunctor<Image2D, Image2D, TintMap_t>(_kernelFunctor,
eargs,
*static_cast<Image2D*>(frames),
*imageOutput,
_kernelParameters);
delete frames;
return imageOutput;
}