aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-06-19 22:55:15 +0200
committerMichael Bien <[email protected]>2011-06-19 22:55:15 +0200
commit3016f4fe04dcabdd82d2475a7c23d3b47e1c8766 (patch)
treef9c03cca77f65dea6094c156ad7e8edb70b2f389 /src/com
parent826dacffbae941a35a7cc74515751ddb1d5711a2 (diff)
CLKernel short setters, setArgs(Object... values) for convenient initialization.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/jogamp/opencl/CLKernel.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java
index 57ef316..8a3a44b 100644
--- a/src/com/jogamp/opencl/CLKernel.java
+++ b/src/com/jogamp/opencl/CLKernel.java
@@ -110,6 +110,12 @@ public class CLKernel extends CLObjectResource implements Cloneable {
return this;
}
+ public CLKernel putArg(short value) {
+ setArg(argIndex, value);
+ argIndex++;
+ return this;
+ }
+
public CLKernel putArg(int value) {
setArg(argIndex, value);
argIndex++;
@@ -171,6 +177,11 @@ public class CLKernel extends CLObjectResource implements Cloneable {
return this;
}
+ public CLKernel setArg(int argumentIndex, short value) {
+ setArgument(argumentIndex, 2, wrap(value));
+ return this;
+ }
+
public CLKernel setArg(int argumentIndex, int value) {
setArgument(argumentIndex, 4, wrap(value));
return this;
@@ -209,6 +220,31 @@ public class CLKernel extends CLObjectResource implements Cloneable {
return this;
}
+ public CLKernel setArgs(Object... values) {
+ if(values == null || values.length == 0) {
+ throw new IllegalArgumentException("values array was empty or null.");
+ }
+ for (int i = 0; i < values.length; i++) {
+ Object value = values[i];
+ if(value instanceof CLMemory<?>) {
+ setArg(i, (CLMemory<?>)value);
+ }else if(value instanceof Short) {
+ setArg(i, (Short)value);
+ }else if(value instanceof Integer) {
+ setArg(i, (Integer)value);
+ }else if(value instanceof Long) {
+ setArg(i, (Long)value);
+ }else if(value instanceof Float) {
+ setArg(i, (Float)value);
+ }else if(value instanceof Double) {
+ setArg(i, (Double)value);
+ }else{
+ throw new IllegalArgumentException(value + " is not a valid argument.");
+ }
+ }
+ return this;
+ }
+
private void setArgs(int startIndex, CLMemory<?>... values) {
for (int i = 0; i < values.length; i++) {
setArg(i+startIndex, values[i]);
@@ -259,6 +295,10 @@ public class CLKernel extends CLObjectResource implements Cloneable {
return buffer.putDouble(0, value);
}
+ private Buffer wrap(short value) {
+ return buffer.putShort(0, value);
+ }
+
private Buffer wrap(int value) {
return buffer.putInt(0, value);
}