PDA

View Full Version : Function Question



toneburst
10-07-2009, 03:21 AM
Hi,

this is probably a really stupid question, but I'm having problems with a simple function-call in an OpenCL Kernel.

Here's the code:

const float PI = 3.14159265359;
const float TWOPI = 6.28318530718;

float4 makeSphere(float4 pos, float radius) {

float u = pos.x * TWOPI;
float v = pos.y * PI;

float4 sphere;
sphere.x = radius * cos(u) * sin(v);
sphere.y = radius * css(u) * sin(v);
sphere.z = radius * cos(v);
sphere.w = 1.0;

return sphere;
}


__kernel void read_rgba8888(__rd image2d_t BaseImg, float Width, float Height, float Displacement,
__global float4 *Mesh, __global float4 *Colors)
{
// Get values for current iteration
int tid_x = get_global_id(0),
tid_y = get_global_id(1),
indx = tid_y * get_global_size(0) + tid_x;

// Init variables
float4 color, vertex;
//int2 pos = (int2)(tid_x, tid_y);
// Floating-point position in 0 > 1 range
float4 posFloat = (float4)((float)tid_x / Width, (float)tid_y / Height, 0.0, 1.0);


sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

// Sample colour from base image
color = read_imagef(BaseImg, smp, (int2)(tid_x, tid_y));

// Write color at index in Colors output array
Colors[indx] = color;

// Displacement is determined by the displacement amount * the "length" of the color vector (ie approximate brightness)
/*vertex = (float4)
((float)tid_x / get_global_size(0) - 0.5,
1.0 - (float)tid_y / get_global_size(1) - 0.5,
Displacement * length(color.xyzw), 1.0);*/


// Write mesh value at index of Mesh output array
Mesh[indx] = makeSphere(posFloat, 0.5);
}

It's obviously just supposed to bend the vertices around into a sphere, but I get an error

kernel referenced an external function css, that can not be found

I'm sure it's something very simple I'm doing wrong...

Anyone any advice?

a|x
http://machinesdontcare.wordpress.com

toneburst
10-07-2009, 03:36 AM
Sorry to have wasted your time guys- it was a typo....
:oops:

I was thinking 'css' meant something other than a mistyping of 'cos'

a|x

dbs2
10-07-2009, 04:48 AM
You should be able to get the line number of the error by requesting the build log back from clGetProgramBuildInfo.