summaryrefslogtreecommitdiffstats
path: root/examples/opencl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/opencl')
-rw-r--r--examples/opencl/colorize/colorizewidget.cpp2
-rw-r--r--examples/opencl/imagedrawing/imagewidget.cpp18
-rw-r--r--examples/opencl/pathdrawing/pathwidget.cpp10
-rw-r--r--examples/opencl/pathdrawing/pathwidget.h1
4 files changed, 12 insertions, 19 deletions
diff --git a/examples/opencl/colorize/colorizewidget.cpp b/examples/opencl/colorize/colorizewidget.cpp
index b5d7c41..4f2f1ab 100644
--- a/examples/opencl/colorize/colorizewidget.cpp
+++ b/examples/opencl/colorize/colorizewidget.cpp
@@ -58,7 +58,7 @@ ColorizeWidget::ColorizeWidget(QWidget *parent)
colorize = program.createKernel("colorize");
colorize.setGlobalWorkSize(img.size());
- colorize.setLocalWorkSize(8, 8);
+ colorize.setLocalWorkSize(colorize.bestLocalWorkSizeImage2D());
}
ColorizeWidget::~ColorizeWidget()
diff --git a/examples/opencl/imagedrawing/imagewidget.cpp b/examples/opencl/imagedrawing/imagewidget.cpp
index b2770ee..9a3c7c5 100644
--- a/examples/opencl/imagedrawing/imagewidget.cpp
+++ b/examples/opencl/imagedrawing/imagewidget.cpp
@@ -53,10 +53,10 @@ ImageWidget::ImageWidget(QWidget *parent)
program = context.buildProgramFromSourceFile(QLatin1String(":/imagedrawing.cl"));
fillRectWithColor = program.createKernel("fillRectWithColor");
- fillRectWithColor.setLocalWorkSize(8, 8);
+ fillRectWithColor.setLocalWorkSize(fillRectWithColor.bestLocalWorkSizeImage2D());
drawImageKernel = program.createKernel("drawImage");
- drawImageKernel.setLocalWorkSize(8, 8);
+ drawImageKernel.setLocalWorkSize(drawImageKernel.bestLocalWorkSizeImage2D());
flower = context.createImage2DCopy
(QImage(QLatin1String(":/flower.jpg")), QCLMemoryObject::ReadOnly);
@@ -104,9 +104,9 @@ void ImageWidget::fillRect(int x, int y, int width, int height,
const QColor& color)
{
// Round up the global work size so we can process the
- // rectangle in 8x8 local work size units. The kernel will
+ // rectangle in local work size units. The kernel will
// ignore pixels that are outside the rectangle limits.
- fillRectWithColor.setGlobalWorkSize((width + 7) & ~7, (height + 7) & ~7);
+ fillRectWithColor.setRoundedGlobalWorkSize(width, height);
fillRectWithColor(surfaceImage, x, y, x + width, y + height, color);
}
@@ -126,9 +126,8 @@ void ImageWidget::drawImage(const QCLImage2D& image, int x, int y, float opacity
if (srcRect.isEmpty() || dstRect.isEmpty())
return;
- // Set the global work size to the destination size rounded up to 8.
- drawImageKernel.setGlobalWorkSize
- ((dstRect.width() + 7) & ~7, (dstRect.height() + 7) & ~7);
+ // Set the global work size to the destination size rounded up to local.
+ drawImageKernel.setRoundedGlobalWorkSize(dstRect.size());
// Draw the image.
QVector4D src(srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height());
@@ -158,9 +157,8 @@ void ImageWidget::drawScaledImage
if (srcRect.isEmpty() || dstRect.isEmpty())
return;
- // Set the global work size to the destination size rounded up to 8.
- drawImageKernel.setGlobalWorkSize
- ((dstRect.width() + 7) & ~7, (dstRect.height() + 7) & ~7);
+ // Set the global work size to the destination size rounded up to local.
+ drawImageKernel.setRoundedGlobalWorkSize(dstRect.size());
// Draw the image.
QVector4D src(srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height());
diff --git a/examples/opencl/pathdrawing/pathwidget.cpp b/examples/opencl/pathdrawing/pathwidget.cpp
index 070341f..57404e1 100644
--- a/examples/opencl/pathdrawing/pathwidget.cpp
+++ b/examples/opencl/pathdrawing/pathwidget.cpp
@@ -52,11 +52,7 @@ PathWidget::PathWidget(QWidget *parent)
program = context.buildProgramFromSourceFile(QLatin1String(":/pathdrawing.cl"));
fillRectWithColor = program.createKernel("fillRectWithColor");
- if (fillRectWithColor.bestLocalWorkSizeImage2D().width() == 8)
- workSize = 8;
- else
- workSize = 1;
- fillRectWithColor.setLocalWorkSize(workSize, workSize);
+ fillRectWithColor.setLocalWorkSize(fillRectWithColor.bestLocalWorkSizeImage2D());
}
PathWidget::~PathWidget()
@@ -91,8 +87,8 @@ void PathWidget::fillRect(int x, int y, int width, int height,
const QColor& color)
{
// Round up the global work size so we can process the
- // rectangle in 8x8 local work size units. The kernel will
+ // rectangle in local work size units. The kernel will
// ignore pixels that are outside the rectangle limits.
- fillRectWithColor.setGlobalWorkSize((width + workSize - 1) & ~(workSize - 1), (height + workSize - 1) & ~(workSize - 1));
+ fillRectWithColor.setRoundedGlobalWorkSize(width, height);
fillRectWithColor(surfaceImage, x, y, x + width, y + height, color);
}
diff --git a/examples/opencl/pathdrawing/pathwidget.h b/examples/opencl/pathdrawing/pathwidget.h
index 512f94a..e084dc4 100644
--- a/examples/opencl/pathdrawing/pathwidget.h
+++ b/examples/opencl/pathdrawing/pathwidget.h
@@ -60,7 +60,6 @@ private:
QCLProgram program;
QCLKernel fillRectWithColor;
- int workSize;
QSize windowSize;
QCLImage2D surfaceImage;