Przeglądaj źródła

Added getter method for the device associated with a command queue

shamanDevel 9 lat temu
rodzic
commit
46db6d95f8

+ 14 - 1
jme3-core/src/main/java/com/jme3/opencl/CommandQueue.java

@@ -43,10 +43,23 @@ package com.jme3.opencl;
  * @author shaman
  */
 public abstract class CommandQueue extends AbstractOpenCLObject {
+	
+	protected Device device;
 
-    protected CommandQueue(ObjectReleaser releaser) {
+    protected CommandQueue(ObjectReleaser releaser, Device device) {
         super(releaser);
+		this.device = device;
     }
+
+	/**
+	 * Returns the device associated with this command queue.
+	 * It can be used to query properties of the device that is used to execute
+	 * the commands issued to this command queue.
+	 * @return the associated device
+	 */
+	public Device getDevice() {
+		return device;
+	}
     
     /**
      * Issues all previously queued OpenCL commands in command_queue to the

+ 3 - 5
jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclCommandQueue.java

@@ -32,11 +32,9 @@
 package com.jme3.opencl.jocl;
 
 import com.jme3.opencl.CommandQueue;
-import com.jme3.opencl.OpenCLObjectManager;
-import com.jogamp.opencl.CLCommandQueue;
+import com.jme3.opencl.Device;
 import com.jogamp.opencl.CLPlatform;
 import com.jogamp.opencl.llb.CL;
-import com.jogamp.opencl.llb.CLCommandQueueBinding;
 
 /**
  *
@@ -47,8 +45,8 @@ public class JoclCommandQueue extends CommandQueue {
     final CL cl;
     final long id;
 
-    public JoclCommandQueue(long id) {
-        super(new ReleaserImpl(id));
+    public JoclCommandQueue(long id, Device device) {
+        super(new ReleaserImpl(id), device);
         this.id = id;
         this.cl = CLPlatform.getLowLevelCLInterface();
     }

+ 1 - 1
jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclContext.java

@@ -88,7 +88,7 @@ public class JoclContext extends Context {
         long properties = 0;
         long q = cl.clCreateCommandQueue(id, d, properties, Utils.errorBuffer);
         Utils.checkError(Utils.errorBuffer, "clCreateCommandQueue");
-        return new JoclCommandQueue(q);
+        return new JoclCommandQueue(q, device);
     }
     
     @Override

+ 3 - 2
jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java

@@ -32,6 +32,7 @@
 package com.jme3.opencl.lwjgl;
 
 import com.jme3.opencl.CommandQueue;
+import com.jme3.opencl.Device;
 import com.jme3.opencl.OpenCLObjectManager;
 import org.lwjgl.opencl.CL10;
 import org.lwjgl.opencl.CLCommandQueue;
@@ -44,8 +45,8 @@ public class LwjglCommandQueue extends CommandQueue {
 
     private final CLCommandQueue queue;
 
-    public LwjglCommandQueue(CLCommandQueue queue) {
-        super(new ReleaserImpl(queue));
+    public LwjglCommandQueue(CLCommandQueue queue, Device device) {
+        super(new ReleaserImpl(queue), device);
         this.queue = queue;
     }
     

+ 1 - 1
jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglContext.java

@@ -79,7 +79,7 @@ public class LwjglContext extends Context {
         long properties = 0;
         CLCommandQueue q = CL10.clCreateCommandQueue(context, d, properties, Utils.errorBuffer);
         Utils.checkError(Utils.errorBuffer, "clCreateCommandQueue");
-        return new LwjglCommandQueue(q);
+        return new LwjglCommandQueue(q, device);
     }
     
     @Override

+ 3 - 2
jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java

@@ -32,6 +32,7 @@
 package com.jme3.opencl.lwjgl;
 
 import com.jme3.opencl.CommandQueue;
+import com.jme3.opencl.Device;
 import org.lwjgl.opencl.CL10;
 
 /**
@@ -42,8 +43,8 @@ public class LwjglCommandQueue extends CommandQueue {
 
     private final long queue;
 
-    public LwjglCommandQueue(long queue) {
-        super(new ReleaserImpl(queue));
+    public LwjglCommandQueue(long queue, Device device) {
+        super(new ReleaserImpl(queue), device);
         this.queue = queue;
     }
     

+ 1 - 1
jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglContext.java

@@ -79,7 +79,7 @@ public class LwjglContext extends Context {
         long properties = 0;
         long q = CL10.clCreateCommandQueue(context, d, properties, Utils.errorBuffer);
         Utils.checkError(Utils.errorBuffer, "clCreateCommandQueue");
-        return new LwjglCommandQueue(q);
+        return new LwjglCommandQueue(q, device);
     }
     
     @Override