aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/CLKernel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp/opencl/CLKernel.java')
-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 57ef316e..8a3a44b9 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);
}