aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/demos/julia3d
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-05-01 22:52:11 +0200
committerMichael Bien <[email protected]>2010-05-01 22:52:11 +0200
commit37401c35717505b79ab203881b86534bb7098ee8 (patch)
tree338d66ca2d1696cba9d838913150781479af1484 /src/com/jogamp/opencl/demos/julia3d
parent2c85c416d85205ab98b33e1a0b0daab32d4d81ff (diff)
MultiDeviceFractal is now... multi device again.
Julia3d + AMD: Fixed segfault on exit. minor misc improvements.
Diffstat (limited to 'src/com/jogamp/opencl/demos/julia3d')
-rw-r--r--src/com/jogamp/opencl/demos/julia3d/Julia3d.java21
-rw-r--r--src/com/jogamp/opencl/demos/julia3d/Renderer.java20
2 files changed, 32 insertions, 9 deletions
diff --git a/src/com/jogamp/opencl/demos/julia3d/Julia3d.java b/src/com/jogamp/opencl/demos/julia3d/Julia3d.java
index 38633c6..f4bf392 100644
--- a/src/com/jogamp/opencl/demos/julia3d/Julia3d.java
+++ b/src/com/jogamp/opencl/demos/julia3d/Julia3d.java
@@ -43,15 +43,18 @@ public class Julia3d {
this.config = renderConfig;
updateCamera();
- //setup
- CLDevice gpu = CLPlatform.getDefault().getMaxFlopsDevice();
- context = CLContext.create(gpu);
+ //setup, prefere GPUs
+ CLDevice device = CLPlatform.getDefault().getMaxFlopsDevice(CLDevice.Type.GPU);
+ if(device == null) {
+ device = CLPlatform.getDefault().getMaxFlopsDevice();
+ }
+ context = CLContext.create(device);
workGroupSize = 256;
//allocate buffers
configBuffer = context.createBuffer(config.getBuffer(), READ_ONLY);
- commandQueue = gpu.createCommandQueue();
+ commandQueue = device.createCommandQueue();
// update(true);
try {
@@ -63,7 +66,7 @@ public class Julia3d {
julia = program.createCLKernel("JuliaGPU");
multiply = program.createCLKernel("multiply");
- System.out.println(program.getBuildStatus(gpu));
+ System.out.println(program.getBuildStatus(device));
System.out.println(program.getBuildLog());
}
@@ -179,6 +182,10 @@ public class Julia3d {
vmul(camY, .5135f, camY);
}
+ CLDevice getDevice() {
+ return commandQueue.getDevice();
+ }
+
public static void main(String[] args) {
@@ -208,5 +215,9 @@ public class Julia3d {
return pixelBuffer.getBuffer();
}
+ void release() {
+ context.release();
+ }
+
}
diff --git a/src/com/jogamp/opencl/demos/julia3d/Renderer.java b/src/com/jogamp/opencl/demos/julia3d/Renderer.java
index ce97e4a..6fe2309 100644
--- a/src/com/jogamp/opencl/demos/julia3d/Renderer.java
+++ b/src/com/jogamp/opencl/demos/julia3d/Renderer.java
@@ -1,9 +1,13 @@
package com.jogamp.opencl.demos.julia3d;
+import com.jogamp.opencl.CLDevice;
import com.jogamp.opencl.demos.julia3d.structs.RenderingConfig;
import com.jogamp.opengl.util.awt.TextRenderer;
import java.awt.Dimension;
import java.awt.Font;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
import java.nio.FloatBuffer;
import java.util.Timer;
import java.util.TimerTask;
@@ -37,11 +41,11 @@ public class Renderer implements GLEventListener {
private TimerTask task;
private final Timer timer;
- public Renderer(Julia3d julia3d) {
+ public Renderer(final Julia3d julia3d) {
this.julia3d = julia3d;
this.config = julia3d.config;
- timer = new Timer();
+ timer = new Timer(true);
juliaSlice = newDirectFloatBuffer(MU_RECT_SIZE * MU_RECT_SIZE * 4);
@@ -51,8 +55,16 @@ public class Renderer implements GLEventListener {
usi = new UserSceneController();
usi.init(this, canvas, config);
- JFrame frame = new JFrame("Java OpenCL - Julia3D GPU");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ CLDevice device = julia3d.getDevice();
+ JFrame frame = new JFrame("Java OpenCL - Julia3D "+device.getType()+" "+device.getName());
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosed(WindowEvent e) {
+ julia3d.release();
+ System.exit(0);
+ }
+ });
canvas.setPreferredSize(new Dimension(config.getWidth(), config.getHeight()));
frame.add(canvas);
frame.pack();