From 3470552355e830e859207968add3978a59632275 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Fri, 1 Oct 2010 17:00:17 +0000 Subject: [PATCH] Fixed Mandelbrot.cl to not crash on Cuda. --- .../org/lwjgl/test/opencl/gl/DemoFractal.java | 2 +- src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl | 16 +++++++++------- .../org/lwjgl/opengl/ARB_viewport_array.java | 10 ++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java b/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java index e6517a52..e0674d35 100644 --- a/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java +++ b/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java @@ -476,7 +476,7 @@ public class DemoFractal { for ( int i = 0; i < programs.length; i++ ) { final CLDevice device = queues[i].getCLDevice(); - final StringBuilder options = new StringBuilder(useTextures ? " -D USE_TEXTURE" : ""); + final StringBuilder options = new StringBuilder(useTextures ? "-D USE_TEXTURE" : ""); final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device); if ( doublePrecision && isDoubleFPAvailable(device) ) { //cl_khr_fp64 diff --git a/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl b/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl index d07c2ae8..a1e97289 100644 --- a/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl +++ b/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl @@ -4,15 +4,17 @@ #else #pragma OPENCL EXTENSION cl_khr_fp64 : enable #endif - typedef double varfloat; + #define varfloat double + #define _255 255.0 #else - typedef float varfloat; + #define varfloat float + #define _255 255.0f #endif #ifdef USE_TEXTURE - typedef __write_only image2d_t OUTPUT_TYPE; + #define OUTPUT_TYPE __write_only image2d_t #else - typedef global uint * OUTPUT_TYPE; + #define OUTPUT_TYPE global uint * #endif /** @@ -54,7 +56,7 @@ kernel void mandelbrot( #else output[iy * width + ix] = 0; #endif - } else { + } else { varfloat alpha = (varfloat)iteration / maxIterations; int colorIndex = (int)(alpha * colorMapSize); #ifdef USE_TEXTURE @@ -67,9 +69,9 @@ kernel void mandelbrot( (c & 0xFF) >> 0, (c & 0xFF00) >> 8, (c & 0xFF0000) >> 16, - 255.0 + _255 ); - write_imagef(output, (int2)(ix, iy), oc / 255.0); + write_imagef(output, (int2)(ix, iy), oc / _255); #else output[iy * width + ix] = colorMap[colorIndex]; #endif diff --git a/src/templates/org/lwjgl/opengl/ARB_viewport_array.java b/src/templates/org/lwjgl/opengl/ARB_viewport_array.java index fa365c7b..f7ef15a3 100644 --- a/src/templates/org/lwjgl/opengl/ARB_viewport_array.java +++ b/src/templates/org/lwjgl/opengl/ARB_viewport_array.java @@ -122,17 +122,15 @@ public interface ARB_viewport_array { @StripPostfix("data") void glGetDoublei_v2(@GLenum int target, @GLuint int index, @OutParameter DoubleBuffer data); - // TODO: It's glGetIntegerIndexedvEXT in EXT_draw_buffers2, spec typo? - //@Reuse(extension = "EXT_draw_buffers2", className = "EXTDrawBuffers2") + @Reuse("EXTDrawBuffers2") @StripPostfix(value = "v", extension = "EXT") - void glGetIntegerIndexedivEXT(@GLenum int target, @GLuint int index, @Check @OutParameter IntBuffer v); + void glGetIntegerIndexedvEXT(@GLenum int target, @GLuint int index, @Check @OutParameter IntBuffer v); - // TODO: It's glGetIntegerIndexedvEXT in EXT_draw_buffers2, spec typo? - //@Reuse(extension = "EXT_draw_buffers2", className = "EXTDrawBuffers2") + @Reuse("EXTDrawBuffers2") @Alternate("glGetIntegerIndexedivEXT") @GLreturn("v") @StripPostfix(value = "v", extension = "EXT") - void glGetIntegerIndexedivEXT2(@GLenum int target, @GLuint int index, @OutParameter IntBuffer v); + void glGetIntegerIndexedvEXT2(@GLenum int target, @GLuint int index, @OutParameter IntBuffer v); @Reuse("EXTDrawBuffers2") void glEnableIndexedEXT(@GLenum int target, @GLuint int index);