summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-11-18 09:17:30 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-11-18 09:22:30 +1000
commit306ed0395e0848be4b67f4b057ddcb083090bc3b (patch)
tree0db8c59809bcb95cff13b1e67cb7f74ac3ee7e7f
parentf11bd27aa26b5effbfba47e0aebc49f45405d470 (diff)
Dynamically adjust local work sizes in examples
-rw-r--r--demos/bezierpatch/bezierwidget.cpp3
-rw-r--r--examples/opencl/pathdrawing/pathwidget.cpp8
-rw-r--r--examples/opencl/pathdrawing/pathwidget.h1
3 files changed, 9 insertions, 3 deletions
diff --git a/demos/bezierpatch/bezierwidget.cpp b/demos/bezierpatch/bezierwidget.cpp
index 62101af..2de3ef1 100644
--- a/demos/bezierpatch/bezierwidget.cpp
+++ b/demos/bezierpatch/bezierwidget.cpp
@@ -149,7 +149,8 @@ void BezierWidget::initializeGL()
program = context.buildProgramFromSourceFile(QLatin1String(":/bezierpatch.cl"));
evaluateBezier = program.createKernel("evaluateBezier");
- evaluateBezier.setLocalWorkSize(8, 8);
+ if (evaluateBezier.bestLocalWorkSizeImage2D().width() == 8)
+ evaluateBezier.setLocalWorkSize(8, 8);
glEnable(GL_DEPTH_TEST);
diff --git a/examples/opencl/pathdrawing/pathwidget.cpp b/examples/opencl/pathdrawing/pathwidget.cpp
index 7e88a06..070341f 100644
--- a/examples/opencl/pathdrawing/pathwidget.cpp
+++ b/examples/opencl/pathdrawing/pathwidget.cpp
@@ -52,7 +52,11 @@ PathWidget::PathWidget(QWidget *parent)
program = context.buildProgramFromSourceFile(QLatin1String(":/pathdrawing.cl"));
fillRectWithColor = program.createKernel("fillRectWithColor");
- fillRectWithColor.setLocalWorkSize(8, 8);
+ if (fillRectWithColor.bestLocalWorkSizeImage2D().width() == 8)
+ workSize = 8;
+ else
+ workSize = 1;
+ fillRectWithColor.setLocalWorkSize(workSize, workSize);
}
PathWidget::~PathWidget()
@@ -89,6 +93,6 @@ void PathWidget::fillRect(int x, int y, int width, int height,
// Round up the global work size so we can process the
// rectangle in 8x8 local work size units. The kernel will
// ignore pixels that are outside the rectangle limits.
- fillRectWithColor.setGlobalWorkSize((width + 7) & ~7, (height + 7) & ~7);
+ fillRectWithColor.setGlobalWorkSize((width + workSize - 1) & ~(workSize - 1), (height + workSize - 1) & ~(workSize - 1));
fillRectWithColor(surfaceImage, x, y, x + width, y + height, color);
}
diff --git a/examples/opencl/pathdrawing/pathwidget.h b/examples/opencl/pathdrawing/pathwidget.h
index e084dc4..512f94a 100644
--- a/examples/opencl/pathdrawing/pathwidget.h
+++ b/examples/opencl/pathdrawing/pathwidget.h
@@ -60,6 +60,7 @@ private:
QCLProgram program;
QCLKernel fillRectWithColor;
+ int workSize;
QSize windowSize;
QCLImage2D surfaceImage;