Fixed Mandelbrot.cl to not crash on Cuda.

This commit is contained in:
Ioannis Tsakpinis 2010-10-01 17:00:17 +00:00
parent c2ba79169b
commit 3470552355
3 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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);