summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-01-21 23:45:39 +0100
committerMichael Bien <[email protected]>2011-01-21 23:45:39 +0100
commit6ca42ce154439b8c2f7f76ce4300ae08678f223a (patch)
tree88eb37098dfa38eae86497544b41cf4d92232a4b
parent410b03d9fd33d3efe9654694aaeb0b63d1c32842 (diff)
missing buffer rewind in source upload code (bug id: #458).
-rw-r--r--src/com/jogamp/opencl/CLProgram.java13
-rw-r--r--test/com/jogamp/opencl/LowLevelBindingTest.java2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java
index 548997e8..e74ebed3 100644
--- a/src/com/jogamp/opencl/CLProgram.java
+++ b/src/com/jogamp/opencl/CLProgram.java
@@ -73,14 +73,19 @@ public class CLProgram extends CLObject implements CLResource {
static CLProgram create(CLContext context, String src) {
- IntBuffer status = newDirectByteBuffer(4).asIntBuffer();
+ IntBuffer status = newDirectIntBuffer(1);
+
+ PointerBuffer length = (PointerBuffer)PointerBuffer.allocateDirect(1).put(0, src.length());
+ String[] srcArray = new String[] {src};
+
// Create the program
- long id = context.cl.clCreateProgramWithSource(context.ID, 1, new String[] {src},
- (PointerBuffer)PointerBuffer.allocateDirect(1).put(src.length()), status);
+ long id = context.cl.clCreateProgramWithSource(context.ID, 1, srcArray, length, status);
int err = status.get();
if(err != CL_SUCCESS) {
- throw newException(err, "can not create program with source on "+context);
+ // don't remove: locks the reference (length and srcArray)
+ length.rewind();
+ throw newException(err, "can not create program with source (length="+srcArray[0].length()+") on "+context);
}
return new CLProgram(context, id);
diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java
index b531dd94..524743b2 100644
--- a/test/com/jogamp/opencl/LowLevelBindingTest.java
+++ b/test/com/jogamp/opencl/LowLevelBindingTest.java
@@ -279,7 +279,7 @@ public class LowLevelBindingTest {
// Create the program
- PointerBuffer lengths = (PointerBuffer)PointerBuffer.allocateDirect(1).put(programSource.length());
+ PointerBuffer lengths = (PointerBuffer)PointerBuffer.allocateDirect(1).put(programSource.length()).rewind();
final long program = cl.clCreateProgramWithSource(context, 1, new String[] {programSource}, lengths, intBuffer);
out.println("program id: "+program);
checkError("on clCreateProgramWithSource", intBuffer.get(0));